115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Protocol Buffers - Google's data interchange format 215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Copyright 2008 Google Inc. All rights reserved. 315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// http://code.google.com/p/protobuf/ 415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Redistribution and use in source and binary forms, with or without 615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// modification, are permitted provided that the following conditions are 715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// met: 815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// * Redistributions of source code must retain the above copyright 1015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// notice, this list of conditions and the following disclaimer. 1115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// * Redistributions in binary form must reproduce the above 1215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// copyright notice, this list of conditions and the following disclaimer 1315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// in the documentation and/or other materials provided with the 1415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// distribution. 1515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// * Neither the name of Google Inc. nor the names of its 1615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// contributors may be used to endorse or promote products derived from 1715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// this software without specific prior written permission. 1815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 1915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 3115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Author: kenton@google.com (Kenton Varda) and others 3215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 3315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Contains basic types and utilities used by the rest of the library. 3415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 3515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_PROTOBUF_COMMON_H__ 3615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PROTOBUF_COMMON_H__ 3715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 3815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <assert.h> 3915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <stdlib.h> 4015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <cstddef> 4115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <string> 4215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <string.h> 4315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if defined(__osf__) 4415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Tru64 lacks stdint.h, but has inttypes.h which defines a superset of 4515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// what stdint.h would define. 4615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <inttypes.h> 4715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#elif !defined(_MSC_VER) 4815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <stdint.h> 4915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 5015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 5115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef PROTOBUF_USE_EXCEPTIONS 5215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if defined(_MSC_VER) && defined(_CPPUNWIND) 5315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define PROTOBUF_USE_EXCEPTIONS 1 5415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#elif defined(__EXCEPTIONS) 5515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define PROTOBUF_USE_EXCEPTIONS 1 5615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 5715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define PROTOBUF_USE_EXCEPTIONS 0 5815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 5915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 6015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 6115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if PROTOBUF_USE_EXCEPTIONS 6215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#include <exception> 6315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 6415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 6515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if defined(_WIN32) && defined(GetMessage) 6615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Allow GetMessage to be used as a valid method name in protobuf classes. 6715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// windows.h defines GetMessage() as a macro. Let's re-define it as an inline 6815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// function. The inline function should be equivalent for C++ users. 6915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline BOOL GetMessage_Win32( 7015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LPMSG lpMsg, HWND hWnd, 7115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot UINT wMsgFilterMin, UINT wMsgFilterMax) { 7215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); 7315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 7415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GetMessage 7515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline BOOL GetMessage( 7615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LPMSG lpMsg, HWND hWnd, 7715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot UINT wMsgFilterMin, UINT wMsgFilterMax) { 7815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); 7915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 8015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 8115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 8215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 8315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace std {} 8415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 8515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace google { 8615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace protobuf { 8715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 8815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS 8915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ 9015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot TypeName(const TypeName&); \ 9115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void operator=(const TypeName&) 9215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 9315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) 9415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #ifdef LIBPROTOBUF_EXPORTS 9515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOBUF_EXPORT __declspec(dllexport) 9615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #else 9715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOBUF_EXPORT __declspec(dllimport) 9815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #endif 9915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #ifdef LIBPROTOC_EXPORTS 10015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOC_EXPORT __declspec(dllexport) 10115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #else 10215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOC_EXPORT __declspec(dllimport) 10315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #endif 10415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 10515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOBUF_EXPORT 10615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot #define LIBPROTOC_EXPORT 10715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 10815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 10915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 11015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 11115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Some of these constants are macros rather than const ints so that they can 11215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// be used in #if directives. 11315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 11415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The current version, represented as a single integer to make comparison 11515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// easier: major * 10^6 + minor * 10^3 + micro 11615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PROTOBUF_VERSION 2005000 11715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 11815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The minimum library version which works with the current version of the 11915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// headers. 12015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 2005000 12115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 12215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The minimum header version which works with the current version of 12315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the library. This constant should only be used by protoc's C++ code 12415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// generator. 12515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int kMinHeaderVersionForLibrary = 2005000; 12615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 12715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The minimum protoc version which works with the current version of the 12815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// headers. 12915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 2005000 13015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 13115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The minimum header version which works with the current version of 13215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// protoc. This constant should only be used in VerifyVersion(). 13315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int kMinHeaderVersionForProtoc = 2005000; 13415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 13515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Verifies that the headers and libraries are compatible. Use the macro 13615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// below to call this. 13715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotvoid LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, 13815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const char* filename); 13915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 14015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Converts a numeric version number to a string. 14115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstd::string LIBPROTOBUF_EXPORT VersionString(int version); 14215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 14315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 14415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 14515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Place this macro in your main() function (or somewhere before you attempt 14615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// to use the protobuf library) to verify that the version you link against 14715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// matches the headers you compiled against. If a version mismatch is 14815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// detected, the process will abort. 14915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PROTOBUF_VERIFY_VERSION \ 15015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ::google::protobuf::internal::VerifyVersion( \ 15115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_PROTOBUF_VERSION, GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION, \ 15215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot __FILE__) 15315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 15415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 15515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// from google3/base/port.h 15615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 15715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef unsigned int uint; 15815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 15915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef _MSC_VER 16015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef __int8 int8; 16115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef __int16 int16; 16215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef __int32 int32; 16315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef __int64 int64; 16415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 16515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef unsigned __int8 uint8; 16615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef unsigned __int16 uint16; 16715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef unsigned __int32 uint32; 16815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef unsigned __int64 uint64; 16915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 17015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef int8_t int8; 17115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef int16_t int16; 17215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef int32_t int32; 17315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef int64_t int64; 17415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 17515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef uint8_t uint8; 17615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef uint16_t uint16; 17715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef uint32_t uint32; 17815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef uint64_t uint64; 17915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 18015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 18115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// long long macros to be used because gcc and vc++ use different suffixes, 18215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// and different size specifiers in format strings 18315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_LONGLONG 18415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_ULONGLONG 18515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_LL_FORMAT 18615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 18715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef _MSC_VER 18815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LONGLONG(x) x##I64 18915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ULONGLONG(x) x##UI64 19015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...) 19115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 19215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LONGLONG(x) x##LL 19315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ULONGLONG(x) x##ULL 19415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also. 19515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 19615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 19715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int32 kint32max = 0x7FFFFFFF; 19815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int32 kint32min = -kint32max - 1; 19915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF); 20015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const int64 kint64min = -kint64max - 1; 20115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const uint32 kuint32max = 0xFFFFFFFFu; 20215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstatic const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); 20315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 20415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ------------------------------------------------------------------- 20515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Annotations: Some parts of the code have been annotated in ways that might 20615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// be useful to some compilers or tools, but are not supported universally. 20715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// You can #define these annotations yourself if the default implementation 20815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// is not right for you. 20915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 21015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE 21115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 21215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// For functions we want to force inline. 21315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Introduced in gcc 3.1. 21415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) 21515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 21615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Other compilers will have to figure it out for themselves. 21715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE 21815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 21915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 22015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 22115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_ATTRIBUTE_DEPRECATED 22215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef __GNUC__ 22315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// If the method/variable/type is used anywhere, produce a warning. 22415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated)) 22515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 22615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ATTRIBUTE_DEPRECATED 22715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 22815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 22915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 23015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_PREDICT_TRUE 23115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef __GNUC__ 23215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Provided at least since GCC 3.0. 23315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) 23415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 23515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_PREDICT_TRUE 23615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 23715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 23815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 23915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Delimits a block of code which may write to memory which is simultaneously 24015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// written by other threads, but which has been determined to be thread-safe 24115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// (e.g. because it is an idempotent write). 24215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN 24315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN() 24415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 24515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END 24615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_SAFE_CONCURRENT_WRITES_END() 24715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 24815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 24915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 25015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// from google3/base/basictypes.h 25115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 25215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The GOOGLE_ARRAYSIZE(arr) macro returns the # of elements in an array arr. 25315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The expression is a compile-time constant, and therefore can be 25415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// used in defining new arrays, for example. 25515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 25615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// GOOGLE_ARRAYSIZE catches a few type errors. If you see a compiler error 25715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 25815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// "warning: division by zero in ..." 25915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 26015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// when using GOOGLE_ARRAYSIZE, you are (wrongfully) giving it a pointer. 26115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// You should only use GOOGLE_ARRAYSIZE on statically allocated arrays. 26215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 26315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The following comments are on the implementation details, and can 26415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// be ignored by the users. 26515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 26615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ARRAYSIZE(arr) works by inspecting sizeof(arr) (the # of bytes in 26715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the array) and sizeof(*(arr)) (the # of bytes in one array 26815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// element). If the former is divisible by the latter, perhaps arr is 26915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// indeed an array, in which case the division result is the # of 27015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// elements in the array. Otherwise, arr cannot possibly be an array, 27115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// and we generate a compiler error to prevent the code from 27215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// compiling. 27315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 27415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Since the size of bool is implementation-defined, we need to cast 27515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final 27615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// result has type size_t. 27715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 27815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// This macro is not perfect as it wrongfully accepts certain 27915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// pointers, namely where the pointer size is divisible by the pointee 28015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// size. Since all our code has to go through a 32-bit compiler, 28115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// where a pointer is 4 bytes, this means all pointers to a type whose 28215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// size is 3 or greater than 4 will be (righteously) rejected. 28315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 28415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Kudos to Jorg Brown for this simple and elegant implementation. 28515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 28615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_ARRAYSIZE 28715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_ARRAYSIZE(a) \ 28815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ((sizeof(a) / sizeof(*(a))) / \ 28915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) 29015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 29115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 29215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 29315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Use implicit_cast as a safe version of static_cast or const_cast 29415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// for upcasting in the type hierarchy (i.e. casting a pointer to Foo 29515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// to a pointer to SuperclassOfFoo or casting a pointer to Foo to 29615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// a const pointer to Foo). 29715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// When you use implicit_cast, the compiler checks that the cast is safe. 29815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Such explicit implicit_casts are necessary in surprisingly many 29915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// situations where C++ demands an exact type match instead of an 30015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// argument type convertable to a target type. 30115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 30215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The From type can be inferred, so the preferred syntax for using 30315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// implicit_cast is the same as for static_cast etc.: 30415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 30515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// implicit_cast<ToType>(expr) 30615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 30715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// implicit_cast would have been part of the C++ standard library, 30815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// but the proposal was submitted too late. It will probably make 30915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// its way into the language in the future. 31015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate<typename To, typename From> 31115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline To implicit_cast(From const &f) { 31215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return f; 31315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 31415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 31515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// When you upcast (that is, cast a pointer from type Foo to type 31615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts 31715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// always succeed. When you downcast (that is, cast a pointer from 31815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because 31915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// how do you know the pointer is really of type SubclassOfFoo? It 32015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus, 32115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// when you downcast, you should use this macro. In debug mode, we 32215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// use dynamic_cast<> to double-check the downcast is legal (we die 32315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// if it's not). In normal mode, we do the efficient static_cast<> 32415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// instead. Thus, it's important to test in debug mode to make sure 32515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the cast is legal! 32615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// This is the only place in the code we should use dynamic_cast<>. 32715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// In particular, you SHOULDN'T be using dynamic_cast<> in order to 32815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// do RTTI (eg code like this: 32915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo); 33015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo); 33115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// You should design the code some other way not to need this. 33215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 33315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate<typename To, typename From> // use like this: down_cast<T*>(foo); 33415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline To down_cast(From* f) { // so we only accept pointers 33515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Ensures that To is a sub-type of From *. This test is here only 33615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // for compile-time type checking, and has no overhead in an 33715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // optimized build at run-time, as it will be optimized away 33815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // completely. 33915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (false) { 34015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot implicit_cast<From*, To>(0); 34115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 34215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 34315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) 34415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only! 34515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 34615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return static_cast<To>(f); 34715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 34815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 34915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 35015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 35115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// We made these internal so that they would show up as such in the docs, 35215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// but we don't want to stick "internal::" in front of them everywhere. 35315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::implicit_cast; 35415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::down_cast; 35515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 35615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The COMPILE_ASSERT macro can be used to verify that a compile time 35715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// expression is true. For example, you could use it to verify the 35815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// size of a static array: 35915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 36015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, 36115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// content_type_names_incorrect_size); 36215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 36315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// or to make sure a struct is smaller than a certain size: 36415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 36515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); 36615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 36715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The second argument to the macro is the name of the variable. If 36815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the expression is false, most compilers will issue a warning/error 36915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// containing the name of the variable. 37015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 37115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 37215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 37315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <bool> 37415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotstruct CompileAssert { 37515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 37615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 37715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 37815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 37915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_COMPILE_ASSERT 38015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_COMPILE_ASSERT(expr, msg) \ 38115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \ 38215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot msg[bool(expr) ? 1 : -1] 38315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 38415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 38515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Implementation details of COMPILE_ASSERT: 38615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 38715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// - COMPILE_ASSERT works by defining an array type that has -1 38815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// elements (and thus is invalid) when the expression is false. 38915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 39015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// - The simpler definition 39115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 39215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] 39315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 39415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// does not work, as gcc supports variable-length arrays whose sizes 39515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// are determined at run-time (this is gcc's extension and not part 39615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// of the C++ standard). As a result, gcc fails to reject the 39715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// following code with the simple definition: 39815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 39915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// int foo; 40015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is 40115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// // not a compile-time constant. 40215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 40315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// - By using the type CompileAssert<(bool(expr))>, we ensures that 40415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// expr is a compile-time constant. (Template arguments must be 40515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// determined at compile-time.) 40615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 40715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// - The outter parentheses in CompileAssert<(bool(expr))> are necessary 40815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written 40915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 41015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// CompileAssert<bool(expr)> 41115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 41215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// instead, these compilers will refuse to compile 41315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 41415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// COMPILE_ASSERT(5 > 0, some_message); 41515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 41615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// (They seem to think the ">" in "5 > 0" marks the end of the 41715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// template argument list.) 41815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 41915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// - The array size is (bool(expr) ? 1 : -1), instead of simply 42015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 42115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ((expr) ? 1 : -1). 42215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 42315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// This is to avoid running into a bug in MS VC 7.1, which 42415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. 42515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 42615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 42715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// from google3/base/scoped_ptr.h 42815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 42915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 43015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 43115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// This is an implementation designed to match the anticipated future TR2 43215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// implementation of the scoped_ptr class, and its closely-related brethren, 43315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// scoped_array, scoped_ptr_malloc, and make_scoped_ptr. 43415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 43515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <class C> class scoped_ptr; 43615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <class C> class scoped_array; 43715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 43815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T> 43915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// automatically deletes the pointer it holds (if any). 44015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// That is, scoped_ptr<T> owns the T object that it points to. 44115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object. 44215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 44315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The size of a scoped_ptr is small: 44415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// sizeof(scoped_ptr<C>) == sizeof(C*) 44515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <class C> 44615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass scoped_ptr { 44715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 44815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 44915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The element type 45015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef C element_type; 45115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 45215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Constructor. Defaults to intializing with NULL. 45315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // There is no way to create an uninitialized scoped_ptr. 45415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The input parameter must be allocated with new. 45515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot explicit scoped_ptr(C* p = NULL) : ptr_(p) { } 45615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 45715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Destructor. If there is a C object, delete it. 45815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // We don't need to test ptr_ == NULL because C++ does that for us. 45915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~scoped_ptr() { 46015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot enum { type_must_be_complete = sizeof(C) }; 46115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot delete ptr_; 46215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 46315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 46415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Reset. Deletes the current owned object, if any. 46515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Then takes ownership of a new object, if given. 46615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // this->reset(this->get()) works. 46715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void reset(C* p = NULL) { 46815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (p != ptr_) { 46915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot enum { type_must_be_complete = sizeof(C) }; 47015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot delete ptr_; 47115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ptr_ = p; 47215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 47315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 47415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 47515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Accessors to get the owned object. 47615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // operator* and operator-> will assert() if there is no current object. 47715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C& operator*() const { 47815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot assert(ptr_ != NULL); 47915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return *ptr_; 48015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 48115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* operator->() const { 48215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot assert(ptr_ != NULL); 48315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return ptr_; 48415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 48515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* get() const { return ptr_; } 48615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 48715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Comparison operators. 48815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // These return whether two scoped_ptr refer to the same object, not just to 48915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // two different but equal objects. 49015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool operator==(C* p) const { return ptr_ == p; } 49115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool operator!=(C* p) const { return ptr_ != p; } 49215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 49315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Swap two scoped pointers. 49415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void swap(scoped_ptr& p2) { 49515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* tmp = ptr_; 49615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ptr_ = p2.ptr_; 49715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot p2.ptr_ = tmp; 49815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 49915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 50015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Release a pointer. 50115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The return value is the current pointer held by this object. 50215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // If this object holds a NULL pointer, the return value is NULL. 50315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // After this operation, this object will hold a NULL pointer, 50415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // and will not own the object any more. 50515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* release() { 50615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* retVal = ptr_; 50715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ptr_ = NULL; 50815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return retVal; 50915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 51015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 51115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 51215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* ptr_; 51315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 51415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Forbid comparison of scoped_ptr types. If C2 != C, it totally doesn't 51515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // make sense, and if C2 == C, it still doesn't make sense because you should 51615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // never have the same object owned by two different scoped_ptrs. 51715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot template <class C2> bool operator==(scoped_ptr<C2> const& p2) const; 51815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot template <class C2> bool operator!=(scoped_ptr<C2> const& p2) const; 51915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 52015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Disallow evil constructors 52115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot scoped_ptr(const scoped_ptr&); 52215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void operator=(const scoped_ptr&); 52315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 52415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 52515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate 52615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// with new [] and the destructor deletes objects with delete []. 52715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 52815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// As with scoped_ptr<C>, a scoped_array<C> either points to an object 52915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// or is NULL. A scoped_array<C> owns the object that it points to. 53015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 53115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Size: sizeof(scoped_array<C>) == sizeof(C*) 53215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <class C> 53315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass scoped_array { 53415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 53515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 53615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The element type 53715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef C element_type; 53815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 53915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Constructor. Defaults to intializing with NULL. 54015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // There is no way to create an uninitialized scoped_array. 54115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The input parameter must be allocated with new []. 54215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot explicit scoped_array(C* p = NULL) : array_(p) { } 54315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 54415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Destructor. If there is a C object, delete it. 54515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // We don't need to test ptr_ == NULL because C++ does that for us. 54615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~scoped_array() { 54715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot enum { type_must_be_complete = sizeof(C) }; 54815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot delete[] array_; 54915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 55015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 55115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Reset. Deletes the current owned object, if any. 55215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Then takes ownership of a new object, if given. 55315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // this->reset(this->get()) works. 55415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void reset(C* p = NULL) { 55515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (p != array_) { 55615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot enum { type_must_be_complete = sizeof(C) }; 55715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot delete[] array_; 55815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot array_ = p; 55915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 56015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 56115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 56215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Get one element of the current object. 56315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Will assert() if there is no current object, or index i is negative. 56415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C& operator[](std::ptrdiff_t i) const { 56515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot assert(i >= 0); 56615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot assert(array_ != NULL); 56715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return array_[i]; 56815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 56915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 57015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Get a pointer to the zeroth element of the current object. 57115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // If there is no current object, return NULL. 57215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* get() const { 57315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return array_; 57415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 57515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 57615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Comparison operators. 57715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // These return whether two scoped_array refer to the same object, not just to 57815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // two different but equal objects. 57915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool operator==(C* p) const { return array_ == p; } 58015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool operator!=(C* p) const { return array_ != p; } 58115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 58215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Swap two scoped arrays. 58315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void swap(scoped_array& p2) { 58415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* tmp = array_; 58515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot array_ = p2.array_; 58615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot p2.array_ = tmp; 58715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 58815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 58915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Release an array. 59015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // The return value is the current pointer held by this object. 59115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // If this object holds a NULL pointer, the return value is NULL. 59215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // After this operation, this object will hold a NULL pointer, 59315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // and will not own the object any more. 59415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* release() { 59515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* retVal = array_; 59615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot array_ = NULL; 59715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return retVal; 59815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 59915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 60015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 60115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot C* array_; 60215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 60315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Forbid comparison of different scoped_array types. 60415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot template <class C2> bool operator==(scoped_array<C2> const& p2) const; 60515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot template <class C2> bool operator!=(scoped_array<C2> const& p2) const; 60615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 60715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Disallow evil constructors 60815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot scoped_array(const scoped_array&); 60915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void operator=(const scoped_array&); 61015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 61115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 61215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 61315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 61415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// We made these internal so that they would show up as such in the docs, 61515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// but we don't want to stick "internal::" in front of them everywhere. 61615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::scoped_ptr; 61715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::scoped_array; 61815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 61915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 62015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// emulates google3/base/logging.h 62115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 62215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotenum LogLevel { 62315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_INFO, // Informational. This is never actually used by 62415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // libprotobuf. 62515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_WARNING, // Warns about issues that, although not technically a 62615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // problem now, could cause problems in the future. For 62715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // example, a // warning will be printed when parsing a 62815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // message that is near the message size limit. 62915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_ERROR, // An error occurred which should never happen during 63015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // normal use. 63115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_FATAL, // An error occurred from which the library cannot 63215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // recover. This usually indicates a programming error 63315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // in the code which calls the library, especially when 63415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // compiled in debug mode. 63515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 63615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef NDEBUG 63715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_DFATAL = LOGLEVEL_ERROR 63815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else 63915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LOGLEVEL_DFATAL = LOGLEVEL_FATAL 64015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 64115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 64215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 64315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 64415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 64515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LogFinisher; 64615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 64715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT LogMessage { 64815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 64915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage(LogLevel level, const char* filename, int line); 65015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~LogMessage(); 65115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 65215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(const std::string& value); 65315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(const char* value); 65415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(char value); 65515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(int value); 65615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(uint value); 65715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(long value); 65815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(unsigned long value); 65915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogMessage& operator<<(double value); 66015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 66115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 66215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot friend class LogFinisher; 66315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Finish(); 66415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 66515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogLevel level_; 66615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const char* filename_; 66715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot int line_; 66815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot std::string message_; 66915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 67015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 67115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Used to make the entire "LOG(BLAH) << etc." expression have a void return 67215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// type and print a newline after each message. 67315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT LogFinisher { 67415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 67515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void operator=(LogMessage& other); 67615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 67715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 67815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 67915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 68015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Undef everything in case we're being mixed with some other Google library 68115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// which already defined them itself. Presumably all Google libraries will 68215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// support the same syntax for these so it should not be a big deal if they 68315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// end up using our definitions instead. 68415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_LOG 68515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_LOG_IF 68615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 68715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK 68815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_EQ 68915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_NE 69015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_LT 69115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_LE 69215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_GT 69315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_GE 69415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_CHECK_NOTNULL 69515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 69615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DLOG 69715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK 69815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_EQ 69915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_NE 70015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_LT 70115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_LE 70215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_GT 70315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#undef GOOGLE_DCHECK_GE 70415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 70515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LOG(LEVEL) \ 70615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ::google::protobuf::internal::LogFinisher() = \ 70715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ::google::protobuf::internal::LogMessage( \ 70815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__) 70915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_LOG_IF(LEVEL, CONDITION) \ 71015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) 71115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 71215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK(EXPRESSION) \ 71315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " 71415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B)) 71515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B)) 71615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B)) 71715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B)) 71815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B)) 71915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) 72015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 72115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 72215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate<typename T> 72315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotT* CheckNotNull(const char *file, int line, const char *name, T* val) { 72415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (val == NULL) { 72515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_LOG(FATAL) << name; 72615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 72715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return val; 72815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 72915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 73015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_CHECK_NOTNULL(A) \ 73115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot internal::CheckNotNull(__FILE__, __LINE__, "'" #A "' must not be NULL", (A)) 73215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 73315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#ifdef NDEBUG 73415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 73515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DLOG GOOGLE_LOG_IF(INFO, false) 73615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 73715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION) 73815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B)) 73915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B)) 74015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B)) 74115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B)) 74215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B)) 74315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B)) 74415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 74515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#else // NDEBUG 74615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 74715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DLOG GOOGLE_LOG 74815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 74915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK GOOGLE_CHECK 75015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ 75115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE 75215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT 75315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE 75415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT 75515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE 75615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 75715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif // !NDEBUG 75815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 75915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef void LogHandler(LogLevel level, const char* filename, int line, 76015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const std::string& message); 76115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 76215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// The protobuf library sometimes writes warning and error messages to 76315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// stderr. These messages are primarily useful for developers, but may 76415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// also help end users figure out a problem. If you would prefer that 76515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// these messages be sent somewhere other than stderr, call SetLogHandler() 76615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// to set your own handler. This returns the old handler. Set the handler 76715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// to NULL to ignore log messages (but see also LogSilencer, below). 76815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 76915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Obviously, SetLogHandler is not thread-safe. You should only call it 77015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// at initialization time, and probably not from library code. If you 77115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// simply want to suppress log messages temporarily (e.g. because you 77215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// have some code that tends to trigger them frequently and you know 77315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the warnings are not important to you), use the LogSilencer class 77415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// below. 77515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotLIBPROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func); 77615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 77715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Create a LogSilencer if you want to temporarily suppress all log 77815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// messages. As long as any LogSilencer objects exist, non-fatal 77915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// log messages will be discarded (the current LogHandler will *not* 78015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// be called). Constructing a LogSilencer is thread-safe. You may 78115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// accidentally suppress log messages occurring in another thread, but 78215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// since messages are generally for debugging purposes only, this isn't 78315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// a big deal. If you want to intercept log messages, use SetLogHandler(). 78415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT LogSilencer { 78515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 78615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot LogSilencer(); 78715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~LogSilencer(); 78815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 78915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 79015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 79115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// emulates google3/base/callback.h 79215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 79315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Abstract interface for a callback. When calling an RPC, you must provide 79415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// a Closure to call when the procedure completes. See the Service interface 79515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// in service.h. 79615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 79715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// To automatically construct a Closure which calls a particular function or 79815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// method with a particular set of parameters, use the NewCallback() function. 79915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Example: 80015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void FooDone(const FooResponse* response) { 80115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ... 80215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// } 80315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 80415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void CallFoo() { 80515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ... 80615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// // When done, call FooDone() and pass it a pointer to the response. 80715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Closure* callback = NewCallback(&FooDone, response); 80815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// // Make the call. 80915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// service->Foo(controller, request, response, callback); 81015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// } 81115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 81215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Example that calls a method: 81315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// class Handler { 81415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// public: 81515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ... 81615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 81715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void FooDone(const FooResponse* response) { 81815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ... 81915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// } 82015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 82115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void CallFoo() { 82215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ... 82315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// // When done, call FooDone() and pass it a pointer to the response. 82415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Closure* callback = NewCallback(this, &Handler::FooDone, response); 82515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// // Make the call. 82615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// service->Foo(controller, request, response, callback); 82715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// } 82815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// }; 82915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 83015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Currently NewCallback() supports binding zero, one, or two arguments. 83115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 83215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Callbacks created with NewCallback() automatically delete themselves when 83315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// executed. They should be used when a callback is to be called exactly 83415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// once (usually the case with RPC callbacks). If a callback may be called 83515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// a different number of times (including zero), create it with 83615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// NewPermanentCallback() instead. You are then responsible for deleting the 83715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// callback (using the "delete" keyword as normal). 83815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 83915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Note that NewCallback() is a bit touchy regarding argument types. Generally, 84015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// the values you provide for the parameter bindings must exactly match the 84115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// types accepted by the callback function. For example: 84215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void Foo(string s); 84315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// NewCallback(&Foo, "foo"); // WON'T WORK: const char* != string 84415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// NewCallback(&Foo, string("foo")); // WORKS 84515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Also note that the arguments cannot be references: 84615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// void Foo(const string& s); 84715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// string my_str; 84815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// NewCallback(&Foo, my_str); // WON'T WORK: Can't use referecnes. 84915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// However, correctly-typed pointers will work just fine. 85015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT Closure { 85115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 85215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Closure() {} 85315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot virtual ~Closure(); 85415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 85515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot virtual void Run() = 0; 85615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 85715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 85815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Closure); 85915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 86015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 86115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 86215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 86315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT FunctionClosure0 : public Closure { 86415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 86515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (*FunctionType)(); 86615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 86715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionClosure0(FunctionType function, bool self_deleting) 86815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : function_(function), self_deleting_(self_deleting) {} 86915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~FunctionClosure0(); 87015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 87115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 87215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 87315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot function_(); 87415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 87515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 87615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 87715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 87815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionType function_; 87915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 88015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 88115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 88215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class> 88315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass MethodClosure0 : public Closure { 88415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 88515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (Class::*MethodType)(); 88615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 88715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodClosure0(Class* object, MethodType method, bool self_deleting) 88815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : object_(object), method_(method), self_deleting_(self_deleting) {} 88915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~MethodClosure0() {} 89015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 89115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 89215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 89315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot (object_->*method_)(); 89415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 89515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 89615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 89715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 89815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Class* object_; 89915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodType method_; 90015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 90115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 90215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 90315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1> 90415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass FunctionClosure1 : public Closure { 90515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 90615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (*FunctionType)(Arg1 arg1); 90715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 90815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionClosure1(FunctionType function, bool self_deleting, 90915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) 91015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : function_(function), self_deleting_(self_deleting), 91115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot arg1_(arg1) {} 91215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~FunctionClosure1() {} 91315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 91415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 91515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 91615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot function_(arg1_); 91715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 91815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 91915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 92015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 92115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionType function_; 92215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 92315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1_; 92415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 92515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 92615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1> 92715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass MethodClosure1 : public Closure { 92815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 92915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (Class::*MethodType)(Arg1 arg1); 93015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 93115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodClosure1(Class* object, MethodType method, bool self_deleting, 93215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) 93315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : object_(object), method_(method), self_deleting_(self_deleting), 93415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot arg1_(arg1) {} 93515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~MethodClosure1() {} 93615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 93715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 93815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 93915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot (object_->*method_)(arg1_); 94015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 94115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 94215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 94315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 94415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Class* object_; 94515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodType method_; 94615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 94715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1_; 94815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 94915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 95015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1, typename Arg2> 95115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass FunctionClosure2 : public Closure { 95215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 95315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (*FunctionType)(Arg1 arg1, Arg2 arg2); 95415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 95515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionClosure2(FunctionType function, bool self_deleting, 95615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) 95715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : function_(function), self_deleting_(self_deleting), 95815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot arg1_(arg1), arg2_(arg2) {} 95915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~FunctionClosure2() {} 96015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 96115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 96215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 96315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot function_(arg1_, arg2_); 96415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 96515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 96615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 96715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 96815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FunctionType function_; 96915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 97015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1_; 97115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg2 arg2_; 97215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 97315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 97415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1, typename Arg2> 97515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass MethodClosure2 : public Closure { 97615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 97715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot typedef void (Class::*MethodType)(Arg1 arg1, Arg2 arg2); 97815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 97915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodClosure2(Class* object, MethodType method, bool self_deleting, 98015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) 98115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : object_(object), method_(method), self_deleting_(self_deleting), 98215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot arg1_(arg1), arg2_(arg2) {} 98315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~MethodClosure2() {} 98415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 98515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Run() { 98615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool needs_delete = self_deleting_; // read in case callback deletes 98715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot (object_->*method_)(arg1_, arg2_); 98815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot if (needs_delete) delete this; 98915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot } 99015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 99115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 99215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Class* object_; 99315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot MethodType method_; 99415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot bool self_deleting_; 99515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1_; 99615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg2 arg2_; 99715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 99815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 99915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 100015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 100115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 100215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(void (*function)()) { 100315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure0(function, true); 100415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 100515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 100615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 100715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback(void (*function)()) { 100815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure0(function, false); 100915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 101015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 101115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 101215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class> 101315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(Class* object, void (Class::*method)()) { 101415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure0<Class>(object, method, true); 101515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 101615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 101715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 101815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class> 101915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback(Class* object, void (Class::*method)()) { 102015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure0<Class>(object, method, false); 102115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 102215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 102315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 102415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1> 102515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(void (*function)(Arg1), 102615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) { 102715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure1<Arg1>(function, true, arg1); 102815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 102915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 103015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 103115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1> 103215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback(void (*function)(Arg1), 103315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) { 103415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure1<Arg1>(function, false, arg1); 103515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 103615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 103715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 103815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1> 103915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(Class* object, void (Class::*method)(Arg1), 104015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) { 104115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure1<Class, Arg1>(object, method, true, arg1); 104215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 104315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 104415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 104515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1> 104615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback(Class* object, void (Class::*method)(Arg1), 104715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1) { 104815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure1<Class, Arg1>(object, method, false, arg1); 104915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 105015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 105115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 105215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1, typename Arg2> 105315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(void (*function)(Arg1, Arg2), 105415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) { 105515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure2<Arg1, Arg2>( 105615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot function, true, arg1, arg2); 105715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 105815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 105915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 106015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Arg1, typename Arg2> 106115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback(void (*function)(Arg1, Arg2), 106215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) { 106315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::FunctionClosure2<Arg1, Arg2>( 106415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot function, false, arg1, arg2); 106515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 106615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 106715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 106815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1, typename Arg2> 106915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewCallback(Class* object, void (Class::*method)(Arg1, Arg2), 107015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) { 107115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure2<Class, Arg1, Arg2>( 107215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot object, method, true, arg1, arg2); 107315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 107415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 107515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// See Closure. 107615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottemplate <typename Class, typename Arg1, typename Arg2> 107715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotinline Closure* NewPermanentCallback( 107815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Class* object, void (Class::*method)(Arg1, Arg2), 107915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Arg1 arg1, Arg2 arg2) { 108015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot return new internal::MethodClosure2<Class, Arg1, Arg2>( 108115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot object, method, false, arg1, arg2); 108215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} 108315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 108415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// A function which does nothing. Useful for creating no-op callbacks, e.g.: 108515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Closure* nothing = NewCallback(&DoNothing); 108615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotvoid LIBPROTOBUF_EXPORT DoNothing(); 108715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 108815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 108915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// emulates google3/base/mutex.h 109015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 109115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 109215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 109315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// A Mutex is a non-reentrant (aka non-recursive) mutex. At most one thread T 109415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// may hold a mutex at a given time. If T attempts to Lock() the same Mutex 109515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// while holding it, T will deadlock. 109615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT Mutex { 109715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 109815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Create a Mutex that is not held by anybody. 109915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Mutex(); 110015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 110115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Destructor 110215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~Mutex(); 110315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 110415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Block if necessary until this Mutex is free, then acquire it exclusively. 110515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Lock(); 110615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 110715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Release this Mutex. Caller must hold it exclusively. 110815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void Unlock(); 110915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 111015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // Crash if this Mutex is not held exclusively by this thread. 111115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot // May fail to crash when it should; will never crash when it should not. 111215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot void AssertHeld(); 111315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 111415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 111515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot struct Internal; 111615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Internal* mInternal; 111715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 111815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Mutex); 111915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 112015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 112115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// MutexLock(mu) acquires mu when constructed and releases it when destroyed. 112215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT MutexLock { 112315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 112415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); } 112515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~MutexLock() { this->mu_->Unlock(); } 112615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 112715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Mutex *const mu_; 112815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock); 112915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 113015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 113115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// TODO(kenton): Implement these? Hard to implement portably. 113215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef MutexLock ReaderMutexLock; 113315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robottypedef MutexLock WriterMutexLock; 113415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 113515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL. 113615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass LIBPROTOBUF_EXPORT MutexLockMaybe { 113715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 113815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot explicit MutexLockMaybe(Mutex *mu) : 113915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } } 114015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot ~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } } 114115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 114215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot Mutex *const mu_; 114315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe); 114415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 114515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 114615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 114715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 114815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// We made these internal so that they would show up as such in the docs, 114915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// but we don't want to stick "internal::" in front of them everywhere. 115015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::Mutex; 115115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::MutexLock; 115215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::ReaderMutexLock; 115315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::WriterMutexLock; 115415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing internal::MutexLockMaybe; 115515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 115615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 115715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// from google3/util/utf8/public/unilib.h 115815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 115915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 116015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 116115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Checks if the buffer contains structurally-valid UTF-8. Implemented in 116215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// structurally_valid.cc. 116315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotLIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len); 116415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 116515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 116615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 116715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 116815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// from google3/util/endian/endian.h 116915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotLIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x); 117015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 117115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// =================================================================== 117215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Shutdown support. 117315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 117415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Shut down the entire protocol buffers library, deleting all static-duration 117515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// objects allocated by the library or by generated .pb.cc files. 117615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 117715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// There are two reasons you might want to call this: 117815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// * You use a draconian definition of "memory leak" in which you expect 117915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// every single malloc() to have a corresponding free(), even for objects 118015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// which live until program exit. 118115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// * You are writing a dynamically-loaded library which needs to clean up 118215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// after itself when the library is unloaded. 118315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// 118415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// It is safe to call this multiple times. However, it is not safe to use 118515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// any other part of the protocol buffers library after 118615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// ShutdownProtobufLibrary() has been called. 118715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotLIBPROTOBUF_EXPORT void ShutdownProtobufLibrary(); 118815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 118915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotnamespace internal { 119015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 119115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// Register a function to be called when ShutdownProtocolBuffers() is called. 119215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team RobotLIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); 119315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 119415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace internal 119515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 119615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#if PROTOBUF_USE_EXCEPTIONS 119715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotclass FatalException : public std::exception { 119815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot public: 119915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot FatalException(const char* filename, int line, const std::string& message) 120015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot : filename_(filename), line_(line), message_(message) {} 120115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot virtual ~FatalException() throw(); 120215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 120315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot virtual const char* what() const throw(); 120415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 120515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const char* filename() const { return filename_; } 120615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot int line() const { return line_; } 120715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const std::string& message() const { return message_; } 120815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 120915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot private: 121015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const char* filename_; 121115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const int line_; 121215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot const std::string message_; 121315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot}; 121415560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif 121515560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 121615560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// This is at the end of the file instead of the beginning to work around a bug 121715560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot// in some versions of MSVC. 121815560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robotusing namespace std; // Don't do this at home, kids. 121915560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 122015560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace protobuf 122115560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot} // namespace google 122215560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot 122315560bb32cdb9b47db48eb4865b736df9708a8fandroid-build-team Robot#endif // GOOGLE_PROTOBUF_COMMON_H__ 1224