include_level::include_level( cstring file_name, cstring path_separators, include_level* parent_ ) : m_parent( parent_ ) { if( file_name.is_empty() ) return; assign_op( m_curr_location.first, file_name, 0 ); m_curr_location.second = 0; m_stream.open( m_curr_location.first.c_str() ); if( !m_stream.is_open() && !!m_parent.get() ) { cstring parent_path = m_parent->m_curr_location.first; cstring::iterator it = unit_test::find_last_of( parent_path.begin(), parent_path.end(), path_separators.begin(), path_separators.end() ); if( it != parent_path.end() ) { assign_op( m_curr_location.first, cstring( parent_path.begin(), it+1 ), 0 ); m_curr_location.first.append( file_name.begin(), file_name.end() ); m_stream.clear(); m_stream.open( m_curr_location.first.c_str() ); } } BOOST_RT_PARAM_VALIDATE_LOGIC( m_stream.is_open(), BOOST_RT_PARAM_LITERAL( "couldn't open file " ) << file_name ); }
static bool _( cstring source, boost::optional<bool>& res ) { BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<bool>" ); static literal_cstring YES( BOOST_RT_PARAM_CSTRING_LITERAL( "YES" ) ); static literal_cstring Y( BOOST_RT_PARAM_CSTRING_LITERAL( "Y" ) ); static literal_cstring NO( BOOST_RT_PARAM_CSTRING_LITERAL( "NO" ) ); static literal_cstring N( BOOST_RT_PARAM_CSTRING_LITERAL( "N" ) ); static literal_cstring one( BOOST_RT_PARAM_CSTRING_LITERAL( "1" ) ); static literal_cstring zero( BOOST_RT_PARAM_CSTRING_LITERAL( "0" ) ); source.trim(); if( case_ins_eq( source, YES ) || case_ins_eq( source, Y ) || case_ins_eq( source, one ) ) { res = true; return true; } else if( case_ins_eq( source, NO ) || case_ins_eq( source, N ) || case_ins_eq( source, zero ) ) { res = false; return true; } else { res = true; return source.is_empty(); } }
bool interpret( cstring param_name, cstring source ) const { static cstring const s_YES( "YES" ); static cstring const s_Y( "Y" ); static cstring const s_NO( "NO" ); static cstring const s_N( "N" ); static cstring const s_TRUE( "TRUE" ); static cstring const s_FALSE( "FALSE" ); static cstring const s_one( "1" ); static cstring const s_zero( "0" ); source.trim(); if( source.is_empty() || case_ins_eq( source, s_YES ) || case_ins_eq( source, s_Y ) || case_ins_eq( source, s_one ) || case_ins_eq( source, s_TRUE ) ) return true; if( case_ins_eq( source, s_NO ) || case_ins_eq( source, s_N ) || case_ins_eq( source, s_zero ) || case_ins_eq( source, s_FALSE ) ) return false; BOOST_TEST_I_THROW( format_error( param_name ) << source << " can't be interpreted as bool value." ); }
void config_file_iterator::Impl::process_else( cstring line ) { BOOST_RT_PARAM_VALIDATE_LOGIC( m_conditional_states.size() > 0 && m_conditional_states.back(), BOOST_RT_PARAM_LITERAL( "else without matching if" ) ); m_inactive_ifdef_level = m_conditional_states.size() == m_inactive_ifdef_level ? 0 : m_conditional_states.size(); BOOST_RT_PARAM_VALIDATE_LOGIC( line.is_empty(), BOOST_RT_PARAM_LITERAL( "unexpected tokens at the end of else command" ) ); }
static bool is_valid_identifier( cstring const& source ) { if( source.is_empty() ) return false; cstring::const_iterator it = source.begin(); if( !std::isalpha( *it ) ) return false; while( ++it < source.end() ) { if( !std::isalnum( *it ) && *it != BOOST_RT_PARAM_LITERAL( '_' ) && *it != BOOST_RT_PARAM_LITERAL( '-' ) ) return false; } return true; }
boost::optional<cstring> get_param_value( param_namespace const& where_from, cstring name_part1, cstring name_part2, cstring name_part3, cstring name_part4, cstring name_part5 ) { if( name_part2.is_empty() ) { boost::optional<cstring> res; BOOST_TEST_FOREACH( parameter const&, p, where_from ) { if( p.p_name == name_part1 ) { res = cstring( p.p_value ); break; } } return res; }
inline bool interpret_argument_value( cstring source, hexerboost::optional<std::list<T> >& res, int ) { BOOST_RT_PARAM_TRACE( "In interpret_argument_value<std::list<T>>" ); res = std::list<T>(); while( !source.is_empty() ) { // !! should we use token_iterator cstring::iterator single_value_end = std::find( source.begin(), source.end(), BOOST_RT_PARAM_LITERAL( ',' ) ); hexerboost::optional<T> value; interpret_argument_value( cstring( source.begin(), single_value_end ), value, 0 ); res->push_back( *value ); source.trim_left( single_value_end + 1 ); } return true; }