| form.h | | form.h | |
| | | | |
| skipping to change at line 182 | | skipping to change at line 182 | |
| }; | | }; | |
| | | | |
| /// | | /// | |
| /// \brief This class is the base class for any form or form widget
used in CppCMS. | | /// \brief This class is the base class for any form or form widget
used in CppCMS. | |
| /// | | /// | |
| /// It provides basic, abstract operations that every widget or form
should implement. | | /// It provides basic, abstract operations that every widget or form
should implement. | |
| /// | | /// | |
| class CPPCMS_API base_form : public form_flags { | | class CPPCMS_API base_form : public form_flags { | |
| public: | | public: | |
| /// | | /// | |
|
| /// Render the widget to std::ostream \a output with the con | | /// Render the widget to the output set in \a cppcms::form_c | |
| trol flags \a flags. | | ontext::out() | |
| | | /// according to the control flags set in \a cppcms::form_fl | |
| | | ags. | |
| /// Usually this function is called directly by the template
rendering functions. | | /// Usually this function is called directly by the template
rendering functions. | |
| /// | | /// | |
| virtual void render(form_context &context) = 0; | | virtual void render(form_context &context) = 0; | |
| | | | |
| /// | | /// | |
| /// Load the form information from the provided http::contex
t \a context. | | /// Load the form information from the provided http::contex
t \a context. | |
| /// A user can call this function to load all information fr
om the raw POST/GET | | /// A user can call this function to load all information fr
om the raw POST/GET | |
| /// data into the internal widget representation. | | /// data into the internal widget representation. | |
| /// | | /// | |
| virtual void load(http::context &context) = 0; | | virtual void load(http::context &context) = 0; | |
| | | | |
| skipping to change at line 206 | | skipping to change at line 207 | |
| /// true is returned. If some widget or form fails, false is
returned. | | /// true is returned. If some widget or form fails, false is
returned. | |
| /// | | /// | |
| virtual bool validate() = 0; | | virtual bool validate() = 0; | |
| | | | |
| /// | | /// | |
| /// Clear the form from all user provided data. | | /// Clear the form from all user provided data. | |
| /// | | /// | |
| virtual void clear() = 0; | | virtual void clear() = 0; | |
| | | | |
| /// | | /// | |
|
| /// Set a parent of this form. Used internally. You should n
ot use it. | | /// Set the parent of this form. Used internally. You should
not use it. | |
| /// | | /// | |
| virtual void parent(base_form *subform) = 0; | | virtual void parent(base_form *subform) = 0; | |
| | | | |
| /// | | /// | |
| /// Get the parent of this form. If this is the topmost form
, NULL is returned. | | /// Get the parent of this form. If this is the topmost form
, NULL is returned. | |
| /// | | /// | |
| virtual base_form *parent() = 0; | | virtual base_form *parent() = 0; | |
| | | | |
| base_form(); | | base_form(); | |
| virtual ~base_form(); | | virtual ~base_form(); | |
| }; | | }; | |
| | | | |
| /// | | /// | |
| /// \brief The \a form is a container used to collect other widgets
and forms into a single unit. | | /// \brief The \a form is a container used to collect other widgets
and forms into a single unit. | |
| /// | | /// | |
|
| /// Generally various widgets and forms are combined into a single f | | /// Generally various widgets and forms are combined into a single f | |
| orm in order to simplify the rendering | | orm in order to simplify their rendering | |
| /// and validation of forms that include more than one widget. | | /// and validation of the forms that include more than one widget. | |
| /// | | /// | |
| class CPPCMS_API form : public booster::noncopyable, | | class CPPCMS_API form : public booster::noncopyable, | |
| public base_form | | public base_form | |
| { | | { | |
| public: | | public: | |
| form(); | | form(); | |
| virtual ~form(); | | virtual ~form(); | |
| | | | |
| /// | | /// | |
| /// Render all the widgets and sub-forms to the \a output, u
sing | | /// Render all the widgets and sub-forms to the \a output, u
sing | |
|
| /// the base_form \a flags. | | /// the flags defined in the \a context. | |
| /// | | /// | |
| virtual void render(form_context &context); | | virtual void render(form_context &context); | |
| | | | |
| /// | | /// | |
| /// Load all the widget information from http::context \a co
nt. | | /// Load all the widget information from http::context \a co
nt. | |
| /// | | /// | |
| virtual void load(http::context &cont); | | virtual void load(http::context &cont); | |
| | | | |
| /// | | /// | |
| /// Validate all subforms and widgets. If at least one of th
em fails, | | /// Validate all subforms and widgets. If at least one of th
em fails, | |
| | | | |
| skipping to change at line 309 | | skipping to change at line 310 | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| /// | | /// | |
| /// Set the parent of this form. It is used internally; you
should not use it. It is called | | /// Set the parent of this form. It is used internally; you
should not use it. It is called | |
| /// when the form is added or attached to another form. | | /// when the form is added or attached to another form. | |
| /// | | /// | |
| virtual void parent(base_form *subform); | | virtual void parent(base_form *subform); | |
| | | | |
| /// | | /// | |
|
| /// Get parent of this form. If this is the topmost form, NU
LL is returned. | | /// Get the parent of this form. If this is the topmost form
, NULL is returned. | |
| /// It is assumed that the parent is always a form. | | /// It is assumed that the parent is always a form. | |
| /// | | /// | |
| virtual form *parent(); | | virtual form *parent(); | |
| | | | |
| /// | | /// | |
| /// \brief Input iterator used to iterate over all the widge
ts in a form. | | /// \brief Input iterator used to iterate over all the widge
ts in a form. | |
| /// | | /// | |
| /// This class is mainly used by templates to render widgets
. It | | /// This class is mainly used by templates to render widgets
. It | |
|
| /// walks over all widgets and subforms recursively. | | /// recursively iterates over all the widgets and subforms. | |
| /// | | /// | |
|
| /// Note: it walks over widgets only: | | /// \note it iterates over widgets only and never \ref | |
| | | /// form objects. | |
| /// | | /// | |
| /// \code | | /// \code | |
| /// iterator p=f.begin(); | | /// iterator p=f.begin(); | |
| /// if(p!=f.end()) | | /// if(p!=f.end()) | |
| /// if p!=f.end() --> *p is derived from widgets::base_wid
get. | | /// if p!=f.end() --> *p is derived from widgets::base_wid
get. | |
| /// \endcode | | /// \endcode | |
| /// | | /// | |
| class CPPCMS_API iterator : public std::iterator<std::input_
iterator_tag,widgets::base_widget> | | class CPPCMS_API iterator : public std::iterator<std::input_
iterator_tag,widgets::base_widget> | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 389 | | skipping to change at line 391 | |
| | | | |
| /// | | /// | |
| /// Check if two iterators point to different elemen
ts. | | /// Check if two iterators point to different elemen
ts. | |
| /// | | /// | |
| bool operator!=(iterator const &other) const | | bool operator!=(iterator const &other) const | |
| { | | { | |
| return !equal(other); | | return !equal(other); | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Post Increment operator, it forward the iterator | | /// Post increment operator. It forwards the iterato | |
| no text widget. | | r to the next widget. | |
| /// Note it does not point to higher level form cont | | /// Note it does not point to the higher level form | |
| ainer. | | container. | |
| /// | | /// | |
| /// Note: it is preferable to use ++i rather than i+
+ as copying iterators is not cheap. | | /// Note: it is preferable to use ++i rather than i+
+ as copying iterators is not cheap. | |
| /// | | /// | |
| iterator operator++(int /*unused*/) | | iterator operator++(int /*unused*/) | |
| { | | { | |
| iterator tmp(*this); | | iterator tmp(*this); | |
| next(); | | next(); | |
| return tmp; | | return tmp; | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Increment operator. It forward the iterator no t | | /// Increment operator. It forwards the iterator to | |
| ext widget. | | the next widget. | |
| /// Note it does not point to higher level form cont | | /// Note it does not point to the higher level form | |
| ainer | | container. | |
| /// | | /// | |
| iterator &operator++() | | iterator &operator++() | |
| { | | { | |
| next(); | | next(); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| private: | | private: | |
| | | | |
| friend class form; | | friend class form; | |
| | | | |
| skipping to change at line 429 | | skipping to change at line 431 | |
| | | | |
| std::stack<unsigned> return_positions_; | | std::stack<unsigned> return_positions_; | |
| form *current_; | | form *current_; | |
| unsigned offset_; | | unsigned offset_; | |
| struct _data; | | struct _data; | |
| booster::copy_ptr<_data> d; | | booster::copy_ptr<_data> d; | |
| | | | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// Returns an iterator to the first widget. | | /// Returns the iterator to the first widget. | |
| /// | | /// | |
| iterator begin(); | | iterator begin(); | |
| | | | |
| /// | | /// | |
|
| /// Returns the end-iterator for walking over all widgets. | | /// Returns the end of the range iterator. | |
| /// | | /// | |
| iterator end(); | | iterator end(); | |
| | | | |
| private: | | private: | |
| friend class iterator; | | friend class iterator; | |
| | | | |
| struct _data; | | struct _data; | |
|
| // Widget and ownership true mine | | // Widget and ownership - true means I own it. | |
| typedef std::pair<base_form *,bool> widget_type; | | typedef std::pair<base_form *,bool> widget_type; | |
| std::vector<widget_type> elements_; | | std::vector<widget_type> elements_; | |
| form *parent_; | | form *parent_; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief This namespace includes all widgets (html-forms) supporte
d by cppcms | | /// \brief This namespace includes all the widgets (i.e. parts of HT
ML forms) supported by cppcms. | |
| /// | | /// | |
| namespace widgets { | | namespace widgets { | |
| | | | |
| /// | | /// | |
|
| /// \brief this class is the base class of all renderable wi | | /// \brief this class is the base class of all renderable wi | |
| dgets that can be | | dgets which | |
| /// used together with forms | | /// can be used with CppCMS form system. | |
| /// | | /// | |
|
| /// All cppcms widgets are derived from this class. User, wh | | /// All cppcms widgets are derived from this class. Users wh | |
| o want to create | | o want to create | |
| /// its own custom widgets must derive them from this class | | /// their own custom widgets must derive them from this clas | |
| | | s. | |
| /// | | /// | |
| | | | |
| class CPPCMS_API base_widget : | | class CPPCMS_API base_widget : | |
| public base_form, | | public base_form, | |
| public booster::noncopyable | | public booster::noncopyable | |
| { | | { | |
| public: | | public: | |
|
| | | | |
| /// | | /// | |
|
| /// Default constructor | | /// Default constructor. | |
| /// | | /// | |
| base_widget(); | | base_widget(); | |
| | | | |
| virtual ~base_widget(); | | virtual ~base_widget(); | |
| | | | |
| /// | | /// | |
|
| /// Check if a value was assigned to widget. Usually | | /// Check if a value has been assigned to the widget | |
| becomes true | | . It is usually true | |
| /// when user assignees value to widget or the widge | | /// when the user has assigned a value to the widget | |
| t is loaded. | | or when the widget is loaded. | |
| /// | | /// | |
|
| /// If there is exist a reasonable default value for
a widget | | /// If there is a reasonable default value for the w
idget | |
| /// then set() should be true. For widgets like file
or numeric | | /// then set() should be true. For widgets like file
or numeric | |
|
| /// where explicit parsing is required the set() val | | /// where explicit parsing is required, the set() va | |
| ue would indecate | | lue would indicate | |
| /// that user provided some value (uploaded a file, | | /// that user provided some value (i.e. uploaded a f | |
| had gave a number) | | ile or entered a number). | |
| /// | | /// | |
| bool set(); | | bool set(); | |
| | | | |
| /// | | /// | |
|
| /// After executing validation, each widget can be t
ested for validity | | /// After having executed the validation process, ea
ch widget can be tested for validity. | |
| /// | | /// | |
| bool valid(); | | bool valid(); | |
| | | | |
| /// | | /// | |
|
| /// Get html id attribute | | /// Get the HTML \a id attribute. | |
| /// | | /// | |
| std::string id(); | | std::string id(); | |
| | | | |
| /// | | /// | |
|
| /// Get html name attribute | | /// Get the HTML \a name attribute. | |
| /// | | /// | |
| std::string name(); | | std::string name(); | |
| | | | |
| /// | | /// | |
|
| /// Get short message that would be displayed near t
he widget | | /// Get the short message that would be displayed ne
ar the widget. | |
| /// | | /// | |
| locale::message message(); | | locale::message message(); | |
| | | | |
| /// | | /// | |
|
| /// Check if message is set | | /// Check if a message is set. | |
| /// | | /// | |
| bool has_message(); | | bool has_message(); | |
| | | | |
| /// | | /// | |
|
| /// Get associated error message that would be displ | | /// Get the error message that would be displayed ne | |
| ayed near the widget | | ar the widget | |
| /// if widget validation failed. | | /// if the widget validation failed. | |
| /// | | /// | |
| locale::message error_message(); | | locale::message error_message(); | |
| | | | |
| /// | | /// | |
|
| /// Check if error message is set | | /// Check if an error message is set. | |
| /// | | /// | |
|
| | | | |
| bool has_error_message(); | | bool has_error_message(); | |
| | | | |
| /// | | /// | |
|
| /// Get long description for specific widget | | /// Get the eventual long description of the wigget. | |
| /// | | /// | |
|
| | | | |
| locale::message help(); | | locale::message help(); | |
| | | | |
| /// | | /// | |
|
| /// Check if help message is set | | /// Check if a help message is set. | |
| /// | | /// | |
|
| | | | |
| bool has_help(); | | bool has_help(); | |
| | | | |
| /// | | /// | |
|
| /// Get disabled html attribute | | /// Get the HTML \c disabled attribute. | |
| /// | | /// | |
|
| | | | |
| bool disabled(); | | bool disabled(); | |
| | | | |
| /// | | /// | |
|
| /// Set/Unset disabled html attribute | | /// Set/Unset the HTML \c disabled attribute. | |
| /// | | /// | |
|
| | | | |
| void disabled(bool); | | void disabled(bool); | |
| | | | |
| /// | | /// | |
|
| /// Get the general user defined attributes string t
hat can be added to widget | | /// Get the general user defined attribute string th
at can be added to the widget. | |
| /// | | /// | |
| std::string attributes_string(); | | std::string attributes_string(); | |
| | | | |
| /// | | /// | |
|
| /// Set the existence of content for widget. By defa | | /// Set the existence of content for the widget. By | |
| ult the widget is not set. | | default the widget is not set. | |
| /// Any value fetch from "unset" widget by conventio | | /// By convention, trying to fetch a value from a wi | |
| n should throw an exception | | dget that is "unset" will throw an exception. | |
| /// Calling set with true -- changes state to "set" | | /// Call set(true) to change the state to "set" and | |
| and with false to "unset" | | call set(false) to change it to "unset". | |
| /// | | /// | |
|
| | | | |
| void set(bool); | | void set(bool); | |
| | | | |
| /// | | /// | |
|
| /// Set validity state of widget. By default the wid | | /// Set th validity state of the widget. By default | |
| get is valid. When it | | the widget is valid. If it fails to pass | |
| /// passes validation its validity state is changed | | /// the validation, its validity state is changed by | |
| by calling this function | | calling this function. | |
| /// | | /// | |
|
| /// Note: widget maybe not-set but still valid and i
t may be set but not-valid | | /// Note: a widget may be "unset" and still be valid
. Conversely, it may be set but be not-valid. | |
| /// | | /// | |
|
| | | | |
| void valid(bool); | | void valid(bool); | |
| | | | |
| /// | | /// | |
|
| /// Set html id attribute of the widget | | /// Set the HTML \c id attribute of the widget. | |
| /// | | /// | |
| void id(std::string); | | void id(std::string); | |
| | | | |
| /// | | /// | |
|
| /// Set html name attribute of the widget. Note: if | | /// Set the HTML \c name attribute of the widget. No | |
| this attribute | | te: if this attribute | |
| /// is not set, the widget would not be able to be l | | /// is not set, the widget will not be able to be lo | |
| oaded from POST/GET | | aded from the POST/GET | |
| /// data. | | /// data. | |
| /// | | /// | |
|
| | | | |
| void name(std::string); | | void name(std::string); | |
| | | | |
| /// | | /// | |
|
| /// Set short description for the widget. Generally
it is good idea to | | /// Set a short description for the widget. Generall
y, it is a good idea to | |
| /// define this value. | | /// define this value. | |
| /// | | /// | |
|
| /// Short message can be also set using base_widget
constructor | | /// The short message can also be set using the base
_widget constructor. | |
| /// | | /// | |
| void message(std::string); | | void message(std::string); | |
| | | | |
| /// | | /// | |
|
| /// Set short translatable description for the widge
t. Generally it is good idea to | | /// Set a short translatable description for the wid
get. Generally, it is a good idea to | |
| /// define this value. | | /// define this value. | |
| /// | | /// | |
|
| /// Short message can be also set using base_widget
constructor | | /// The short message can also be set using the base
_widget constructor. | |
| /// | | /// | |
| void message(locale::message const &); | | void message(locale::message const &); | |
| | | | |
| /// | | /// | |
|
| /// Set error message that is displayed for invalid
widgets. | | /// Set the error message that is displayed for inva
lid widgets. | |
| /// | | /// | |
|
| /// If it is not set, simple "*" is shown | | /// If it is not set, a simple "*" is shown instead. | |
| /// | | /// | |
| void error_message(std::string); | | void error_message(std::string); | |
| | | | |
| /// | | /// | |
|
| /// Set translatable error message that is displayed
for invalid widgets. | | /// Set the translatable error message that is displ
ayed for invalid widgets. | |
| /// | | /// | |
|
| /// If it is not set, simple "*" is shown | | /// If it is not set, a simple "*" is shown instead. | |
| /// | | /// | |
| void error_message(locale::message const &); | | void error_message(locale::message const &); | |
| | | | |
| /// | | /// | |
|
| /// Set longer help message that describes this widg
et | | /// Set a longer help message that describes this wi
dget. | |
| /// | | /// | |
| void help(std::string); | | void help(std::string); | |
| | | | |
| /// | | /// | |
|
| /// Set translatable help message that describes thi
s widget | | /// Set a translatable help message that describes t
his widget. | |
| /// | | /// | |
| void help(locale::message const &msg); | | void help(locale::message const &msg); | |
| | | | |
| /// | | /// | |
|
| /// Set general html attributes that are not support | | /// Set general HTML attributes that are not directl | |
| ed | | y supported | |
| /// directly. For example: | | /// For example: | |
| /// | | /// | |
| /// \code | | /// \code | |
| /// my_widget.attributes_string("style='direction:r
tl' onclick='return foo()'"); | | /// my_widget.attributes_string("style='direction:r
tl' onclick='return foo()'"); | |
| /// \endcode | | /// \endcode | |
| /// | | /// | |
|
| /// This string is inserted as-is just behind render
_input_start | | /// This string is inserted as-is just after render_
input_start. | |
| /// | | /// | |
| void attributes_string(std::string v); | | void attributes_string(std::string v); | |
| | | | |
| /// | | /// | |
|
| /// Render full widget with error messages and decor | | /// Render the full widget together with error messa | |
| ations as paragraphs | | ges and decorations as paragraphs | |
| /// or table elements to \a output | | /// or table elements to the output set in \a cppcms | |
| | | ::form_context::out(). | |
| /// | | /// | |
|
| | | | |
| virtual void render(form_context &context); | | virtual void render(form_context &context); | |
| | | | |
| /// | | /// | |
|
| /// This is a virtual member function that should be | | /// This is a virtual member function that should be | |
| implemented by each widget | | implemented by each widget. | |
| /// It executes actual rendering of the input HTML f | | /// It executes the actual rendering of the HTML for | |
| orm | | m. | |
| /// | | /// | |
| virtual void render_input(form_context &context) = 0
; | | virtual void render_input(form_context &context) = 0
; | |
| | | | |
| /// | | /// | |
|
| /// Clean the form. Calls set(false) as well | | /// Clear the form. It also calls set(false). | |
| /// | | /// | |
| virtual void clear(); | | virtual void clear(); | |
| | | | |
| /// | | /// | |
|
| /// Validate form. If not overridden it sets widget
to valid | | /// Validate the form. If not overridden, it sets th
e widget to \a valid. | |
| /// | | /// | |
| virtual bool validate(); | | virtual bool validate(); | |
| | | | |
| /// | | /// | |
|
| /// Render standard common attributes like id, name,
disabled etc. | | /// Render standard common attributes like \a id, \a
name, \a disabled, etc. | |
| /// | | /// | |
|
| | | | |
| virtual void render_attributes(form_context &context
); | | virtual void render_attributes(form_context &context
); | |
| | | | |
| /// | | /// | |
|
| /// Set parent of this widget. Used internaly, shoul | | /// Set the parent of this widget. It is used intern | |
| d not be used. It is called | | ally; you should not use it. It is called | |
| /// when the form is added or attached to other form | | /// when the form is added or attached to another fo | |
| . | | rm. | |
| /// | | /// | |
|
| | | | |
| virtual void parent(base_form *subform); | | virtual void parent(base_form *subform); | |
| | | | |
| /// | | /// | |
|
| /// Get parent of this form. If this is topmost form | | /// Get the parent of this form. If this is the topm | |
| , NULL is returned | | ost form, NULL is returned. | |
| /// Note widget is assumed to be assigned to forms o | | /// It is assumed that the parent is always a form. | |
| nly | | | |
| /// | | /// | |
| virtual form *parent(); | | virtual form *parent(); | |
| | | | |
| /// | | /// | |
| /// This function should be called before actual loa
ding | | /// This function should be called before actual loa
ding | |
| /// of widgets, it performs cross widgets validation | | /// of widgets, it performs cross widgets validation | |
| /// and causes automatic generation of undefined nam
es | | /// and causes automatic generation of undefined nam
es | |
| /// | | /// | |
| void pre_load(http::context &); | | void pre_load(http::context &); | |
| | | | |
| protected: | | protected: | |
| /// | | /// | |
|
| /// This function should be called by overloaded loa | | /// This function should be called by overloadeding | |
| d/render methods | | the load/render methods | |
| /// before rendering/loading starts | | /// before the loading/rendering starts. | |
| /// | | /// | |
| void auto_generate(form_context *context = 0); | | void auto_generate(form_context *context = 0); | |
|
| private: | | | |
| | | | |
|
| | | private: | |
| void generate(int position,form_context *context = 0
); | | void generate(int position,form_context *context = 0
); | |
| | | | |
| std::string id_; | | std::string id_; | |
| std::string name_; | | std::string name_; | |
| locale::message message_; | | locale::message message_; | |
| locale::message error_message_; | | locale::message error_message_; | |
| locale::message help_; | | locale::message help_; | |
| std::string attr_; | | std::string attr_; | |
| form *parent_; | | form *parent_; | |
| | | | |
| | | | |
| skipping to change at line 715 | | skipping to change at line 705 | |
| uint32_t has_message_ : 1; | | uint32_t has_message_ : 1; | |
| uint32_t has_error_ : 1; | | uint32_t has_error_ : 1; | |
| uint32_t has_help_ : 1; | | uint32_t has_help_ : 1; | |
| uint32_t reserverd_ : 25; | | uint32_t reserverd_ : 25; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief this is the widget that is used as base for text
input field representation | | /// \brief This widget is used as base for text input fields
. | |
| /// | | /// | |
|
| /// This widget is used as base class for other widgets that | | /// This widget is used as the base class for other widgets | |
| are used for | | that are used for | |
| /// text input like: text, textarea, etc. | | /// text input like: \ref text, \ref textarea, etc. | |
| /// | | /// | |
|
| /// This widget does much more then reading simple filed dat | | /// This widget does much more than reading simple text data | |
| a from the POST | | from the POST | |
| /// or GET form, it performs charset validation and if requi | | /// or GET form. It also performs charset validation. | |
| red conversion | | | |
| /// to and from Unicode charset to locale charset. | | | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API base_text : virtual public base_widget { | | class CPPCMS_API base_text : virtual public base_widget { | |
| public: | | public: | |
| | | | |
| base_text(); | | base_text(); | |
| virtual ~base_text(); | | virtual ~base_text(); | |
| | | | |
| /// | | /// | |
|
| /// Get the string that contains input value of the
widget. | | /// Get the string that contains the input value of
the widget. | |
| /// | | /// | |
|
| | | | |
| std::string value(); | | std::string value(); | |
| | | | |
| /// | | /// | |
|
| /// Set the widget content before rendering, the val
ue \a v | | /// Set the widget content to the value \a v before
rendering. | |
| /// | | /// | |
|
| | | | |
| void value(std::string v); | | void value(std::string v); | |
| | | | |
| /// | | /// | |
|
| /// Acknowledge the validator that this text widget | | /// Inform the validator that this text widget shoul | |
| should contain some text. | | d contain some text. | |
| /// similar to limits(1,-1) | | /// It is similar to limits(1,-1). | |
| /// | | /// | |
| void non_empty(); | | void non_empty(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set minimum and maximum limits for text size. No | | /// Set the minimum and maximum limits of the text s | |
| te max == -1 indicates that there | | ize. Note: max == -1 indicates that there | |
| /// is no maximal limit, min==0 indicates that there | | /// is no maximum limit; min==0 indicates that there | |
| is no minimal limit. | | is no minimum limit. | |
| /// | | /// | |
| /// Note: these numbers represent the length in Unic
ode code points (even if the encoding | | /// Note: these numbers represent the length in Unic
ode code points (even if the encoding | |
|
| /// is not Unicode). If character set validation is
disabled, then these number represent | | /// is not Unicode). If the character set validation
is disabled, then these numbers represent | |
| /// the number of octets in the string. | | /// the number of octets in the string. | |
| /// | | /// | |
| void limits(int min,int max); | | void limits(int min,int max); | |
| | | | |
| /// | | /// | |
|
| /// Get minimal and maximal size limits, | | /// Get the minimum and maximum size limits, | |
| /// | | /// | |
|
| | | | |
| std::pair<int,int> limits(); | | std::pair<int,int> limits(); | |
| | | | |
| /// | | /// | |
|
| /// Acknowledge the validator if it should not check | | /// Inform the validator whether it should check the | |
| the validity of the charset. | | validity of the charset. | |
| /// Default -- enabled | | /// The default is enabled (true). | |
| /// | | /// | |
|
| /// Generally you should not use this option unless | | /// Generally you should not use this option to disa | |
| you want to load some raw data as | | ble the charset validation | |
| /// form input, or the character set is different fr | | /// unless you want to load some raw data as | |
| om the defined in locale. | | /// form input, or the character set is different fr | |
| | | om the one defined in the locale. | |
| /// | | /// | |
| void validate_charset(bool ); | | void validate_charset(bool ); | |
| | | | |
| /// | | /// | |
|
| /// Returns true if charset validation is enabled. | | /// Return true if the charset validation is enabled
. | |
| /// | | /// | |
|
| | | | |
| bool validate_charset(); | | bool validate_charset(); | |
| | | | |
| /// | | /// | |
|
| /// Validate the widget content according to rules a
nd charset encoding. | | /// Validate the widget content according to the rul
es and to the charset encoding. | |
| /// | | /// | |
| /// Notes: | | /// Notes: | |
| /// | | /// | |
|
| /// - The charset validation is very efficient for | | /// - The charset validation is very efficient for | |
| variable length UTF-8 encoding, | | variable length UTF-8 encoding as well as | |
| /// and most popular fixed length ISO-8859-*, win | | /// for most popular fixed length encodings like | |
| dows-125* and koi8* encodings, for other | | ISO-8859-*, windows-125* and koi8*. | |
| /// encodings iconv conversion is used for actual | | /// For other encodings, character set conversion | |
| validation. | | is used for the actual validation. | |
| /// - Special characters (that not allowed in HTML) | | /// - Special characters (that are not allowed in H | |
| are assumed as forbidden, even if they are | | TML) are assumed to be forbidden, even if they are | |
| /// valid code points (like NUL = 0 or DEL=127). | | /// valid code points (like NUL = 0 or DEL=127). | |
| /// | | /// | |
| virtual bool validate(); | | virtual bool validate(); | |
| | | | |
| /// | | /// | |
|
| /// Load the widget for http::context. It used the l | | /// Load the widget for http::context. It uses the l | |
| ocale given in the context for | | ocale given in the context to | |
| /// validation of text. | | /// validate the text. | |
| /// | | /// | |
| virtual void load(http::context &); | | virtual void load(http::context &); | |
|
| | | | |
| private: | | private: | |
| std::string value_; | | std::string value_; | |
| int low_; | | int low_; | |
| int high_; | | int high_; | |
| bool validate_charset_; | | bool validate_charset_; | |
| size_t code_points_; | | size_t code_points_; | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 808 | | skipping to change at line 795 | |
| std::string value_; | | std::string value_; | |
| int low_; | | int low_; | |
| int high_; | | int high_; | |
| bool validate_charset_; | | bool validate_charset_; | |
| size_t code_points_; | | size_t code_points_; | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// This class represents a basic widget that generates html | | /// \brief This class represents a basic widget that generat | |
| for common widgets | | es HTML form elements | |
| /// that use <input \/> HTML tag. | | /// the widgets that use the <input \/> HTML tag. | |
| /// | | /// | |
|
| /// It allows you creating your own widgets easier as it doe | | /// It allows you to create your own widgets more easily. It | |
| s most of job required for | | does most of job required to | |
| /// generating the HTML and user is required only to generat | | /// generate the HTML. The user is only required to generate | |
| e actual value like | | the actual value like | |
| /// value="10.34" as for numeric widget. | | /// value="10.34" as with a numeric widget. | |
| /// | | /// | |
| | | | |
| class CPPCMS_API base_html_input : virtual public base_widge
t { | | class CPPCMS_API base_html_input : virtual public base_widge
t { | |
| public: | | public: | |
|
| | | | |
| /// | | /// | |
|
| /// Creates new instance, \a type is HTML type tag o
f the input element, for example "text" or | | /// Create a new instance. \a type is the HTML type
tag of the input element, for example "text" or | |
| /// "password". | | /// "password". | |
| /// | | /// | |
| base_html_input(std::string const &type); | | base_html_input(std::string const &type); | |
|
| | | | |
| /// | | /// | |
|
| /// Virtual destructor... | | /// Virtual destructor. | |
| /// | | /// | |
| virtual ~base_html_input(); | | virtual ~base_html_input(); | |
|
| | | | |
| /// | | /// | |
|
| /// This function is actual HTML generation function
that calls render_value where needed. | | /// This function generates the actual HTML. It call
s render_value where needed. | |
| /// | | /// | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
| | | | |
| protected: | | protected: | |
| /// | | /// | |
|
| /// This is what user actually expected to implement
. Write actual value HTML tag. | | /// Write the actual value of the HTML tag. Derived
classes must implement this. | |
| /// | | /// | |
| virtual void render_value(form_context &context) = 0
; | | virtual void render_value(form_context &context) = 0
; | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| std::string type_; | | std::string type_; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief This class represents html input of type text | | /// \brief This class represents an HTML form input element
of type text. | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API text : public base_html_input, public base_
text | | class CPPCMS_API text : public base_html_input, public base_
text | |
| { | | { | |
| public: | | public: | |
| /// | | /// | |
|
| /// Create text field widget | | /// Create a text field widget. | |
| /// | | /// | |
| text(); | | text(); | |
| | | | |
| /// | | /// | |
| /// This constructor is provided for use by derived
classes where it is required | | /// This constructor is provided for use by derived
classes where it is required | |
|
| /// to change the type of widget, like text, passwor
d, etc. | | /// to change the type of the widget, like text, pas
sword, etc. | |
| /// | | /// | |
| text(std::string const &type); | | text(std::string const &type); | |
| | | | |
| ~text(); | | ~text(); | |
| | | | |
| /// | | /// | |
|
| /// Set html attribute size of the widget | | /// Set the HTML size attribute of the widget. | |
| /// | | /// | |
|
| | | | |
| void size(int n); | | void size(int n); | |
| | | | |
| /// | | /// | |
|
| /// Get html attribute size of the widget, -1 undefi
ned | | /// Get the HTML size attribute size of the widget.
It returns -1 if it is undefined. | |
| /// | | /// | |
|
| | | | |
| int size(); | | int size(); | |
| | | | |
| virtual void render_attributes(form_context &context
); | | virtual void render_attributes(form_context &context
); | |
| virtual void render_value(form_context &context); | | virtual void render_value(form_context &context); | |
|
| | | | |
| private: | | private: | |
| int size_; | | int size_; | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// This widget represents hidden input form type. It is use | | /// \brief This widget represents a hidden input form elemen | |
| d to provide | | t. It is used to provide | |
| /// some invisible to user information. | | /// information invisible to the user. | |
| /// | | /// | |
|
| /// I has same properties that text widget has but it does n | | /// I has the same properties as a text widget has but it do | |
| ot render any HTML | | es not render any HTML | |
| /// related to message(), help() and other informational typ | | /// for message(), help() and other informational types. | |
| es. | | | |
| /// | | /// | |
|
| /// When your render the form in templates it is good idea t | | /// When you render the form in templates, it is a good idea | |
| o render it separately | | to render it separately | |
| /// to make sure that no invalid HTML would be created. | | /// to make sure that no invalid HTML is created. | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API hidden : public text | | class CPPCMS_API hidden : public text | |
| { | | { | |
| public: | | public: | |
| hidden(); | | hidden(); | |
| ~hidden(); | | ~hidden(); | |
| /// | | /// | |
|
| /// Actual rendering function that is redefined | | /// Render the HTML of the widget. It overrides | |
| | | /// the default HTML rendering as hidden widget | |
| | | /// is never displayed. | |
| /// | | /// | |
| virtual void render(form_context &context); | | virtual void render(form_context &context); | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// This text widget behaves similarly to text widget but us | | /// \brief This text widget behaves similarly to the text wi | |
| es rather HTML | | dget but uses | |
| /// textarea and not input HTML tags | | /// the \c textarea HTML tag rather than the \c input HTML t | |
| | | ag. | |
| /// | | /// | |
| class CPPCMS_API textarea : public base_text | | class CPPCMS_API textarea : public base_text | |
| { | | { | |
| public: | | public: | |
| textarea(); | | textarea(); | |
| ~textarea(); | | ~textarea(); | |
| | | | |
| /// | | /// | |
|
| /// Get number of rows in textarea -- default -1 --
undefined | | /// Get the number of rows in the textarea. The defa
ult is -1 -- undefined. | |
| /// | | /// | |
| int rows(); | | int rows(); | |
|
| | | | |
| /// | | /// | |
|
| /// Get number of columns in textarea -- default -1
-- undefined | | /// Get the number of columns in the textarea. The d
efault is -1 -- undefined. | |
| /// | | /// | |
| int cols(); | | int cols(); | |
| | | | |
| /// | | /// | |
|
| /// Set number of rows in textarea | | /// Set the number of rows in the textarea. | |
| /// | | /// | |
| void rows(int n); | | void rows(int n); | |
|
| | | | |
| /// | | /// | |
|
| /// Set number of columns in textarea | | /// Set the number of columns in the textarea. | |
| /// | | /// | |
| void cols(int n); | | void cols(int n); | |
| | | | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
|
| | | | |
| private: | | private: | |
| int rows_,cols_; | | int rows_,cols_; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief Widget for number input. It is template class tha
t assumes that T is number | | /// \brief Widget for number input. It is a template class t
hat assumes that T is a number. | |
| /// | | /// | |
|
| /// This class parses the input and checks if it is value va | | /// This class parses the input and checks if it is input te | |
| lue. If it is set() would | | xt is a valid | |
| | | /// numeric value. If it is valid, the set() would return tr | |
| | | ue | |
| /// be true. | | /// be true. | |
| /// | | /// | |
|
| /// If the value was not defined access to value() would thr
ow an exception | | /// If the value was not defined, access to value() will thr
ow an exception. | |
| /// | | /// | |
|
| | | | |
| template<typename T> | | template<typename T> | |
| class numeric: public base_html_input { | | class numeric: public base_html_input { | |
| public: | | public: | |
| numeric() : | | numeric() : | |
| base_html_input("text"), | | base_html_input("text"), | |
| check_low_(false), | | check_low_(false), | |
| check_high_(false), | | check_high_(false), | |
| non_empty_(false) | | non_empty_(false) | |
| { | | { | |
| } | | } | |
| | | | |
| skipping to change at line 966 | | skipping to change at line 957 | |
| public: | | public: | |
| numeric() : | | numeric() : | |
| base_html_input("text"), | | base_html_input("text"), | |
| check_low_(false), | | check_low_(false), | |
| check_high_(false), | | check_high_(false), | |
| non_empty_(false) | | non_empty_(false) | |
| { | | { | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Defines that this widget should have some value | | /// Inform the validator that this widget should con
tain some value. | |
| /// | | /// | |
| void non_empty() | | void non_empty() | |
| { | | { | |
| non_empty_=true; | | non_empty_=true; | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Get loaded widget value | | /// 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 ide | |
| | | a to | |
| | | /// check if \ref set() returns true before using th | |
| | | is | |
| | | /// function. | |
| /// | | /// | |
| T value() | | T value() | |
| { | | { | |
| if(!set()) | | if(!set()) | |
| throw cppcms_error("Value not loaded
"); | | throw cppcms_error("Value not loaded
"); | |
| return value_; | | return value_; | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Set widget value | | /// Set the value of the widget. | |
| /// | | /// | |
| void value(T v) | | void value(T v) | |
| { | | { | |
| set(true); | | set(true); | |
| value_=v; | | value_=v; | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Set minimal input number value | | /// Set the minimum valid value. | |
| /// | | /// | |
| void low(T a) | | void low(T a) | |
| { | | { | |
| min_=a; | | min_=a; | |
| check_low_=true; | | check_low_=true; | |
| non_empty(); | | non_empty(); | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Set maximal input number value | | /// Set the maximum valid value. | |
| /// | | /// | |
|
| | | | |
| void high(T b) | | void high(T b) | |
| { | | { | |
| max_=b; | | max_=b; | |
| check_high_=true; | | check_high_=true; | |
| non_empty(); | | non_empty(); | |
| } | | } | |
| | | | |
| /// | | /// | |
| /// Same as low(a); high(b); | | /// Same as low(a); high(b); | |
| /// | | /// | |
| | | | |
| skipping to change at line 1023 | | skipping to change at line 1019 | |
| /// | | /// | |
| /// Same as low(a); high(b); | | /// Same as low(a); high(b); | |
| /// | | /// | |
| void range(T a,T b) | | void range(T a,T b) | |
| { | | { | |
| low(a); | | low(a); | |
| high(b); | | high(b); | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Render first part of widget | | /// Render the first part of the widget. | |
| /// | | /// | |
|
| | | | |
| virtual void render_value(form_context &context) | | virtual void render_value(form_context &context) | |
| { | | { | |
| if(set()) | | if(set()) | |
| context.out()<<"value=\""<<value_<<"
\" "; | | context.out()<<"value=\""<<value_<<"
\" "; | |
| else | | else | |
| context.out()<<"value=\""<<util::esc
ape(loaded_string_)<<"\" "; | | context.out()<<"value=\""<<util::esc
ape(loaded_string_)<<"\" "; | |
| } | | } | |
| | | | |
| virtual void clear() | | virtual void clear() | |
| { | | { | |
| | | | |
| skipping to change at line 1041 | | skipping to change at line 1036 | |
| context.out()<<"value=\""<<util::esc
ape(loaded_string_)<<"\" "; | | context.out()<<"value=\""<<util::esc
ape(loaded_string_)<<"\" "; | |
| } | | } | |
| | | | |
| virtual void clear() | | virtual void clear() | |
| { | | { | |
| base_html_input::clear(); | | base_html_input::clear(); | |
| loaded_string_.clear(); | | loaded_string_.clear(); | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Load widget data | | /// Load the widget data. | |
| /// | | /// | |
|
| | | | |
| virtual void load(http::context &context) | | virtual void load(http::context &context) | |
| { | | { | |
| pre_load(context); | | pre_load(context); | |
| | | | |
| loaded_string_.clear(); | | loaded_string_.clear(); | |
| | | | |
| set(false); | | set(false); | |
| valid(true); | | valid(true); | |
| | | | |
| http::request::form_type::const_iterator p; | | http::request::form_type::const_iterator p; | |
| | | | |
| skipping to change at line 1075 | | skipping to change at line 1069 | |
| ss.imbue(context.locale()); | | ss.imbue(context.locale()); | |
| ss>>value_; | | ss>>value_; | |
| if(ss.fail() || !ss.eof()) | | if(ss.fail() || !ss.eof()) | |
| valid(false); | | valid(false); | |
| else | | else | |
| set(true); | | set(true); | |
| } | | } | |
| } | | } | |
| | | | |
| /// | | /// | |
|
| /// Validate widget | | /// Validate the widget. | |
| /// | | /// | |
| virtual bool validate() | | virtual bool validate() | |
| { | | { | |
| if(!valid()) | | if(!valid()) | |
| return false; | | return false; | |
| if(!set()) { | | if(!set()) { | |
| if(non_empty_) { | | if(non_empty_) { | |
| valid(false); | | valid(false); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| skipping to change at line 1110 | | skipping to change at line 1104 | |
| | | | |
| T min_,max_,value_; | | T min_,max_,value_; | |
| | | | |
| bool check_low_; | | bool check_low_; | |
| bool check_high_; | | bool check_high_; | |
| bool non_empty_; | | bool non_empty_; | |
| std::string loaded_string_; | | std::string loaded_string_; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief The password widget is a simple text widget with
some different | | /// \brief The password widget is a simple text widget with
few, obvious differences. | |
| // | | // | |
|
| | | | |
| class CPPCMS_API password: public text { | | class CPPCMS_API password: public text { | |
| public: | | public: | |
| password(); | | password(); | |
| | | | |
| ~password(); | | ~password(); | |
| | | | |
| /// | | /// | |
|
| /// Set equality constraint to password widget -- th | | /// Set the equality constraint to another password | |
| is password should be | | widget. This password should be | |
| /// equal to other one \a p2. Usefull for creation o | | /// equal to the one in \a p2. It is usefull when cr | |
| f new passwords -- if passwords | | eating new passwords: if the passwords | |
| /// are not equal, validation would fail | | /// are not equal, the validation will fail. | |
| /// | | /// | |
| void check_equal(password &p2); | | void check_equal(password &p2); | |
| virtual bool validate(); | | virtual bool validate(); | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| password *password_to_check_; | | password *password_to_check_; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief This class is extinction of text widget that vali
dates it using additional regular expression | | /// \brief This class is extending a simple text widget by u
sing additional regular expression validation. | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API regex_field : public text { | | class CPPCMS_API regex_field : public text { | |
| public: | | public: | |
| regex_field(); | | regex_field(); | |
| /// | | /// | |
|
| /// Create widget using regular expression \a e | | /// Create a widget using the regular expression \a
e. | |
| /// | | /// | |
| regex_field(booster::regex const &e); | | regex_field(booster::regex const &e); | |
| | | | |
| /// | | /// | |
|
| /// Create widget using regular expression \a e | | /// Create a widget using the regular expression \a
e. | |
| /// | | /// | |
| regex_field(std::string const &e); | | regex_field(std::string const &e); | |
| | | | |
| /// | | /// | |
|
| /// Set regular expression | | /// Set the regular expression. | |
| /// | | /// | |
| void regex(booster::regex const &e); | | void regex(booster::regex const &e); | |
| | | | |
| ~regex_field(); | | ~regex_field(); | |
| | | | |
| virtual bool validate(); | | virtual bool validate(); | |
|
| | | | |
| private: | | private: | |
| booster::regex expression_; | | booster::regex expression_; | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief widget that checks that input is valid e-mail | | /// \brief This widget checks that the input is a valid emai
l address. | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API email : public regex_field { | | class CPPCMS_API email : public regex_field { | |
| public: | | public: | |
| | | | |
| email(); | | email(); | |
| ~email(); | | ~email(); | |
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| skipping to change at line 1179 | | skipping to change at line 1172 | |
| | | | |
| email(); | | email(); | |
| ~email(); | | ~email(); | |
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// This class represent an html checkbox input widget | | /// \brief This class represent an HTML checkbox input eleme
nt. | |
| /// | | /// | |
| class CPPCMS_API checkbox: public base_html_input { | | class CPPCMS_API checkbox: public base_html_input { | |
| public: | | public: | |
| /// | | /// | |
|
| /// The constructor that allows you to specify other | | /// The constructor that allows you to specify \c ty | |
| type like "radio" | | pe HTML | |
| | | /// attribute. It is passed to the constructor of th | |
| | | e | |
| | | /// \ref base_html_input class. | |
| /// | | /// | |
| checkbox(std::string const &type); | | checkbox(std::string const &type); | |
|
| | | | |
| /// | | /// | |
|
| /// Default constructor, type checkbox | | /// Default constructor. | |
| /// | | /// | |
| checkbox(); | | checkbox(); | |
| virtual ~checkbox(); | | virtual ~checkbox(); | |
| | | | |
| /// | | /// | |
|
| /// Returns true of box was checked (selected) | | /// Return true if the checkbox was checked (selecte
d). | |
| /// | | /// | |
| bool value(); | | bool value(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set checked state | | /// Set the state as \a checked. | |
| /// | | /// | |
| void value(bool is_set); | | void value(bool is_set); | |
| | | | |
| /// | | /// | |
|
| /// Get unique identification of the checkbox | | /// Get the unique identification string of the chec
kbox. | |
| /// | | /// | |
| std::string identification(); | | std::string identification(); | |
| | | | |
| /// | | /// | |
|
| /// Set unique identification to the checkbox, usefu | | /// Set the unique identification string of the chec | |
| l when you want to | | kbox. It is useful when you want to | |
| /// have many options with same name | | /// have many options with the same name. | |
| /// | | /// | |
| void identification(std::string const &); | | void identification(std::string const &); | |
| | | | |
| virtual void render_value(form_context &context); | | virtual void render_value(form_context &context); | |
| virtual void load(http::context &context); | | virtual void load(http::context &context); | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| std::string identification_; | | std::string identification_; | |
| bool value_; | | bool value_; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// Select multiple elements widget | | /// \brief This widget represents an HTML multiple select fo
rm element. | |
| /// | | /// | |
| class CPPCMS_API select_multiple : public base_widget { | | class CPPCMS_API select_multiple : public base_widget { | |
| public: | | public: | |
| select_multiple(); | | select_multiple(); | |
| ~select_multiple(); | | ~select_multiple(); | |
| | | | |
| /// | | /// | |
|
| /// Add a new option to list with display name \a ms | | /// Add to the multiple select a new option with the | |
| g, and specify if it is initially | | display name \a msg, and specify if it is initially | |
| /// selected, default false | | /// selected. The default is \a false. | |
| /// | | /// | |
| void add(std::string const &msg,bool selected=false)
; | | void add(std::string const &msg,bool selected=false)
; | |
|
| | | | |
| /// | | /// | |
|
| /// Add a new option to list with display name \a ms | | /// Add to the multiple select a new option with the | |
| g, and specify if it is initially | | display name \a msg, and specify if it is initially | |
| /// selected, default false, providing unique identi | | /// selected (the default is \a false), providing a | |
| fication for the element \a id | | unique identification string to use as the element's \a id. | |
| /// | | /// | |
| void add(std::string const &msg,std::string const &i
d,bool selected=false); | | void add(std::string const &msg,std::string const &i
d,bool selected=false); | |
|
| | | | |
| /// | | /// | |
|
| /// Add a new option to list with localized display | | /// Add to the multiple select a new option with the | |
| name \a msg, and specify if it is initially | | localized display name \a msg, and specify if it is initially | |
| /// selected, default false | | /// selected. The default is \a false. | |
| /// | | /// | |
| void add(locale::message const &msg,bool selected=fa
lse); | | void add(locale::message const &msg,bool selected=fa
lse); | |
|
| | | | |
| /// | | /// | |
|
| /// Add a new option to list with localized display | | /// Add to the multiple select a new option with the | |
| name \a msg, and specify if it is initially | | localized display name \a msg, and specify if it is initially | |
| /// selected, default false, providing unique identi | | /// selected (the default is \a false), providing a | |
| fication for the element \a id | | unique identification string to use as the element's \a id. | |
| /// | | /// | |
| void add(locale::message const &msg,std::string cons
t &id,bool selected=false); | | void add(locale::message const &msg,std::string cons
t &id,bool selected=false); | |
| | | | |
| /// | | /// | |
|
| /// Get the mapping of all selected items according
to the order they where added to the list | | /// Get the mapping of all the selected items accord
ing to the order they where added to the multiple select list. | |
| /// | | /// | |
| std::vector<bool> selected_map(); | | std::vector<bool> selected_map(); | |
|
| | | | |
| /// | | /// | |
|
| /// Get all selected items ids according to the orde | | /// Get all the selected items ids according to the | |
| r they where added to the list, if no | | order they where added to the list. If no | |
| /// specific id was given, strings "0", "1"... would | | /// specific id was given, a string like "0", "1"... | |
| be used | | will be used. | |
| /// | | /// | |
| std::set<std::string> selected_ids(); | | std::set<std::string> selected_ids(); | |
| | | | |
| /// | | /// | |
|
| /// Get minimal amount of options that should be cho
sen, default = 0 | | /// Get the minimum amount of options that can be ch
osen. The default is \a 0. | |
| /// | | /// | |
| unsigned at_least(); | | unsigned at_least(); | |
| | | | |
| /// | | /// | |
|
| /// Set minimal amount of options that should be cho
sen, default = 0 | | /// Set the minimum amount of options that can be ch
osen. The default is \a 0. | |
| /// | | /// | |
| void at_least(unsigned v); | | void at_least(unsigned v); | |
| | | | |
| /// | | /// | |
|
| /// Get maximal amount of options that should be cho
sen, default unlimited | | /// Get the maximum amount of options that can be ch
osen. The default is unlimited. | |
| /// | | /// | |
| unsigned at_most(); | | unsigned at_most(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set maximal amount of options that should be cho
sen, default unlimited | | /// Set the maximum amount of options that can be ch
osen. The default is unlimited. | |
| /// | | /// | |
| void at_most(unsigned v); | | void at_most(unsigned v); | |
| | | | |
| /// | | /// | |
|
| /// Same as at_least(1) | | /// Same as at_least(1). | |
| /// | | /// | |
| void non_empty(); | | void non_empty(); | |
| | | | |
| /// | | /// | |
|
| /// Get the number of rows used for widget, default
0 -- undefined | | /// Get the number of rows used to display the widge
t. The default is \a 0 -- undefined. | |
| /// | | /// | |
| unsigned rows(); | | unsigned rows(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set the number of rows used for widget, default
0 -- undefined | | /// Set the number of rows used to display the widge
t. The default is \a 0 -- undefined. | |
| /// | | /// | |
| void rows(unsigned n); | | void rows(unsigned n); | |
| | | | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
| virtual bool validate(); | | virtual bool validate(); | |
| virtual void load(http::context &context); | | virtual void load(http::context &context); | |
| virtual void clear(); | | virtual void clear(); | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| | | | |
| struct element { | | struct element { | |
| element(); | | element(); | |
| element(std::string const &v,locale::message
const &msg,bool sel); | | element(std::string const &v,locale::message
const &msg,bool sel); | |
| element(std::string const &v,std::string con
st &msg,bool sel); | | element(std::string const &v,std::string con
st &msg,bool sel); | |
| uint32_t selected : 1; | | uint32_t selected : 1; | |
| uint32_t need_translation : 1; | | uint32_t need_translation : 1; | |
| | | | |
| skipping to change at line 1325 | | skipping to change at line 1330 | |
| | | | |
| std::vector<element> elements_; | | std::vector<element> elements_; | |
| | | | |
| unsigned low_; | | unsigned low_; | |
| unsigned high_; | | unsigned high_; | |
| unsigned rows_; | | unsigned rows_; | |
| | | | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// This is the base class for "select" like widgets which i | | /// \brief This is the base class for "select" like widgets | |
| ncludes dropdown list | | which include dropdown lists | |
| /// and radio buttons set. | | /// and radio button sets. | |
| /// | | /// | |
| class CPPCMS_API select_base : public base_widget { | | class CPPCMS_API select_base : public base_widget { | |
| public: | | public: | |
| select_base(); | | select_base(); | |
| virtual ~select_base(); | | virtual ~select_base(); | |
| | | | |
| /// | | /// | |
|
| /// Add new entry to selection list | | /// Add a new entry to the selection list. | |
| /// | | /// | |
| void add(std::string const &string); | | void add(std::string const &string); | |
| | | | |
| /// | | /// | |
|
| /// Add new entry to selection list giving the uniqu
e entry identification \a id | | /// Add to the selection list a new entry with the u
nique identification string \a id. | |
| /// | | /// | |
| void add(std::string const &string,std::string const
&id); | | void add(std::string const &string,std::string const
&id); | |
|
| | | | |
| /// | | /// | |
|
| /// Add new localized entry to selection list | | /// Add a new localized entry to the selection list. | |
| /// | | /// | |
| void add(locale::message const &msg); | | void add(locale::message const &msg); | |
|
| | | | |
| /// | | /// | |
|
| /// Add new localized entry to selection list giving
the unique entry identification \a id | | /// Add to the selection list a new localized entry
with the unique identification string \a id. | |
| /// | | /// | |
| void add(locale::message const &msg,std::string cons
t &id); | | void add(locale::message const &msg,std::string cons
t &id); | |
| | | | |
| /// | | /// | |
|
| /// Return the selected entry number in the list sta
rting from 0. -1 indicates that nothing | | /// Return the number of the selected entry in the l
ist. Entries are numbered starting from 0. -1 indicates that nothing | |
| /// was selected. | | /// was selected. | |
| /// | | /// | |
| int selected(); | | int selected(); | |
| | | | |
| /// | | /// | |
|
| /// Return the identification string of the selected | | /// Return the identification string of the selected | |
| entry, empty string indicates that | | entry in the list. An empty string indicates that | |
| /// nothing was selected | | /// nothing was selected. | |
| /// | | /// | |
| std::string selected_id(); | | std::string selected_id(); | |
| | | | |
| /// | | /// | |
|
| /// Select entry number \a no in the list for render
ing | | /// Select the entry numbered \a no. | |
| /// | | /// | |
| void selected(int no); | | void selected(int no); | |
|
| | | | |
| /// | | /// | |
|
| /// Select entry with identification \a id in the li
st for rendering | | /// Select the entry with the identification string
\a id. | |
| /// | | /// | |
| void selected_id(std::string id); | | void selected_id(std::string id); | |
| | | | |
| /// | | /// | |
|
| /// Require that item should be selected (for valida
tion) | | /// Require that one item in the list should be sele
cted (for the validation). | |
| /// | | /// | |
| void non_empty(); | | void non_empty(); | |
| | | | |
| virtual void render_input(form_context &context) = 0
; | | virtual void render_input(form_context &context) = 0
; | |
| virtual bool validate(); | | virtual bool validate(); | |
| virtual void load(http::context &context); | | virtual void load(http::context &context); | |
| virtual void clear(); | | virtual void clear(); | |
|
| protected: | | | |
| | | | |
|
| | | protected: | |
| struct CPPCMS_API element { | | struct CPPCMS_API element { | |
| | | | |
| element(); | | element(); | |
| element(std::string const &v,locale::message
const &msg); | | element(std::string const &v,locale::message
const &msg); | |
| element(std::string const &v,std::string con
st &msg); | | element(std::string const &v,std::string con
st &msg); | |
| element(element const &); | | element(element const &); | |
| element const &operator=(element const &); | | element const &operator=(element const &); | |
| ~element(); | | ~element(); | |
| | | | |
| uint32_t need_translation : 1; | | uint32_t need_translation : 1; | |
| | | | |
| skipping to change at line 1417 | | skipping to change at line 1426 | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| | | | |
| int selected_; | | int selected_; | |
| int default_selected_; | | int default_selected_; | |
| | | | |
| uint32_t non_empty_ : 1; | | uint32_t non_empty_ : 1; | |
| uint32_t reserverd : 32; | | uint32_t reserverd : 32; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// Select widget that uses drop-down list | | /// \brief The widget that uses a drop-down list for selecti
on. | |
| /// | | /// | |
|
| | | | |
| class CPPCMS_API select : public select_base { | | class CPPCMS_API select : public select_base { | |
| public: | | public: | |
| select(); | | select(); | |
| virtual ~select(); | | virtual ~select(); | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// Select widget that uses a set of radio buttons | | /// \brief The widget that uses a set of radio buttons.. | |
| /// | | /// | |
| class CPPCMS_API radio : public select_base { | | class CPPCMS_API radio : public select_base { | |
| public: | | public: | |
| radio(); | | radio(); | |
| virtual ~radio(); | | virtual ~radio(); | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
| | | | |
| /// | | /// | |
| /// Return the rendering order | | /// Return the rendering order | |
| /// | | /// | |
| | | | |
| skipping to change at line 1443 | | skipping to change at line 1452 | |
| class CPPCMS_API radio : public select_base { | | class CPPCMS_API radio : public select_base { | |
| public: | | public: | |
| radio(); | | radio(); | |
| virtual ~radio(); | | virtual ~radio(); | |
| virtual void render_input(form_context &context); | | virtual void render_input(form_context &context); | |
| | | | |
| /// | | /// | |
| /// Return the rendering order | | /// Return the rendering order | |
| /// | | /// | |
| bool vertical(); | | bool vertical(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set rendering order of the list one behind other | | /// Set rendering order of the list one behind other | |
| (default) or in same line. | | (default) | |
| | | /// or in same line. | |
| | | /// | |
| | | /// Baiscally it defines whether the radio buttons s | |
| | | hould | |
| | | /// appear in row (false) or in column (true). | |
| /// | | /// | |
| void vertical(bool); | | void vertical(bool); | |
| | | | |
| private: | | private: | |
| uint32_t vertical_ : 1; | | uint32_t vertical_ : 1; | |
| uint32_t reserved_ : 31; | | uint32_t reserved_ : 31; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// \brief Class that represents file upload form entry | | /// \brief This class represents a file upload form entry. | |
| /// | | /// | |
|
| /// If the file was not uploaded set() would be false and | | /// If the file was not uploaded, set() will be false and | |
| /// on attempt to access value() member function it would th | | /// an attempt to access the member function value() will th | |
| row | | row. | |
| /// | | /// | |
| class CPPCMS_API file : public base_html_input { | | class CPPCMS_API file : public base_html_input { | |
| public: | | public: | |
| /// | | /// | |
|
| /// Ensure that file is uploaded. | | /// Ensure that a file is uploaded (for the validati
on). | |
| /// | | /// | |
| void non_empty(); | | void non_empty(); | |
|
| | | | |
| /// | | /// | |
|
| /// Set minimum and maximum limits for file size. No | | /// Set the minimum and maximum limits for the file | |
| te max == -1 indicates that there | | size. Note: max == -1 indicates that there | |
| /// is no maximal limit, min==0 indicates that there | | /// is no maximum limit; min==0 indicates that there | |
| is no minimal limit. | | is no minimum limit. | |
| /// | | /// | |
| /// | | /// | |
| void limits(int min,int max); | | void limits(int min,int max); | |
| | | | |
| /// | | /// | |
|
| /// Get minimal and maximal size limits, | | /// Get the minimum and maximum size limits. | |
| /// | | /// | |
|
| | | | |
| std::pair<int,int> limits(); | | std::pair<int,int> limits(); | |
| | | | |
| /// | | /// | |
|
| /// Set filename validation pattern. For example ".*
\\.(jpg|jpeg|png)" | | /// Set the filename validation pattern. For example
".*\\.(jpg|jpeg|png)". | |
| /// | | /// | |
|
| /// Please, note that it is good idea to check magic | | /// Please, note that it is a good idea to check mag | |
| number as well. | | ic numbers as well | |
| | | /// and not rely on file name only. | |
| | | /// | |
| | | /// See add_valid_magic() function | |
| /// | | /// | |
| void filename(booster::regex const &fn); | | void filename(booster::regex const &fn); | |
| | | | |
| /// | | /// | |
|
| /// Get regular expression for filename validation | | /// Get the regular expression for the filename vali
dation. | |
| /// | | /// | |
| booster::regex filename(); | | booster::regex filename(); | |
| | | | |
| /// | | /// | |
|
| /// Validate the filename's charset (default is on) | | /// Validate or not the filename's charset. The defa
ult is \a true. | |
| /// | | /// | |
| void validate_filename_charset(bool); | | void validate_filename_charset(bool); | |
|
| | | | |
| /// | | /// | |
|
| /// Get validation option for filename's charset | | /// Get the validation option for the filename's cha
rset. | |
| /// | | /// | |
| bool validate_filename_charset(); | | bool validate_filename_charset(); | |
| | | | |
| /// | | /// | |
|
| /// Get uploaded file, throws cppcms_error if set() | | /// Get the uploaded file. This throws cppcms_error | |
| == false, i.e. if the file | | if set() == false, i.e. if no file | |
| /// was not uploaded | | /// was uploaded. | |
| /// | | /// | |
| booster::shared_ptr<http::file> value(); | | booster::shared_ptr<http::file> value(); | |
| | | | |
| /// | | /// | |
|
| /// Set required file mime type | | /// Set the required file mime type. | |
| /// | | /// | |
| void mime(std::string const &); | | void mime(std::string const &); | |
| | | | |
| /// | | /// | |
|
| /// Set regular expression that checks for valid mim
e type | | /// Set the regular expression to validate the mime
type. | |
| /// | | /// | |
| void mime(booster::regex const &expr); | | void mime(booster::regex const &expr); | |
| | | | |
| /// | | /// | |
|
| /// Add a string that represents a valid magic numbe
r that shoud exist on begging of file | | /// Add a string that represents a valid magic numbe
r that shoud exist on begging of file. | |
| /// | | /// | |
|
| /// By default no tests are performed | | /// By default no tests are performed. | |
| /// | | /// | |
| void add_valid_magic(std::string const &); | | void add_valid_magic(std::string const &); | |
| | | | |
| virtual void load(http::context &context); | | virtual void load(http::context &context); | |
| virtual void render_value(form_context &context); | | virtual void render_value(form_context &context); | |
| virtual bool validate(); | | virtual bool validate(); | |
| | | | |
| file(); | | file(); | |
| ~file(); | | ~file(); | |
| | | | |
| | | | |
| skipping to change at line 1554 | | skipping to change at line 1572 | |
| uint32_t check_non_empty_ : 1; | | uint32_t check_non_empty_ : 1; | |
| uint32_t reserved_ : 30; | | uint32_t reserved_ : 30; | |
| | | | |
| booster::shared_ptr<http::file> file_; | | booster::shared_ptr<http::file> file_; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// Submit button widget | | /// \brief Submit button widget. | |
| /// | | /// | |
| class CPPCMS_API submit : public base_html_input { | | class CPPCMS_API submit : public base_html_input { | |
| public: | | public: | |
| submit(); | | submit(); | |
| ~submit(); | | ~submit(); | |
| | | | |
| /// | | /// | |
|
| /// Returns true if this specific button was pressed | | /// Return true if this specific button was pressed. | |
| /// | | /// | |
| bool value(); | | bool value(); | |
| | | | |
| /// | | /// | |
|
| /// Sets the text on button | | /// Set the text on the button. | |
| /// | | /// | |
| void value(std::string val); | | void value(std::string val); | |
|
| | | | |
| /// | | /// | |
|
| /// Sets the text on button | | /// Set the text on the button. | |
| /// | | /// | |
| void value(locale::message const &msg); | | void value(locale::message const &msg); | |
| | | | |
| virtual void render_value(form_context &context); | | virtual void render_value(form_context &context); | |
| virtual void load(http::context &context); | | virtual void load(http::context &context); | |
|
| | | | |
| private: | | private: | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| bool pressed_; | | bool pressed_; | |
| locale::message value_; | | locale::message value_; | |
| }; | | }; | |
| | | | |
| } // widgets | | } // widgets | |
| | | | |
| } //cppcms | | } //cppcms | |
| | | | |
End of changes. 227 change blocks. |
| 316 lines changed or deleted | | 343 lines changed or added | |
|
| rpc_json.h | | rpc_json.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| ///////////////////////////////////////////////////////////////////////////
//// | | ///////////////////////////////////////////////////////////////////////////
//// | |
| #ifndef CPPCMS_RPC_JSON_OBJECT_H | | #ifndef CPPCMS_RPC_JSON_OBJECT_H | |
| #define CPPCMS_RPC_JSON_OBJECT_H | | #define CPPCMS_RPC_JSON_OBJECT_H | |
| | | | |
| #include <cppcms/application.h> | | #include <cppcms/application.h> | |
| #include <booster/function.h> | | #include <booster/function.h> | |
| #include <cppcms/json.h> | | #include <cppcms/json.h> | |
| #include <cppcms/cppcms_error.h> | | #include <cppcms/cppcms_error.h> | |
| | | | |
| namespace cppcms { | | namespace cppcms { | |
|
| | | /// | |
| | | /// \brief This namespace holds API for implementing various RPC APIs, like | |
| | | JsonRPC | |
| | | /// | |
| namespace rpc { | | namespace rpc { | |
| | | | |
| /// | | /// | |
|
| /// The error thrown in case of bad call - parameters mismatch or | | /// \brief The error thrown in case of bad call - parameters mismatc
h or | |
| /// invalid request. | | /// invalid request. | |
| /// | | /// | |
| /// User should may throw it case of a error as invalid request insi
de the | | /// User should may throw it case of a error as invalid request insi
de the | |
| /// method. However return_error() is preferred. | | /// method. However return_error() is preferred. | |
| /// | | /// | |
| class CPPCMS_API call_error : public cppcms_error { | | class CPPCMS_API call_error : public cppcms_error { | |
| public: | | public: | |
| /// | | /// | |
| /// Define error message | | /// Define error message | |
| /// | | /// | |
| call_error(std::string const &message); | | call_error(std::string const &message); | |
| }; | | }; | |
| | | | |
| class json_rpc_server; | | class json_rpc_server; | |
| | | | |
| /// | | /// | |
|
| /// This class represents single call of json-rpc method. It is used | | /// \brief This class represents single call of json-rpc method. | |
| | | /// | |
| | | /// It is used | |
| /// for handling asynchronous responses only. Similar API is provide
d | | /// for handling asynchronous responses only. Similar API is provide
d | |
| /// in json_rpc_server class for synchronous methods. | | /// in json_rpc_server class for synchronous methods. | |
| /// | | /// | |
| class CPPCMS_API json_call : public booster::noncopyable { | | class CPPCMS_API json_call : public booster::noncopyable { | |
| public: | | public: | |
| | | | |
| /// | | /// | |
| /// Destructor. Automatically deletes appropriate context as
once it given to user it owns it. | | /// Destructor. Automatically deletes appropriate context as
once it given to user it owns it. | |
| /// | | /// | |
| ~json_call(); | | ~json_call(); | |
| | | | |
| skipping to change at line 114 | | skipping to change at line 119 | |
| json::value id_; | | json::value id_; | |
| json::array params_; | | json::array params_; | |
| std::string method_; | | std::string method_; | |
| bool notification_; | | bool notification_; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
| /// | | /// | |
|
| /// JSON-RPC service provider | | /// \brief JSON-RPC service application. | |
| | | /// | |
| | | /// User is expected to derive his own objects from this class in or | |
| | | der to implement Json-RPC calls | |
| | | /// similarly to how cppcms::application is used. | |
| /// | | /// | |
| class CPPCMS_API json_rpc_server : public application { | | class CPPCMS_API json_rpc_server : public application { | |
| public: | | public: | |
| /// | | /// | |
| /// The role of the method - receives notification, returns
result or any one of them | | /// The role of the method - receives notification, returns
result or any one of them | |
| /// | | /// | |
| typedef enum { | | typedef enum { | |
| any_role, ///< Method may receive noti
fication and return result | | any_role, ///< Method may receive noti
fication and return result | |
| method_role, ///< Method can't be used wi
th notification calls | | method_role, ///< Method can't be used wi
th notification calls | |
| notification_role ///< Method should be used w
ith notification calls only | | notification_role ///< Method should be used w
ith notification calls only | |
| | | | |
| skipping to change at line 205 | | skipping to change at line 213 | |
| typedef std::map<std::string,method_data> methods_map_type; | | typedef std::map<std::string,method_data> methods_map_type; | |
| methods_map_type methods_; | | methods_map_type methods_; | |
| booster::shared_ptr<json_call> current_call_; | | booster::shared_ptr<json_call> current_call_; | |
| | | | |
| std::string smd_; | | std::string smd_; | |
| | | | |
| struct _data; | | struct _data; | |
| booster::hold_ptr<_data> d; | | booster::hold_ptr<_data> d; | |
| }; | | }; | |
| | | | |
|
| | | /// \cond INTERNAL | |
| | | | |
| | | namespace details { | |
| | | | |
| | | template<typename T> struct fw_ret { typedef T type; }; | |
| | | template<typename T> struct fw_ret<T const &> { typedef T ty | |
| | | pe; }; | |
| | | template<typename T> struct fw_ret<T const> { typedef T type | |
| | | ; }; | |
| | | | |
| | | template<> struct fw_ret<json::value> { typedef json::value | |
| | | const &type; }; | |
| | | template<> struct fw_ret<json::object> { typedef json::objec | |
| | | t const &type; }; | |
| | | template<> struct fw_ret<json::array> { typedef json::array | |
| | | const &type; }; | |
| | | template<> struct fw_ret<std::string> { typedef std::string | |
| | | const &type; }; | |
| | | | |
| | | template<> struct fw_ret<json::value const &> { typedef jso | |
| | | n::value const &type; }; | |
| | | template<> struct fw_ret<json::object const &> { typedef jso | |
| | | n::object const &type; }; | |
| | | template<> struct fw_ret<json::array const &> { typedef jso | |
| | | n::array const &type; }; | |
| | | template<> struct fw_ret<std::string const &> { typedef std | |
| | | ::string const &type; }; | |
| | | | |
| | | template<> struct fw_ret<json::value const> { typedef json: | |
| | | :value const &type; }; | |
| | | template<> struct fw_ret<json::object const> { typedef json: | |
| | | :object const &type; }; | |
| | | template<> struct fw_ret<json::array const> { typedef json: | |
| | | :array const &type; }; | |
| | | template<> struct fw_ret<std::string const> { typedef std:: | |
| | | string const &type; }; | |
| | | | |
| | | template<typename T> | |
| | | struct fw_ret_handle { | |
| | | static typename fw_ret<T>::type extract(json::value | |
| | | const &v) | |
| | | { | |
| | | return v.get_value<typename fw_ret<T>::type> | |
| | | (); | |
| | | } | |
| | | }; | |
| | | | |
| | | template<> | |
| | | struct fw_ret_handle<json::value const &> | |
| | | { | |
| | | static json::value const &extract(json::value const | |
| | | &v) | |
| | | { | |
| | | return v; | |
| | | } | |
| | | }; | |
| | | | |
| | | template<> | |
| | | struct fw_ret_handle<json::array const &> | |
| | | { | |
| | | static json::array const &extract(json::value const | |
| | | &v) | |
| | | { | |
| | | return v.array(); | |
| | | } | |
| | | }; | |
| | | | |
| | | template<> | |
| | | struct fw_ret_handle<json::object const &> | |
| | | { | |
| | | static json::object const &extract(json::value const | |
| | | &v) | |
| | | { | |
| | | return v.object(); | |
| | | } | |
| | | }; | |
| | | | |
| | | template<> | |
| | | struct fw_ret_handle<std::string const &> | |
| | | { | |
| | | static std::string const &extract(json::value const | |
| | | &v) | |
| | | { | |
| | | return v.str(); | |
| | | } | |
| | | }; | |
| | | | |
| | | template <typename T> | |
| | | inline typename fw_ret<T>::type forward_value(json::value co | |
| | | nst &v) | |
| | | { | |
| | | typedef typename fw_ret<T>::type return_type; | |
| | | return fw_ret_handle<return_type>::extract(v); | |
| | | } | |
| | | | |
| | | } | |
| | | | |
| #define CPPCMS_JSON_RPC_BINDER(N)
\ | | #define CPPCMS_JSON_RPC_BINDER(N)
\ | |
| namespace details {
\ | | namespace details {
\ | |
| template<typename Class,typename Ptr CPPCMS_TEMPLATE_PARAMS>
\ | | template<typename Class,typename Ptr CPPCMS_TEMPLATE_PARAMS>
\ | |
| struct binder##N {
\ | | struct binder##N {
\ | |
| Ptr object;
\ | | Ptr object;
\ | |
| void (Class::*member)(CPPCMS_FUNC_PARAMS);
\ | | void (Class::*member)(CPPCMS_FUNC_PARAMS);
\ | |
| void operator()(json::array const &a) const
\ | | void operator()(json::array const &a) const
\ | |
| {
\ | | {
\ | |
| if(a.size()!=N)
\ | | if(a.size()!=N)
\ | |
| throw call_error("Invalid parametres
number"); \ | | throw call_error("Invalid parametres
number"); \ | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 320 | |
| #define CPPCMS_CALL_PARAMS | | #define CPPCMS_CALL_PARAMS | |
| #define CPPCMS_BINDER_PARAMS | | #define CPPCMS_BINDER_PARAMS | |
| CPPCMS_JSON_RPC_BINDER(0) | | CPPCMS_JSON_RPC_BINDER(0) | |
| #undef CPPCMS_TEMPLATE_PARAMS | | #undef CPPCMS_TEMPLATE_PARAMS | |
| #undef CPPCMS_FUNC_PARAMS | | #undef CPPCMS_FUNC_PARAMS | |
| #undef CPPCMS_CALL_PARAMS | | #undef CPPCMS_CALL_PARAMS | |
| #undef CPPCMS_BINDER_PARAMS | | #undef CPPCMS_BINDER_PARAMS | |
| | | | |
| #define CPPCMS_TEMPLATE_PARAMS ,typename P1 | | #define CPPCMS_TEMPLATE_PARAMS ,typename P1 | |
| #define CPPCMS_FUNC_PARAMS P1 | | #define CPPCMS_FUNC_PARAMS P1 | |
|
| #define CPPCMS_CALL_PARAMS a[0].get_value<P1>() | | #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]) | |
| #define CPPCMS_BINDER_PARAMS ,P1 | | #define CPPCMS_BINDER_PARAMS ,P1 | |
| CPPCMS_JSON_RPC_BINDER(1) | | CPPCMS_JSON_RPC_BINDER(1) | |
| #undef CPPCMS_TEMPLATE_PARAMS | | #undef CPPCMS_TEMPLATE_PARAMS | |
| #undef CPPCMS_FUNC_PARAMS | | #undef CPPCMS_FUNC_PARAMS | |
| #undef CPPCMS_CALL_PARAMS | | #undef CPPCMS_CALL_PARAMS | |
| #undef CPPCMS_BINDER_PARAMS | | #undef CPPCMS_BINDER_PARAMS | |
| | | | |
| #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2 | | #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2 | |
| #define CPPCMS_FUNC_PARAMS P1,P2 | | #define CPPCMS_FUNC_PARAMS P1,P2 | |
|
| #define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>(
) | | #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2
>(a[1]) | |
| #define CPPCMS_BINDER_PARAMS ,P1,P2 | | #define CPPCMS_BINDER_PARAMS ,P1,P2 | |
| CPPCMS_JSON_RPC_BINDER(2) | | CPPCMS_JSON_RPC_BINDER(2) | |
| #undef CPPCMS_TEMPLATE_PARAMS | | #undef CPPCMS_TEMPLATE_PARAMS | |
| #undef CPPCMS_FUNC_PARAMS | | #undef CPPCMS_FUNC_PARAMS | |
| #undef CPPCMS_CALL_PARAMS | | #undef CPPCMS_CALL_PARAMS | |
| #undef CPPCMS_BINDER_PARAMS | | #undef CPPCMS_BINDER_PARAMS | |
| | | | |
| #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 | | #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 | |
| #define CPPCMS_FUNC_PARAMS P1,P2,P3 | | #define CPPCMS_FUNC_PARAMS P1,P2,P3 | |
|
| #define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>(
),a[2].get_value<P3>() | | #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2
>(a[1]), forward_value<P3>(a[2]) | |
| #define CPPCMS_BINDER_PARAMS ,P1,P2,P3 | | #define CPPCMS_BINDER_PARAMS ,P1,P2,P3 | |
| CPPCMS_JSON_RPC_BINDER(3) | | CPPCMS_JSON_RPC_BINDER(3) | |
| #undef CPPCMS_TEMPLATE_PARAMS | | #undef CPPCMS_TEMPLATE_PARAMS | |
| #undef CPPCMS_FUNC_PARAMS | | #undef CPPCMS_FUNC_PARAMS | |
| #undef CPPCMS_CALL_PARAMS | | #undef CPPCMS_CALL_PARAMS | |
| #undef CPPCMS_BINDER_PARAMS | | #undef CPPCMS_BINDER_PARAMS | |
| | | | |
| #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,
typename P4 | | #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,
typename P4 | |
| #define CPPCMS_FUNC_PARAMS P1,P2,P3,P4 | | #define CPPCMS_FUNC_PARAMS P1,P2,P3,P4 | |
|
| #define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>( | | #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2 | |
| ),a[2].get_value<P3>(), \ | | >(a[1]), forward_value<P3>(a[2]), forward_value<P4>(a[3]) | |
| a[3].get_value<P4>() | | | |
| #define CPPCMS_BINDER_PARAMS ,P1,P2,P3,P4 | | #define CPPCMS_BINDER_PARAMS ,P1,P2,P3,P4 | |
| CPPCMS_JSON_RPC_BINDER(4) | | CPPCMS_JSON_RPC_BINDER(4) | |
| #undef CPPCMS_TEMPLATE_PARAMS | | #undef CPPCMS_TEMPLATE_PARAMS | |
| #undef CPPCMS_FUNC_PARAMS | | #undef CPPCMS_FUNC_PARAMS | |
| #undef CPPCMS_CALL_PARAMS | | #undef CPPCMS_CALL_PARAMS | |
| #undef CPPCMS_BINDER_PARAMS | | #undef CPPCMS_BINDER_PARAMS | |
| | | | |
| #undef CPPCMS_JSON_RPC_BINDER | | #undef CPPCMS_JSON_RPC_BINDER | |
| | | | |
|
| | | /// \endcond | |
| | | | |
| } // rpc | | } // rpc | |
| } // cppcms | | } // cppcms | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 10 change blocks. |
| 9 lines changed or deleted | | 117 lines changed or added | |
|
| string_key.h | | string_key.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| #ifndef CPPCMS_STRING_KEY_H | | #ifndef CPPCMS_STRING_KEY_H | |
| #define CPPCMS_STRING_KEY_H | | #define CPPCMS_STRING_KEY_H | |
| | | | |
| #include <string> | | #include <string> | |
| #include <string.h> | | #include <string.h> | |
| #include <algorithm> | | #include <algorithm> | |
| #include <stdexcept> | | #include <stdexcept> | |
| #include <ostream> | | #include <ostream> | |
| | | | |
| namespace cppcms { | | namespace cppcms { | |
|
| | | | |
| | | /// | |
| | | /// \brief This is a special object that may hold an std::string or | |
| | | /// alternatively reference to external (unowned) chunk of text | |
| | | /// | |
| | | /// It is designed to be used for efficiency and reduce amount of | |
| | | /// memory allocations and copies. | |
| | | /// | |
| | | /// It has interface that is roughly similar to the interface of std | |
| | | ::string, | |
| | | /// but it does not provide a members that can mutate it or provide | |
| | | a NUL terminated | |
| | | /// string c_str(). | |
| | | /// | |
| class string_key { | | class string_key { | |
| public: | | public: | |
| | | | |
|
| | | /// | |
| | | /// Iterator type | |
| | | /// | |
| typedef char const *const_iterator; | | typedef char const *const_iterator; | |
| | | | |
|
| | | /// | |
| | | /// The last position of the character in the string | |
| | | /// | |
| static const size_t npos = -1; | | static const size_t npos = -1; | |
| | | | |
|
| | | /// | |
| | | /// Default constructor - empty key | |
| | | /// | |
| string_key() : | | string_key() : | |
| begin_(0), | | begin_(0), | |
| end_(0) | | end_(0) | |
| { | | { | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Create a new string copying the \a key | |
| | | /// | |
| string_key(char const *key) : | | string_key(char const *key) : | |
| begin_(0), | | begin_(0), | |
| end_(0), | | end_(0), | |
| key_(key) | | key_(key) | |
| { | | { | |
| } | | } | |
|
| | | /// | |
| | | /// Create a new string copying the \a key | |
| | | /// | |
| string_key(std::string const &key) : | | string_key(std::string const &key) : | |
| begin_(0), | | begin_(0), | |
| end_(0), | | end_(0), | |
| key_(key) | | key_(key) | |
| { | | { | |
| } | | } | |
|
| | | /// | |
| | | /// String size in bytes | |
| | | /// | |
| size_t size() const | | size_t size() const | |
| { | | { | |
| return end() - begin(); | | return end() - begin(); | |
| } | | } | |
|
| | | /// | |
| | | /// Same as size() | |
| | | /// | |
| size_t length() const | | size_t length() const | |
| { | | { | |
| return size(); | | return size(); | |
| } | | } | |
|
| | | /// | |
| | | /// Clear the string | |
| | | /// | |
| void clear() | | void clear() | |
| { | | { | |
| begin_ = end_ = 0; | | begin_ = end_ = 0; | |
| key_.clear(); | | key_.clear(); | |
| } | | } | |
|
| | | /// | |
| | | /// Check if the string is empty | |
| | | /// | |
| bool empty() const | | bool empty() const | |
| { | | { | |
| return end() == begin(); | | return end() == begin(); | |
| } | | } | |
|
| | | /// | |
| | | /// Find first occurrence of a character \c in the string st | |
| | | arting from | |
| | | /// position \a pos. Returns npos if not character found. | |
| | | /// | |
| size_t find(char c,size_t pos = 0) const | | size_t find(char c,size_t pos = 0) const | |
| { | | { | |
| size_t s = size(); | | size_t s = size(); | |
| if(pos >= s) | | if(pos >= s) | |
| return npos; | | return npos; | |
| char const *p=begin() + pos; | | char const *p=begin() + pos; | |
| while(pos <= s && *p!=c) { | | while(pos <= s && *p!=c) { | |
| pos++; | | pos++; | |
| p++; | | p++; | |
| } | | } | |
| if(pos >= s) | | if(pos >= s) | |
| return npos; | | return npos; | |
| return pos; | | return pos; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Create a substring from this string starting from charac | |
| | | ter \a pos of size at most \a n | |
| | | /// | |
| string_key substr(size_t pos = 0,size_t n=npos) const | | string_key substr(size_t pos = 0,size_t n=npos) const | |
| { | | { | |
| string_key tmp = unowned_substr(pos,n); | | string_key tmp = unowned_substr(pos,n); | |
| return string_key(std::string(tmp.begin(),tmp.end())
); | | return string_key(std::string(tmp.begin(),tmp.end())
); | |
| } | | } | |
|
| | | /// | |
| | | /// Create a substring from this string starting from charac | |
| | | ter \a pos of size at most \a n | |
| | | /// such that the memory is not copied but only reference by | |
| | | the created substring | |
| | | /// | |
| string_key unowned_substr(size_t pos = 0,size_t n=npos) cons
t | | string_key unowned_substr(size_t pos = 0,size_t n=npos) cons
t | |
| { | | { | |
| if(pos >= size()) { | | if(pos >= size()) { | |
| return string_key(); | | return string_key(); | |
| } | | } | |
| char const *p=begin() + pos; | | char const *p=begin() + pos; | |
| char const *e=end(); | | char const *e=end(); | |
| if(n > size_t(e-p)) { | | if(n > size_t(e-p)) { | |
| return string_key(p,e); | | return string_key(p,e); | |
| } | | } | |
| else { | | else { | |
| return string_key(p,p+n); | | return string_key(p,p+n); | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Get a character at position \a n | |
| | | /// | |
| char const &operator[](size_t n) const | | char const &operator[](size_t n) const | |
| { | | { | |
| return *(begin() + n); | | return *(begin() + n); | |
| } | | } | |
|
| | | /// | |
| | | /// Get a character at position \a n, if \a n is not valid p | |
| | | osition, throws std::out_of_range exception | |
| | | /// | |
| char const &at(size_t n) const | | char const &at(size_t n) const | |
| { | | { | |
| if(n > size()) | | if(n > size()) | |
| throw std::out_of_range("cppcms::string_key:
:at() range error"); | | throw std::out_of_range("cppcms::string_key:
:at() range error"); | |
| return *(begin() + n); | | return *(begin() + n); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Create a string from \a v without copying the memory. \a | |
| | | v should remain valid | |
| | | /// as long as this object is used | |
| | | /// | |
| static string_key unowned(std::string const &v) | | static string_key unowned(std::string const &v) | |
| { | | { | |
| return string_key(v.c_str(),v.c_str()+v.size()); | | return string_key(v.c_str(),v.c_str()+v.size()); | |
| } | | } | |
|
| | | /// | |
| | | /// Create a string from \a str without copying the memory. | |
| | | \a str should remain valid | |
| | | /// as long as this object is used | |
| | | /// | |
| static string_key unowned(char const *str) | | static string_key unowned(char const *str) | |
| { | | { | |
| char const *end = str; | | char const *end = str; | |
| while(*end) | | while(*end) | |
| end++; | | end++; | |
| return string_key(str,end); | | return string_key(str,end); | |
| } | | } | |
|
| | | /// | |
| | | /// Create a string from \a characters at rang [begin,end) w | |
| | | ithout copying the memory. | |
| | | /// The range should remain valid as long as this object is | |
| | | used | |
| | | /// | |
| static string_key unowned(char const *begin,char const *end) | | static string_key unowned(char const *begin,char const *end) | |
| { | | { | |
| return string_key(begin,end); | | return string_key(begin,end); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Get a pointer to the first character in the string | |
| | | /// | |
| char const *begin() const | | char const *begin() const | |
| { | | { | |
| if(begin_) | | if(begin_) | |
| return begin_; | | return begin_; | |
| return key_.c_str(); | | return key_.c_str(); | |
| } | | } | |
|
| | | /// | |
| | | /// Get a pointer to the one past last character in the stri | |
| | | ng | |
| | | /// | |
| char const *end() const | | char const *end() const | |
| { | | { | |
| if(begin_) | | if(begin_) | |
| return end_; | | return end_; | |
| return key_.c_str() + key_.size(); | | return key_.c_str() + key_.size(); | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator<(string_key const &other) const | | bool operator<(string_key const &other) const | |
| { | | { | |
| return std::lexicographical_compare( begin(),end(
), | | return std::lexicographical_compare( begin(),end(
), | |
| other.begin(
),other.end(), | | other.begin(
),other.end(), | |
| std::char_tr
aits<char>::lt); | | std::char_tr
aits<char>::lt); | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator>(string_key const &other) const | | bool operator>(string_key const &other) const | |
| { | | { | |
| return other < *this; | | return other < *this; | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator>=(string_key const &other) const | | bool operator>=(string_key const &other) const | |
| { | | { | |
| return !(*this < other); | | return !(*this < other); | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator<=(string_key const &other) const | | bool operator<=(string_key const &other) const | |
| { | | { | |
| return !(*this > other); | | return !(*this > other); | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator==(string_key const &other) const | | bool operator==(string_key const &other) const | |
| { | | { | |
| return (end() - begin() == other.end() - other.begin
()) | | return (end() - begin() == other.end() - other.begin
()) | |
| && memcmp(begin(),other.begin(),end()-begin(
)) == 0; | | && memcmp(begin(),other.begin(),end()-begin(
)) == 0; | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| bool operator!=(string_key const &other) const | | bool operator!=(string_key const &other) const | |
| { | | { | |
| return !(*this!=other); | | return !(*this!=other); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Get the pointer to the first character in the string. No | |
| | | te it should not be NUL terminated | |
| | | /// | |
| char const *data() const | | char const *data() const | |
| { | | { | |
| return begin(); | | return begin(); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Create std::string from the key | |
| | | /// | |
| std::string str() const | | std::string str() const | |
| { | | { | |
| if(begin_) | | if(begin_) | |
| return std::string(begin_,end_-begin_); | | return std::string(begin_,end_-begin_); | |
| else | | else | |
| return key_; | | return key_; | |
| } | | } | |
|
| | | /// | |
| | | /// Convert the key to the std::string | |
| | | /// | |
| operator std::string() const | | operator std::string() const | |
| { | | { | |
| return str(); | | return str(); | |
| } | | } | |
| private: | | private: | |
| string_key(char const *b,char const *e) : | | string_key(char const *b,char const *e) : | |
| begin_(b), | | begin_(b), | |
| end_(e) | | end_(e) | |
| { | | { | |
| } | | } | |
| | | | |
| char const *begin_; | | char const *begin_; | |
| char const *end_; | | char const *end_; | |
| std::string key_; | | std::string key_; | |
| }; | | }; | |
| | | | |
|
| | | /// | |
| | | /// Write the string to the stream | |
| | | /// | |
| inline std::ostream &operator<<(std::ostream &out,string_key const &
s) | | inline std::ostream &operator<<(std::ostream &out,string_key const &
s) | |
| { | | { | |
| out.write(s.data(),s.size()); | | out.write(s.data(),s.size()); | |
| return out; | | return out; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator==(string_key const &l,char const *r) | | inline bool operator==(string_key const &l,char const *r) | |
| { | | { | |
| return l==string_key::unowned(r); | | return l==string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator==(char const *l,string_key const &r) | | inline bool operator==(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) == r; | | return string_key::unowned(l) == r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator==(string_key const &l,std::string const &r) | | inline bool operator==(string_key const &l,std::string const &r) | |
| { | | { | |
| return l==string_key::unowned(r); | | return l==string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator==(std::string const &l,string_key const &r) | | inline bool operator==(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) == r; | | return string_key::unowned(l) == r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator!=(string_key const &l,char const *r) | | inline bool operator!=(string_key const &l,char const *r) | |
| { | | { | |
| return l!=string_key::unowned(r); | | return l!=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator!=(char const *l,string_key const &r) | | inline bool operator!=(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) != r; | | return string_key::unowned(l) != r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator!=(string_key const &l,std::string const &r) | | inline bool operator!=(string_key const &l,std::string const &r) | |
| { | | { | |
| return l!=string_key::unowned(r); | | return l!=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator!=(std::string const &l,string_key const &r) | | inline bool operator!=(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) != r; | | return string_key::unowned(l) != r; | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<=(string_key const &l,char const *r) | | inline bool operator<=(string_key const &l,char const *r) | |
| { | | { | |
| return l<=string_key::unowned(r); | | return l<=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<=(char const *l,string_key const &r) | | inline bool operator<=(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) <= r; | | return string_key::unowned(l) <= r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<=(string_key const &l,std::string const &r) | | inline bool operator<=(string_key const &l,std::string const &r) | |
| { | | { | |
| return l<=string_key::unowned(r); | | return l<=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<=(std::string const &l,string_key const &r) | | inline bool operator<=(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) <= r; | | return string_key::unowned(l) <= r; | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>=(string_key const &l,char const *r) | | inline bool operator>=(string_key const &l,char const *r) | |
| { | | { | |
| return l>=string_key::unowned(r); | | return l>=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>=(char const *l,string_key const &r) | | inline bool operator>=(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) >= r; | | return string_key::unowned(l) >= r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>=(string_key const &l,std::string const &r) | | inline bool operator>=(string_key const &l,std::string const &r) | |
| { | | { | |
| return l>=string_key::unowned(r); | | return l>=string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>=(std::string const &l,string_key const &r) | | inline bool operator>=(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) >= r; | | return string_key::unowned(l) >= r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<(string_key const &l,char const *r) | | inline bool operator<(string_key const &l,char const *r) | |
| { | | { | |
| return l<string_key::unowned(r); | | return l<string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<(char const *l,string_key const &r) | | inline bool operator<(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) < r; | | return string_key::unowned(l) < r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<(string_key const &l,std::string const &r) | | inline bool operator<(string_key const &l,std::string const &r) | |
| { | | { | |
| return l<string_key::unowned(r); | | return l<string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator<(std::string const &l,string_key const &r) | | inline bool operator<(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) < r; | | return string_key::unowned(l) < r; | |
| } | | } | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>(string_key const &l,char const *r) | | inline bool operator>(string_key const &l,char const *r) | |
| { | | { | |
| return l>string_key::unowned(r); | | return l>string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>(char const *l,string_key const &r) | | inline bool operator>(char const *l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) > r; | | return string_key::unowned(l) > r; | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>(string_key const &l,std::string const &r) | | inline bool operator>(string_key const &l,std::string const &r) | |
| { | | { | |
| return l>string_key::unowned(r); | | return l>string_key::unowned(r); | |
| } | | } | |
| | | | |
|
| | | /// | |
| | | /// Compare two strings | |
| | | /// | |
| inline bool operator>(std::string const &l,string_key const &r) | | inline bool operator>(std::string const &l,string_key const &r) | |
| { | | { | |
| return string_key::unowned(l) > r; | | return string_key::unowned(l) > r; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 54 change blocks. |
| 2 lines changed or deleted | | 189 lines changed or added | |
|