conf::ConfInt< T > Class Template Reference

Class implementing an integer directive type. More...

#include <directives.h>

Inheritance diagram for conf::ConfInt< T >:

conf::ConfValue< T > conf::ConfDir conf::ConfIntNZ< T > conf::ConfUint< T > List of all members.

Public Member Functions

 ConfInt (std::string const &name, bool reloadable, T minvalue, T maxvalue)
 Constructor without default value.
 ConfInt (std::string const &name, T const &defval, bool reloadable, T minvalue, T maxvalue)
 Constructor with default value.
 ConfInt (std::string const &name, bool reloadable)
 ConfArray-specific constructor.
 ConfInt (ConfInt const &cd)
 Copy constructor.
virtual ConfInt< T > & operator= (ConfInt< T > const &right)
 Assignment operator.
 operator T () const
 Conversion operator.
virtual char const * label (size_t index) const
 Implements ConfDir::label().

Protected Member Functions

virtual bool assign (Conf &conf, unsigned short count, std::string const params[])
 Sets the value.
virtual bool check (Conf &conf, T const &value) const
 Checks if the value is in the m_minvalue..m_maxvalue range.
virtual bool convert (Conf &conf, std::string const &expr, T &result) const
 Converts the string to an integer.
virtual T my_strtol (char const *nptr, char **endptr, int base) const
 Calls the strtol() function.

Protected Attributes

m_minvalue
m_maxvalue

Detailed Description

template<class T>
class conf::ConfInt< T >

This class is used to store integer values (the exact integer type is specified by the template parameter).

Conversions are done with strtol() (therefore the range of possible values is LONG_MIN..LONG_MAX). This can be changed by overriding the convert() and/or my_strtol() functions in derived classes. The class also overrides check() to refine range checking to the caller's need.

A conversion operator to the integer type T is provided as well for easy access to the value.


Constructor & Destructor Documentation

template<class T>
conf::ConfInt< T >::ConfInt std::string const &  name,
bool  reloadable,
minvalue,
maxvalue
[inline, explicit]
 

This constructor sets the directive name and whether it can be reloaded, along with the minimum and maximum values that will be accepted when the directive is set.

Parameters:
[in] name The name of the directive
[in] reloadable true if the directive can be reloaded, false otherwise.
[in] minvalue The minimum to accept as a value.
[in] maxvalue The maximum to accept as a value.

template<class T>
conf::ConfInt< T >::ConfInt std::string const &  name,
T const &  defval,
bool  reloadable,
minvalue,
maxvalue
[inline]
 

This constructor sets the directive name, default value and whether it can be reloaded, along with the minimum and maximum values that will be accepted when the directive is set.

Parameters:
[in] name The name of the directive.
[in] defval The default value.
[in] reloadable true if the directive can be reloaded, false otherwise.
[in] minvalue The minimum to accept as a value.
[in] maxvalue The maximum to accept as a value.


Member Function Documentation

template<class T>
bool conf::ConfInt< T >::assign Conf conf,
unsigned short  count,
std::string const   params[]
[protected, virtual]
 

Transforms the string array passed by the parser into the directive's value. This function must ensure that the value is valid through a call to check() before setting it (you don't need to set m_value_set to true, this will be handled by set() when the function returns successfully).

Parameters:
[in] conf The Conf object that called set().
[in] count Number of parameters in params.
[in] params Parameters passed to the directive (NULL if count is 0).
Returns:
true if the function is successful, false otherwise (conf.error() should have be called with an appropriate error message in that case).

Implements conf::ConfValue< T >.

template<class T>
bool conf::ConfInt< T >::convert Conf conf,
std::string const &  expr,
T &  result
const [protected, virtual]
 

Converts the given string to an integer, if possible. The my_strtol() function of the class is used to do the conversion.

Parameters:
[in] conf The Conf object that called the set() function.
[in] expr The string to convert to an integer.
[out] result The function will set this variable before returning if successful.
Returns:
true if the conversion went well, false otherwise.

Reimplemented in conf::ConfUint< T >.

template<class T>
virtual T conf::ConfInt< T >::my_strtol char const *  nptr,
char **  endptr,
int  base
const [inline, protected, virtual]
 

This function just calls the strtol() function. You may override it to call other strtol-like functions... Parameters are the same than those of the strtol() function, but the return value is different.

Reimplemented in conf::ConfUint< T >.


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:17 2007 for Epona API by  doxygen 1.4.6