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 ); }
basic_param( cstring name, bool is_optional, bool is_repeatable, Modifiers const& m ) : p_name( name.begin(), name.end() ) , p_description( nfp::opt_get( m, description, std::string() ) ) , p_help( nfp::opt_get( m, runtime::help, std::string() ) ) , p_env_var( nfp::opt_get( m, env_var, std::string() ) ) , p_value_hint( nfp::opt_get( m, value_hint, std::string() ) ) , p_optional( is_optional ) , p_repeatable( is_repeatable ) , p_has_optional_value( m.has( optional_value ) ) , p_has_default_value( m.has( default_value ) || is_repeatable ) , p_callback( nfp::opt_get( m, callback, callback_type() ) ) { add_cla_id( help_prefix, name, ":" ); }
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; }
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; }