Wolframe, 0.0.3

parseStack.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_STRUCT_PARSE_STACK_HPP_INCLUDED
36 #define _Wolframe_SERIALIZE_STRUCT_PARSE_STACK_HPP_INCLUDED
37 #include "filter/typedfilter.hpp"
38 #include "types/variant.hpp"
39 #include "serialize/mapContext.hpp"
40 #include <vector>
41 #include <stdexcept>
42 
43 namespace _Wolframe {
44 namespace serialize {
45 
47 class ParseStateStack;
48 
52 {
53 public:
54  typedef bool (*Parse)( langbind::TypedInputFilter& inp, Context& ctx, ParseStateStack& stk);
55 
56 public:
57  ParseState( const ParseState& o);
58  ParseState( const char* name_, Parse p, void* v);
59  ~ParseState();
60 
61  std::size_t selectElement( std::size_t idx, std::size_t size);
62  std::size_t initCount( std::size_t idx) const;
63 
64  void* value() const {return m_value;}
65  const char* name() const {return m_name;}
66  Parse parse() const {return m_parse;}
67  std::size_t state() const {return m_stateidx;}
68  void state( std::size_t idx) {m_stateidx = idx;}
69 private:
71  int* m_initar;
72  std::size_t m_size;
73  void* m_value;
74  const char* m_name;
75  std::size_t m_stateidx;
76 };
77 
80 class ParseStateStack :public std::vector<ParseState>
81 {
82 public:
85  :std::vector<ParseState>(o)
87 
88  bool hasbufvalue() const {return m_valuebuf.initialized();}
91  const types::VariantConst& valuebuf() const {return m_valuebuf;}
92 
93 private:
95 };
96 
97 }}//namespace
98 #endif
99 
ParseStateStack(const ParseStateStack &o)
Definition: parseStack.hpp:84
State stack for an initializer of a structure.
Definition: parseStack.hpp:80
void clear()
Reseting the content of this.
Definition: variant.hpp:343
std::size_t selectElement(std::size_t idx, std::size_t size)
bool(* Parse)(langbind::TypedInputFilter &inp, Context &ctx, ParseStateStack &stk)
Definition: parseStack.hpp:54
types::VariantConst m_valuebuf
Definition: parseStack.hpp:94
const types::VariantConst & valuebuf() const
Definition: parseStack.hpp:91
void bufvalue(const types::VariantConst &e)
Definition: parseStack.hpp:89
bool initialized() const
Test if this value is initialized.
Definition: variant.hpp:222
void * m_value
Definition: parseStack.hpp:73
std::size_t m_stateidx
Definition: parseStack.hpp:75
std::size_t m_size
Definition: parseStack.hpp:72
void clearbuf()
Definition: parseStack.hpp:90
std::size_t state() const
Definition: parseStack.hpp:67
const char * m_name
Definition: parseStack.hpp:74
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
Variant value type.
const char * name() const
Definition: parseStack.hpp:65
State stack element for an initializer of a structure.
Definition: parseStack.hpp:51
std::size_t initCount(std::size_t idx) const
Parse m_parse
Definition: parseStack.hpp:70
Defines the data structure holding the global serialization state variables (without the stack) ...
bool hasbufvalue() const
Definition: parseStack.hpp:88
ParseStateStack()
Definition: parseStack.hpp:83
ParseState(const ParseState &o)
void state(std::size_t idx)
Definition: parseStack.hpp:68
int * m_initar
Definition: parseStack.hpp:71
Typed interface for input/output filter.
Global state variables of a running serialization/deserialization procedure (without the stack) ...
Definition: mapContext.hpp:46
void * value() const
Definition: parseStack.hpp:64
void setInitialized(bool v=true)
Set the value to be initialized.
Definition: variant.hpp:224
Input filter with atomic values having a type.
Definition: typedfilter.hpp:48
Parse parse() const
Definition: parseStack.hpp:66