异想天开

What's the true meaning of light, Could you tell me why

gflags

日期:2016-02-16 20:58:44
  
最后更新日期:2016-02-17 14:16:58
google命令行开源解析库
示例程序:
[code lang="cpp"]
#include <gflags/gflags.h>
#include <iostream>
using namespace std;

DEFINE_string(foo, "",
"The model definition protocol buffer text file..");
void test()
{
if (FLAGS_foo.size()>0)
{
cout<<"foo len:" << FLAGS_foo.size() << " val :" << FLAGS_foo << endl;
}
}

int main(int argc, char **argv)
{
::gflags::SetusageMessage("Usage: test.bin -foo=xxx\n\n");
::gflags::ParseCommandLineFlags(&argc, &argv, true);
test();
return 0;
}
[/code]
编译
g++ -I ../lib/gflags/ gflag_foo.cpp -lgflags -o testaout
运行:
./testaout -foo="hello world"
foo len:11 val :hello world