Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/test/example/cla/remainder.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.3 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/named_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", "-abd", "as", "-cd", "aswdf", "--da", "25", "-ffd", "(fgh,", "asd)" };
20    int argc = sizeof(argv)/sizeof(char*);
21
22    try {
23        cla::parser P;
24
25        P - cla::ignore_mismatch
26          << cla::named_parameter<int>( "da" ) - ( cla::prefix = "--" )
27          << cla::named_parameter<std::string>( "abd" );
28
29        P.parse( argc, argv );
30
31        std::cout << "da = " << P.get<int>( "da" ) << std::endl;
32        std::cout << "abd = " << P.get<std::string>( "abd" ) << std::endl;
33
34        std::cout << "argc = " << argc << std::endl;
35        for( int i = 0; i<argc; ++i )
36            std::cout << "argv[" << i << "]= " << argv[i] << std::endl;
37    }
38    catch( rt::logic_error const& ex ) {
39        std::cout << "Logic error: " << ex.msg() << std::endl;
40        return -1;
41    }
42
43    return 0;
44}
45
46// EOF
Note: See TracBrowser for help on using the repository browser.