blob: 8674bd2144f4490177142793aad0ba18ed127439 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (C) Copyright Gennadiy Rozental 2005-2008.
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$
9//
10// Version : $Revision: 57992 $
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 <ndnboost/test/utils/runtime/config.hpp>
20
21// Boost.Test
22#include <ndnboost/test/utils/class_properties.hpp>
23
24// Boost
25#include <ndnboost/noncopyable.hpp>
26#include <ndnboost/shared_array.hpp>
27
28namespace ndnboost {
29
30namespace BOOST_RT_PARAM_NAMESPACE {
31
32namespace cla {
33
34// ************************************************************************** //
35// ************** runtime::cla::argv_traverser ************** //
36// ************************************************************************** //
37
38class argv_traverser : noncopyable {
39 class parser;
40public:
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
73private:
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 ndnboost
90
91#ifndef BOOST_RT_PARAM_OFFLINE
92
93# define BOOST_RT_PARAM_INLINE inline
94# include <ndnboost/test/utils/runtime/cla/argv_traverser.ipp>
95
96#endif
97
98#endif // BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER