strusAnalyzer  0.17
tokenMarkup.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_ANALYZER_TOKEN_MARKUP_HPP_INCLUDED
11 #define _STRUS_ANALYZER_TOKEN_MARKUP_HPP_INCLUDED
12 #include <vector>
13 #include <string>
14 
16 namespace strus {
18 namespace analyzer {
19 
22 {
23 public:
25  class Attribute
26  {
27  public:
29  Attribute( const std::string& name_, const std::string& value_)
30  :m_name(name_),m_value(value_){}
32 #if __cplusplus >= 201103L
33  Attribute( Attribute&& ) = default;
34  Attribute( const Attribute& ) = default;
35  Attribute& operator= ( Attribute&& ) = default;
36  Attribute& operator= ( const Attribute& ) = default;
37 #else
38  Attribute( const Attribute& o)
39  :m_name(o.m_name),m_value(o.m_value){}
40 #endif
41  const std::string& name() const {return m_name;}
44  const std::string& value() const {return m_value;}
45 
46  private:
47  std::string m_name;
48  std::string m_value;
49  };
50 
53  :m_name(),m_attributes(){}
55  explicit TokenMarkup( const std::string& name_)
56  :m_name(name_),m_attributes(){}
58  TokenMarkup( const std::string& name_, const std::vector<Attribute>& attributes_)
59  :m_name(name_),m_attributes(attributes_){}
61 #if __cplusplus >= 201103L
62  TokenMarkup( TokenMarkup&& ) = default;
63  TokenMarkup( const TokenMarkup& ) = default;
64  TokenMarkup& operator= ( TokenMarkup&& ) = default;
65  TokenMarkup& operator= ( const TokenMarkup& ) = default;
66 #else
68  :m_name(o.m_name),m_attributes(o.m_attributes){}
69 #endif
70 
72  const std::string& name() const {return m_name;}
74  const std::vector<Attribute>& attributes() const {return m_attributes;}
75 
76  TokenMarkup& operator()( const std::string& name_, const std::string& value_)
77  {
78  m_attributes.push_back( Attribute( name_, value_));
79  return *this;
80  }
81 
82 private:
83  std::string m_name;
84  std::vector<Attribute> m_attributes;
85 };
86 
87 }}//namespace
88 #endif
89 
TokenMarkup()
Default constructor.
Definition: tokenMarkup.hpp:52
const std::string & name() const
Get the tag name of the markup attribute.
Definition: tokenMarkup.hpp:42
const std::vector< Attribute > & attributes() const
Get the list of attributes of the markup element.
Definition: tokenMarkup.hpp:74
TokenMarkup & operator()(const std::string &name_, const std::string &value_)
Definition: tokenMarkup.hpp:76
Structure describing a document markup attribute.
Definition: tokenMarkup.hpp:25
const std::string & name() const
Get the tag name of the markup element.
Definition: tokenMarkup.hpp:72
TokenMarkup(const TokenMarkup &o)
Copy constructor.
Definition: tokenMarkup.hpp:67
Attribute(const Attribute &o)
Copy constructor.
Definition: tokenMarkup.hpp:38
TokenMarkup(const std::string &name_, const std::vector< Attribute > &attributes_)
Constructor.
Definition: tokenMarkup.hpp:58
Structure defining an annotation of text in a document.
Definition: tokenMarkup.hpp:21
TokenMarkup(const std::string &name_)
Constructor.
Definition: tokenMarkup.hpp:55
const std::string & value() const
Get the tag value of the markup attribute.
Definition: tokenMarkup.hpp:44
Attribute(const std::string &name_, const std::string &value_)
Constructor.
Definition: tokenMarkup.hpp:29