OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 1999, Google Inc. |
| 2 // All rights reserved. |
| 3 // |
| 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are |
| 6 // met: |
| 7 // |
| 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above |
| 11 // copyright notice, this list of conditions and the following disclaimer |
| 12 // in the documentation and/or other materials provided with the |
| 13 // distribution. |
| 14 // * Neither the name of Google Inc. nor the names of its |
| 15 // contributors may be used to endorse or promote products derived from |
| 16 // this software without specific prior written permission. |
| 17 // |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
| 30 // --- |
| 31 // |
| 32 // Revamped and reorganized by Craig Silverstein |
| 33 // |
| 34 // This is the file that should be included by any file which declares |
| 35 // command line flag. |
| 36 |
| 37 #ifndef GFLAGS_DECLARE_H_ |
| 38 #define GFLAGS_DECLARE_H_ |
| 39 |
| 40 |
| 41 // --------------------------------------------------------------------------- |
| 42 // Namespace of gflags library symbols. |
| 43 #define GFLAGS_NAMESPACE google |
| 44 |
| 45 // --------------------------------------------------------------------------- |
| 46 // Windows DLL import/export. |
| 47 |
| 48 // We always want to import the symbols of the gflags library |
| 49 #ifndef GFLAGS_DLL_DECL |
| 50 # if 0 && defined(_MSC_VER) |
| 51 # define GFLAGS_DLL_DECL __declspec(dllimport) |
| 52 # else |
| 53 # define GFLAGS_DLL_DECL |
| 54 # endif |
| 55 #endif |
| 56 |
| 57 // We always want to import variables declared in user code |
| 58 #ifndef GFLAGS_DLL_DECLARE_FLAG |
| 59 # ifdef _MSC_VER |
| 60 # define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport) |
| 61 # else |
| 62 # define GFLAGS_DLL_DECLARE_FLAG |
| 63 # endif |
| 64 #endif |
| 65 |
| 66 // --------------------------------------------------------------------------- |
| 67 // Flag types |
| 68 #include <string> |
| 69 #if 1 |
| 70 # include <stdint.h> // the normal place uint32_t is defined |
| 71 #elif 1 |
| 72 # include <sys/types.h> // the normal place u_int32_t is defined |
| 73 #elif 0 |
| 74 # include <inttypes.h> // a third place for uint32_t or u_int32
_t |
| 75 #endif |
| 76 |
| 77 namespace GFLAGS_NAMESPACE { |
| 78 |
| 79 #if 0 // C99 |
| 80 typedef int32_t int32; |
| 81 typedef uint32_t uint32; |
| 82 typedef int64_t int64; |
| 83 typedef uint64_t uint64; |
| 84 #elif 0 // BSD |
| 85 typedef int32_t int32; |
| 86 typedef u_int32_t uint32; |
| 87 typedef int64_t int64; |
| 88 typedef u_int64_t uint64; |
| 89 #elif 1 // Windows |
| 90 typedef __int32 int32; |
| 91 typedef unsigned __int32 uint32; |
| 92 typedef __int64 int64; |
| 93 typedef unsigned __int64 uint64; |
| 94 #else |
| 95 # error Do not know how to define a 32-bit integer quantity on your system |
| 96 #endif |
| 97 |
| 98 } // namespace GFLAGS_NAMESPACE |
| 99 |
| 100 |
| 101 namespace fLS { |
| 102 |
| 103 // The meaning of "string" might be different between now and when the |
| 104 // macros below get invoked (e.g., if someone is experimenting with |
| 105 // other string implementations that get defined after this file is |
| 106 // included). Save the current meaning now and use it in the macros. |
| 107 typedef std::string clstring; |
| 108 |
| 109 } // namespace fLS |
| 110 |
| 111 |
| 112 #define DECLARE_VARIABLE(type, shorttype, name) \ |
| 113 /* We always want to import declared variables, dll or no */ \ |
| 114 namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; }
\ |
| 115 using fL##shorttype::FLAGS_##name |
| 116 |
| 117 #define DECLARE_bool(name) \ |
| 118 DECLARE_VARIABLE(bool, B, name) |
| 119 |
| 120 #define DECLARE_int32(name) \ |
| 121 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name) |
| 122 |
| 123 #define DECLARE_int64(name) \ |
| 124 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name) |
| 125 |
| 126 #define DECLARE_uint64(name) \ |
| 127 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name) |
| 128 |
| 129 #define DECLARE_double(name) \ |
| 130 DECLARE_VARIABLE(double, D, name) |
| 131 |
| 132 #define DECLARE_string(name) \ |
| 133 /* We always want to import declared variables, dll or no */ \ |
| 134 namespace fLS { \ |
| 135 using ::fLS::clstring; \ |
| 136 extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \ |
| 137 } \ |
| 138 using fLS::FLAGS_##name |
| 139 |
| 140 |
| 141 #endif // GFLAGS_DECLARE_H_ |
OLD | NEW |