本文整理汇总了C++中PacketReader::hasPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::hasPacket方法的具体用法?C++ PacketReader::hasPacket怎么用?C++ PacketReader::hasPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::hasPacket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
boost::program_options::notify(vm);
/**
* Special case for help
*/
if ( vm.count("help") )
{
std::cout << desc << std::endl;
return 0;
}
std::cout << "Server : " << vm["server"].as<std::string>() << std::endl;
std::cout << "Port : " << vm["port"].as<int>() << std::endl;
std::cout << "---------------" << std::endl;
for (boost::program_options::variables_map::iterator it=vm.begin(); it!=vm.end(); ++it )
{
if ( it->second.value().type() == typeid(int) )
{
std::cout << it->first.c_str() << "=" << it->second.as<int>() << std::endl;
}
else if (it->second.value().type() == typeid(std::string) )
{
std::cout << it->first.c_str() << "=" << it->second.as<std::string>().c_str() << std::endl;
}
else if (it->second.value().type() == typeid(attribute_list) )
{
std::cout << it->first.c_str() << "=Attribute List" << std::endl;
}
}
std::cout << "-------------------------" << std::endl;
/**
* because boost query is too stupid to take port as an int
*/
std::stringstream port_str;
port_str << vm["port"].as<int>();
/**
* Wrangle the file etc options
*/
std::string file = "";
bool playOnly = false;
if( vm.count("playonly") )
{
std::string s = vm["playonly"].as<std::string>();
if ( boost::iequals(s,"true") )
{
playOnly = true;
}
}
if( vm.count("file") )
{
file = vm["file"].as<std::string>();
}
if ( file.empty() )
{
std::cout << "--file option not specified, but is required" << std::endl;
return 13;
}
/**
* Initialize reader
*/
p = new PacketReader();
int pkts = p->parseBinaryFile(file);
if( playOnly )
{
while(p->hasPacket())
{
MetaServerPacket msp = p->pop();
unsigned int i = msp.getPacketType();
std::string s = msp.getOutBound() ? ">>>>" : "<<<<";
std::cout << "Packet [";
std::cout << std::setfill('0') << std::setw(10) << msp.getSequence();
std::cout << "] " << s << " : " << NMT_PRETTY[i] << std::endl;
}
}
else
{
std::cout << "TODO: play packets to listed metaserver" << std::endl;
}
std::cout << "Packet File : " << file << std::endl;
std::cout << "Packet Count: " << pkts << std::endl;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
}
std::cout << "All Done!" << std::endl;
return 0;
}