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
392eb67d
Commit
392eb67d
authored
Apr 21, 2013
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CMakeLists.txt and adapt source files accordingly.
parent
2eed08d9
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
321 additions
and
177 deletions
+321
-177
CMakeLists.txt
CMakeLists.txt
+134
-0
gflags.h.in
include/gflags/gflags.h.in
+35
-17
gflags_completions.h.in
include/gflags/gflags_completions.h.in
+2
-11
gflags_declare.h.in
include/gflags/gflags_declare.h.in
+47
-20
config.h.in
src/config.h.in
+57
-83
gflags.cc
src/gflags.cc
+12
-11
gflags_completions.cc
src/gflags_completions.cc
+5
-5
gflags_reporting.cc
src/gflags_reporting.cc
+5
-5
mutex.h
src/mutex.h
+4
-9
util.h
src/util.h
+20
-16
No files found.
CMakeLists.txt
0 → 100644
View file @
392eb67d
cmake_minimum_required
(
VERSION 2.6 FATAL_ERROR
)
# ----------------------------------------------------------------------------
# package information
set
(
PROJECT_NAME
"gflags"
)
set
(
PACKAGE_NAME
"
${
PROJECT_NAME
}
"
)
set
(
PACKAGE_VERSION
"2.1.0"
)
set
(
PACKAGE_STRING
"
${
PROJECT_NAME
}
${
PACKAGE_VERSION
}
"
)
set
(
PACKAGE_TARNAME
"
${
PROJECT_NAME
}
-
${
PACKAGE_VERSION
}
"
)
set
(
PACKAGE_BUGREPORT
"https://code.google.com/p/gflags/issues/"
)
project
(
${
PROJECT_NAME
}
)
# ----------------------------------------------------------------------------
# configure options
option
(
BUILD_SHARED_LIBS
"Request build of shared libraries."
OFF
)
set
(
GFLAGS_NAMESPACE
"gflags"
CACHE STRING
"C++ namespace identifier of gflags library."
)
mark_as_advanced
(
GFLAGS_NAMESPACE
)
# ----------------------------------------------------------------------------
# source files - excluding root subdirectory and/or .in suffix
set
(
PUBLIC_HDRS
"gflags/gflags.h"
"gflags/gflags_declare.h"
"gflags/gflags_completions.h"
)
set
(
PRIVATE_HDRS
"config.h"
)
set
(
GFLAGS_SRCS
"gflags.cc"
"gflags_reporting.cc"
"gflags_completions.cc"
)
# ----------------------------------------------------------------------------
# system checks
include
(
CheckTypeSize
)
foreach
(
type IN ITEMS uint16_t u_int16_t __int16
)
CHECK_TYPE_SIZE
(
${
type
}
SIZE
)
if
(
SIZE
)
set
(
HAVE_
${
type
}
1
)
else
()
set
(
HAVE_
${
type
}
0
)
endif
()
endforeach
()
include
(
CheckIncludeFileCXX
)
foreach
(
fname IN ITEMS fnmatch inttypes unistd sys/stat
)
string
(
TOUPPER
"
${
fname
}
"
FNAME
)
string
(
REGEX REPLACE
"/"
"_"
FNAME
"
${
FNAME
}
"
)
CHECK_INCLUDE_FILE_CXX
(
"
${
fname
}
.h"
HAVE_
${
FNAME
}
_H
)
if
(
HAVE_
${
FNAME
}
_H
)
set
(
HAVE_
${
FNAME
}
_H 1
)
else
()
set
(
HAVE_
${
FNAME
}
_H 0
)
endif
()
endforeach
()
include
(
CheckSymbolExists
)
foreach
(
fname IN ITEMS strtoll strtoq
)
string
(
TOUPPER
"
${
fname
}
"
FNAME
)
CHECK_SYMBOL_EXISTS
(
"
${
fname
}
"
stdlib.h HAVE_
${
FNAME
}
)
if
(
HAVE_
${
FNAME
}
)
set
(
HAVE_
${
FNAME
}
1
)
else
()
set
(
HAVE_
${
FNAME
}
0
)
endif
()
endforeach
()
find_package
(
Threads
)
if
(
Threads_FOUND
)
if
(
CMAKE_USE_PTHREADS_INIT
)
set
(
HAVE_PTHREAD 1
)
else
()
set
(
HAVE_PTHREAD 0
)
endif
()
endif
()
# ----------------------------------------------------------------------------
# configure source files
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
__ATTRIBUTE__UNUSED
"__attribute((unused))"
)
else
()
set
(
__ATTRIBUTE__UNUSED
)
endif
()
function
(
configure_sources out subdir
)
set
(
tmp
)
foreach
(
src IN LISTS ARGN
)
set
(
src
"
${
subdir
}
/
${
src
}
"
)
if
(
EXISTS
"
${
PROJECT_SOURCE_DIR
}
/
${
src
}
.in"
)
configure_file
(
"
${
PROJECT_SOURCE_DIR
}
/
${
src
}
.in"
"
${
PROJECT_BINARY_DIR
}
/
${
src
}
"
@ONLY
)
list
(
APPEND tmp
"
${
PROJECT_BINARY_DIR
}
/
${
src
}
"
)
else
()
list
(
APPEND tmp
"
${
PROJECT_SOURCE_DIR
}
/
${
src
}
"
)
endif
()
endforeach
()
set
(
${
out
}
"
${
tmp
}
"
PARENT_SCOPE
)
endfunction
()
configure_sources
(
PUBLIC_HDRS include
${
PUBLIC_HDRS
}
)
configure_sources
(
PRIVATE_HDRS src
${
PRIVATE_HDRS
}
)
configure_sources
(
GFLAGS_SRCS src
${
GFLAGS_SRCS
}
)
# ----------------------------------------------------------------------------
# output directories
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
"bin"
)
set
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
"lib"
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"lib"
)
# ----------------------------------------------------------------------------
# add library target
include_directories
(
"
${
PROJECT_BINARY_DIR
}
/include"
"
${
PROJECT_SOURCE_DIR
}
/include"
"
${
PROJECT_BINARY_DIR
}
/src"
"
${
PROJECT_SOURCE_DIR
}
/src"
)
if
(
WIN32
)
add_definitions
(
-DGFLAGS_DLL_EXPORT
)
endif
()
add_library
(
gflags
${
GFLAGS_SRCS
}
)
# ----------------------------------------------------------------------------
# installation
install
(
TARGETS gflags DESTINATION lib
)
install
(
FILES
${
PUBLIC_HDRS
}
DESTINATION include/gflags
)
include/gflags/gflags.h.in
View file @
392eb67d
...
...
@@ -78,18 +78,34 @@
#ifndef GFLAGS_GFLAGS_H_
#define GFLAGS_GFLAGS_H_
#if !defined(GFLAGS_DLL_DECL)
# if defined(_MSC_VER)
# if defined(GFLAGS_DLL_EXPORT)
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL __declspec(dllimport)
# endif
# else
# define GFLAGS_DLL_DECL
# endif
#endif
// We always want to export defined variables, dll or no
#if !defined(GFLAGS_DLL_DEFINE_FLAG)
# if defined(_MSC_VER)
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllimport)
# else
# define GFLAGS_DLL_DEFINE_FLAG
# endif
#endif
#include <string>
#include <vector>
#include <gflags/gflags_declare.h> // IWYU pragma: export
@ac_google_start_namespace@
//
// NOTE: all functions below MUST have an explicit 'extern' before
// them. Our automated opensourcing tools use this as a signal to do
// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
//
#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
#define GFLAGS_DLL_DEFINE_FLAG /* rewritten to be non-empty in windows dir */
namespace @GFLAGS_NAMESPACE@ {
// --------------------------------------------------------------------
...
...
@@ -138,7 +154,7 @@ extern bool RegisterFlagValidator(const std::string* flag,
// Convenience macro for the registration of a flag validator
#define DEFINE_validator(name, validator) \
static const bool name##_validator_registered = \
@
ac_google_namespace
@::RegisterFlagValidator(&FLAGS_##name, validator)
@
GFLAGS_NAMESPACE
@::RegisterFlagValidator(&FLAGS_##name, validator)
// --------------------------------------------------------------------
...
...
@@ -288,7 +304,7 @@ class GFLAGS_DLL_DECL FlagSaver {
FlagSaver(const FlagSaver&); // no copying!
void operator=(const FlagSaver&);
}
@
ac_cv___attribute__unused
@;
@
__ATTRIBUTE__UNUSED
@;
// --------------------------------------------------------------------
// Some deprecated or hopefully-soon-to-be-deprecated functions.
...
...
@@ -445,14 +461,16 @@ class GFLAGS_DLL_DECL FlagRegisterer {
extern const char kStrippedFlagHelp[];
@ac_google_end_namespace@
} // namespace @GFLAGS_NAMESPACE@
#ifndef SWIG // In swig, ignore the main flag declarations
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
// Need this construct to avoid the 'defined but not used' warning.
#define MAYBE_STRIPPED_HELP(txt) \
(false ? (txt) : @
ac_google_namespace
@::kStrippedFlagHelp)
(false ? (txt) : @
GFLAGS_NAMESPACE
@::kStrippedFlagHelp)
#else
#define MAYBE_STRIPPED_HELP(txt) txt
#endif
...
...
@@ -474,7 +492,7 @@ extern const char kStrippedFlagHelp[];
/* We always want to export defined variables, dll or no */ \
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
type FLAGS_no##name = FLAGS_nono##name; \
static @
ac_google_namespace
@::FlagRegisterer o_##name( \
static @
GFLAGS_NAMESPACE
@::FlagRegisterer o_##name( \
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
&FLAGS_##name, &FLAGS_no##name); \
} \
...
...
@@ -507,15 +525,15 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
DEFINE_VARIABLE(bool, B, name, val, txt)
#define DEFINE_int32(name, val, txt) \
DEFINE_VARIABLE(@
ac_google_namespace
@::int32, I, \
DEFINE_VARIABLE(@
GFLAGS_NAMESPACE
@::int32, I, \
name, val, txt)
#define DEFINE_int64(name, val, txt) \
DEFINE_VARIABLE(@
ac_google_namespace
@::int64, I64, \
DEFINE_VARIABLE(@
GFLAGS_NAMESPACE
@::int64, I64, \
name, val, txt)
#define DEFINE_uint64(name,val, txt) \
DEFINE_VARIABLE(@
ac_google_namespace
@::uint64, U64, \
DEFINE_VARIABLE(@
GFLAGS_NAMESPACE
@::uint64, U64, \
name, val, txt)
#define DEFINE_double(name, val, txt) \
...
...
@@ -556,7 +574,7 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
clstring* const FLAGS_no##name = ::fLS:: \
dont_pass0toDEFINE_string(s_##name[0].s, \
val); \
static @
ac_google_namespace@::FlagRegisterer o_##name(
\
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)); \
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
...
...
include/gflags/gflags_completions.h.in
View file @
392eb67d
...
...
@@ -112,19 +112,10 @@ $ complete -o bashdefault -o default -o nospace -C \
#ifndef GFLAGS_COMPLETIONS_H_
#define GFLAGS_COMPLETIONS_H_
// Annoying stuff for windows -- makes sure clients can import these functions
//
// NOTE: all functions below MUST have an explicit 'extern' before
// them. Our automated opensourcing tools use this as a signal to do
// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
//
#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
@ac_google_start_namespace@
namespace @GFLAGS_NAMESPACE@ {
extern void HandleCommandLineCompletions(void);
@ac_google_end_namespace@
}
#endif // GFLAGS_COMPLETIONS_H_
include/gflags/gflags_declare.h.in
View file @
392eb67d
...
...
@@ -37,40 +37,64 @@
#ifndef GFLAGS_DECLARE_H_
#define GFLAGS_DECLARE_H_
#if !defined(GFLAGS_DLL_DECL)
# if defined(_MSC_VER)
# if defined(GFLAGS_DLL_EXPORT)
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL __declspec(dllimport)
# endif
# else
# define GFLAGS_DLL_DECL
# endif
#endif
// We always want to import declared variables, dll or no
#if !defined(GFLAGS_DLL_DECLARE_FLAG)
# if defined(_MSC_VER)
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
# else
# define GFLAGS_DLL_DECLARE_FLAG
# endif
#endif
#include <string>
#if @
ac_cv_have_stdint_h
@
#if @
HAVE_STDINT_H
@
#include <stdint.h> // the normal place uint16_t is defined
#endif
#if @
ac_cv_have_systypes_h
@
#if @
HAVE_SYS_TYPES_H
@
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
#if @
ac_cv_have_inttypes_h
@
#if @
HAVE_INTTYPES_H
@
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
@ac_google_start_namespace@
#if @ac_cv_have_uint16_t@ // the C99 format
typedef int32_t int32;
namespace @GFLAGS_NAMESPACE@ {
#if @HAVE_uint16_t@ // the C99 format
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef int64_t
int64;
typedef uint64_t uint64;
#elif @
ac_cv_have_u_int16_t@
// the BSD format
typedef int32_t int32;
#elif @
HAVE_u_int16_t@
// the BSD format
typedef int32_t
int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef int64_t
int64;
typedef u_int64_t uint64;
#elif @
ac_cv_have___int16@
// the windows (vc7) format
typedef __int32 int32;
#elif @
HAVE___int16@
// the windows (vc7) format
typedef __int32
int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef __int64
int64;
typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#
error Do not know how to define a 32-bit integer quantity on your system
#endif
@ac_google_end_namespace@
} // namespace @GFLAGS_NAMESPACE@
#define GFLAGS_DLL_DECLARE_FLAG /* rewritten to be non-empty in windows dir */
namespace fLS {
...
...
@@ -80,7 +104,8 @@ namespace fLS {
// included). Save the current meaning now and use it in the macros.
typedef std::string clstring;
}
} // namespace fLS
#define DECLARE_VARIABLE(type, shorttype, name) \
/* We always want to import declared variables, dll or no */ \
...
...
@@ -103,10 +128,12 @@ typedef std::string clstring;
DECLARE_VARIABLE(double, D, name)
#define DECLARE_string(name) \
namespace fLS { \
using ::fLS::clstring; \
/* We always want to import declared variables, dll or no */ \
namespace fLS { \
using ::fLS::clstring; \
extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
}
\
} \
using fLS::FLAGS_##name
#endif // GFLAGS_DECLARE_H_
src/config.h.in
View file @
392eb67d
/*
src/config.h.in. Generated from configure.ac by autoheader.
*/
/*
Generated from config.h.in during configuration using CMake.
*/
/* Always the empty-string on non-windows systems. On windows, should be
"__declspec(dllexport)". This way, when we compile the dll, we export our
functions/classes. It's safe to define this here because config.h is only
used internally, to compile the DLL, and every DLL source file #includes
"config.h" before anything else. */
#undef GFLAGS_DLL_DECL
// ---------------------------------------------------------------------------
// Meta-information
/
* Namespace for Google classes */
#
undef GOOGLE_NAMESPACE
/
/ Name of package.
#
define PACKAGE @PROJECT_NAME@
/
* Define to 1 if you have the <dlfcn.h> header file. */
#
undef HAVE_DLFCN_H
/
/ Define to the full name of this package.
#
define PACKAGE_NAME @PACKAGE_NAME@
/
* Define to 1 if you have the <fnmatch.h> header file. */
#
undef HAVE_FNMATCH_H
/
/ Define to the full name and version of this package.
#
define PACKAGE_STRING @PACKAGE_STRING@
/
* Define to 1 if you have the <inttypes.h> header file. */
#
undef HAVE_INTTYPES_H
/
/ Define to the one symbol short name of this package.
#
define PACKAGE_TARNAME @PACKAGE_TARNAME@
/
* Define to 1 if you have the <memory.h> header file. */
#
undef HAVE_MEMORY_H
/
/ Define to the version of this package.
#
define PACKAGE_VERSION @PACKAGE_VERSION@
/
* define if the compiler implements namespaces */
#
undef HAVE_NAMESPACES
/
/ Version number of package.
#
define VERSION PACKAGE_VERSION
/
* Define if you have POSIX threads libraries and header files. */
#
undef HAVE_PTHREAD
/
/ Define to the address where bug reports for this package should be sent.
#
define PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
// ---------------------------------------------------------------------------
// Namespace for gflags symbols.
#define GFLAGS_NAMESPACE @GFLAGS_NAMESPACE@
/
* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/
/ ---------------------------------------------------------------------------
// Available system headers
/
* Define to 1 if you have the <strings.h> header file. */
#
undef HAVE_STRINGS_H
/
/ Whether sources are compiled on a Windows system
#
define WINDOWS (defined(_WIN32) || defined(WIN32) || defined(_WINDOWS))
/
* Define to 1 if you have the <string.h> header file. */
#
undef HAVE_STRING_H
/
/ Define to 1 if you have the <fnmatch.h> header file.
#
define HAVE_FNMATCH_H @HAVE_FNMATCH_H@
/
* Define to 1 if you have the `strtoll' function. */
#
undef HAVE_STRTOLL
/
/ Define to 1 if you have the <inttypes.h> header file.
#
define HAVE_INTTYPES_H @HAVE_INTTYPES_H@
/
* Define to 1 if you have the `strtoq' function. */
#
undef HAVE_STRTOQ
/
/ Define to 1 if you have the <unistd.h> header file.
#
define HAVE_UNISTD_H @HAVE_UNISTD_H@
/
* Define to 1 if you have the <sys/stat.h> header file. */
#
undef HAVE_SYS_STAT_H
/
/ Define to 1 if you have the <sys/stat.h> header file.
#
define HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
/
* Define to 1 if you have the <sys/types.h> header file. */
#
undef HAVE_SYS_TYPES_H
/
/ Define to 1 if you have the strtoll function.
#
define HAVE_STRTOLL @HAVE_STRTOLL@
/
* Define to 1 if you have the <unistd.h> header file. */
#
undef HAVE_UNISTD_H
/
/ Define to 1 if you have the strtoq function.
#
define HAVE_STRTOQ @HAVE_STRTOQ@
/
* define if your compiler has __attribute__ */
#
undef HAVE___ATTRIBUTE__
/
/ Define to 1 if you have the <pthread.h> header file.
#
define HAVE_PTHREAD @HAVE_PTHREAD@
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* the namespace where STL code like vector<> is defined */
#undef STL_NAMESPACE
/* Version number of package */
#undef VERSION
/* Stops putting the code inside the Google namespace */
#undef _END_GOOGLE_NAMESPACE_
/* Puts following code inside the Google namespace */
#undef _START_GOOGLE_NAMESPACE_
// ---------------------------------------------------------------------------
// Path separator
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
#endif
// ---------------------------------------------------------------------------
// Windows-specific definitions
#if !defined(GFLAGS_DLL_DECL)
# if defined(_MSC_VER)
# if defined(GFLAGS_DLL_EXPORT)
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL __declspec(dllimport)
# endif
# else
# define GFLAGS_DLL_DECL
# endif
#endif
#if defined( __MINGW32__) || defined(__MINGW64__)
#include "windows/port.h"
#
include "windows/port.h"
#endif
src/gflags.cc
View file @
392eb67d
...
...
@@ -89,7 +89,7 @@
// This comes first to ensure we define __STDC_FORMAT_MACROS in time.
#include <config.h>
#if
defined(HAVE_INTTYPES_H)
&& !defined(__STDC_FORMAT_MACROS)
#if
HAVE_INTTYPES_H
&& !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1 // gcc requires this to get PRId64, etc.
#endif
...
...
@@ -97,7 +97,7 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#if
def
HAVE_FNMATCH_H
#if HAVE_FNMATCH_H
# include <fnmatch.h>
#endif
#include <stdarg.h> // For va_list and related operations
...
...
@@ -113,7 +113,7 @@
#include "util.h"
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
#
define PATH_SEPARATOR '/'
#endif
...
...
@@ -133,7 +133,7 @@ DEFINE_string(undefok, "",
"with that name. IMPORTANT: flags in this list that have "
"arguments MUST use the flag=value format"
);
_START_GOOGLE_NAMESPACE_
namespace
GFLAGS_NAMESPACE
{
using
std
::
map
;
using
std
::
pair
;
...
...
@@ -206,7 +206,7 @@ class FlagValue {
private
:
friend
class
CommandLineFlag
;
// for many things, including Validate()
friend
class
G
OOGLE
_NAMESPACE
::
FlagSaverImpl
;
// calls New()
friend
class
G
FLAGS
_NAMESPACE
::
FlagSaverImpl
;
// calls New()
friend
class
FlagRegistry
;
// checks value_buffer_ for flags_by_ptr_ map
template
<
typename
T
>
friend
T
GetFromEnv
(
const
char
*
,
const
char
*
,
T
);
friend
bool
TryParseLocked
(
const
CommandLineFlag
*
,
FlagValue
*
,
...
...
@@ -504,7 +504,7 @@ class CommandLineFlag {
private
:
// for SetFlagLocked() and setting flags_by_ptr_
friend
class
FlagRegistry
;
friend
class
G
OOGLE
_NAMESPACE
::
FlagSaverImpl
;
// for cloning the values
friend
class
G
FLAGS
_NAMESPACE
::
FlagSaverImpl
;
// for cloning the values
// set validate_fn
friend
bool
AddFlagValidator
(
const
void
*
,
ValidateFnProto
);
...
...
@@ -671,9 +671,9 @@ class FlagRegistry {
static
FlagRegistry
*
GlobalRegistry
();
// returns a singleton registry
private
:
friend
class
G
OOGLE
_NAMESPACE
::
FlagSaverImpl
;
// reads all the flags in order to copy them
friend
class
G
FLAGS
_NAMESPACE
::
FlagSaverImpl
;
// reads all the flags in order to copy them
friend
class
CommandLineFlagParser
;
// for ValidateAllFlags
friend
void
G
OOGLE
_NAMESPACE
::
GetAllFlags
(
vector
<
CommandLineFlagInfo
>*
);
friend
void
G
FLAGS
_NAMESPACE
::
GetAllFlags
(
vector
<
CommandLineFlagInfo
>*
);
// The map from name to flag, for FindFlagLocked().
typedef
map
<
const
char
*
,
CommandLineFlag
*
,
StringCmp
>
FlagMap
;
...
...
@@ -1318,7 +1318,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
// We try matching both against the full argv0 and basename(argv0)
if
(
glob
==
ProgramInvocationName
()
// small optimization
||
glob
==
ProgramInvocationShortName
()
#if
def
HAVE_FNMATCH_H
#if HAVE_FNMATCH_H
||
fnmatch
(
glob
.
c_str
(),
ProgramInvocationName
(),
FNM_PATHNAME
)
==
0
...
...
@@ -1505,7 +1505,7 @@ const char* ProgramInvocationName() { // like the GNU libc fn
}
const
char
*
ProgramInvocationShortName
()
{
// like the GNU libc fn
const
char
*
slash
=
strrchr
(
argv0
,
'/'
);
#ifdef
OS_
WINDOWS
#ifdef WINDOWS
if
(
!
slash
)
slash
=
strrchr
(
argv0
,
'\\'
);
#endif
return
slash
?
slash
+
1
:
argv0
;
...
...
@@ -1957,4 +1957,5 @@ void ShutDownCommandLineFlags() {
FlagRegistry
::
DeleteGlobalRegistry
();
}
_END_GOOGLE_NAMESPACE_
}
// namespace GFLAGS_NAMESPACE
src/gflags_completions.cc
View file @
392eb67d
...
...
@@ -64,9 +64,6 @@ using std::set;
using
std
::
string
;
using
std
::
vector
;
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
#endif
DEFINE_string
(
tab_completion_word
,
""
,
"If non-empty, HandleCommandLineCompletions() will hijack the "
...
...
@@ -75,7 +72,9 @@ DEFINE_string(tab_completion_word, "",
DEFINE_int32
(
tab_completion_columns
,
80
,
"Number of columns to use in output for tab completion"
);
_START_GOOGLE_NAMESPACE_
namespace
GFLAGS_NAMESPACE
{
namespace
{
// Function prototypes and Type forward declarations. Code may be
...
...
@@ -765,4 +764,5 @@ void HandleCommandLineCompletions(void) {
gflags_exitfunc
(
0
);
}
_END_GOOGLE_NAMESPACE_
}
// namespace GFLAGS_NAMESPACE
src/gflags_reporting.cc
View file @
392eb67d
...
...
@@ -59,9 +59,6 @@
#include <gflags/gflags_completions.h>
#include "util.h"
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
#endif
// The 'reporting' flags. They all call gflags_exitfunc().
DEFINE_bool
(
help
,
false
,
...
...
@@ -81,7 +78,9 @@ DEFINE_bool(helpxml, false,
DEFINE_bool
(
version
,
false
,
"show version and build info and exit"
);
_START_GOOGLE_NAMESPACE_
namespace
GFLAGS_NAMESPACE
{
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -444,4 +443,5 @@ void HandleCommandLineHelpFlags() {
}
}
_END_GOOGLE_NAMESPACE_
}
// namespace GFLAGS_NAMESPACE
src/mutex.h
View file @
392eb67d
...
...
@@ -32,11 +32,6 @@
// A simple mutex wrapper, supporting locks and read-write locks.
// You should assume the locks are *not* re-entrant.
//
// To use: you should define the following macros in your configure.ac:
// ACX_PTHREAD
// AC_RWLOCK
// The latter is defined in ../autoconf.
//
// This class is meant to be internal-only and should be wrapped by an
// internal namespace. Before you use this module, please give the
// name of your internal namespace for this module. Or, if you want
...
...
@@ -108,8 +103,8 @@
// weird to a Mutex's memory after it is destroyed, but for a
// static global variable, that's pretty safe.
#ifndef G
OOGLE
_MUTEX_H_
#define G
OOGLE
_MUTEX_H_
#ifndef G
FLAGS
_MUTEX_H_
#define G
FLAGS
_MUTEX_H_
#include "config.h" // to figure out pthreads support
...
...
@@ -145,7 +140,7 @@
# endif
# include <pthread.h>
typedef
pthread_rwlock_t
MutexType
;
#elif
defined(HAVE_PTHREAD)
#elif
HAVE_PTHREAD
# include <pthread.h>
typedef
pthread_mutex_t
MutexType
;
#else
...
...
@@ -353,4 +348,4 @@ using namespace MUTEX_NAMESPACE;
#undef MUTEX_NAMESPACE
#endif
/* #define G
OOGLE
_MUTEX_H__ */
#endif
/* #define G
FLAGS
_MUTEX_H__ */
src/util.h
View file @
392eb67d
...
...
@@ -36,46 +36,48 @@
#include <assert.h>
#include <config.h>
#if
def
HAVE_INTTYPES_H
# include <inttypes.h>
#if HAVE_INTTYPES_H
#
include <inttypes.h>
#endif
#include <stdarg.h> // for va_*
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#if
def
HAVE_SYS_STAT_H
# include <sys/stat.h>
#if HAVE_SYS_STAT_H
#
include <sys/stat.h>
#endif // for mkdir()
_START_GOOGLE_NAMESPACE_
namespace
GFLAGS_NAMESPACE
{
// This is used for unittests for death-testing. It is defined in gflags.cc.
extern
GFLAGS_DLL_DECL
void
(
*
gflags_exitfunc
)(
int
);
// Work properly if either strtoll or strtoq is on this system
#if
def
HAVE_STRTOLL
# define strto64 strtoll
# define strtou64 strtoull
#if HAVE_STRTOLL
#
define strto64 strtoll
#
define strtou64 strtoull
#elif HAVE_STRTOQ
# define strto64 strtoq
# define strtou64 strtouq
#
define strto64 strtoq
#
define strtou64 strtouq
#else
// Neither strtoll nor strtoq are defined. I hope strtol works!
# define strto64 strtol
# define strtou64 strtoul
#
define strto64 strtol
#
define strtou64 strtoul
#endif
// If we have inttypes.h, it will have defined PRId32/etc for us. If
// not, take our best guess.
#ifndef PRId32
# define PRId32 "d"
#
define PRId32 "d"
#endif
#ifndef PRId64
# define PRId64 "lld"
#
define PRId64 "lld"
#endif
#ifndef PRIu64
# define PRIu64 "llu"
#
define PRIu64 "llu"
#endif
typedef
signed
char
int8
;
...
...
@@ -320,6 +322,8 @@ inline std::string StringPrintf(const char* format, ...) {
return
output
;
}
_END_GOOGLE_NAMESPACE_
}
// namespace GFLAGS_NAMESPACE
#endif // GFLAGS_UTIL_H_
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