#include <directives.h>
Inheritance diagram for conf::ConfInt< T >:

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 | |
| T | m_minvalue |
| T | m_maxvalue |
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.
| conf::ConfInt< T >::ConfInt | ( | std::string const & | name, | |
| bool | reloadable, | |||
| T | minvalue, | |||
| T | 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.
| [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. |
| conf::ConfInt< T >::ConfInt | ( | std::string const & | name, | |
| T const & | defval, | |||
| bool | reloadable, | |||
| T | minvalue, | |||
| T | 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.
| [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. |
| bool conf::ConfInt< T >::assign | ( | Conf & | conf, | |
| unsigned short | count, | |||
| std::string const | params[] | |||
| ) | [inline, 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).
| [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). |
Implements conf::ConfValue< T >.
| bool conf::ConfInt< T >::convert | ( | Conf & | conf, | |
| std::string const & | expr, | |||
| T & | result | |||
| ) | const [inline, protected, virtual] |
Converts the given string to an integer, if possible. The my_strtol() function of the class is used to do the conversion.
| [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. |
Reimplemented in conf::ConfUint< 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 >.
1.5.2