Wolframe, 0.0.3

mapContext.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_MAPCONTEXT_HPP_INCLUDED
36 #define _Wolframe_SERIALIZE_MAPCONTEXT_HPP_INCLUDED
37 #include <string>
38 #include "filter/typedfilter.hpp"
39 #include "serialize/flags.hpp"
40 
41 namespace _Wolframe {
42 namespace serialize {
43 
46 class Context
47 {
48 public:
52  {
55 
57  :m_type(langbind::FilterBase::Value)
58  {}
60  :m_type(o.m_type)
61  ,m_value(o.m_value)
62  {}
63  };
64 
66  Context( const Context& o);
68 
69  void clear();
70 
71  bool flag( Flags::Enum f) const {return ((int)f & (int)m_flags) == (int)f;}
72  void setFlags( Flags::Enum f) {int ff=(int)m_flags | (int)f; m_flags=(Flags::Enum)ff;}
73  void unsetFlags( Flags::Enum f) {int ff=(int)m_flags - ((int)m_flags & (int)f); m_flags=(Flags::Enum)ff;}
74 
75  void setElem( const ElementBuffer& e)
76  {
77  m_elem = e;
78  m_has_elem = true;
79  }
80 
82  {
83  m_elem.m_type = t;
85  m_has_elem = true;
86  }
87 
89  {
90  m_elem.m_type = t;
91  m_elem.m_value = v;
92  m_has_elem = true;
93  }
94 
95  template <typename VALTYPE>
96  void setElem_( langbind::FilterBase::ElementType t, const VALTYPE& val)
97  {
98  setElem( t, types::VariantConst( val));
99  }
100 
102  {
103  if (m_has_elem)
104  {
105  m_has_elem = false;
106  return &m_elem;
107  }
108  return 0;
109  }
110 
112  {
113  m_has_elem = true;
114  }
115 
116 private:
120 };
121 
122 
123 }}
124 #endif
125 
void setElementUnconsumed()
Definition: mapContext.hpp:111
bool flag(Flags::Enum f) const
Definition: mapContext.hpp:71
ElementBuffer m_elem
Definition: mapContext.hpp:118
void setElem_(langbind::FilterBase::ElementType t, const VALTYPE &val)
Definition: mapContext.hpp:96
langbind::FilterBase::ElementType m_type
Definition: mapContext.hpp:53
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
Buffer for one element fetched.
Definition: mapContext.hpp:51
bool m_has_elem
Definition: mapContext.hpp:119
ElementBuffer(const ElementBuffer &o)
Definition: mapContext.hpp:59
Flags::Enum m_flags
Definition: mapContext.hpp:117
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
types::VariantConst m_value
Definition: mapContext.hpp:54
Enum
the enumeration that can also be interpreted as bit set
Definition: flags.hpp:47
void init(const char *o, std::size_t len)
Initialization as string constant.
Definition: variant.hpp:332
void unsetFlags(Flags::Enum f)
Definition: mapContext.hpp:73
void setFlags(Flags::Enum f)
Definition: mapContext.hpp:72
Defines the flags for serialization behaviour.
ElementBuffer()
Definition: mapContext.hpp:56
void setElem(langbind::FilterBase::ElementType t, const types::VariantConst &v)
Definition: mapContext.hpp:88
const ElementBuffer * getElem()
Definition: mapContext.hpp:101
Empty flag set (no flags set)
Definition: flags.hpp:49
Context(Flags::Enum f=Flags::None)
Typed interface for input/output filter.
void setElem(langbind::FilterBase::ElementType t)
Definition: mapContext.hpp:81
Global state variables of a running serialization/deserialization procedure (without the stack) ...
Definition: mapContext.hpp:46
~Context()
Definition: mapContext.hpp:67
void setElem(const ElementBuffer &e)
Definition: mapContext.hpp:75