31#ifndef CFGFILE__TAG_SCALAR_HPP__INCLUDED
32#define CFGFILE__TAG_SCALAR_HPP__INCLUDED
42#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
44#include <QDomDocument>
57template<
class T,
class Trait =
string_trait_t >
59 :
public tag_t< Trait >
97 if( !m_constraint->check(
v ) )
99 Trait::from_ascii(
"Invalid value: \"" ) +
100 typename Trait::string_t(
102 Trait::from_ascii(
"\". Value must match to "
103 "the constraint in tag \"" ) +
104 this->
name() + Trait::from_ascii(
"\"." ) );
136 typename Trait::string_t
result;
140 result.append(
typename Trait::string_t(
indent,
147 typename Trait::string_t
value =
158 result.append(
tag->print(
indent + 1 ) );
171#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
205 Trait::from_ascii(
"Undefined value of tag: \"" ) +
206 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
208 Trait::from_ascii(
"\" on line " ) +
209 Trait::to_string(
info.line_number() ) +
210 Trait::from_ascii(
"." ) );
214 if(
tag->is_mandatory() && !
tag->is_defined() )
216 Trait::from_ascii(
"Undefined child mandatory tag: \"" ) +
217 tag->name() + Trait::from_ascii(
"\". Where parent is: \"" ) +
218 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
220 Trait::from_ascii(
"\" on line " ) +
221 Trait::to_string(
info.line_number() ) +
222 Trait::from_ascii(
"." ) );
228 const typename Trait::string_t &
str )
override
234 Trait::from_ascii(
"Value \"" ) +
str +
235 Trait::from_ascii(
"\" for tag \"" ) + this->
name() +
236 Trait::from_ascii(
"\" must be defined before any "
237 "child tag. In file \"" ) +
238 info.file_name() + Trait::from_ascii(
"\" on line " ) +
239 Trait::to_string(
info.line_number() ) +
240 Trait::from_ascii(
"." ) );
246 if( !m_constraint->check(
value ) )
248 Trait::from_ascii(
"Invalid value: \"" ) +
250 Trait::from_ascii(
"\". Value must match to the "
251 "constraint in tag \"" ) +
252 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
254 Trait::from_ascii(
"\" on line " ) +
255 Trait::to_string(
info.line_number() ) +
256 Trait::from_ascii(
"." ) );
265 Trait::from_ascii(
"Value for the tag \"" ) +
267 Trait::from_ascii(
"\" already defined. In file \"" ) +
268 info.file_name() + Trait::from_ascii(
"\" on line " ) +
269 Trait::to_string(
info.line_number() ) +
270 Trait::from_ascii(
"." ) );
286template<
typename Trait >
288 :
public tag_t< Trait >
344 typename Trait::string_t
result;
348 result.append(
typename Trait::string_t(
indent,
355 typename Trait::string_t
value =
366 result.append(
tag->print(
indent + 1 ) );
379#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
392 typename Trait::string_t
value =
414 Trait::from_ascii(
"Undefined value of tag: \"" ) +
415 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
417 Trait::from_ascii(
"\" on line " ) +
418 Trait::to_string(
info.line_number() ) +
419 Trait::from_ascii(
"." ) );
423 if(
tag->is_mandatory() && !
tag->is_defined() )
425 Trait::from_ascii(
"Undefined child mandatory tag: \"" ) +
427 Trait::from_ascii(
"\". Where parent is: \"" ) +
428 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
430 Trait::from_ascii(
"\" on line " ) +
431 Trait::to_string(
info.line_number() ) +
432 Trait::from_ascii(
"." ) );
438 const typename Trait::string_t &
str )
override
444 Trait::from_ascii(
"Value \"" ) +
str +
445 Trait::from_ascii(
"\" for tag \"" ) + this->
name() +
446 Trait::from_ascii(
"\" must be defined before any child "
447 "tag. In file \"" ) +
448 info.file_name() + Trait::from_ascii(
"\" on line " ) +
449 Trait::to_string(
info.line_number() ) +
450 Trait::from_ascii(
"." ) );
458 Trait::from_ascii(
"Value for the tag \"" ) +
460 Trait::from_ascii(
"\" already defined. In file \"" ) +
461 info.file_name() + Trait::from_ascii(
"\" on line " ) +
462 Trait::to_string(
info.line_number() ) +
463 Trait::from_ascii(
"." ) );
477template<
typename Trait >
479 :
public tag_t< Trait >
481 static const typename Trait::pos_t c_max_string_length = 80;
507 const typename Trait::string_t &
519 if( !m_constraint->check(
v ) )
521 Trait::from_ascii(
"Invalid value: \"" ) +
523 Trait::from_ascii(
"\". Value must match to the "
524 "constraint in tag \"" ) +
525 this->
name() + Trait::from_ascii(
"\"." ) );
557 typename Trait::string_t
result;
561 result.append(
typename Trait::string_t(
indent,
568 typename Trait::string_t
value =
571 const typename Trait::pos_t
sections =
572 (
value.length() / c_max_string_length +
573 (
value.length() % c_max_string_length > 0 ? 1 : 0 ) );
577 const typename Trait::string_t
spaces =
578 typename Trait::string_t( this->
name().length() + 2,
581 for(
typename Trait::pos_t
i = 0;
i <
sections; ++
i )
593 const typename Trait::string_t
tmp =
595 value.substr(
i * c_max_string_length,
596 c_max_string_length ) );
612 result.append(
tag->print(
indent + 1 ) );
625#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
638 typename Trait::string_t
value =
660 Trait::from_ascii(
"Undefined value of tag: \"" ) +
661 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
662 info.file_name() + Trait::from_ascii(
"\" on line " ) +
663 Trait::to_string(
info.line_number() ) +
664 Trait::from_ascii(
"." ) );
668 if( !m_constraint->check( m_value ) )
670 Trait::from_ascii(
"Invalid value: \"" ) +
672 Trait::from_ascii(
"\". Value must match to the "
673 "constraint in tag \"" ) +
674 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
675 info.file_name() + Trait::from_ascii(
"\" on line " ) +
676 Trait::to_string(
info.line_number() ) +
677 Trait::from_ascii(
"." ) );
682 if(
tag->is_mandatory() && !
tag->is_defined() )
684 Trait::from_ascii(
"Undefined child mandatory tag: \"" ) +
686 Trait::from_ascii(
"\". Where parent is: \"" ) +
687 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
688 info.file_name() + Trait::from_ascii(
"\" on line " ) +
689 Trait::to_string(
info.line_number() ) +
690 Trait::from_ascii(
"." ) );
696 const typename Trait::string_t &
str )
override
700 Trait::from_ascii(
"Value \"" ) +
str +
701 Trait::from_ascii(
"\" for tag \"" ) + this->
name() +
702 Trait::from_ascii(
"\" must be defined before any child "
703 "tag. In file \"" ) +
704 info.file_name() + Trait::from_ascii(
"\" on line " ) +
705 Trait::to_string(
info.line_number() ) +
706 Trait::from_ascii(
"." ) );
708 const typename Trait::string_t
value =
711 m_value.append(
value );
718 typename Trait::string_t m_value;
724#ifdef CFGFILE_QT_SUPPORT
731template<
typename Trait >
733 :
public tag_t< Trait >
735 static const typename Trait::pos_t c_max_string_length = 80;
773 if( !m_constraint->check(
v ) )
775 Trait::from_ascii(
"Invalid value: \"" ) +
776 typename Trait::string_t(
778 Trait::from_ascii(
"\". Value must match to the constraint "
780 this->
name() + Trait::from_ascii(
"\"." ) );
812 typename Trait::string_t
result;
816 result.append(
typename Trait::string_t(
indent,
825 const typename Trait::pos_t
sections =
826 (
value.length() / c_max_string_length +
827 (
value.length() % c_max_string_length > 0 ? 1 : 0 ) );
831 const typename Trait::string_t
spaces =
typename Trait::string_t(
834 for(
typename Trait::pos_t
i = 0;
i <
sections; ++
i )
846 const typename Trait::string_t
tmp =
848 value.mid(
i * c_max_string_length,
849 c_max_string_length ) );
865 result.append(
tag->print(
indent + 1 ) );
878#ifdef CFGFILE_XML_SUPPORT
891 typename Trait::string_t
value =
913 if( !m_constraint->check( m_value ) )
915 Trait::from_ascii(
"Invalid value: \"" ) +
916 typename Trait::string_t( m_value ) +
917 Trait::from_ascii(
"\". Value must match to the "
918 "constraint in tag \"" ) +
919 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
920 info.file_name() + Trait::from_ascii(
"\" on line " ) +
921 Trait::to_string(
info.line_number() ) +
922 Trait::from_ascii(
"." ) );
927 Trait::from_ascii(
"Undefined value of tag: \"" ) +
928 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
929 info.file_name() + Trait::from_ascii(
"\" on line " ) +
930 Trait::to_string(
info.line_number() ) +
931 Trait::from_ascii(
"." ) );
935 if(
tag->is_mandatory() && !
tag->is_defined() )
937 Trait::from_ascii(
"Undefined child mandatory tag: \"" ) +
938 tag->name() + Trait::from_ascii(
"\". Where parent is: \"" ) +
939 this->
name() + Trait::from_ascii(
"\". In file \"" ) +
940 info.file_name() + Trait::from_ascii(
"\" on line " ) +
941 Trait::to_string(
info.line_number() ) +
942 Trait::from_ascii(
"." ) );
948 const typename Trait::string_t &
str )
override
952 Trait::from_ascii(
"Value \"" ) +
str +
953 Trait::from_ascii(
"\" for tag \"" ) + this->
name() +
954 Trait::from_ascii(
"\" must be defined before any "
955 "child tag. In file \"" ) +
956 info.file_name() + Trait::from_ascii(
"\" on line " ) +
957 Trait::to_string(
info.line_number() ) +
958 Trait::from_ascii(
"." ) );
962 m_value.append(
value );
Exception in the library.
Definition exceptions.hpp:51
Trait::string_t print(int indent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:810
tag_scalar_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:739
void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str) override
Called when string found.
Definition tag_scalar.hpp:947
void print(QDomDocument &doc, QDomElement *parent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:880
void query_opt_value(QString &receiver)
Query optional value.
Definition tag_scalar.hpp:796
~tag_scalar_t()
Definition tag_scalar.hpp:756
void on_finish(const parser_info_t< Trait > &info) override
Called when tag parsing finished.
Definition tag_scalar.hpp:909
const QString & value() const
Definition tag_scalar.hpp:762
void set_value(const QString &v)
Set value.
Definition tag_scalar.hpp:769
tag_scalar_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:748
void set_constraint(constraint_t< QString > *c)
Set constraint for the tag's value.
Definition tag_scalar.hpp:804
Trait::string_t print(int indent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:342
tag_scalar_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:292
void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str) override
Called when string found.
Definition tag_scalar.hpp:437
~tag_scalar_t()
Definition tag_scalar.hpp:307
tag_scalar_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:300
void on_finish(const parser_info_t< Trait > &info) override
Called when tag parsing finished.
Definition tag_scalar.hpp:410
void set_value(const bool &v)
Set value.
Definition tag_scalar.hpp:320
void query_opt_value(bool &receiver)
Query optional value.
Definition tag_scalar.hpp:335
const bool & value() const
Definition tag_scalar.hpp:313
void print(QDomDocument &doc, QDomElement *parent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:381
~tag_scalar_t()
Definition tag_scalar.hpp:502
tag_scalar_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:485
void print(QDomDocument &doc, QDomElement *parent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:627
void set_constraint(constraint_t< typename Trait::string_t > *c)
Set constraint for the tag's value.
Definition tag_scalar.hpp:549
const Trait::string_t & value() const
Definition tag_scalar.hpp:508
void query_opt_value(typename Trait::string_t &receiver)
Query optional value.
Definition tag_scalar.hpp:541
void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str) override
Called when string found.
Definition tag_scalar.hpp:695
tag_scalar_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:494
void on_finish(const parser_info_t< Trait > &info) override
Called when tag parsing finished.
Definition tag_scalar.hpp:656
void set_value(const typename Trait::string_t &v)
Set value.
Definition tag_scalar.hpp:515
Trait::string_t print(int indent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:555
Tag with scalar value.
Definition tag_scalar.hpp:60
tag_scalar_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:72
void on_finish(const parser_info_t< Trait > &info) override
Called when tag parsing finished.
Definition tag_scalar.hpp:201
Trait::string_t print(int indent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:134
void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str) override
Called when string found.
Definition tag_scalar.hpp:227
void query_opt_value(T &receiver)
Query optional value.
Definition tag_scalar.hpp:120
~tag_scalar_t()
Definition tag_scalar.hpp:80
void set_value(const T &v)
Set value.
Definition tag_scalar.hpp:93
void set_constraint(constraint_t< T > *c)
Set constraint for the tag's value.
Definition tag_scalar.hpp:128
void print(QDomDocument &doc, QDomElement *parent=0) const override
Print tag to the output.
Definition tag_scalar.hpp:173
const T & value() const
Definition tag_scalar.hpp:86
tag_scalar_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag_scalar.hpp:63
Base class for the tags in the configuration file.
Definition tag.hpp:58
bool is_defined_member_value() const
Definition tag.hpp:227
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