本文整理汇总了C++中Flag::help方法的典型用法代码示例。如果您正苦于以下问题:C++ Flag::help方法的具体用法?C++ Flag::help怎么用?C++ Flag::help使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flag
的用法示例。
在下文中一共展示了Flag::help方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char *argv[])
{
Flag flag;
flag.addOption("h", "127.0.0.1", "server address");
flag.addOption("p", "10001", "server port");
flag.addOption("c", "1", "number of client to run");
if (!flag.parse(argc, argv))
{
std::cout << flag.help() << std::endl;
return -1;
}
std::string host;
int port;
int clientNum;
flag.getString("h", host);
flag.getInt("p", port);
flag.getInt("c", clientNum);
io_service ios;
std::list<boost::shared_ptr<Client> > clients;
boost::thread_group threads;
// for (int i = 0; i < clientNum; ++i)
// {
// boost::shared_ptr<Client> c(new Client(ios, host, port));
// clients.push_back(c);
// threads.create_thread(boost::bind(&Client::startConnect, c));
// }
for (int i = 0; i < clientNum; ++i)
{
boost::shared_ptr<Client> c(new Client(ios, host, port));
clients.push_back(c);
c->startConnect();
}
int coreNum = boost::thread::hardware_concurrency();
for (int i = 0; i < coreNum; ++i)
{
threads.create_thread(boost::bind(&boost::asio::io_service::run, &ios));
}
threads.join_all();
return 0;
}