diff options
author | Craig Silverstein <csilvers+gflags@google.com> | 2010-05-07 21:33:49 +0000 |
---|---|---|
committer | Craig Silverstein <csilvers+gflags@google.com> | 2010-05-07 21:33:49 +0000 |
commit | 20500a9e59d47a8954d014de519f22453ccde8cc (patch) | |
tree | 53466d9c374c8d9df99a5cefc58402b5503a825b /src/gflags.cc | |
parent | 31226b61f2d8056261b429ee7c2e2cb3a746513f (diff) | |
download | gflags-20500a9e59d47a8954d014de519f22453ccde8cc.tar.gz gflags-20500a9e59d47a8954d014de519f22453ccde8cc.tar.bz2 gflags-20500a9e59d47a8954d014de519f22453ccde8cc.zip |
* Added a contentful NEWS file (csilvers)
* Fixed email address in maintainers to actually work (csilvers)
* Update docs with info on validators (wojtekm)
git-svn-id: https://gflags.googlecode.com/svn/trunk@38 6586e3c6-dcc4-952a-343f-ff74eb82781d
Diffstat (limited to 'src/gflags.cc')
-rw-r--r-- | src/gflags.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gflags.cc b/src/gflags.cc index e1d5294..d233e50 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -106,7 +106,6 @@ #ifdef HAVE_FNMATCH_H #include <fnmatch.h> #endif // HAVE_FNMATCH_H -#include <iostream> // for cerr #include <string> #include <map> #include <vector> @@ -162,7 +161,6 @@ DEFINE_string(undefok, "", _START_GOOGLE_NAMESPACE_ -using std::cerr; using std::map; using std::pair; using std::sort; @@ -243,6 +241,7 @@ class FlagValue { bool Equal(const FlagValue& x) const; FlagValue* New() const; // creates a new one with default value void CopyFrom(const FlagValue& x); + int ValueSize() const; // Calls the given validate-fn on value_buffer_, and returns // whatever it returns. But first casts validate_fn_proto to a @@ -250,6 +249,7 @@ class FlagValue { // (*validate_fn)(bool) for a bool flag). bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const; + void* value_buffer_; // points to the buffer holding our data ValueType type_; // how to interpret value_ @@ -455,6 +455,18 @@ void FlagValue::CopyFrom(const FlagValue& x) { } } +int FlagValue::ValueSize() const { + switch (type_) { + case FV_BOOL: return sizeof(bool); + case FV_INT32: return sizeof(int32); + case FV_INT64: return sizeof(int64); + case FV_UINT64: return sizeof(uint64); + case FV_DOUBLE: return sizeof(double); + case FV_STRING: return sizeof(string); + default: assert(false); return 0; // unknown type + } +} + // -------------------------------------------------------------------- // CommandLineFlag // This represents a single flag, including its name, description, |