Wolframe, 0.0.3

configSerialize.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 #ifndef _Wolframe_SERIALIZE_CONFIG_SERIALIZE_HPP_INCLUDED
35 #define _Wolframe_SERIALIZE_CONFIG_SERIALIZE_HPP_INCLUDED
36 #include "filter/ptreefilter.hpp"
37 #include "filter/typedfilter.hpp"
41 #include "types/variantStruct.hpp"
42 #include "types/propertyTree.hpp"
44 
45 namespace _Wolframe {
46 namespace serialize {
47 
49 
50 template <class Structure>
51 void parseConfigStructure( Structure& st, const config::ConfigurationNode& pt)
52 {
53  parseConfigStructureVP( (void*)&st, st.getStructDescription(), pt);
54 }
55 
56 template <class Structure>
58 {
61  serialize::StructSerializer serializer( (const void*)&st, st.getStructDescription());
62  serializer.init( out);
63  if (!serializer.call()) throw std::runtime_error( "illegal state in structure serializer");
64  return res->content();
65 }
66 
67 std::string structureToStringVP( const void* stptr, const serialize::StructDescriptionBase* descr);
68 
69 template <class Structure>
70 std::string structureToString( const Structure& st)
71 {
72  return structureToStringVP( (const void*)&st, st.getStructDescription());
73 }
74 
75 }}//namespace
76 #endif
void parseConfigStructure(Structure &st, const config::ConfigurationNode &pt)
Definition: configSerialize.hpp:51
Serialization interface.
Property tree node.
Definition: propertyTree.hpp:86
Base class for structure description used for introspection in serialization/deserialization.
Definition: structDescriptionBase.hpp:51
std::string structureToStringVP(const void *stptr, const serialize::StructDescriptionBase *descr)
Filter for serialization/deserialization of a property tree.
types::PropertyTree::Node structureToPropertyTree(const Structure &st)
Definition: configSerialize.hpp:57
void parseConfigStructureVP(void *stptr, const serialize::StructDescriptionBase *descr, const config::ConfigurationNode &pt)
void init(const langbind::TypedOutputFilterR &out, serialize::Flags::Enum flags=serialize::Flags::None)
Serialize start initialization.
const types::PropertyTree::Node & content() const
Get the content.
Definition: ptreefilter.hpp:124
std::string structureToString(const Structure &st)
Definition: configSerialize.hpp:70
boost::shared_ptr< TypedOutputFilter > TypedOutputFilterR
Shared output filter (langbind::TypedOutputFilter) reference.
Definition: typedfilter.hpp:149
Deserialization interface.
Iterator on elements of structures based on a structure description.
Definition: structSerializer.hpp:43
Interface to a key value tree based on boost::property_tree::ptree with position info for better erro...
Output filter for serializing a structure as property tree.
Definition: ptreefilter.hpp:107
Structures of variant types.
Typed interface for input/output filter.
Configuration tree for the configuration parser.
Description of structures of variant types.