Wolframe, 0.0.3

ddlSerializeStack.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_SERIALIZE_DDL_SERIALIZE_STACK_HPP_INCLUDED
36 #define _Wolframe_SERIALIZE_DDL_SERIALIZE_STACK_HPP_INCLUDED
37 #include "filter/typedfilter.hpp"
38 #include "types/variant.hpp"
39 #include "types/variantStruct.hpp"
40 #include <vector>
41 #include <cstddef>
42 #include <stdexcept>
43 
44 namespace _Wolframe {
45 namespace serialize {
46 
50 {
51 public:
54  :m_value(o.m_value)
57  ,m_tag(o.m_tag)
58  {}
59 
62  :m_value(v)
63  ,m_stateidx(0)
64  ,m_elemtype(langbind::FilterBase::Value)
65  ,m_tag(t)
66  {
68  }
69 
72  :m_value(v)
73  ,m_stateidx(0)
74  ,m_elemtype(langbind::FilterBase::Value)
75  {}
76 
79  :m_value(0)
80  ,m_stateidx(0)
81  ,m_elemtype(typ)
82  ,m_tag(elem)
83  {
85  }
86 
88  const types::VariantStruct* value() const
89  {
90  return m_value;
91  }
92 
94  std::size_t state() const
95  {
96  return m_stateidx;
97  }
98 
100  void state( std::size_t idx)
101  {
102  m_stateidx = idx;
103  }
104 
107  {
108  return m_elemtype;
109  }
110 
112  const types::VariantConst& tag() const
113  {
114  return m_tag;
115  }
116 
117 private:
119  std::size_t m_stateidx;
122 };
123 
125 typedef std::vector<DDLSerializeState> DDLSerializeStateStack;
126 
127 }}//namespace
128 #endif
const types::VariantConst & tag() const
Get the name of the element visited in the current state.
Definition: ddlSerializeStack.hpp:112
State stack element for an iterator on a DDL structure (serializer of VariantStruct) ...
Definition: ddlSerializeStack.hpp:49
DDLSerializeState(langbind::FilterBase::ElementType typ, const types::VariantConst &elem)
Constructor.
Definition: ddlSerializeStack.hpp:78
Structure of variant type atoms or substructures.
Definition: variantStruct.hpp:57
std::size_t m_stateidx
Definition: ddlSerializeStack.hpp:119
const types::VariantStruct * value() const
Get the value reference of the current state.
Definition: ddlSerializeStack.hpp:88
langbind::FilterBase::ElementType type() const
Set the element type visited in the current state.
Definition: ddlSerializeStack.hpp:106
DDLSerializeState(const types::VariantStruct *v, const types::VariantConst &t)
Constructor.
Definition: ddlSerializeStack.hpp:61
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
Variant value type.
types::VariantConst m_tag
Definition: ddlSerializeStack.hpp:121
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
void state(std::size_t idx)
Set the current internal state.
Definition: ddlSerializeStack.hpp:100
std::size_t state() const
Get the current internal state.
Definition: ddlSerializeStack.hpp:94
const types::VariantStruct * m_value
Definition: ddlSerializeStack.hpp:118
langbind::FilterBase::ElementType m_elemtype
Definition: ddlSerializeStack.hpp:120
DDLSerializeState(const types::VariantStruct *v)
Constructor.
Definition: ddlSerializeStack.hpp:71
std::vector< DDLSerializeState > DDLSerializeStateStack
State stack for an iterator on a DDL structure (serializer of VariantStruct)
Definition: ddlSerializeStack.hpp:125
Structures of variant types.
Typed interface for input/output filter.
void setInitialized(bool v=true)
Set the value to be initialized.
Definition: variant.hpp:224
DDLSerializeState(const DDLSerializeState &o)
Copy constructor.
Definition: ddlSerializeStack.hpp:53