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


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

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


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

示例1: main

int CDECL main(int aArgc, char* aArgv[])
{
    OptionParser parser;
    OptionUint optionDuration("-d", "--duration", 15, "Number of seconds to run the test");
    parser.AddOption(&optionDuration);
    OptionString optionUri("-u", "--uri", Brx::Empty(), "Uri to monitor");
    parser.AddOption(&optionUri);
    if (!parser.Parse(aArgc, aArgv)) {
        return 1;
    }
    InitialisationParams* initParams = InitialisationParams::Create();
    UpnpLibrary::Initialise(initParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager3Logger* logger = new ReceiverManager3Logger(Brx::Empty());
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
	delete blocker;
	
	delete logger;
	UpnpLibrary::Close();
}
开发者ID:cedric-andrieu,项目名称:ohSongcast,代码行数:28,代码来源:TestReceiverManager3.cpp

示例2: TestSsdpMListen

void TestSsdpMListen(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint duration("-d", "--duration", 30, "Number of seconds to listen for.  Defaults to 30");
    parser.AddOption(&duration);
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    Runner runner("SSDP multicast listener\n");
    runner.Add(new SuiteListen(duration.Value(), adapter.Value()));
    runner.Run();
}
开发者ID:astaykov,项目名称:ohNet,代码行数:15,代码来源:TestSsdpMListen.cpp

示例3: TestTopology2

void TestTopology2(Environment& aEnv, const std::vector<Brn>& aArgs)
{
    if( find(aArgs.begin(), aArgs.end(), Brn("--path")) == aArgs.end() )
    {
        Log::Print("No path supplied!\n");
        ASSERTS();
    }

    OptionParser parser;
    OptionString optionServer("-s", "--server", Brn("eng"), "address of server to connect to");
    parser.AddOption(&optionServer);
    OptionUint optionPort("-p", "--port", 80, "server port to connect on");
    parser.AddOption(&optionPort);
    OptionString optionPath("", "--path", Brn(""), "path to use on server");
    parser.AddOption(&optionPath);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    TUint port = optionPort.Value();
    ASSERT(port <= 65535);

    Bwh uriBuf(100);
    Endpoint endptServer = Endpoint(port, optionServer.Value());
    uriBuf.Replace(Brn("http://"));
    endptServer.AppendEndpoint(uriBuf);
    uriBuf.Append(Brn("/"));
    uriBuf.Append(optionPath.Value());
    Uri uri(uriBuf);

    auto reader = new HttpReader(aEnv);
    TUint code = reader->Connect(uri);

    if ((code < HttpStatus::kSuccessCodes) || (code >= HttpStatus::kRedirectionCodes))
    {
        Log::Print("Failed to connect \n");
        ASSERTS();
    }

    ReaderUntilS<1024>* readerUntil = new ReaderUntilS<1024>(*reader);

    Runner runner("Topology2 tests\n");
    runner.Add(new SuiteTopology2(*readerUntil));
    runner.Run();

    delete readerUntil;
    delete reader;
}
开发者ID:kylegordon,项目名称:ohTopologyC,代码行数:48,代码来源:TestTopology2.cpp

示例4: TestNetwork

void TestNetwork(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(Net::InitialisationParams::ELoopbackUse, "TestNetwork");
    ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size());
    TIpAddress addr = (*ifs)[adapter.Value()]->Address();
    for (TUint i=0; i<ifs->size(); i++) {
        (*ifs)[i]->RemoveRef("TestNetwork");
    }
    delete ifs;
    Endpoint endpt(0, addr);
    Endpoint::AddressBuf buf;
    endpt.AppendAddress(buf);
    Print("Using network interface %s\n\n", buf.Ptr());
    Thread* th = new MainNetworkTestThread(addr);
    th->Start();
    th->Wait();
    delete th;
}
开发者ID:chinshou,项目名称:ohNet,代码行数:25,代码来源:TestNetwork.cpp

示例5: main

int CDECL main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");
    parser.AddOption(&optionDuration);
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    Library* lib = new Library(initParams);
    std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    Library::DestroySubnetList(subnetList);
    CpStack* cpStack = lib->StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager1Logger* logger = new ReceiverManager1Logger(*cpStack);
	
    Blocker* blocker = new Blocker(lib->Env());
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	Print("Closing ... ");
	delete lib;
	Print("closed\n");
}
开发者ID:DoomHammer,项目名称:ohSongcast,代码行数:31,代码来源:TestReceiverManager1.cpp

示例6: main

int __cdecl main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");

    parser.AddOption(&optionDuration);
    
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    UpnpLibrary::Initialise(initParams);
    
    UpnpLibrary::StartCp();

    //Debug::SetLevel(Debug::kTopology);

	ReceiverManager2Logger* logger = new ReceiverManager2Logger();
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

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

示例7: duration

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;

    OptionUint duration("-d", "--duration", 30, "Number of seconds to run the test");
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");

    parser.AddOption(&duration);
    parser.AddOption(&adapter);

    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }

    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(false, "TestTopology3");
    ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size());
    TIpAddress subnet = (*ifs)[adapter.Value()]->Subnet();
    for (TUint i=0; i<ifs->size(); i++) {
        (*ifs)[i]->RemoveRef("TestTopology3");
    }
    delete ifs;
    UpnpLibrary::StartCp(subnet);

    Endpoint endpt(0, subnet);
    Endpoint::AddressBuf buf;
    endpt.AppendAddress(buf);
    Print("Using network interface %s\n\n", buf.Ptr());

    // Debug::SetLevel(Debug::kTopology);
    // Debug::SetLevel(Debug::kAll);

    TopologyLogger logger;

    CpTopology3* topology = new CpTopology3(logger);

    if (topology != NULL) {
        Blocker* blocker = new Blocker;
        blocker->Wait(duration.Value());
        delete blocker;
    }

    delete topology;

    UpnpLibrary::Close();

}
开发者ID:cedric-andrieu,项目名称:ohTopology,代码行数:47,代码来源:TestTopology3.cpp

示例8: mx

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over");
    parser.AddOption(&mx);
    OptionBool refresh("-f", "--refresh", "Wait mx secs then refresh list");
    parser.AddOption(&refresh);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }

    if (mx.Value() != 0) {
        aInitParams->SetMsearchTime(mx.Value());
    }
    
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);
    // Debug::SetLevel(Debug::kAll);

    TopologyLogger logger;

    CpTopology1* topology = new CpTopology1(logger);

    if (topology != NULL) {
        Blocker* blocker = new Blocker;
        blocker->Wait(aInitParams->MsearchTimeSecs());
        delete blocker;
    }
    if (refresh.Value()) {
        Blocker* blocker = new Blocker;
        blocker->Wait(mx.Value());
        Print("\nRefreshing...\n\n");
        topology->Refresh();
        blocker->Wait(mx.Value());
        delete blocker;
    }
    
    delete topology;

    UpnpLibrary::Close();
}
开发者ID:cedric-andrieu,项目名称:ohTopology,代码行数:46,代码来源:TestTopology1.cpp

示例9: loopback

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkInterface();
    }
    UpnpLibrary::Initialise(aInitParams);
    UpnpLibrary::StartCombined();
    //Debug::SetLevel(Debug::kDevice/*Debug::kXmlFetch | Debug::kHttp*/);

    Print("TestDviDeviceList - starting\n");

    DvDevices* devices = new DvDevices;
    CpDevices* deviceList = new CpDevices;
    FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed);

    Print("Count devices implementing service1\n");
    Brn domainName("a.b.c");
    Brn serviceType("service1");
    TUint ver = 1;
    CpDeviceListUpnpServiceType* list =
                new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed);
    Blocker* blocker = new Blocker;
    blocker->Wait(aInitParams->MsearchTimeSecs());
    std::vector<const char*> udns;
    udns.push_back((const char*)gNameDevice1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;
    deviceList->Clear();

    Print("Count devices implementing service2\n");
    serviceType.Set("service2");
    list = new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed);
    blocker->Wait(aInitParams->MsearchTimeSecs());
    udns.push_back((const char*)gNameDevice1_1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;

    delete blocker;
    delete deviceList;
    delete devices;

    Print("TestDviDeviceList - completed\n");
    UpnpLibrary::Close();
}
开发者ID:wifigeek,项目名称:ohNet,代码行数:55,代码来源:TestDviDeviceList.cpp

示例10: loopback

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkAdapter();
    }
    aInitParams->SetMsearchTime(1);
    aInitParams->SetDvUpnpServerPort(0);
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCombined(subnet);
    //Debug::SetLevel(Debug::kEvent | Debug::kDvEvent);

    Print("TestDvDeviceStd - starting\n");

    Semaphore* sem = new Semaphore("SEM1", 0);
    DeviceBasic* device = new DeviceBasic(DeviceBasic::eProtocolUpnp);
    CpDevices* deviceList = new CpDevices(device->Device().Udn(), *sem);
    FunctorCpDeviceCpp added = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Added);
    FunctorCpDeviceCpp removed = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Removed);
    std::string domainName("openhome.org");
    std::string serviceType("TestBasic");
    TUint ver = 1;
    CpDeviceListCppUpnpServiceType* list =
                new CpDeviceListCppUpnpServiceType(domainName, serviceType, ver, added, removed);
    sem->Wait(30*1000); // allow up to 30s to find our one device
    try {
        deviceList->TestActions();
        Functor cb = MakeFunctor(sem, &DeviceDisabled);
        device->Device().SetDisabled(cb);
        sem->Wait();
        deviceList->TestThrows();
        device->Device().SetEnabled();
        deviceList->TestSubscriptions();
    }
    catch (Exception& e) {
        Print("Exception %s from %s:%u\n", e.Message(), e.File(), e.Line());
        ASSERTS();
    }
    delete sem;
    delete list;
    delete deviceList;
    delete device;

    Print("TestDvDeviceStd - completed\n");
    UpnpLibrary::Close();
}
开发者ID:alexkit,项目名称:ohNet,代码行数:54,代码来源:TestDvDeviceStd.cpp

示例11: 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

示例12: mx

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], Net::InitialisationParams* aInitParams)
{
    std::vector<Brn> args = OptionParser::ConvertArgs(aArgc, aArgv);

    OptionParser parser;
    OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over");
    parser.AddOption(&mx);
    if (!parser.Parse(args, true) || parser.HelpDisplayed()) {
        return;
    }

    if (mx.Value() != 0) {
        aInitParams->SetMsearchTime(mx.Value());
    }
    Library* lib = new Net::Library(aInitParams);

    TestSsdpUListen(lib->Env(), args);

    delete lib;
}
开发者ID:ACDN,项目名称:ohNet,代码行数:20,代码来源:TestSsdpUListenMain.cpp

示例13: mx

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], Net::InitialisationParams* aInitParams)
{
    std::vector<Brn> args = OptionParser::ConvertArgs(aArgc, aArgv);

    OptionParser parser;
    OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over");
    parser.AddOption(&mx);
    if (!parser.Parse(args, true) || parser.HelpDisplayed()) {
        return;
    }

    if (mx.Value() != 0) {
        aInitParams->SetMsearchTime(mx.Value());
    }
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCp(subnet);

    TestSsdpUListen(args);

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

示例14: loopback

void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], Net::InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkAdapter();
    }
    aInitParams->SetDvUpnpServerPort(0);
    Library* lib = new Library(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    Library::DestroySubnetList(subnetList);
    CpStack* cpStack = NULL;
    DvStack* dvStack = NULL;
    lib->StartCombined(subnet, cpStack, dvStack);

    TestDvSubscription(*cpStack, *dvStack);

    delete lib;
}
开发者ID:ACDN,项目名称:ohNet,代码行数:24,代码来源:TestDvSubscriptionMain.cpp

示例15: main

int main(int aArgc, char* aArgv[])
{
    OptionParser parser;

    OptionString optionRenderer("-r", "--renderer", Brn("dummy"), "Renderer module name.");
    parser.AddOption(&optionRenderer);

    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    Net::InitialisationParams* initParams = Net::InitialisationParams::Create();

    Net::Library* lib = new Net::Library(initParams);

    Net::DvStack* dvStack = lib->StartDv();

    Brhz udn("device1");

    Net::DvDeviceStandard* device = new Net::DvDeviceStandard(*dvStack, udn);

    SourceIndexHandler* sourceIndexHandler = new SourceIndexHandler();
    StandbyHandler* standbyHandler = new StandbyHandler();

    IRenderer* renderer = NULL;
    if (0 == strcmp((const char*)optionRenderer.Value().Ptr(), "dummy"))
    {
      renderer = new Dummy(lib->Env());
    }
#ifdef HAVE_VLC_VLC_H
    else
    {
      renderer = new Vlc(lib->Env());
    }
#endif

    std::vector<OpenHome::NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress adapter = (*subnetList)[0]->Address();
    OpenHome::Net::Library::DestroySubnetList(subnetList);

    char url[1024];
    char attributes[1024];

    sprintf(url, "%d.%d.%d.%d", adapter&0xff, (adapter>>8)&0xff, (adapter>>16)&0xff, (adapter>>24)&0xff);
    Config::GetInstance().GetAbout().SetUrl(url);
    sprintf(url, "http://%s:%s/", url, kHttpPort);
    sprintf(attributes, "Info Time App:Config=%s Volume", url);
    Config::GetInstance().GetAbout().SetVersion(VERSION);

    unsigned long long size;
    const char* res = getResource("/renderer.js", &size);
    Config::GetInstance().RegisterController(res, size);
    Config::GetInstance().GetDataMapper().Append("/data/renderer.json", "renderer");

    Player* player = new Player(
        renderer,
        *device,
        *standbyHandler,
        *sourceIndexHandler,
        true,
        attributes,
        "OpenHome",
        "OpenHome Consortium",
        "http://openhome.org",
        "",
        "OpenHome Media Player",
        "",
        "",
        "",
        Config::GetInstance().GetString("device", "room").c_str(),
        Config::GetInstance().GetString("device", "name").c_str(),
        "",
        url,
        "");

    SourcePlaylist* sourcePlaylist = new SourcePlaylist(*device, kTracksMax, kProtocolInfo, *player);

    player->AddSource(sourcePlaylist);

    device->SetEnabled();

    char c = '\0';
    while (c != 'q') {
        if(scanf("%c", &c))
          ;
    }

    Log::Print("Quiting...\n");

    delete sourcePlaylist;
    delete device;
    delete sourceIndexHandler;
    delete standbyHandler;
    delete player;

    Log::Print("Exit complete\n");

    return (0);
}
开发者ID:roccozhang,项目名称:ohMediaPlayer,代码行数:99,代码来源:main.cpp


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