Beispiel #1
0
    void                accept_modifier( Modifier const& m )
    {
        optionally_assign( m_value_handler, m, handler );
        optionally_assign( m_value_interpreter, m, interpreter );

        if( m.has( default_value ) ) {
            BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, 
                BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) );

            T const& dv_ref = m[default_value];
            m_value_generator = rt_cla_detail::const_generator<T>( dv_ref );
        }

        if( m.has( default_refer_to ) ) {
            BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, 
                BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) );

            cstring ref_id = m[default_refer_to];
            m_value_generator = rt_cla_detail::ref_generator<T>( ref_id );
        }

        if( m.has( assign_to ) ) {
            BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_handler, 
                BOOST_RT_PARAM_LITERAL( "multiple value handlers for parameter" ) );

            m_value_handler = rt_cla_detail::assigner<T>( m[assign_to] );
        }
    }
 virtual void    usage_info( format_stream& fs ) const
 {
     fs << BOOST_RT_PARAM_LITERAL( '{' );
     m_primary.usage_info( fs );
     fs << BOOST_RT_PARAM_LITERAL( '|' );
     m_secondary.usage_info( fs );
     fs << BOOST_RT_PARAM_LITERAL( '}' );
 }
Beispiel #3
0
    void            usage_info( format_stream& fs ) const
    { 
        m_id_policy.usage_info( fs );
        if( p_optional_value )
            fs << BOOST_RT_PARAM_LITERAL( '[' );

        m_arg_factory.argument_usage_info( fs );

        if( p_optional_value )
            fs << BOOST_RT_PARAM_LITERAL( ']' );
    }
Beispiel #4
0
inline argument_ptr
typed_argument_factory<T>::produce_using( parameter& p, argv_traverser& tr )
{
    hexerboost::optional<T> value;

    try {
        m_value_interpreter( tr, value );
    }
    catch( ... ) { // !! should we do that?
        BOOST_RT_PARAM_TRACE( "Fail to parse argument value" );

        if( !p.p_optional_value )
            throw;
    }

    argument_ptr actual_arg = p.actual_argument();

    BOOST_RT_CLA_VALIDATE_INPUT( !!value || p.p_optional_value, tr, 
        BOOST_RT_PARAM_LITERAL( "Argument value missing for parameter " ) << p.id_2_report() );

    BOOST_RT_CLA_VALIDATE_INPUT( !actual_arg || p.p_multiplicable, tr, 
        BOOST_RT_PARAM_LITERAL( "Unexpected repetition of the parameter " ) << p.id_2_report() );

    if( !!value && !!m_value_handler )
        m_value_handler( p, *value );

    if( !p.p_multiplicable )
        actual_arg.reset( p.p_optional_value && (rtti::type_id<T>() != rtti::type_id<bool>())
            ? static_cast<argument*>(new typed_argument<hexerboost::optional<T> >( p, value ))
            : static_cast<argument*>(new typed_argument<T>( p, *value )) );
    else {
        typedef std::list<hexerboost::optional<T> > optional_list;

        if( !actual_arg )
            actual_arg.reset( p.p_optional_value 
                ? static_cast<argument*>(new typed_argument<optional_list>( p ))
                : static_cast<argument*>(new typed_argument<std::list<T> >( p )) );

        if( p.p_optional_value ) {
            optional_list& values = arg_value<optional_list>( *actual_arg );

            values.push_back( value );
        }
        else {
            std::list<T>& values = arg_value<std::list<T> >( *actual_arg );
            
            values.push_back( *value );
        }
    }

    return actual_arg;
}
Beispiel #5
0
    void    accept_modifier( Modifier const& m )
    {
        cla::parameter::accept_modifier( m );

        m_arg_factory.accept_modifier( m );

        BOOST_RT_PARAM_VALIDATE_LOGIC( !p_optional || !m_arg_factory.m_value_generator,
            BOOST_RT_PARAM_LITERAL( "couldn't define a value generator for optional parameter " ) << id_2_report() );
    }
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;
}