当前位置: 首页>>代码示例>>C++>>正文


C++ OptionParser::DisplayHelp方法代码示例

本文整理汇总了C++中OptionParser::DisplayHelp方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionParser::DisplayHelp方法的具体用法?C++ OptionParser::DisplayHelp怎么用?C++ OptionParser::DisplayHelp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OptionParser的用法示例。


在下文中一共展示了OptionParser::DisplayHelp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: emptyString

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    Brn emptyString("");
    OptionString config("-c", "--config", emptyString, "[full dir path] to folder containing web UI");
    parser.AddOption(&config);
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (config.Value().Bytes() == 0) {
        parser.DisplayHelp();
        return;
    }

    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkAdapter();
    }
    aInitParams->SetDvNumWebSocketThreads(5);
    aInitParams->SetDvWebSocketPort(54320);
    aInitParams->SetDvUpnpServerPort(0);
    UpnpLibrary::Initialise(aInitParams);
    Debug::SetLevel(Debug::kDvWebSocket | Debug::kError | Debug::kDvInvocation | Debug::kDvEvent | Debug::kDvDevice);
    UpnpLibrary::StartDv();

    Print("TestDvTestBasic - starting ('q' to quit)\n");
    DeviceBasic* device = new DeviceBasic(config.Value());
    while (getchar() != 'q') {
        ;
    }
    delete device;
    Print("TestDvTestBasic - exiting\n");

    UpnpLibrary::Close();
}
开发者ID:astaykov,项目名称:ohNet,代码行数:36,代码来源:TestDvTestBasic.cpp

示例2: TestDeviceList

void TestDeviceList(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over");
    parser.AddOption(&mx);
    OptionBool all("-a", "--all", "Search for all devices and services");
    parser.AddOption(&all);
    OptionBool root("-r", "--root", "Search for root devices only");
    parser.AddOption(&root);
    Brn emptyString("");
    OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device");
    parser.AddOption(&uuid);
    OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]");
    parser.AddOption(&urn);
    OptionBool refresh("-f", "--refresh", "Wait mx secs then refresh list");
    parser.AddOption(&refresh);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

//    Debug::SetLevel(Debug::kDevice);
    DeviceListLogger logger;
    CpDeviceList* deviceList = NULL;
    FunctorCpDevice added = MakeFunctorCpDevice(logger, &DeviceListLogger::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(logger, &DeviceListLogger::Removed);
    if (all.Value()) {
        deviceList = new CpDeviceListUpnpAll(added, removed);
    }
    else if (root.Value()) {
        Print("Search root...\n");
        deviceList = new CpDeviceListUpnpRoot(added, removed);
    }
    else if (uuid.Value().Bytes() > 0) {
        Print("Search uuid...\n");
        deviceList = new CpDeviceListUpnpUuid(uuid.Value(), added, removed);
    }
    else if (urn.Value().Bytes() > 0) {
        Print("Search device/service...\n");
        Brn domainName;
        Brn type;
        TUint ver;
        if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, type, ver)) {
            deviceList = new CpDeviceListUpnpDeviceType(domainName, type, ver, added, removed);
        }
        else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, type, ver)) {
            deviceList = new CpDeviceListUpnpServiceType(domainName, type, ver, added, removed);
        }
        else {
            parser.DisplayHelp();
        }
    }
    else {
        parser.DisplayHelp();
    }

    Blocker* blocker = new Blocker;
    if (deviceList != NULL) {
        blocker->Wait(Stack::InitParams().MsearchTimeSecs());
    }
    if (refresh.Value()) {
        Print("\nRefreshing...\n\n");
        deviceList->Refresh();
        blocker->Wait(Stack::InitParams().MsearchTimeSecs());
    }
    delete blocker;
    delete deviceList;
}
开发者ID:astaykov,项目名称:ohNet,代码行数:67,代码来源:TestDeviceList.cpp

示例3: TestSsdpUListen

void TestSsdpUListen(Environment& aEnv, const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint mx("-mx", "--mx", 0, "[1..5] number of second to spread response over");
    parser.AddOption(&mx);
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    OptionBool all("-a", "--all", "Search for all devices and services");
    parser.AddOption(&all);
    OptionBool root("-r", "--root", "Search for root devices only");
    parser.AddOption(&root);
    Brn emptyString("");
    OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device");
    parser.AddOption(&uuid);
    OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]");
    parser.AddOption(&urn);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    //Debug::SetLevel(Debug::kSsdpMulticast);
    TBool block = true;
    SsdpNotifyLoggerU logger;
    SsdpListenerUnicast* uListener = new SsdpListenerUnicast(aEnv, logger, NetworkIf(aEnv, adapter.Value()));
    uListener->Start();
    if (all.Value()) {
        Print("Search all...\n");
        uListener->MsearchAll();
    }
    else if (root.Value()) {
        Print("Search root...\n");
        uListener->MsearchRoot();
    }
    else if (uuid.Value().Bytes() > 0) {
        Print("Search uuid...\n");
        uListener->MsearchUuid(uuid.Value());
    }
    else if (urn.Value().Bytes() > 0) {
        Print("Search device/service...\n");
        Brn domainName;
        Brn deviceType;
        TUint ver;
        if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, deviceType, ver)) {
            uListener->MsearchDeviceType(domainName, deviceType, ver);
        }
        else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, deviceType, ver)) {
            uListener->MsearchServiceType(domainName, deviceType, ver);
        }
        else {
            parser.DisplayHelp();
            block = false;
        }
    }
    else {
        parser.DisplayHelp();
        block = false;
    }

    if (block) {
        Blocker* blocker = new Blocker(aEnv);
        blocker->Wait(aEnv.InitParams()->MsearchTimeSecs());
        delete blocker;
    }
    delete uListener;
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:65,代码来源:TestSsdpUListen.cpp


注:本文中的OptionParser::DisplayHelp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。