Common.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2009  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_Common_hxx
00024 #define __ccxx_Common_hxx
00025 
00053 #define CCXX_VERSION 0x00000603
00054 #define CCXX_VERSION_MAJOR ((uint_t)((CCXX_VERSION >> 16) & 0xFF))
00055 #define CCXX_VERSION_MINOR ((uint_t)((CCXX_VERSION >> 8) & 0xFF))
00056 #define CCXX_VERSION_MICRO ((uint_t)(CCXX_VERSION & 0xFF))
00057 
00058 // platform detection
00059 
00074 #if defined(__CYGWIN__)
00075 #define CCXX_OS_POSIX
00076 #define COMMONCPP_API
00077 #define COMMONCPPDB_API
00078 #define COMMONCPPJVM_API
00079 #define COMMONCPPXML_API
00080 #else
00081 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
00082 #define CCXX_OS_WINDOWS
00083 
00084 #ifdef __MINGW32__
00085 #define CCXX_OS_WINDOWS_GNU
00086 #endif
00087 
00088 #if defined(COMMONCPP_EXPORTS)
00089 #define COMMONCPP_API __declspec(dllexport)
00090 #else // ! COMMONCPP_EXPORTS
00091 #define COMMONCPP_API __declspec(dllimport)
00092 #endif // COMMONCPP_EXPORTS
00093 
00094 #if defined(COMMONCPPDB_EXPORTS)
00095 #define COMMONCPPDB_API __declspec(dllexport)
00096 #else // ! COMMONCPPDB_EXPORTS
00097 #define COMMONCPPDB_API __declspec(dllimport)
00098 #endif // COMMONCPPDB_EXPORTS
00099 
00100 #if defined(COMMONCPPJVM_EXPORTS)
00101 #define COMMONCPPJVM_API __declspec(dllexport)
00102 #else // ! COMMONCPPJVM_EXPORTS
00103 #define COMMONCPPJVM_API __declspec(dllimport)
00104 #endif // COMMONCPPJVM_EXPORTS
00105 
00106 #if defined(COMMONCPPXML_EXPORTS)
00107 #define COMMONCPPXML_API __declspec(dllexport)
00108 #else // ! COMMONCPPXML_EXPORTS
00109 #define COMMONCPPXML_API __declspec(dllimport)
00110 #endif // COMMONCPPXML_EXPORTS
00111 
00112 #else // !WIN32
00113 #define CCXX_OS_POSIX
00114 
00115 #ifdef __APPLE__
00116 #define CCXX_OS_MACOSX
00117 #endif
00118 
00119 #define COMMONCPP_API
00120 #define COMMONCPPDB_API
00121 #define COMMONCPPJVM_API
00122 #define COMMONCPPXML_API
00123 #endif // WIN32
00124 #endif //__CYGWIN
00125 
00126 #ifdef CCXX_OS_WINDOWS
00127 
00128 #ifndef NOMINMAX
00129 #define NOMINMAX
00130 #endif
00131 
00132 #define _WINSOCKAPI_
00133 #ifdef _WIN32_WINNT
00134 #undef _WIN32_WINNT
00135 #endif
00136 #define _WIN32_WINNT 0x0500 // Windows 2000 or later ONLY
00137 #include <winsock2.h> // compilation of MulticastSocket fails otherwise.
00138 #include <windows.h>
00139 #endif // CCXX_OS_WINDOWS
00140 
00151 #if defined(__GNUC__) && ((__GNUC__ > 3)                                \
00152                           || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 0)))
00153 
00154 #define ___DEPRECATED(DECL) DECL __attribute__((deprecated))
00155 #define ___UNUSED __attribute__((unused))
00156 #define ___NORETURN(DECL) DECL __attribute__((noreturn))
00157 
00158 #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
00159 
00160 #define ___DEPRECATED(DECL) __declspec(deprecated) DECL
00161 #define ___UNUSED
00162 #define ___NORETURN(DECL) __declspec(noreturn) DECL
00163 
00164 #else
00165 
00166 #define ___DEPRECATED(DECL) DECL
00167 #define ___UNUSED
00168 #define ___NORETURN(DECL) DECL
00169 
00170 #endif
00171 
00172 #include <cstddef>
00173 
00174 #ifndef CCXX_OS_WINDOWS
00175 #include <sys/types.h>
00176 #include <pthread.h>
00177 #endif
00178 
00179 #include <commonc++/Integers.h++>
00180 
00181 namespace ccxx {
00182 
00183 #ifdef CCXX_OS_WINDOWS
00184 
00185 typedef HANDLE ProcessHandle;
00186 typedef DWORD ProcessID;
00187 typedef HANDLE ThreadHandle;
00188 typedef DWORD ThreadID;
00189 typedef HANDLE FileHandle;
00190 
00191 #define CCXX_INVALID_FILE_HANDLE INVALID_HANDLE_VALUE
00192 
00193 #else // ! CCXX_OS_WINDOWS
00194 
00195 typedef pid_t ProcessHandle;
00196 typedef pid_t ProcessID;
00197 typedef pthread_t ThreadHandle;
00198 typedef pthread_t ThreadID;
00199 typedef int FileHandle;
00200 
00203 #define CCXX_INVALID_FILE_HANDLE (-1)
00204 
00205 #endif // CCXX_OS_WINDOWS
00206 
00211 #ifdef NUL
00212 #undef NUL
00213 #endif
00214 #define NUL '\0'
00215 
00220 #ifdef WNUL
00221 #undef WNUL
00222 #endif
00223 #define WNUL L'\0'
00224 
00230 #define CCXX_LENGTHOF(A)                        \
00231   (sizeof(A) / sizeof(A[0]))
00232 
00237 #define CCXX_OFFSETOF(S, F)                                     \
00238   ((size_t)(((void *)(&(((S)NULL)->F))) - ((void *)NULL)))
00239 
00244 #define CCXX_ZERO(V)                            \
00245   (std::memset(&(V), 0, sizeof(V)))
00246 
00249 #define __CCXX_STRINGIFY__(S) #S
00250 
00255 #define CCXX_STRINGIFY(S) __CCXX_STRINGIFY__(S)
00256 
00261 #define __CCXX_UNIQUE_VARNAME__(pfx, id, sfx) pfx ## _ ## id ## _ ## sfx
00262 #define CCXX_UNIQUE_VARNAME(pfx, id, sfx)       \
00263   __CCXX_UNIQUE_VARNAME__(pfx, id, sfx)
00264 
00267 #define CCXX_STATIC_INITIALIZER                                         \
00268   static void __ccxx_static_init__(void);                               \
00269   static bool __ccxx_static_init_done__ = (__ccxx_static_init__(), true); \
00270   static void __ccxx_static_init__(void)
00271 
00278 #define CCXX_COPY_DECLS(CLASS)                  \
00279   CLASS(const CLASS &other);                    \
00280   CLASS& operator=(const CLASS &other);
00281 
00283 enum Priority { PrioLowest, PrioLow, PrioNormal, PrioHigh, PrioHighest };
00284 
00285 
00287 enum Endianness { BigEndian = 0, LittleEndian = 1 };
00288 
00289 }; // namespace ccxx
00290 
00296 #define CCXX_FWD_DECL(CLASS)                    \
00297   namespace ccxx { class CLASS; };
00298 
00299 #endif // __ccxx_Common_hxx
00300 
00301 /* end of header file */

Generated on Sat Apr 17 23:03:05 2010 for libcommonc++ by  doxygen 1.5.9