OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 | 11 |
12 // Originally comes from shared/commandlineflags/flags.h | 12 // Originally comes from shared/commandlineflags/flags.h |
13 | 13 |
14 // Flags are defined and declared using DEFINE_xxx and DECLARE_xxx macros, | 14 // Flags are defined and declared using DEFINE_xxx and DECLARE_xxx macros, |
15 // where xxx is the flag type. Flags are referred to via FLAG_yyy, | 15 // where xxx is the flag type. Flags are referred to via FLAG_yyy, |
16 // where yyy is the flag name. For intialization and iteration of flags, | 16 // where yyy is the flag name. For intialization and iteration of flags, |
17 // see the FlagList class. For full programmatic access to any | 17 // see the FlagList class. For full programmatic access to any |
18 // flag, see the Flag class. | 18 // flag, see the Flag class. |
19 // | 19 // |
20 // The implementation only relies and basic C++ functionality | 20 // The implementation only relies and basic C++ functionality |
21 // and needs no special library or STL support. | 21 // and needs no special library or STL support. |
22 | 22 |
23 #ifndef WEBRTC_BASE_FLAGS_H__ | 23 #ifndef WEBRTC_BASE_FLAGS_H__ |
24 #define WEBRTC_BASE_FLAGS_H__ | 24 #define WEBRTC_BASE_FLAGS_H__ |
25 | 25 |
26 #include <assert.h> | |
27 | |
28 #include "webrtc/base/checks.h" | 26 #include "webrtc/base/checks.h" |
29 #include "webrtc/base/common.h" | 27 #include "webrtc/base/common.h" |
30 #include "webrtc/base/constructormagic.h" | 28 #include "webrtc/base/constructormagic.h" |
31 | 29 |
32 namespace rtc { | 30 namespace rtc { |
33 | 31 |
34 // Internal use only. | 32 // Internal use only. |
35 union FlagValue { | 33 union FlagValue { |
36 // Note: Because in C++ non-bool values are silently converted into | 34 // Note: Because in C++ non-bool values are silently converted into |
37 // bool values ('bool b = "false";' results in b == true!), we pass | 35 // bool values ('bool b = "false";' results in b == true!), we pass |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // General flag information | 79 // General flag information |
82 const char* file() const { return file_; } | 80 const char* file() const { return file_; } |
83 const char* name() const { return name_; } | 81 const char* name() const { return name_; } |
84 const char* comment() const { return comment_; } | 82 const char* comment() const { return comment_; } |
85 | 83 |
86 // Flag type | 84 // Flag type |
87 Type type() const { return type_; } | 85 Type type() const { return type_; } |
88 | 86 |
89 // Flag variables | 87 // Flag variables |
90 bool* bool_variable() const { | 88 bool* bool_variable() const { |
91 assert(type_ == BOOL); | 89 RTC_DCHECK_EQ(BOOL, type_); |
92 return &variable_->b; | 90 return &variable_->b; |
93 } | 91 } |
94 | 92 |
95 int* int_variable() const { | 93 int* int_variable() const { |
96 assert(type_ == INT); | 94 RTC_DCHECK_EQ(INT, type_); |
97 return &variable_->i; | 95 return &variable_->i; |
98 } | 96 } |
99 | 97 |
100 double* float_variable() const { | 98 double* float_variable() const { |
101 assert(type_ == FLOAT); | 99 RTC_DCHECK_EQ(FLOAT, type_); |
102 return &variable_->f; | 100 return &variable_->f; |
103 } | 101 } |
104 | 102 |
105 const char** string_variable() const { | 103 const char** string_variable() const { |
106 assert(type_ == STRING); | 104 RTC_DCHECK_EQ(STRING, type_); |
107 return &variable_->s; | 105 return &variable_->s; |
108 } | 106 } |
109 | 107 |
110 // Default values | 108 // Default values |
111 bool bool_default() const { | 109 bool bool_default() const { |
112 assert(type_ == BOOL); | 110 RTC_DCHECK_EQ(BOOL, type_); |
113 return default_.b; | 111 return default_.b; |
114 } | 112 } |
115 | 113 |
116 int int_default() const { | 114 int int_default() const { |
117 assert(type_ == INT); | 115 RTC_DCHECK_EQ(INT, type_); |
118 return default_.i; | 116 return default_.i; |
119 } | 117 } |
120 | 118 |
121 double float_default() const { | 119 double float_default() const { |
122 assert(type_ == FLOAT); | 120 RTC_DCHECK_EQ(FLOAT, type_); |
123 return default_.f; | 121 return default_.f; |
124 } | 122 } |
125 | 123 |
126 const char* string_default() const { | 124 const char* string_default() const { |
127 assert(type_ == STRING); | 125 RTC_DCHECK_EQ(STRING, type_); |
128 return default_.s; | 126 return default_.s; |
129 } | 127 } |
130 | 128 |
131 // Resets a flag to its default value | 129 // Resets a flag to its default value |
132 void SetToDefault(); | 130 void SetToDefault(); |
133 | 131 |
134 // Iteration support | 132 // Iteration support |
135 Flag* next() const { return next_; } | 133 Flag* next() const { return next_; } |
136 | 134 |
137 // Prints flag information. The current flag value is only printed | 135 // Prints flag information. The current flag value is only printed |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 char **argv_; | 260 char **argv_; |
263 | 261 |
264 private: | 262 private: |
265 RTC_DISALLOW_COPY_AND_ASSIGN(WindowsCommandLineArguments); | 263 RTC_DISALLOW_COPY_AND_ASSIGN(WindowsCommandLineArguments); |
266 }; | 264 }; |
267 #endif // WEBRTC_WIN | 265 #endif // WEBRTC_WIN |
268 | 266 |
269 } // namespace rtc | 267 } // namespace rtc |
270 | 268 |
271 #endif // SHARED_COMMANDLINEFLAGS_FLAGS_H__ | 269 #endif // SHARED_COMMANDLINEFLAGS_FLAGS_H__ |
OLD | NEW |