Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/test/example/cla/dual_name.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1//  (C) Copyright Gennadiy Rozental 2001-2005.
2//  Distributed under the Boost Software License, Version 1.0.
3//  (See accompanying file LICENSE_1_0.txt or copy at
4//  http://www.boost.org/LICENSE_1_0.txt)
5
6//  See http://www.boost.org/libs/test for the library home page.
7
8// Boost.Runtime.Param
9#include <boost/test/utils/runtime/cla/dual_name_parameter.hpp>
10#include <boost/test/utils/runtime/cla/parser.hpp>
11
12namespace rt  = boost::runtime;
13namespace cla = boost::runtime::cla;
14
15// STL
16#include <iostream>
17
18int main() {
19    char* argv[] = { "basic", "/abcd", "25", "-k=1" };
20    int argc = sizeof(argv)/sizeof(char*);
21
22    try {
23        cla::parser P;
24
25        P << cla::dual_name_parameter<int>( "abcd|a" ) - (cla::prefix = "/|-")
26          << cla::dual_name_parameter<int>()           - (cla::name = "klmn|k", cla::separator = "|=");
27
28        P.parse( argc, argv );
29
30        std::cout << "abcd = " << P.get<int>( "abcd" ) << std::endl;
31
32        std::cout << "klmn = " << P.get<int>( "k" ) << std::endl;
33    }
34    catch( rt::logic_error const& ex ) {
35        std::cout << "Logic error: " << ex.msg() << std::endl;
36        return -1;
37    }
38
39    return 0;
40}
41
42// EOF
Note: See TracBrowser for help on using the repository browser.