31#ifndef CFGFILE__TAG_HPP__INCLUDED
32#define CFGFILE__TAG_HPP__INCLUDED
34#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
36#include <QDomDocument>
57template<
typename Trait =
string_trait_t >
66 explicit tag_t(
const typename Trait::string_t &
name,
70 , m_is_defined(
false )
73 , m_column_number( -1 )
82 , m_is_defined(
false )
85 , m_column_number( -1 )
87 owner.add_child( *
this );
97 if( std::find_if( m_child_tags.cbegin(), m_child_tags.cend(),
100 return ( tag.name() == t->name() );
101 } ) != m_child_tags.cend() )
104 Trait::from_ascii(
"Tag with name \"" ) +
106 Trait::from_ascii(
"\" already exists in parent tag \"" ) +
108 Trait::from_ascii(
"\"." ) );
111 if( std::find( m_child_tags.cbegin(), m_child_tags.cend(), &
tag ) ==
112 m_child_tags.cend() )
114 m_child_tags.push_back( &
tag );
116 tag.set_parent(
this );
123 auto it = std::find( m_child_tags.cbegin(), m_child_tags.cend(), &
tag );
125 if(
it != m_child_tags.cend() )
127 m_child_tags.erase(
it );
129 tag.set_parent(
nullptr );
140 const typename Trait::string_t &
name()
const
148 return m_is_mandatory;
156 if(
tag->is_mandatory() && !
tag->is_defined() )
172 return m_line_number;
178 return m_column_number;
188 virtual typename Trait::string_t
print(
int indent = 0 )
const = 0;
190#if defined( CFGFILE_QT_SUPPORT ) && defined( CFGFILE_XML_SUPPORT )
199 m_line_number =
info.line_number();
200 m_column_number =
info.column_number();
208 const typename Trait::string_t &
str ) = 0;
222 return std::any_of( m_child_tags.cbegin(), m_child_tags.cend(),
236 typename Trait::string_t m_name;
246 typename Trait::pos_t m_line_number;
248 typename Trait::pos_t m_column_number;
Exception in the library.
Definition exceptions.hpp:51
Parser of the configuration file.
Definition parser.hpp:520
Base class for the tags in the configuration file.
Definition tag.hpp:58
bool is_defined_member_value() const
Definition tag.hpp:227
tag_t(tag_t< Trait > &owner, const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag.hpp:78
void add_child(tag_t< Trait > &tag)
Add child tag.
Definition tag.hpp:95
void set_defined(bool on=true)
Set "defined" property.
Definition tag.hpp:164
virtual void on_string(const parser_info_t< Trait > &info, const typename Trait::string_t &str)=0
Called when string found.
Trait::pos_t column_number() const
Definition tag.hpp:176
bool is_mandatory() const
Definition tag.hpp:146
virtual ~tag_t()
Definition tag.hpp:90
void remove_child(tag_t< Trait > &tag)
Remove child tag.
Definition tag.hpp:121
virtual void on_start(const parser_info_t< Trait > &info)
Called when tag parsing started.
Definition tag.hpp:197
tag_t(const typename Trait::string_t &name, bool is_mandatory=false)
Construct tag.
Definition tag.hpp:66
bool is_any_child_defined() const
Definition tag.hpp:220
Trait::pos_t line_number() const
Definition tag.hpp:170
bool is_defined() const
Definition tag.hpp:152
const tag_t< Trait > * parent() const
Definition tag.hpp:134
std::vector< tag_t< Trait > * > child_tags_list_t
List with children.
Definition tag.hpp:63
virtual const child_tags_list_t & children() const
Definition tag.hpp:182
const Trait::string_t & name() const
Definition tag.hpp:140
virtual void on_finish(const parser_info_t< Trait > &info)=0
Called when tag parsing finished.
virtual Trait::string_t print(int indent=0) const =0
Print tag to the output.
virtual void print(QDomDocument &doc, QDomElement *parent=0) const =0
Print tag to the output.
void set_parent(const tag_t< Trait > *p)
Set parent tag.
Definition tag.hpp:214
#define DISABLE_COPY(Class)
Macro for disabling copy.
Definition types.hpp:580