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