eoserial: renamed String/Object/Array into Serial* to avoid compiler confusion.
This commit is contained in:
parent
633209be48
commit
787b293b94
11 changed files with 18 additions and 18 deletions
|
|
@ -13,10 +13,10 @@ set(EOSERIAL_LIB_OUTPUT_PATH ${EO_BIN_DIR}/lib)
|
||||||
set(LIBRARY_OUTPUT_PATH ${EOSERIAL_LIB_OUTPUT_PATH})
|
set(LIBRARY_OUTPUT_PATH ${EOSERIAL_LIB_OUTPUT_PATH})
|
||||||
|
|
||||||
set(EOSERIAL_SOURCES
|
set(EOSERIAL_SOURCES
|
||||||
Array.cpp
|
SerialArray.cpp
|
||||||
Object.cpp
|
SerialObject.cpp
|
||||||
Parser.cpp
|
Parser.cpp
|
||||||
String.cpp
|
SerialString.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(eoserial STATIC ${EOSERIAL_SOURCES})
|
add_library(eoserial STATIC ${EOSERIAL_SOURCES})
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ Authors:
|
||||||
|
|
||||||
# include "Parser.h"
|
# include "Parser.h"
|
||||||
|
|
||||||
# include "Array.h"
|
# include "SerialArray.h"
|
||||||
# include "Object.h"
|
# include "SerialObject.h"
|
||||||
# include "String.h"
|
# include "SerialString.h"
|
||||||
|
|
||||||
// in debug mode only
|
// in debug mode only
|
||||||
// # define DEBUG(x) std::cout << x << std::endl;
|
// # define DEBUG(x) std::cout << x << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ Authors:
|
||||||
# define __EOSERIAL_PARSER_H__
|
# define __EOSERIAL_PARSER_H__
|
||||||
|
|
||||||
# include "Entity.h"
|
# include "Entity.h"
|
||||||
# include "String.h"
|
# include "SerialString.h"
|
||||||
# include "Object.h"
|
# include "SerialObject.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file Parser.h
|
* @file Parser.h
|
||||||
|
|
|
||||||
58
eo/src/serial/SerialArray.cpp
Normal file
58
eo/src/serial/SerialArray.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# include "SerialArray.h"
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
std::ostream& Array::print( std::ostream& out ) const
|
||||||
|
{
|
||||||
|
out << "[";
|
||||||
|
bool first = true;
|
||||||
|
for (ArrayChildren::const_iterator it = begin(),
|
||||||
|
end = this->end();
|
||||||
|
it != end;
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
if ( first )
|
||||||
|
{
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
|
(*it)->print( out );
|
||||||
|
}
|
||||||
|
out << "]\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array::~Array()
|
||||||
|
{
|
||||||
|
for (ArrayChildren::iterator it = begin(),
|
||||||
|
end = this->end();
|
||||||
|
it != end;
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace eoserial
|
||||||
170
eo/src/serial/SerialArray.h
Normal file
170
eo/src/serial/SerialArray.h
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# ifndef __EOSERIAL_ARRAY_H__
|
||||||
|
# define __EOSERIAL_ARRAY_H__
|
||||||
|
|
||||||
|
# include <vector>
|
||||||
|
|
||||||
|
# include "Entity.h"
|
||||||
|
# include "Serializable.h"
|
||||||
|
# include "SerialObject.h"
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration for below declarations.
|
||||||
|
class Array;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declarations of functions present in Utils.h
|
||||||
|
* These are put here to avoid instead of including the file Utils.h, which would
|
||||||
|
* cause a circular inclusion.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
void unpack( const Array & array, unsigned int index, T & value );
|
||||||
|
|
||||||
|
void unpackObject( const Array & array, unsigned int index, Persistent & value );
|
||||||
|
|
||||||
|
template< class Container, template<class> class UnpackAlgorithm >
|
||||||
|
void unpackArray( const Array & array, unsigned int index, Container & container );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Represents a JSON array.
|
||||||
|
*
|
||||||
|
* Wrapper for an array, so as to be used as a JSON object.
|
||||||
|
*
|
||||||
|
* @ingroup Serialization
|
||||||
|
*/
|
||||||
|
class Array : public eoserial::Entity, public std::vector< eoserial::Entity* >
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
typedef std::vector< eoserial::Entity* > ArrayChildren;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Adds the serializable object as a JSON object.
|
||||||
|
* @param obj Object which implemnets JsonSerializable.
|
||||||
|
*/
|
||||||
|
void push_back( const eoserial::Printable* obj )
|
||||||
|
{
|
||||||
|
ArrayChildren::push_back( obj->pack() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Proxy for vector::push_back.
|
||||||
|
*/
|
||||||
|
void push_back( eoserial::Entity* json )
|
||||||
|
{
|
||||||
|
ArrayChildren::push_back( json );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints the JSON array into the given stream.
|
||||||
|
* @param out The stream
|
||||||
|
*/
|
||||||
|
virtual std::ostream& print( std::ostream& out ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dtor
|
||||||
|
*/
|
||||||
|
~Array();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following parts allows the user to automatically deserialize an eoserial::Array into a
|
||||||
|
* standard container, by giving the algorithm which will be used to deserialize contained entities.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Functor which determines how to retrieve the real value contained in a eoserial::Entity at
|
||||||
|
* a given place.
|
||||||
|
*
|
||||||
|
* It will be applied for each contained variable in the array.
|
||||||
|
*/
|
||||||
|
template<class Container>
|
||||||
|
struct BaseAlgorithm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Main operator.
|
||||||
|
*
|
||||||
|
* @param array The eoserial::Array from which we're reading.
|
||||||
|
* @param i The index of the contained value.
|
||||||
|
* @param container The standard (STL) container in which we'll push back the read value.
|
||||||
|
*/
|
||||||
|
virtual void operator()( const eoserial::Array& array, unsigned int i, Container & container ) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief BaseAlgorithm for retrieving primitive variables.
|
||||||
|
*
|
||||||
|
* This one should be used to retrieve primitive (and types which implement operator>>) variables, for instance
|
||||||
|
* int, double, std::string, etc...
|
||||||
|
*/
|
||||||
|
template<typename C>
|
||||||
|
struct UnpackAlgorithm : public BaseAlgorithm<C>
|
||||||
|
{
|
||||||
|
void operator()( const eoserial::Array& array, unsigned int i, C & container ) const
|
||||||
|
{
|
||||||
|
typename C::value_type t;
|
||||||
|
unpack( array, i, t );
|
||||||
|
container.push_back( t );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief BaseAlgorithm for retrieving eoserial::Persistent objects.
|
||||||
|
*
|
||||||
|
* This one should be used to retrieve objects which implement eoserial::Persistent.
|
||||||
|
*/
|
||||||
|
template<typename C>
|
||||||
|
struct UnpackObjectAlgorithm : public BaseAlgorithm<C>
|
||||||
|
{
|
||||||
|
void operator()( const eoserial::Array& array, unsigned int i, C & container ) const
|
||||||
|
{
|
||||||
|
typename C::value_type t;
|
||||||
|
unpackObject( array, i, t );
|
||||||
|
container.push_back( t );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief General algorithm for array deserialization.
|
||||||
|
*
|
||||||
|
* Applies the BaseAlgorithm to each contained variable in the eoserial::Array.
|
||||||
|
*/
|
||||||
|
template<class Container, template<class T> class UnpackAlgorithm>
|
||||||
|
inline void deserialize( Container & array )
|
||||||
|
{
|
||||||
|
UnpackAlgorithm< Container > algo;
|
||||||
|
for( unsigned int i = 0, size = this->size();
|
||||||
|
i < size;
|
||||||
|
++i)
|
||||||
|
{
|
||||||
|
algo( *this, i, array );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace eoserial
|
||||||
|
|
||||||
|
# endif // __EOSERIAL_ARRAY_H__
|
||||||
|
|
||||||
60
eo/src/serial/SerialObject.cpp
Normal file
60
eo/src/serial/SerialObject.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# include "SerialObject.h"
|
||||||
|
|
||||||
|
using namespace eoserial;
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
std::ostream& Object::print( std::ostream& out ) const
|
||||||
|
{
|
||||||
|
out << '{';
|
||||||
|
bool first = true;
|
||||||
|
for(JsonValues::const_iterator it = begin(), end = this->end();
|
||||||
|
it != end;
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
if ( first )
|
||||||
|
{
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
out << '"' << it->first << "\":"; // key
|
||||||
|
it->second->print( out ); // value
|
||||||
|
}
|
||||||
|
out << "}\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object::~Object()
|
||||||
|
{
|
||||||
|
for(JsonValues::iterator it = begin(), end = this->end();
|
||||||
|
it != end;
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
delete it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace eoserial
|
||||||
88
eo/src/serial/SerialObject.h
Normal file
88
eo/src/serial/SerialObject.h
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# ifndef __EOSERIAL_OBJECT_H__
|
||||||
|
# define __EOSERIAL_OBJECT_H__
|
||||||
|
|
||||||
|
# include <map>
|
||||||
|
# include <string>
|
||||||
|
|
||||||
|
# include "Entity.h"
|
||||||
|
# include "Serializable.h"
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief JSON Object
|
||||||
|
*
|
||||||
|
* This class represents a JSON object, which is basically a dictionnary
|
||||||
|
* of keys (strings) and values (JSON entities).
|
||||||
|
*
|
||||||
|
* @ingroup Serialization
|
||||||
|
*/
|
||||||
|
class Object : public eoserial::Entity, public std::map< std::string, eoserial::Entity* >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::map<std::string, eoserial::Entity*> JsonValues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adds a pair into the JSON object.
|
||||||
|
* @param key The key associated with the eoserial object
|
||||||
|
* @param json The JSON object as created with framework.
|
||||||
|
*/
|
||||||
|
void add( const std::string& key, eoserial::Entity* json )
|
||||||
|
{
|
||||||
|
(*this)[ key ] = json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adds a pair into the JSON object.
|
||||||
|
* @param key The key associated with the eoserial object
|
||||||
|
* @param obj A JSON-serializable object
|
||||||
|
*/
|
||||||
|
void add( const std::string& key, const eoserial::Printable* obj )
|
||||||
|
{
|
||||||
|
(*this)[ key ] = obj->pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deserializes a Serializable class instance from this JSON object.
|
||||||
|
* @param obj The object we want to rebuild.
|
||||||
|
*/
|
||||||
|
void deserialize( eoserial::Persistent & obj )
|
||||||
|
{
|
||||||
|
obj.unpack( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dtor
|
||||||
|
*/
|
||||||
|
~Object();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints the content of a JSON object into a stream.
|
||||||
|
*/
|
||||||
|
virtual std::ostream& print( std::ostream& out ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace eoserial
|
||||||
|
# endif // __EOSERIAL_OBJECT_H__
|
||||||
|
|
||||||
32
eo/src/serial/SerialString.cpp
Normal file
32
eo/src/serial/SerialString.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# include "SerialString.h"
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
std::ostream& String::print( std::ostream& out ) const
|
||||||
|
{
|
||||||
|
out << '"' << *this << '"';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
} // namespace eoserial
|
||||||
|
|
||||||
103
eo/src/serial/SerialString.h
Normal file
103
eo/src/serial/SerialString.h
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
(c) Thales group, 2012
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation;
|
||||||
|
version 2 of the License.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Contact: http://eodev.sourceforge.net
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||||
|
*/
|
||||||
|
# ifndef __EOSERIAL_STRING_H__
|
||||||
|
# define __EOSERIAL_STRING_H__
|
||||||
|
|
||||||
|
# include <string>
|
||||||
|
# include <sstream>
|
||||||
|
# include <limits>
|
||||||
|
|
||||||
|
# include "Entity.h"
|
||||||
|
|
||||||
|
namespace eoserial
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief JSON String
|
||||||
|
*
|
||||||
|
* Wrapper for string, so as to be used as a JSON object.
|
||||||
|
*
|
||||||
|
* @ingroup Serialization
|
||||||
|
*/
|
||||||
|
class String : public eoserial::Entity, public std::string
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default ctor.
|
||||||
|
* @param str The string we want to wrap.
|
||||||
|
*/
|
||||||
|
String( const std::string& str ) : std::string( str ) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Ctor used only when parsing.
|
||||||
|
*/
|
||||||
|
String( ) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints out the string.
|
||||||
|
*/
|
||||||
|
virtual std::ostream& print( std::ostream& out ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deserializes the current String into a given primitive type value.
|
||||||
|
* @param value The value in which we're writing.
|
||||||
|
*/
|
||||||
|
template<class T>
|
||||||
|
inline void deserialize( T & value ) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Copy and reaffectation are forbidden
|
||||||
|
explicit String( const String& _ );
|
||||||
|
String& operator=( const String& _ );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Casts a eoserial::String into a primitive value, or in a type which at
|
||||||
|
* least overload operator>>.
|
||||||
|
*
|
||||||
|
* @param value A reference to the variable we're writing into.
|
||||||
|
*
|
||||||
|
* It's not necessary to specify the variable type, which can be infered by compiler when
|
||||||
|
* invoking.
|
||||||
|
*/
|
||||||
|
template<class T>
|
||||||
|
inline void String::deserialize( T & value ) const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.precision(std::numeric_limits<double>::digits10 + 1);
|
||||||
|
ss << *this;
|
||||||
|
ss >> value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Specialization for strings, which don't need to be converted through
|
||||||
|
* a stringstream.
|
||||||
|
*/
|
||||||
|
template<>
|
||||||
|
inline void String::deserialize( std::string & value ) const
|
||||||
|
{
|
||||||
|
value = *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace eoserial
|
||||||
|
|
||||||
|
# endif // __EOSERIAL_STRING_H__
|
||||||
|
|
@ -22,9 +22,9 @@ Authors:
|
||||||
# ifndef __EOSERIAL_UTILS_H__
|
# ifndef __EOSERIAL_UTILS_H__
|
||||||
# define __EOSERIAL_UTILS_H__
|
# define __EOSERIAL_UTILS_H__
|
||||||
|
|
||||||
# include "Array.h"
|
# include "SerialArray.h"
|
||||||
# include "Object.h"
|
# include "SerialObject.h"
|
||||||
# include "String.h"
|
# include "SerialString.h"
|
||||||
|
|
||||||
namespace eoserial
|
namespace eoserial
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ Authors:
|
||||||
# ifndef __EOSERIAL_HEADERS__
|
# ifndef __EOSERIAL_HEADERS__
|
||||||
# define __EOSERIAL_HEADERS__
|
# define __EOSERIAL_HEADERS__
|
||||||
|
|
||||||
# include "Object.h"
|
# include "SerialObject.h"
|
||||||
# include "Serializable.h"
|
# include "Serializable.h"
|
||||||
# include "Array.h"
|
# include "SerialArray.h"
|
||||||
# include "Object.h"
|
# include "SerialObject.h"
|
||||||
# include "String.h"
|
# include "String.h"
|
||||||
# include "Parser.h"
|
# include "Parser.h"
|
||||||
# include "Utils.h"
|
# include "Utils.h"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue