File indexing completed on 2025-01-18 09:52:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_TEST_UTILS_RUNTIME_CLA_ARGV_TRAVERSER_HPP
0016 #define BOOST_TEST_UTILS_RUNTIME_CLA_ARGV_TRAVERSER_HPP
0017
0018
0019 #include <boost/test/utils/runtime/fwd.hpp>
0020 #include <cstring>
0021
0022 #include <boost/test/detail/suppress_warnings.hpp>
0023
0024 namespace boost {
0025 namespace runtime {
0026 namespace cla {
0027
0028
0029
0030
0031
0032 class argv_traverser {
0033 typedef char const** argv_type;
0034 public:
0035
0036
0037
0038 argv_traverser( int argc, argv_type argv )
0039 : m_argc( argc )
0040 , m_curr_token( 0 )
0041 , m_token_size( 0 )
0042 , m_argv( argv )
0043 {
0044
0045 save_token();
0046 }
0047
0048
0049 int remainder()
0050 {
0051 return static_cast<int>(m_argc);
0052 }
0053
0054
0055 bool eoi() const
0056 {
0057 return m_curr_token == m_argc;
0058 }
0059
0060
0061 cstring current_token()
0062 {
0063 if( eoi() )
0064 return cstring();
0065
0066 return cstring( m_argv[m_curr_token], m_token_size );
0067 }
0068
0069
0070 void save_token()
0071 {
0072 ++m_curr_token;
0073
0074 if( !eoi() )
0075 m_token_size = ::strlen( m_argv[m_curr_token] );
0076 }
0077
0078
0079 void next_token()
0080 {
0081 if( !eoi() ) {
0082 for( std::size_t i = m_curr_token; i < m_argc-1; ++i )
0083 m_argv[i] = m_argv[i + 1];
0084
0085 --m_argc;
0086
0087 m_token_size = ::strlen( m_argv[m_curr_token] );
0088 }
0089 }
0090
0091 private:
0092
0093
0094 std::size_t m_argc;
0095 std::size_t m_curr_token;
0096 std::size_t m_token_size;
0097 argv_type m_argv;
0098 };
0099
0100 }
0101 }
0102 }
0103
0104 #include <boost/test/detail/enable_warnings.hpp>
0105
0106 #endif