cppcms::widgets::numeric< T > Class Template Reference

Widget for number input. It is a template class that assumes that T is a number. More...

`#include <cppcms/form.h>`

Inheritance diagram for cppcms::widgets::numeric< T >:

## Public Member Functions

void | non_empty ()
T | value ()
void | value (T v)
void | low (T a)
void | high (T b)
void | range (T a, T b)
virtual void | render_value (form_context &context)
virtual void | clear ()
virtual void | load (http::context &context)
virtual bool | validate ()
Public Member Functions inherited from cppcms::widgets::base_html_input
| base_html_input (std::string const &type)
virtual | ~base_html_input ()
virtual void | render_input (form_context &context)
Public Member Functions inherited from cppcms::widgets::base_widget
| base_widget ()
bool | set ()
bool | valid ()
std::string | id ()
std::string | name ()
locale::message | message ()
bool | has_message ()
locale::message | error_message ()
bool | has_error_message ()
locale::message | help ()
bool | has_help ()
bool | disabled ()
void | disabled (bool)
std::string | attributes_string ()
void | set (bool)
void | valid (bool)
void | id (std::string)
void | name (std::string)
void | message (std::string)
void | message (locale::message const &)
void | error_message (std::string)
void | error_message (locale::message const &)
void | help (std::string)
void | help (locale::message const &msg)
void | attributes_string (std::string v)
virtual void | render (form_context &context)
virtual void | render_attributes (form_context &context)
virtual void | parent (base_form *subform)
virtual form * | parent ()
void | pre_load (http::context &)

## Additional Inherited Members

Public Types inherited from cppcms::form_flags
enum | html_type { as_html = 0, as_xhtml = 1 }
enum | html_list_type { as_p = 0, as_table = 1, as_ul = 2, as_dl = 3, as_space = 4 }
enum | widget_part_type { first_part = 0, second_part = 1 }
Protected Member Functions inherited from cppcms::widgets::base_widget
void | auto_generate (form_context *context=0)

## Detailed Description

### template<typename T>
class cppcms::widgets::numeric< T >

Widget for number input. It is a template class that assumes that T is a number.

This class parses the input and checks if it is input text is a valid numeric value. If it is valid, the set() would return true be true.

If the value was not defined, access to value() will throw an exception.

## Member Function Documentation

template<typename T >

virtual void cppcms::widgets::numeric< T >::clear | ( |  | ) |

inlinevirtual

Clear the form. It also calls set(false).

Reimplemented from cppcms::widgets::base_widget.

References cppcms::widgets::base_widget::clear().

template<typename T >

void cppcms::widgets::numeric< T >::high | ( | T | b | ) |

inline

Set the maximum valid value.

References cppcms::widgets::numeric< T >::non_empty().

Referenced by cppcms::widgets::numeric< T >::range().

template<typename T >

virtual void cppcms::widgets::numeric< T >::load | ( | http::context & | context | ) |

inlinevirtual

Load the widget data.

Implements cppcms::base_form.

References cppcms::http::context::locale(), cppcms::widgets::base_widget::name(), cppcms::http::request::post_or_get(), cppcms::widgets::base_widget::pre_load(), cppcms::http::context::request(), cppcms::widgets::base_widget::set(), and cppcms::widgets::base_widget::valid().

template<typename T >

void cppcms::widgets::numeric< T >::low | ( | T | a | ) |

inline

Set the minimum valid value.

References cppcms::widgets::numeric< T >::non_empty().

Referenced by cppcms::widgets::numeric< T >::range().

template<typename T >

void cppcms::widgets::numeric< T >::non_empty | ( |  | ) |

inline

Inform the validator that this widget should contain some value.

Referenced by cppcms::widgets::numeric< T >::high(), and cppcms::widgets::numeric< T >::low().

template<typename T >

void cppcms::widgets::numeric< T >::range | ( | T | a,
|  | T | b
| ) |  |

inline

Same as low(a); high(b);

References cppcms::widgets::numeric< T >::high(), and cppcms::widgets::numeric< T >::low().

template<typename T >

virtual void cppcms::widgets::numeric< T >::render_value | ( | form_context & | context | ) |

inlinevirtual

Render the first part of the widget.

Implements cppcms::widgets::base_html_input.

References cppcms::util::escape(), cppcms::form_context::out(), and cppcms::widgets::base_widget::set().

template<typename T >

virtual bool cppcms::widgets::numeric< T >::validate | ( |  | ) |

inlinevirtual

Validate the widget.

Reimplemented from cppcms::widgets::base_widget.

References cppcms::widgets::base_widget::set(), and cppcms::widgets::base_widget::valid().

template<typename T >

T cppcms::widgets::numeric< T >::value | ( |  | ) |

inline

Get numeric value that was loaded from the POST or GET data.

Note
  if the value was not set (empty field for example) then this function will throw. So it is good idea to check if set() returns true before using this function.

References cppcms::widgets::base_widget::set().

template<typename T >

void cppcms::widgets::numeric< T >::value | ( | T | v | ) |

inline

Set the value of the widget.

References cppcms::widgets::base_widget::set().

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

- cppcms/form.h