35 #ifndef GOOGLE_PROTOBUF_COMMON_H__
36 #define GOOGLE_PROTOBUF_COMMON_H__
47 #elif !defined(_MSC_VER)
51 #ifndef PROTOBUF_USE_EXCEPTIONS
52 #if defined(_MSC_VER) && defined(_CPPUNWIND)
53 #define PROTOBUF_USE_EXCEPTIONS 1
54 #elif defined(__EXCEPTIONS)
55 #define PROTOBUF_USE_EXCEPTIONS 1
57 #define PROTOBUF_USE_EXCEPTIONS 0
61 #if PROTOBUF_USE_EXCEPTIONS
65 #if defined(_WIN32) && defined(GetMessage)
69 inline BOOL GetMessage_Win32(
70 LPMSG lpMsg, HWND hWnd,
71 UINT wMsgFilterMin, UINT wMsgFilterMax) {
72 return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
75 inline BOOL GetMessage(
76 LPMSG lpMsg, HWND hWnd,
77 UINT wMsgFilterMin, UINT wMsgFilterMax) {
78 return GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
88 #undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
89 #define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
90 TypeName(const TypeName&); \
91 void operator=(const TypeName&)
93 #if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)
94 #ifdef LIBPROTOBUF_EXPORTS
95 #define LIBPROTOBUF_EXPORT __declspec(dllexport)
97 #define LIBPROTOBUF_EXPORT __declspec(dllimport)
99 #ifdef LIBPROTOC_EXPORTS
100 #define LIBPROTOC_EXPORT __declspec(dllexport)
102 #define LIBPROTOC_EXPORT __declspec(dllimport)
105 #define LIBPROTOBUF_EXPORT
106 #define LIBPROTOC_EXPORT
116 #define GOOGLE_PROTOBUF_VERSION 2006001
120 #define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 2006000
129 #define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 2006000
138 const char* filename);
149 #define GOOGLE_PROTOBUF_VERIFY_VERSION \
150 ::google::protobuf::internal::VerifyVersion( \
151 GOOGLE_PROTOBUF_VERSION, GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION, \
161 typedef __int16
int16;
162 typedef __int32
int32;
163 typedef __int64
int64;
165 typedef unsigned __int8
uint8;
166 typedef unsigned __int16
uint16;
167 typedef unsigned __int32
uint32;
168 typedef unsigned __int64
uint64;
183 #undef GOOGLE_LONGLONG
184 #undef GOOGLE_ULONGLONG
185 #undef GOOGLE_LL_FORMAT
188 #define GOOGLE_LONGLONG(x) x##I64
189 #define GOOGLE_ULONGLONG(x) x##UI64
190 #define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...)
192 #define GOOGLE_LONGLONG(x) x##LL
193 #define GOOGLE_ULONGLONG(x) x##ULL
194 #define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
210 #ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
211 #if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
214 #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
217 #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE
221 #ifndef GOOGLE_ATTRIBUTE_DEPRECATED
224 #define GOOGLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
226 #define GOOGLE_ATTRIBUTE_DEPRECATED
230 #ifndef GOOGLE_PREDICT_TRUE
233 #define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
235 #define GOOGLE_PREDICT_TRUE
242 #ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
243 #define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN()
245 #ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END
246 #define GOOGLE_SAFE_CONCURRENT_WRITES_END()
286 #undef GOOGLE_ARRAYSIZE
287 #define GOOGLE_ARRAYSIZE(a) \
288 ((sizeof(a) / sizeof(*(a))) / \
289 static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
310 template<
typename To,
typename From>
333 template<
typename To,
typename From>
343 #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
344 assert(f ==
NULL || dynamic_cast<To>(f) !=
NULL);
346 return static_cast<To
>(f);
379 #undef GOOGLE_COMPILE_ASSERT
380 #define GOOGLE_COMPILE_ASSERT(expr, msg) \
381 typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \
382 msg[bool(expr) ? 1 : -1]
460 enum { type_must_be_complete =
sizeof(C) };
469 enum { type_must_be_complete =
sizeof(C) };
485 C*
get()
const {
return ptr_; }
547 enum { type_must_be_complete =
sizeof(C) };
556 enum { type_must_be_complete =
sizeof(C) };
566 assert(array_ !=
NULL);
688 #undef GOOGLE_CHECK_OK
689 #undef GOOGLE_CHECK_EQ
690 #undef GOOGLE_CHECK_NE
691 #undef GOOGLE_CHECK_LT
692 #undef GOOGLE_CHECK_LE
693 #undef GOOGLE_CHECK_GT
694 #undef GOOGLE_CHECK_GE
695 #undef GOOGLE_CHECK_NOTNULL
699 #undef GOOGLE_DCHECK_EQ
700 #undef GOOGLE_DCHECK_NE
701 #undef GOOGLE_DCHECK_LT
702 #undef GOOGLE_DCHECK_LE
703 #undef GOOGLE_DCHECK_GT
704 #undef GOOGLE_DCHECK_GE
706 #define GOOGLE_LOG(LEVEL) \
707 ::google::protobuf::internal::LogFinisher() = \
708 ::google::protobuf::internal::LogMessage( \
709 ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__)
710 #define GOOGLE_LOG_IF(LEVEL, CONDITION) \
711 !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL)
713 #define GOOGLE_CHECK(EXPRESSION) \
714 GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": "
715 #define GOOGLE_CHECK_OK(A) GOOGLE_CHECK(A)
716 #define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B))
717 #define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B))
718 #define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B))
719 #define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B))
720 #define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B))
721 #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B))
726 const char* name, T* val) {
733 #define GOOGLE_CHECK_NOTNULL(A) \
734 internal::CheckNotNull(__FILE__, __LINE__, "'" #A "' must not be NULL", (A))
738 #define GOOGLE_DLOG GOOGLE_LOG_IF(INFO, false)
740 #define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION)
741 #define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B))
742 #define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B))
743 #define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B))
744 #define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B))
745 #define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B))
746 #define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B))
750 #define GOOGLE_DLOG GOOGLE_LOG
752 #define GOOGLE_DCHECK GOOGLE_CHECK
753 #define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ
754 #define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE
755 #define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT
756 #define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE
757 #define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT
758 #define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE
763 const std::string& message);
858 virtual void Run() = 0;
868 typedef void (*FunctionType)();
871 : function_(function), self_deleting_(self_deleting) {}
875 bool needs_delete = self_deleting_;
877 if (needs_delete)
delete this;
885 template <
typename Class>
888 typedef void (Class::*MethodType)();
891 : object_(object), method_(method), self_deleting_(self_deleting) {}
895 bool needs_delete = self_deleting_;
896 (object_->*method_)();
897 if (needs_delete)
delete this;
906 template <
typename Arg1>
909 typedef void (*FunctionType)(Arg1 arg1);
913 : function_(function), self_deleting_(self_deleting),
918 bool needs_delete = self_deleting_;
920 if (needs_delete)
delete this;
929 template <
typename Class,
typename Arg1>
932 typedef void (Class::*MethodType)(Arg1 arg1);
936 : object_(object), method_(method), self_deleting_(self_deleting),
941 bool needs_delete = self_deleting_;
942 (object_->*method_)(arg1_);
943 if (needs_delete)
delete this;
953 template <
typename Arg1,
typename Arg2>
956 typedef void (*FunctionType)(Arg1 arg1, Arg2 arg2);
959 Arg1 arg1, Arg2 arg2)
960 : function_(function), self_deleting_(self_deleting),
961 arg1_(arg1), arg2_(arg2) {}
965 bool needs_delete = self_deleting_;
966 function_(arg1_, arg2_);
967 if (needs_delete)
delete this;
977 template <
typename Class,
typename Arg1,
typename Arg2>
980 typedef void (Class::*MethodType)(Arg1 arg1, Arg2 arg2);
983 Arg1 arg1, Arg2 arg2)
984 : object_(object), method_(method), self_deleting_(self_deleting),
985 arg1_(arg1), arg2_(arg2) {}
989 bool needs_delete = self_deleting_;
990 (object_->*method_)(arg1_, arg2_);
991 if (needs_delete)
delete this;
1015 template <
typename Class>
1021 template <
typename Class>
1027 template <
typename Arg1>
1034 template <
typename Arg1>
1041 template <
typename Class,
typename Arg1>
1048 template <
typename Class,
typename Arg1>
1055 template <
typename Arg1,
typename Arg2>
1057 Arg1 arg1, Arg2 arg2) {
1059 function,
true, arg1, arg2);
1063 template <
typename Arg1,
typename Arg2>
1065 Arg1 arg1, Arg2 arg2) {
1067 function,
false, arg1, arg2);
1071 template <
typename Class,
typename Arg1,
typename Arg2>
1073 Arg1 arg1, Arg2 arg2) {
1075 object, method,
true, arg1, arg2);
1079 template <
typename Class,
typename Arg1,
typename Arg2>
1081 Class*
object,
void (Class::*method)(Arg1, Arg2),
1082 Arg1 arg1, Arg2 arg2) {
1084 object, method,
false, arg1, arg2);
1142 mu_(mu) {
if (this->mu_ !=
NULL) { this->mu_->Lock(); } }
1199 #if PROTOBUF_USE_EXCEPTIONS
1200 class FatalException :
public std::exception {
1202 FatalException(
const char* filename,
int line,
const std::string& message)
1203 : filename_(filename), line_(line), message_(message) {}
1204 virtual ~FatalException() throw();
1208 const char* filename()
const {
return filename_; }
1209 int line()
const {
return line_; }
1210 const std::string& message()
const {
return message_; }
1213 const char* filename_;
1215 const std::string message_;
1221 using namespace std;
1226 #endif // GOOGLE_PROTOBUF_COMMON_H__
~scoped_array()
Definition: common.h:546
Definition: common.h:1139
bool self_deleting_
Definition: common.h:972
Class * object_
Definition: common.h:901
bool operator!=(C *p) const
Definition: common.h:580
Definition: common.h:1125
Definition: common.h:1099
MutexLockMaybe(Mutex *mu)
Definition: common.h:1141
bool operator==(C *p) const
Definition: common.h:579
MethodType method_
Definition: common.h:948
signed short int16_t
Definition: stdint.h:76
C * array_
Definition: common.h:601
T * CheckNotNull(const char *, int, const char *name, T *val)
Definition: common.h:725
MutexLock ReaderMutexLock
Definition: common.h:1135
bool operator==(C *p) const
Definition: common.h:490
FunctionType function_
Definition: common.h:881
MethodClosure0(Class *object, MethodType method, bool self_deleting)
Definition: common.h:890
static const int64 kint64max
Definition: common.h:199
~FunctionClosure2()
Definition: common.h:962
MutexLock WriterMutexLock
Definition: common.h:1136
uint8_t uint8
Definition: common.h:175
bool self_deleting_
Definition: common.h:949
void swap(scoped_ptr &p2)
Definition: common.h:494
MethodClosure1(Class *object, MethodType method, bool self_deleting, Arg1 arg1)
Definition: common.h:934
void swap(scoped_array &p2)
Definition: common.h:583
arena_t NULL
Definition: jemalloc_internal.h:624
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
Definition: common.h:89
MethodClosure2(Class *object, MethodType method, bool self_deleting, Arg1 arg1, Arg2 arg2)
Definition: common.h:982
C * ptr_
Definition: common.h:512
static const int kMinHeaderVersionForLibrary
Definition: common.h:125
C element_type
Definition: common.h:537
static const int32 kint32min
Definition: common.h:198
Closure * NewCallback(void(*function)())
Definition: common.h:1005
~scoped_ptr()
Definition: common.h:459
bool self_deleting_
Definition: common.h:925
C * release()
Definition: common.h:594
bool operator!=(C *p) const
Definition: common.h:491
signed __int64 int64_t
Definition: stdint.h:89
scoped_ptr(C *p=NULL)
Definition: common.h:455
unsigned int uint
Definition: common.h:157
LIBPROTOBUF_EXPORT void OnShutdown(void(*func)())
scoped_array(C *p=NULL)
Definition: common.h:542
Arg2 arg2_
Definition: common.h:999
int8_t int8
Definition: common.h:170
std::string message_
Definition: common.h:668
C * operator->() const
Definition: common.h:481
MethodType method_
Definition: common.h:902
void reset(C *p=NULL)
Definition: common.h:554
int32_t int32
Definition: common.h:172
bool self_deleting_
Definition: common.h:882
unsigned int uint32_t
Definition: stdint.h:80
void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, const char *filename)
C & operator*() const
Definition: common.h:477
FunctionType function_
Definition: common.h:924
bool self_deleting_
Definition: common.h:903
C & operator[](std::ptrdiff_t i) const
Definition: common.h:564
Closure()
Definition: common.h:855
#define GOOGLE_LOG(LEVEL)
Definition: common.h:706
#define GOOGLE_LONGLONG(x)
Definition: common.h:192
~MethodClosure1()
Definition: common.h:938
std::string LIBPROTOBUF_EXPORT VersionString(int version)
C * release()
Definition: common.h:505
FunctionClosure1(FunctionType function, bool self_deleting, Arg1 arg1)
Definition: common.h:911
MutexLock(Mutex *mu)
Definition: common.h:1127
unsigned __int64 uint64_t
Definition: stdint.h:90
uint16_t uint16
Definition: common.h:176
Mutex *const mu_
Definition: common.h:1130
static const uint32 kuint32max
Definition: common.h:201
LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary()
void Run()
Definition: common.h:964
~MethodClosure2()
Definition: common.h:986
bool self_deleting_
Definition: common.h:997
uint32_t uint32
Definition: common.h:177
FunctionClosure0(FunctionType function, bool self_deleting)
Definition: common.h:870
No & operator<<(std::ostream &, int)
void LIBPROTOBUF_EXPORT DoNothing()
uint64_t uint64
Definition: common.h:178
Internal * mInternal
Definition: common.h:1118
int16_t int16
Definition: common.h:171
void Run()
Definition: common.h:988
~MutexLock()
Definition: common.h:1128
C element_type
Definition: common.h:450
Arg1 arg1_
Definition: common.h:973
MethodType method_
Definition: common.h:996
static const int kMinHeaderVersionForProtoc
Definition: common.h:133
~MutexLockMaybe()
Definition: common.h:1143
LogLevel level_
Definition: common.h:665
FunctionType function_
Definition: common.h:971
void Run()
Definition: common.h:874
Definition: document.h:390
LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char *buf, int len)
#define LIBPROTOBUF_EXPORT
Definition: common.h:105
LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x)
Arg1 arg1_
Definition: common.h:998
void reset(C *p=NULL)
Definition: common.h:467
unsigned char uint8_t
Definition: stdint.h:78
Arg2 arg2_
Definition: common.h:974
FunctionClosure2(FunctionType function, bool self_deleting, Arg1 arg1, Arg2 arg2)
Definition: common.h:958
static const int32 kint32max
Definition: common.h:197
void Run()
Definition: common.h:940
Class * object_
Definition: common.h:947
int64_t int64
Definition: common.h:173
signed char int8_t
Definition: stdint.h:75
static const uint64 kuint64max
Definition: common.h:202
~FunctionClosure1()
Definition: common.h:915
LIBPROTOBUF_EXPORT LogHandler * SetLogHandler(LogHandler *new_func)
LogLevel
Definition: common.h:622
Definition: BnetFileGenerator.h:47
signed int int32_t
Definition: stdint.h:77
int line_
Definition: common.h:667
const FieldDescriptor value
Definition: descriptor.h:1522
#define GOOGLE_ULONGLONG(x)
Definition: common.h:193
~MethodClosure0()
Definition: common.h:892
void LogHandler(LogLevel level, const char *filename, int line, const std::string &message)
Definition: common.h:762
#define const
Definition: zconf.h:217
G3D::int16 x
Definition: Vector2int16.h:37
To down_cast(From *f)
Definition: common.h:334
Arg1 arg1_
Definition: common.h:926
Closure * NewPermanentCallback(void(*function)())
Definition: common.h:1010
const char * filename_
Definition: common.h:666
void Run()
Definition: common.h:894
unsigned short uint16_t
Definition: stdint.h:79
static const int64 kint64min
Definition: common.h:200
void Run()
Definition: common.h:917
To implicit_cast(From const &f)
Definition: common.h:311
Mutex *const mu_
Definition: common.h:1145
void operator=(const scoped_ptr &)
Class * object_
Definition: common.h:995
Arg1 arg1_
Definition: common.h:950