Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/test/example/env/variable_ex.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.5 KB
Line 
1//  (C) Copyright Gennadiy Rozental 2001-2006.
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/env/variable.hpp>
10#include <boost/test/utils/basic_cstring/io.hpp>
11
12namespace rt  = boost::runtime;
13namespace env = boost::runtime::env;
14
15// STL
16#include <iostream>
17
18env::variable<> TEMP( "TEMP" );
19
20env::variable<int> ProcNumber( "NUMBER_OF_PROCESSORS" );
21
22env::variable<int> abc( "abccccc" );
23
24void print_int( env::variable_base const& var ) {
25    std::cout << var.name() << (var.has_value() ? " is present: " : " is not present: " ) << var.value<int>() << std::endl;
26}
27
28int main() {
29    std::cout << TEMP << '\n' << ProcNumber << std::endl;
30
31    rt::cstring val = TEMP.value();
32    std::cout << " val="  << val << std::endl;
33
34    int n = ProcNumber.value();
35
36    std::cout << " n="  << n << std::endl;
37
38    boost::optional<int> opt_n;
39    ProcNumber.value( opt_n );
40
41    std::cout << " n="  << opt_n << std::endl;
42
43    print_int( ProcNumber );
44
45    if( ProcNumber == 1 )
46        std::cout << "ProcNumber = 1\n";
47
48    if( 2 != ProcNumber )
49        std::cout << "ProcNumber != 2\n";
50
51    if( abc != 1 )
52        std::cout << "abc != 1\n";
53
54    abc = 1;
55
56    if( abc == 1 )
57        std::cout << "abc == 1\n";
58
59    TEMP = "../tmp";
60
61    std::cout << TEMP << std::endl;
62
63    return 0;
64}
65
66// EOF
67
Note: See TracBrowser for help on using the repository browser.