cfgfile 0.2.11
Loading...
Searching...
No Matches
constraint_one_of.hpp
Go to the documentation of this file.
1
31#ifndef CFGFILE__CONSTRAINT_ONE_OF_HPP__INCLUDED
32#define CFGFILE__CONSTRAINT_ONE_OF_HPP__INCLUDED
33
34// cfgfile include.
35#include "constraint.hpp"
36
37// C++ include.
38#include <set>
39
40
41namespace cfgfile {
42
43//
44// constraint_one_of_t
45//
46
48template< class T >
50 : public constraint_t< T >
51{
52public:
57
61
63 void
64 add_value( const T & value )
65 {
66 m_list.insert( value );
67 }
68
70 void
71 remove_value( const T & value )
72 {
73 m_list.erase( value );
74 }
75
83 bool check( const T & value ) const override
84 {
85 return ( m_list.find( value ) != m_list.cend() );
86 }
87
88private:
90 std::set< T > m_list;
91}; // class constraint_one_of_t
92
93} /* namespace cfgfile */
94
95#endif // CFGFILE__CONSTRAINT_ONE_OF_HPP__INCLUDED
Constraint that allowed values to be in the given list of values.
Definition constraint_one_of.hpp:51
~constraint_one_of_t()
Definition constraint_one_of.hpp:58
bool check(const T &value) const override
Check value for correctness.
Definition constraint_one_of.hpp:83
void add_value(const T &value)
Add value to the list of values of the constraint.
Definition constraint_one_of.hpp:64
void remove_value(const T &value)
Add value to the list of values of the constraint.
Definition constraint_one_of.hpp:71
constraint_one_of_t()
Construct constraint.
Definition constraint_one_of.hpp:54
Base class for constraints.
Definition constraint.hpp:43
Definition const.hpp:38