31#ifndef CFGFILE__TAG_SCALAR_VECTOR_HPP__INCLUDED
32#define CFGFILE__TAG_SCALAR_VECTOR_HPP__INCLUDED
43#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
45#include <QDomDocument>
61template<
class T,
class Trait =
string_trait_t >
63 :
public tag_t< Trait >
79 const typename Trait::string_t &
name,
91 typename values_vector_t::size_type
94 return m_values.size();
99 at(
typename values_vector_t::size_type index )
const
101 return m_values.at( index );
121 if( !m_constraint->check(
v ) )
123 Trait::from_ascii(
"Invalid value: \"" ) +
124 typename Trait::string_t(
126 Trait::from_ascii(
"\". Value must match to the "
127 "constraint in tag \"" ) +
128 this->
name() + Trait::from_ascii(
"\"." ) );
131 m_values.push_back(
v );
169 typename Trait::string_t
result;
173 result.append(
typename Trait::string_t(
indent,
178 for(
const T &
v : m_values )
182 typename Trait::string_t value =
195 result.append(
tag->print(
indent + 1 ) );
208#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
221 typename values_vector_t::size_type
i = 1;
223 for(
const T &
v : m_values )
225 typename Trait::string_t value =
256 if(
tag->is_mandatory() && !
tag->is_defined() )
258 Trait::from_ascii(
"Undefined child mandatory tag: \"" ) +
260 Trait::from_ascii(
"\". Where parent is: \"" ) +
261 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
262 info.file_name() + Trait::from_ascii(
"\" on line " ) +
263 Trait::to_string(
info.line_number() ) +
264 Trait::from_ascii(
"." ) );
270 const typename Trait::string_t &
str )
override
274 Trait::from_ascii(
"Value \"" ) +
str +
275 Trait::from_ascii(
"\" for tag \"" ) + this->
name() +
276 Trait::from_ascii(
"\" must be defined before any child "
277 "tag. In file \"" ) +
278 info.file_name() + Trait::from_ascii(
"\" on line " ) +
279 Trait::to_string(
info.line_number() ) +
280 Trait::from_ascii(
"." ) );
286 if( !m_constraint->check( value ) )
288 Trait::from_ascii(
"Invalid value: \"" ) +
289 str + Trait::from_ascii(
"\". Value must match to the "
290 "constraint in tag \"" ) +
291 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
292 info.file_name() + Trait::from_ascii(
"\" on line " ) +
293 Trait::to_string(
info.line_number() ) +
294 Trait::from_ascii(
"." ) );
297 m_values.push_back( value );
304 values_vector_t m_values;
Exception in the library.
Definition exceptions.hpp:51
Tag with multiple scalar values.
Definition tag_scalar_vector.hpp:64
void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str) override
Called when string found.
Definition tag_scalar_vector.hpp:269
void set_constraint(constraint_t< T > *c)
Set constraint for the tag's value.
Definition tag_scalar_vector.hpp:161
void on_finish(const parser_info_t< Trait > &info) override
Called when tag parsing finished.
Definition tag_scalar_vector.hpp:252
tag_scalar_vector_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar_vector.hpp:70
void set_value(const T &v)
Set value.
Definition tag_scalar_vector.hpp:117
void print(QDomDocument &doc, QDomElement *parent=0) const override
Print tag to the output.
Definition tag_scalar_vector.hpp:210
void set_values(const values_vector_t &v)
Set values.
Definition tag_scalar_vector.hpp:138
std::vector< T > values_vector_t
Vector of values.
Definition tag_scalar_vector.hpp:67
tag_scalar_vector_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar_vector.hpp:78
void query_opt_values(values_vector_t &receiver)
Query optional values.
Definition tag_scalar_vector.hpp:153
const values_vector_t & values() const
Definition tag_scalar_vector.hpp:106
const T & at(typename values_vector_t::size_type index) const
Definition tag_scalar_vector.hpp:99
~tag_scalar_vector_t()
Definition tag_scalar_vector.hpp:86
values_vector_t::size_type size() const
Definition tag_scalar_vector.hpp:92
Trait::string_t print(int indent=0) const override
Print tag to the output.
Definition tag_scalar_vector.hpp:167
Base class for the tags in the configuration file.
Definition tag.hpp:58
void set_defined(bool on=true)
Set "defined" property.
Definition tag.hpp:164
bool is_mandatory() const
Definition tag.hpp:146
bool is_any_child_defined() const
Definition tag.hpp:220
bool is_defined() const
Definition tag.hpp:152
const tag_t< Trait > * parent() const
Definition tag.hpp:134
virtual const child_tags_list_t & children() const
Definition tag.hpp:182
const Trait::string_t & name() const
Definition tag.hpp:140