Wolframe, 0.0.3

docmetadata.hpp
Go to the documentation of this file.
1 /************************************************************************
2 Copyright (C) 2011 - 2014 Project Wolframe.
3 All rights reserved.
4 
5 This file is part of Project Wolframe.
6 
7 Commercial Usage
8 Licensees holding valid Project Wolframe Commercial licenses may
9 use this file in accordance with the Project Wolframe
10 Commercial License Agreement provided with the Software or,
11 alternatively, in accordance with the terms contained
12 in a written agreement between the licensee and Project Wolframe.
13 
14 GNU General Public License Usage
15 Alternatively, you can redistribute this file and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19 
20 Wolframe is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
27 
28 If you have questions regarding the use of this file, please contact
29 Project Wolframe.
30 
31 ************************************************************************/
34 
35 #ifndef _Wolframe_TYPES_DOC_METADATA_HPP_INCLUDED
36 #define _Wolframe_TYPES_DOC_METADATA_HPP_INCLUDED
37 #include <string>
38 #include <vector>
39 #include <boost/shared_ptr.hpp>
40 
41 namespace _Wolframe {
42 namespace types {
43 
47 {
50  struct Attribute
51  {
52  std::string name;
53  std::string value;
54 
58  Attribute( const std::string& n, const std::string& v)
59  :name(n),value(v){}
61  Attribute( const Attribute& o)
62  :name(o.name),value(o.value){}
63  };
64 
66  DocMetaData( const DocMetaData& o);
70  DocMetaData( const std::string& doctype_, const std::vector<Attribute>& attributes_);
72  DocMetaData();
73 
75  void clear();
76 
79  void join( const std::vector<Attribute>& attributes_);
80 
83  void setDoctype( const std::string& doctype_)
84  {
85  m_doctype = doctype_;
86  }
87 
90  void setAttribute( const Attribute& attr);
91 
95  void setAttribute( const std::string& name_, const std::string& value_);
96 
100  void defineAttribute( const std::string& name_, const std::string& value_);
101 
104  bool deleteAttribute( const std::string& name_);
105 
109  const char* getAttribute( const std::string& name_) const;
110 
113  const std::string& doctype() const
114  {
115  return m_doctype;
116  }
119  const std::vector<Attribute>& attributes() const
120  {
121  return m_attributes;
122  }
123 
128  static std::string replaceStem( const std::string& src, const std::string& newstem);
132  static std::string extractStem( const std::string& src);
133 
135  std::string tostring() const;
136 
137 private:
138  std::vector<Attribute> m_attributes;
139  std::string m_doctype;
140 };
141 
143 typedef boost::shared_ptr<DocMetaData> DocMetaDataR;
144 
145 }}//namespace
146 #endif
147 
148 
std::vector< Attribute > m_attributes
meta data attributes
Definition: docmetadata.hpp:138
Document meta data representation.
Definition: docmetadata.hpp:46
std::string name
name of the attribute
Definition: docmetadata.hpp:52
void defineAttribute(const std::string &name_, const std::string &value_)
Define a unique attribute and throw if attribute with this name is already defined.
DocMetaData()
Default constructor.
void setAttribute(const Attribute &attr)
Set a unique attribute by name (add or redefine)
static std::string extractStem(const std::string &src)
Extract the value between the last '/' or start of the string and the last '.' or the end of the stri...
void join(const std::vector< Attribute > &attributes_)
Update or insert all attributes passed.
std::string m_doctype
document type
Definition: docmetadata.hpp:139
const std::string & doctype() const
Get the document type.
Definition: docmetadata.hpp:113
const char * getAttribute(const std::string &name_) const
Get an attribute identified by name or NULL if not defined.
std::string tostring() const
Get the meta data as string to log.
void setDoctype(const std::string &doctype_)
Set the document type.
Definition: docmetadata.hpp:83
One document meta data attribute.
Definition: docmetadata.hpp:50
const std::vector< Attribute > & attributes() const
Get the meta data attributes.
Definition: docmetadata.hpp:119
boost::shared_ptr< DocMetaData > DocMetaDataR
Shared meta data reference.
Definition: docmetadata.hpp:143
bool deleteAttribute(const std::string &name_)
Delete an attribute identified by name.
void clear()
Clear (reset) content.
static std::string replaceStem(const std::string &src, const std::string &newstem)
Replace the value between the last '/' or start of the string and the last '.' or the end of the stri...
Attribute(const std::string &n, const std::string &v)
Constructor.
Definition: docmetadata.hpp:58
Attribute(const Attribute &o)
Copy constructor.
Definition: docmetadata.hpp:61
Attribute()
Default constructor.
Definition: docmetadata.hpp:56
std::string value
value of the attribute
Definition: docmetadata.hpp:53