Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
a5a1b287
Commit
a5a1b287
authored
Aug 01, 2016
by
Andreas Schuh
Committed by
GitHub
Aug 01, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #158 from dreamer-dead/use-type-name-enum
Use enum to specify flag value type.
parents
fe57e5af
7ba99218
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
gflags.cc
src/gflags.cc
+0
-0
gflags.h.in
src/gflags.h.in
+10
-5
gflags_unittest.cc
test/gflags_unittest.cc
+3
-3
No files found.
src/gflags.cc
View file @
a5a1b287
This diff is collapsed.
Click to expand it.
src/gflags.h.in
View file @
a5a1b287
...
...
@@ -431,9 +431,14 @@ extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
class GFLAGS_DLL_DECL FlagRegisterer {
public:
FlagRegisterer(const char* name, const char* type,
// We instantiate this template ctor for all supported types,
// so it is possible to place implementation of the FlagRegisterer ctor in
// .cc file.
// Calling this constructor with unsupported type will produce linker error.
template <typename FlagType>
FlagRegisterer(const char* name,
const char* help, const char* filename,
void* current_storage, void
* defvalue_storage);
FlagType* current_storage, FlagType
* defvalue_storage);
};
// If your application #defines STRIP_FLAG_HELP to a non-zero value
...
...
@@ -475,7 +480,7 @@ extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
type FLAGS_no##name = FLAGS_nono##name; \
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
#name,
#type, MAYBE_STRIPPED_HELP(help), __FILE__,
\
#name,
MAYBE_STRIPPED_HELP(help), __FILE__,
\
&FLAGS_##name, &FLAGS_no##name); \
} \
using fL##shorttype::FLAGS_##name
...
...
@@ -581,8 +586,8 @@ public:
dont_pass0toDEFINE_string(s_##name[0].s, \
val); \
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
#name,
"string", MAYBE_STRIPPED_HELP(txt), __FILE__,
\
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name));
\
#name,
MAYBE_STRIPPED_HELP(txt), __FILE__,
\
FLAGS_no##name, new (s_##name[1].s) clstring(*FLAGS_no##name));
\
static StringFlagDestructor d_##name(s_##name[0].s, s_##name[1].s); \
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
using fLS::FLAGS_##name; \
...
...
test/gflags_unittest.cc
View file @
a5a1b287
...
...
@@ -216,7 +216,7 @@ namespace fLI {
int32
FLAGS_tldflag1
=
FLAGS_nonotldflag1
;
int32
FLAGS_notldflag1
=
FLAGS_nonotldflag1
;
static
FlagRegisterer
o_tldflag1
(
"tldflag1"
,
"int32"
,
"tldflag1"
,
"should show up in --helpshort"
,
"gflags_unittest.cc"
,
&
FLAGS_tldflag1
,
&
FLAGS_notldflag1
);
}
...
...
@@ -227,7 +227,7 @@ namespace fLI {
int32
FLAGS_tldflag2
=
FLAGS_nonotldflag2
;
int32
FLAGS_notldflag2
=
FLAGS_nonotldflag2
;
static
FlagRegisterer
o_tldflag2
(
"tldflag2"
,
"int32"
,
"tldflag2"
,
"should show up in --helpshort"
,
"gflags_unittest."
,
&
FLAGS_tldflag2
,
&
FLAGS_notldflag2
);
}
...
...
@@ -1355,7 +1355,7 @@ TEST(ParseCommandLineFlagsWrongFields,
// addresses of these variables will be overwritten... Stack smash!
static
bool
current_storage
;
static
bool
defvalue_storage
;
FlagRegisterer
fr
(
"flag_name"
,
"bool"
,
0
,
"filename"
,
FlagRegisterer
fr
(
"flag_name"
,
NULL
,
"filename"
,
&
current_storage
,
&
defvalue_storage
);
CommandLineFlagInfo
fi
;
EXPECT_TRUE
(
GetCommandLineFlagInfo
(
"flag_name"
,
&
fi
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment