1 #include <c10/macros/Macros.h> 2 3 #ifdef C10_USE_GFLAGS 4 5 #include <c10/util/Flags.h> 6 #include <string> 7 8 namespace c10 { 9 10 using std::string; 11 SetUsageMessage(const string & str)12C10_EXPORT void SetUsageMessage(const string& str) { 13 if (UsageMessage() != nullptr) { 14 // Usage message has already been set, so we will simply return. 15 return; 16 } 17 gflags::SetUsageMessage(str); 18 } 19 UsageMessage()20C10_EXPORT const char* UsageMessage() { 21 return gflags::ProgramUsage(); 22 } 23 ParseCommandLineFlags(int * pargc,char *** pargv)24C10_EXPORT bool ParseCommandLineFlags(int* pargc, char*** pargv) { 25 // In case there is no commandline flags to parse, simply return. 26 if (*pargc == 0) 27 return true; 28 return gflags::ParseCommandLineFlags(pargc, pargv, true); 29 } 30 CommandLineFlagsHasBeenParsed()31C10_EXPORT bool CommandLineFlagsHasBeenParsed() { 32 // There is no way we query gflags right now, so we will simply return true. 33 return true; 34 } 35 36 } // namespace c10 37 #endif // C10_USE_GFLAGS 38