nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
serializers
RapidXmlDeserializer.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_SERIALIZERS_RAPIDXML_DESERIALIZER_HPP
30
#define NOMLIB_SERIALIZERS_RAPIDXML_DESERIALIZER_HPP
31
32
#include <iostream>
33
#include <string>
34
#include <fstream>
35
#include <sstream>
36
#include <stdexcept>
37
38
#include "export.hpp"
39
#include "nomlib/config.hpp"
40
#include "nomlib/serializers/serializers_config.hpp"
41
#include "nomlib/serializers/IValueDeserializer.hpp"
42
#include "nomlib/ptree.hpp"
43
44
// Enable dumping output of each key, value pair, sizes, etc. as we traverse
45
// the object.
46
// #define NOM_DEBUG_RAPIDXML_DESERIALIZER_VALUES
47
48
// Forward declarations for third-party libraries used; these allow us to not
49
// worry about including third-party header files in outside-project builds,
50
// such as is the case with TTcards.
51
namespace
rapidxml {
52
53
template
<
class
Ch>
class
xml_node
;
54
template
<
class
Ch>
class
xml_document
;
55
56
}
// namespace rapidxml
57
58
namespace
nom {
59
62
class
NOM_EXPORT
RapidXmlDeserializer
:
public
IValueDeserializer
63
{
64
public
:
65
typedef
RapidXmlDeserializer
SelfType;
66
71
RapidXmlDeserializer
(
void
);
72
74
~RapidXmlDeserializer
(
void
);
75
79
RapidXmlDeserializer
( uint32 options );
80
89
Value
deserialize
(
const
std::string& source );
90
97
bool
load
(
const
std::string& filename,
Value
& output );
98
99
private
:
100
uint32 options_;
101
102
// rapidxml::xml_document<> doc;
103
104
bool
read(
const
std::string& input,
Value
& dest )
const
;
105
106
bool
read_value(
const
rapidxml::xml_node<char>
&
object
,
Value
& dest )
const
;
107
111
bool
read_array
(
const
rapidxml::xml_node<char>
*
object
,
Value
& dest )
const
;
112
114
bool
read_object
(
const
rapidxml::xml_node<char>
* node,
Value
& dest )
const
;
115
};
116
117
}
// namespace nom
118
119
#endif
// include guard defined
120
nom::RapidXmlDeserializer::load
bool load(const std::string &filename, Value &output)
Restore data from a XML (.xml) file to a nom::Value object.
nom::RapidXmlDeserializer::RapidXmlDeserializer
RapidXmlDeserializer(uint32 options)
Construct a parser with a feature set enumeration.
nom::RapidXmlDeserializer::RapidXmlDeserializer
RapidXmlDeserializer(void)
Default constructor; initialize the parser with no additional options.
nom::RapidXmlDeserializer::read_object
bool read_object(const rapidxml::xml_node< char > *node, Value &dest) const
Internal helper method for un-serialization of object nodes.
nom::RapidXmlDeserializer::~RapidXmlDeserializer
~RapidXmlDeserializer(void)
Destructor.
nom::RapidXmlDeserializer::deserialize
Value deserialize(const std::string &source)
Parse XML data to a nom::Value object.
nom::RapidXmlDeserializer::read_array
bool read_array(const rapidxml::xml_node< char > *object, Value &dest) const
Internal helper method for un-serialization of array nodes.
nom::Value
Generic interface for opaque data containers.
Definition
Value.hpp:44
rapidxml::xml_document
Definition
RapidXmlDeserializer.hpp:54
rapidxml::xml_node
Definition
RapidXmlDeserializer.hpp:53
Generated on
for nomlib by
1.18.0