Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::program_options::typed_value< T, charT > Class Template Reference

Class which handles value of a specific type. More...

#include <value_semantic.hpp>

Inheritance diagram for boost::program_options::typed_value< T, charT >:
Collaboration diagram for boost::program_options::typed_value< T, charT >:

Public Member Functions

 typed_value (T *store_to)
 Ctor. More...
 
typed_valuedefault_value (const T &v)
 Specifies default value, which will be used if none is explicitly specified. More...
 
typed_valuedefault_value (const T &v, const std::string &textual)
 Specifies default value, which will be used if none is explicitly specified. More...
 
typed_valueimplicit_value (const T &v)
 Specifies an implicit value, which will be used if the option is given, but without an adjacent value. More...
 
typed_valuevalue_name (const std::string &name)
 Specifies the name used to to the value in help message. More...
 
typed_valueimplicit_value (const T &v, const std::string &textual)
 Specifies an implicit value, which will be used if the option is given, but without an adjacent value. More...
 
typed_valuenotifier (function1< void, const T & > f)
 Specifies a function to be called when the final value is determined. More...
 
typed_valuecomposing ()
 Specifies that the value is composing. More...
 
typed_valuemultitoken ()
 Specifies that the value can span multiple tokens. More...
 
typed_valuezero_tokens ()
 Specifies that no tokens may be provided as the value of this option, which means that only presense of the option is significant. More...
 
typed_valuerequired ()
 Specifies that the value must occur. More...
 
std::string name () const
 
bool is_composing () const
 
unsigned min_tokens () const
 
unsigned max_tokens () const
 
bool is_required () const
 
void xparse (boost::any &value_store, const std::vector< std::basic_string< charT > > &new_tokens) const
 Creates an instance of the 'validator' class and calls its operator() to perform the actual conversion. More...
 
virtual bool apply_default (boost::any &value_store) const
 If default value was specified via previous call to 'default_value', stores that value into 'value_store'. More...
 
void notify (const boost::any &value_store) const
 If an address of variable to store value was specified when creating *this, stores the value there. More...
 
const std::type_info & value_type () const
 

Detailed Description

template<class T, class charT = char>
class boost::program_options::typed_value< T, charT >

Class which handles value of a specific type.

Constructor & Destructor Documentation

template<class T , class charT = char>
boost::program_options::typed_value< T, charT >::typed_value ( T store_to)
inline

Ctor.

The 'store_to' parameter tells where to store the value when it's known. The parameter can be NULL.

Member Function Documentation

template<class T , class charT = char>
virtual bool boost::program_options::typed_value< T, charT >::apply_default ( boost::any value_store) const
inlinevirtual

If default value was specified via previous call to 'default_value', stores that value into 'value_store'.

Returns true if default value was stored.

References boost::any::empty().

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::composing ( )
inline

Specifies that the value is composing.

See the 'is_composing' method for explanation.

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::default_value ( const T v)
inline

Specifies default value, which will be used if none is explicitly specified.

The type 'T' should provide operator<< for ostream.

References boost::fusion::any(), and boost::lexical_cast().

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::default_value ( const T v,
const std::string &  textual 
)
inline

Specifies default value, which will be used if none is explicitly specified.

Unlike the above overload, the type 'T' need not provide operator<< for ostream, but textual representation of default value must be provided by the user.

References boost::fusion::any().

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::implicit_value ( const T v)
inline

Specifies an implicit value, which will be used if the option is given, but without an adjacent value.

Using this implies that an explicit value is optional, but if given, must be strictly adjacent to the option, i.e.: '-ovalue' or '–option=value'. Giving '-o' or '–option' will cause the implicit value to be applied.

References boost::fusion::any(), and boost::lexical_cast().

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::implicit_value ( const T v,
const std::string &  textual 
)
inline

Specifies an implicit value, which will be used if the option is given, but without an adjacent value.

Using this implies that an explicit value is optional, but if given, must be strictly adjacent to the option, i.e.: '-ovalue' or '–option=value'. Giving '-o' or '–option' will cause the implicit value to be applied. Unlike the above overload, the type 'T' need not provide operator<< for ostream, but textual representation of default value must be provided by the user.

References boost::fusion::any().

template<class T , class charT = char>
bool boost::program_options::typed_value< T, charT >::is_composing ( ) const
inline
template<class T , class charT = char>
bool boost::program_options::typed_value< T, charT >::is_required ( ) const
inline
template<class T , class charT = char>
unsigned boost::program_options::typed_value< T, charT >::max_tokens ( ) const
inline
template<class T , class charT = char>
unsigned boost::program_options::typed_value< T, charT >::min_tokens ( ) const
inline

References boost::any::empty().

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::multitoken ( )
inline

Specifies that the value can span multiple tokens.

template<class T , class charT = char>
std::string boost::program_options::typed_value< T, charT >::name ( ) const
template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::notifier ( function1< void, const T & >  f)
inline

Specifies a function to be called when the final value is determined.

template<class T , class charT = char>
void boost::program_options::typed_value< T, charT >::notify ( const boost::any value_store) const

If an address of variable to store value was specified when creating *this, stores the value there.

Otherwise, does nothing.

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::required ( )
inline

Specifies that the value must occur.

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::value_name ( const std::string &  name)
inline

Specifies the name used to to the value in help message.

References boost::program_options::typed_value< T, charT >::name().

template<class T , class charT = char>
const std::type_info& boost::program_options::typed_value< T, charT >::value_type ( ) const
inlinevirtual
template<class T , class charT = char>
void boost::program_options::typed_value< T, charT >::xparse ( boost::any value_store,
const std::vector< std::basic_string< charT > > &  new_tokens 
) const

Creates an instance of the 'validator' class and calls its operator() to perform the actual conversion.

template<class T , class charT = char>
typed_value* boost::program_options::typed_value< T, charT >::zero_tokens ( )
inline

Specifies that no tokens may be provided as the value of this option, which means that only presense of the option is significant.

For such option to be useful, either the 'validate' function should be specialized, or the 'implicit_value' method should be also used. In most cases, you can use the 'bool_switch' function instead of using this method.


The documentation for this class was generated from the following file: