1 | // (C) Copyright Gennadiy Rozental 2005.
|
---|
2 | // Use, modification, and distribution are subject to the
|
---|
3 | // Boost Software License, Version 1.0. (See accompanying file
|
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
---|
5 |
|
---|
6 | // See http://www.boost.org/libs/test for the library home page.
|
---|
7 | //
|
---|
8 | // File : $RCSfile: argv_traverser.hpp,v $
|
---|
9 | //
|
---|
10 | // Version : $Revision: 1.1 $
|
---|
11 | //
|
---|
12 | // Description : defines facility to hide input traversing details
|
---|
13 | // ***************************************************************************
|
---|
14 |
|
---|
15 | #ifndef BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
|
---|
16 | #define BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
|
---|
17 |
|
---|
18 | // Boost.Runtime.Parameter
|
---|
19 | #include <boost/test/utils/runtime/config.hpp>
|
---|
20 |
|
---|
21 | // Boost.Test
|
---|
22 | #include <boost/test/utils/class_properties.hpp>
|
---|
23 |
|
---|
24 | // Boost
|
---|
25 | #include <boost/noncopyable.hpp>
|
---|
26 | #include <boost/shared_array.hpp>
|
---|
27 |
|
---|
28 | namespace boost {
|
---|
29 |
|
---|
30 | namespace BOOST_RT_PARAM_NAMESPACE {
|
---|
31 |
|
---|
32 | namespace cla {
|
---|
33 |
|
---|
34 | // ************************************************************************** //
|
---|
35 | // ************** runtime::cla::argv_traverser ************** //
|
---|
36 | // ************************************************************************** //
|
---|
37 |
|
---|
38 | class argv_traverser : noncopyable {
|
---|
39 | class parser;
|
---|
40 | public:
|
---|
41 | // Constructor
|
---|
42 | argv_traverser();
|
---|
43 |
|
---|
44 | // public_properties
|
---|
45 | unit_test::readwrite_property<bool> p_ignore_mismatch;
|
---|
46 | unit_test::readwrite_property<char_type> p_separator;
|
---|
47 |
|
---|
48 | // argc+argv <-> internal buffer exchange
|
---|
49 | void init( int argc, char_type** argv );
|
---|
50 | void remainder( int& argc, char_type** argv );
|
---|
51 |
|
---|
52 | // token based parsing
|
---|
53 | cstring token() const;
|
---|
54 | void next_token();
|
---|
55 |
|
---|
56 | // whole input parsing
|
---|
57 | cstring input() const;
|
---|
58 | void trim( std::size_t size );
|
---|
59 | bool match_front( cstring );
|
---|
60 | bool match_front( char_type c );
|
---|
61 | bool eoi() const;
|
---|
62 |
|
---|
63 | // transaction logic support
|
---|
64 | void commit();
|
---|
65 | void rollback();
|
---|
66 |
|
---|
67 | // current position access; used to save some reference points in input
|
---|
68 | std::size_t input_pos() const;
|
---|
69 |
|
---|
70 | // returns true if mismatch detected during input parsing handled successfully
|
---|
71 | bool handle_mismatch();
|
---|
72 |
|
---|
73 | private:
|
---|
74 | // Data members
|
---|
75 | dstring m_buffer;
|
---|
76 | cstring m_work_buffer;
|
---|
77 |
|
---|
78 | cstring m_token;
|
---|
79 | cstring::iterator m_commited_end;
|
---|
80 |
|
---|
81 | shared_array<char_type> m_remainder;
|
---|
82 | std::size_t m_remainder_size;
|
---|
83 | };
|
---|
84 |
|
---|
85 | } // namespace cla
|
---|
86 |
|
---|
87 | } // namespace BOOST_RT_PARAM_NAMESPACE
|
---|
88 |
|
---|
89 | } // namespace boost
|
---|
90 |
|
---|
91 | #ifndef BOOST_RT_PARAM_OFFLINE
|
---|
92 |
|
---|
93 | # define BOOST_RT_PARAM_INLINE inline
|
---|
94 | # include <boost/test/utils/runtime/cla/argv_traverser.ipp>
|
---|
95 |
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | // ************************************************************************** //
|
---|
99 | // Revision History:
|
---|
100 | //
|
---|
101 | // $Log: argv_traverser.hpp,v $
|
---|
102 | // Revision 1.1 2005/04/12 06:42:43 rogeeff
|
---|
103 | // Runtime.Param library initial commit
|
---|
104 | //
|
---|
105 | // ************************************************************************** //
|
---|
106 |
|
---|
107 | #endif // BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
|
---|