Wolframe, 0.0.3

form.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_FORM_HPP_INCLUDED
36 #define _Wolframe_TYPES_FORM_HPP_INCLUDED
37 #include "types/variantStruct.hpp"
39 #include "types/docmetadata.hpp"
40 #include <string>
41 #include <cstddef>
42 #include <stdexcept>
43 #include <iostream>
44 #include <sstream>
45 #include <boost/shared_ptr.hpp>
46 
47 namespace _Wolframe {
48 namespace utils {
50  struct PrintFormat;
51 }
52 namespace types {
53 
58 {
59 public:
63  virtual ~FormDescription(){}
64 
66  FormDescription( const std::string& ddlname_, const std::string& name_, const types::DocMetaData& metadata_)
67  :m_name(name_)
68  ,m_ddlname(ddlname_)
69  ,m_metadata(metadata_){}
70  explicit FormDescription( const std::string& ddlname_)
71  :m_ddlname(ddlname_)
72  {}
75  :types::VariantStructDescription(o)
76  ,m_name(o.m_name)
79 
83  {
84  types::VariantStructDescription::operator=( o);
85  m_name = o.m_name;
86  m_ddlname = o.m_ddlname;
88  return *this;
89  }
90 
92  const char* attribute( const std::string& name_) const
93  {
94  return m_metadata.getAttribute( name_);
95  }
96 
98  const std::string& name() const
99  {
100  return m_name;
101  }
102 
104  const std::string& ddlname() const
105  {
106  return m_ddlname;
107  }
108 
109  void print( std::ostream& out, const utils::PrintFormat* pformat, size_t level=0) const;
110 
112  std::string tostring( const utils::PrintFormat* pformat=0) const;
113 
115  {
116  return m_metadata;
117  }
118 
119 private:
120  std::string m_name;
121  std::string m_ddlname;
123 };
124 
125 typedef boost::shared_ptr<FormDescription> FormDescriptionR;
126 
127 
130 class Form
131  :public types::VariantStruct
132 {
133 public:
136  :m_description(0){}
138  explicit Form( const FormDescription* description_)
139  :types::VariantStruct(description_)
140  ,m_description(description_){}
142  Form( const Form& o)
143  :types::VariantStruct(o)
145 
147  virtual ~Form(){}
148 
151  Form& operator= ( const Form& o)
152  {
155  return *this;
156  }
157 
159  {
160  return m_description;
161  }
162 
163  void print( std::ostream& out, const utils::PrintFormat* pformat, size_t level=0) const;
164 
166  std::string tostring( const utils::PrintFormat* pformat=0) const;
167 
168 private:
170 };
171 
173 typedef boost::shared_ptr<Form> FormR;
174 
175 }}//namespace
176 #endif
177 
const FormDescription * description() const
Definition: form.hpp:158
Document meta data representation.
Definition: docmetadata.hpp:46
std::string m_ddlname
data definition language name of the form
Definition: form.hpp:121
boost::shared_ptr< Form > FormR
shared ownership reference to form data structure
Definition: form.hpp:173
const char * attribute(const std::string &name_) const
Get the metadata attribute of the form.
Definition: form.hpp:92
FormDescription()
Default constructor.
Definition: form.hpp:61
Description of a variant structure as array of attributes and content elements.
Definition: variantStructDescription.hpp:57
Structure of variant type atoms or substructures.
Definition: variantStruct.hpp:57
std::string tostring(const utils::PrintFormat *pformat=0) const
Gets the form as string.
Structure representing document meta data.
Structure with info for uniform printing for a type of message (log format as compact one liner...
Definition: printFormats.hpp:45
FormDescription & operator=(const FormDescription &o)
Assignement operator.
Definition: form.hpp:82
Form data structure.
Definition: form.hpp:130
FormDescription(const std::string &ddlname_)
Definition: form.hpp:70
virtual ~Form()
Destructor.
Definition: form.hpp:147
std::string tostring() const
Getter with value conversion.
Form(const Form &o)
Copy constructor.
Definition: form.hpp:142
const FormDescription * m_description
Definition: form.hpp:169
const std::string & name() const
Get the name of the form.
Definition: form.hpp:98
Form(const FormDescription *description_)
Constructor.
Definition: form.hpp:138
const char * getAttribute(const std::string &name_) const
Get an attribute identified by name or NULL if not defined.
virtual ~FormDescription()
Destructor.
Definition: form.hpp:63
boost::shared_ptr< FormDescription > FormDescriptionR
Definition: form.hpp:125
const std::string & ddlname() const
Get the data definition language name of the form.
Definition: form.hpp:104
Description of a form structure.
Definition: form.hpp:56
Form & operator=(const Form &o)
Assignement operator.
Definition: form.hpp:151
types::DocMetaData m_metadata
document meta data
Definition: form.hpp:122
FormDescription(const std::string &ddlname_, const std::string &name_, const types::DocMetaData &metadata_)
Constructor.
Definition: form.hpp:66
const types::DocMetaData & metadata() const
Definition: form.hpp:114
std::string m_name
name of the form
Definition: form.hpp:120
void print(std::ostream &out, const utils::PrintFormat *pformat, size_t level=0) const
Form()
Default constructor.
Definition: form.hpp:135
FormDescription(const FormDescription &o)
Copy constructor.
Definition: form.hpp:74
VariantStruct & operator=(const VariantStruct &o)
Assignment operator, keeping the initialization flag of this.
Definition: variantStruct.hpp:99
void print(std::ostream &out, const utils::PrintFormat *pformat, size_t level=0) const
Structures of variant types.
Description of structures of variant types.