本文整理汇总了C++中util::Config::getBool方法的典型用法代码示例。如果您正苦于以下问题:C++ Config::getBool方法的具体用法?C++ Config::getBool怎么用?C++ Config::getBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util::Config
的用法示例。
在下文中一共展示了Config::getBool方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Start
/// Starts a loop, waiting for connections to send data to.
int Start(int argc, char ** argv) {
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
conf.addOption("stream_name", JSON::fromString("{\"arg_num\":1, \"arg\":\"string\", \"help\":\"Name of the stream this buffer will be providing.\"}"));
conf.addOption("awaiting_ip", JSON::fromString("{\"arg_num\":2, \"arg\":\"string\", \"default\":\"\", \"help\":\"IP address to expect incoming data from. This will completely disable reading from standard input if used.\"}"));
conf.addOption("reportstats", JSON::fromString("{\"default\":0, \"help\":\"Report stats to a controller process.\", \"short\":\"s\", \"long\":\"reportstats\"}"));
conf.parseArgs(argc, argv);
std::string name = conf.getString("stream_name");
SS = Util::Stream::makeLive(name);
if (!SS.connected()) {
perror("Could not create stream socket");
return 1;
}
conf.activate();
thisStream = Stream::get();
thisStream->setName(name);
Socket::Connection incoming;
Socket::Connection std_input(fileno(stdin));
tthread::thread * StatsThread = 0;
if (conf.getBool("reportstats")){StatsThread = new tthread::thread(handleStats, 0);}
tthread::thread * StdinThread = 0;
std::string await_ip = conf.getString("awaiting_ip");
if (await_ip == ""){
StdinThread = new tthread::thread(handleStdin, 0);
}else{
thisStream->setWaitingIP(await_ip);
StdinThread = new tthread::thread(handlePushin, 0);
}
while (buffer_running && SS.connected() && conf.is_active){
//check for new connections, accept them if there are any
//starts a thread for every accepted connection
incoming = SS.accept(true);
if (incoming.connected()){
user * usr_ptr = new user(incoming);
thisStream->addUser(usr_ptr);
usr_ptr->Thread = new tthread::thread(handleUser, (void *)usr_ptr);
}
}//main loop
// disconnect listener
buffer_running = false;
std::cout << "End of input file - buffer shutting down" << std::endl;
SS.close();
if (StatsThread){StatsThread->join();}
StdinThread->join();
delete thisStream;
return 0;
}
示例2: Start
///\brief Starts a loop, waiting for connections to send data to.
///\param argc The number of arguments to the program.
///\param argv The arguments to the program.
///\return The return code of the buffer.
int Start(int argc, char ** argv){
/*std::ofstream myfile ("/home/sharvanath/mistserver/test.txt",std::ios::app);
//struct sockaddr add;
//socklen_t add_length=sizeof(struct sockaddr);
//getsockname(incoming.sock, &add,&add_length);
myfile<<"hello1\n";
//myfile << "the family here is : "<<add.sa_family<<"\n";
myfile.close();
*/
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
conf.addOption("stream_name",
JSON::fromString("{\"arg_num\":1, \"arg\":\"string\", \"help\":\"Name of the stream this buffer will be providing.\"}"));
conf.addOption("awaiting_ip",
JSON::fromString(
"{\"arg_num\":2, \"arg\":\"string\", \"default\":\"\", \"help\":\"IP address to expect incoming data from. This will completely disable reading from standard input if used.\"}"));
conf.addOption("reportstats",
JSON::fromString("{\"default\":0, \"help\":\"Report stats to a controller process.\", \"short\":\"s\", \"long\":\"reportstats\"}"));
conf.addOption("time",
JSON::fromString(
"{\"default\":0, \"arg\": \"integer\", \"help\":\"Buffer a specied amount of time in ms.\", \"short\":\"t\", \"long\":\"time\"}"));
conf.parseArgs(argc, argv);
std::string name = conf.getString("stream_name");
SS = Util::Stream::makeLive(name);
if ( !SS.connected()){
perror("Could not create stream socket");
return 1;
}
SS.setBlocking(false);
conf.activate();
thisStream = Stream::get();
thisStream->setName(name);
thisStream->getStream()->setBufferTime(conf.getInteger("time"));
Socket::Connection incoming;
Socket::Connection std_input(fileno(stdin));
if (conf.getBool("reportstats")){
tthread::thread StatsThread(handleStats, 0);
StatsThread.detach();
}
std::string await_ip = conf.getString("awaiting_ip");
if (await_ip == ""){
tthread::thread StdinThread(handleStdin, 0);
StdinThread.detach();
}else{
thisStream->setWaitingIP(await_ip);
tthread::thread StdinThread(handlePushin, 0);
StdinThread.detach();
}
while (buffer_running && SS.connected() && conf.is_active){
//check for new connections, accept them if there are any
//starts a thread for every accepted connection
//sharva_mod
incoming = SS.accept(true);
if (incoming.connected()){
tthread::thread thisUser(handleUser, (void *)new user(incoming));
thisUser.detach();
}else{
Util::sleep(50);//sleep 50ms
}
} //main loop
// disconnect listener
buffer_running = false;
std::cout << "Buffer shutting down" << std::endl;
SS.close();
if (thisStream->getIPInput().connected()){
thisStream->getIPInput().close();
}
delete thisStream;
return 0;
}
示例3: DTSCFix
///\brief Reads a DTSC file and attempts to fix the metadata in it.
///\param conf The current configuration of the program.
///\return The return code for the fixed program.
int DTSCFix(Util::Config & conf){
DTSC::File F(conf.getString("filename"));
F.seek_bpos(0);
F.parseNext();
JSON::Value oriheader = F.getJSON();
JSON::Value meta = F.getMeta();
JSON::Value pack;
if ( !oriheader.isMember("moreheader")){
std::cerr << "This file is too old to fix - please reconvert." << std::endl;
return 1;
}
if (DTSC::isFixed(meta) && !conf.getBool("force")){
std::cerr << "This file was already fixed or doesn't need fixing - cancelling." << std::endl;
return 0;
}
meta.removeMember("isFixed");
meta.removeMember("keytime");
meta.removeMember("keybpos");
meta.removeMember("moreheader");
std::map<std::string,int> trackIDs;
std::map<std::string,HeaderEntryDTSC> trackData;
long long int nowpack = 0;
std::string currentID;
int nextFreeID = 0;
for (JSON::ObjIter it = meta["tracks"].ObjBegin(); it != meta["tracks"].ObjEnd(); it++){
trackIDs.insert(std::pair<std::string,int>(it->first,it->second["trackid"].asInt()));
trackData[it->first].type = it->second["type"].asString();
trackData[it->first].trackID = it->second["trackid"].asInt();
trackData[it->first].type = it->second["type"].asString();
if (it->second["trackid"].asInt() >= nextFreeID){
nextFreeID = it->second["trackid"].asInt() + 1;
}
it->second.removeMember("keylen");
it->second.removeMember("keybpos");
it->second.removeMember("frags");
it->second.removeMember("keytime");
it->second.removeMember("keynum");
it->second.removeMember("keydata");
it->second.removeMember("keyparts");
it->second.removeMember("keys");
}
F.parseNext();
while ( !F.getJSON().isNull()){
currentID = "";
if (F.getJSON()["trackid"].asInt() == 0){
if (F.getJSON()["datatype"].asString() == "video"){
currentID = "video0";
if (trackData[currentID].trackID == 0){
trackData[currentID].trackID = nextFreeID++;
}
if (meta.isMember("video")){
meta["tracks"][currentID] = meta["video"];
meta.removeMember("video");
}
trackData[currentID].type = F.getJSON()["datatype"].asString();
}else{
if (F.getJSON()["datatype"].asString() == "audio"){
currentID = "audio0";
if (trackData[currentID].trackID == 0){
trackData[currentID].trackID = nextFreeID++;
}
if (meta.isMember("audio")){
meta["tracks"][currentID] = meta["audio"];
meta.removeMember("audio");
}
trackData[currentID].type = F.getJSON()["datatype"].asString();
}else{
//fprintf(stderr, "Found an unknown package with packetid 0 and datatype %s\n",F.getJSON()["datatype"].asString().c_str());
F.parseNext();
continue;
}
}
}else{
for( std::map<std::string,int>::iterator it = trackIDs.begin(); it != trackIDs.end(); it++ ) {
if( it->second == F.getJSON()["trackid"].asInt() ) {
currentID = it->first;
break;
}
}
if( currentID == "" ) {
//fprintf(stderr, "Found an unknown v2 packet with id %d\n", F.getJSON()["trackid"].asInt());
F.parseNext();
continue;
//should create new track but this shouldnt be needed...
}
}
if (F.getJSON()["time"].asInt() < trackData[currentID].firstms){
trackData[currentID].firstms = F.getJSON()["time"].asInt();
}
if (F.getJSON()["time"].asInt() >= nowpack){
//.........这里部分代码省略.........