30 #ifndef __CLAW_CONFIGURATION_FILE_HPP__
31 #define __CLAW_CONFIGURATION_FILE_HPP__
59 std::string
make_comment(
const std::string& value )
const;
61 (
const std::string& key,
const std::string& value )
const;
78 typedef std::multimap<std::string, std::string> section_content;
81 typedef std::map<std::string, section_content> file_content;
84 typedef section_content* section_content_ptr;
89 <
const file_content::key_type,
90 file_content::const_iterator,
96 <
const section_content::key_type,
97 section_content::const_iterator,
108 typedef section_content::const_iterator wrapped_iterator_type;
111 typedef std::string value_type;
112 typedef const value_type& reference;
113 typedef const value_type* pointer;
114 typedef wrapped_iterator_type::difference_type difference_type;
116 typedef wrapped_iterator_type::iterator_category iterator_category;
124 return m_iterator == that.m_iterator;
129 return m_iterator != that.m_iterator;
158 reference operator*()
const
160 return m_iterator->second;
163 pointer operator->()
const
165 return &m_iterator->second;
170 wrapped_iterator_type m_iterator;
185 operator()(
const std::string& section,
const std::string& field )
const;
187 const std::string&
operator()(
const std::string& field )
const;
190 (
const std::string& section,
const std::string& field )
const;
191 bool has_field(
const std::string& field )
const;
194 (
const std::string& section,
const std::string& field,
195 const std::string& val );
196 void set_value(
const std::string& field,
const std::string& val );
199 (
const std::string& section,
const std::string& field,
200 const std::string& val );
201 void add_value(
const std::string& field,
const std::string& val );
206 field_begin(
const std::string& section,
const std::string& field )
const;
208 field_end(
const std::string& section,
const std::string& field )
const;
224 std::string& line )
const;
227 section_content_ptr& section );
230 std::string& line )
const;
235 void save_section_content
236 (
const section_content& c, std::ostream& os,
241 section_content m_noname_section;
244 file_content m_sections;
247 static const std::string s_unknow_field_value;
252 #endif // __CLAW_CONFIGURATION_FILE_HPP__
std::string make_section_name(const std::string &name) const
Create a section name from a string.
std::string make_assignment(const std::string &key, const std::string &value) const
Make an assignment of a value to a key.
std::pair< char, char > paired_symbol
Two symbols making a pair (like () or []).
const_field_iterator field_end(const std::string §ion, const std::string &field) const
Get an iterator past the last value set for a field.
const_file_iterator file_begin() const
Get an iterator on the first named section.
std::string make_comment(const std::string &value) const
Create a comment from a string.
char assignment
Symbol used to assign a value to a field.
This class defines an iterator resulting of the appliance of a function to an effective iterator...
Fuction object to get the first element of a std::pair.
A class to get the content of a configuration file.
bool has_field(const std::string §ion, const std::string &field) const
Tell if a field exists.
Base class for wrapped iterators.
syntax_description()
Default constructor.
const_file_iterator file_end() const
Get an iterator just past the last named section.
claw::wrapped_iterator< const section_content::key_type, section_content::const_iterator, const_pair_first< section_content::value_type > >::iterator_type const_section_iterator
Iterator on the fields of a section.
const_section_iterator section_end() const
Get an iterator past the last field name of a section.
const_field_iterator field_begin(const std::string §ion, const std::string &field) const
Get an iterator on the first value set for a field.
const_section_iterator section_begin() const
Get an iterator on the field names of a section.
paired_symbol section_name
Pair of symbols around a section name.
bool open(std::istream &is, const syntax_description &syntax=syntax_description())
Read the configuration from a stream.
void add_value(const std::string §ion, const std::string &field, const std::string &val)
Add a value to a field.
void save(std::ostream &os, const syntax_description &syntax=syntax_description())
Write the configuration in a stream.
void clear_section(const std::string §ion)
Remove a section and its fields.
configuration_file()
Default constructor.
Some special kind of iterators. As an example: iterator on the keys of a map.
This class tells us how to parse the input file.
void set_value(const std::string §ion, const std::string &field, const std::string &val)
Set the value of a field.
const std::string & operator()(const std::string §ion, const std::string &field) const
Get the value of a field.
char comment
Symbol used to comment the rest of the line.
This class is an iterator on the values set for a same field name.
claw::wrapped_iterator< const file_content::key_type, file_content::const_iterator, const_pair_first< file_content::value_type > >::iterator_type const_file_iterator
Iterator on the name of the sections.
Some function object classes.