18 #ifndef ION_BASE_SERIALIZE_H_
19 #define ION_BASE_SERIALIZE_H_
61 if (!in.fail() && (value ==
"true" || value ==
"false")) {
62 *val = value ==
"true";
70 template <
typename T,
typename U,
typename V>
72 std::basic_string<T, U, V>* val) {
75 bool escaping =
false;
76 if (GetExpectedChar<'"'>(in)) {
80 c =
static_cast<char>(in.get());
81 done = !escaping && c ==
'"';
82 escaping = !escaping && c ==
'\\';
83 if (!done && !escaping)
85 }
while (!in.fail() && !done);
87 if (!in.fail() && done) {
96 template <
typename T,
typename U>
98 std::pair<const T, U>* val) {
104 *
const_cast<T*
>(&val->first) = key;
114 template <
typename ContainerType>
116 ContainerType* val) {
121 typename ContainerType::value_type
value;
123 v.insert(v.end(),
value);
125 in.setstate(std::ios_base::failbit);
135 if (!GetExpectedChar<','>(in))
144 template <
typename T,
typename U,
typename V,
typename W,
typename X,
bool B,
145 template <
class,
class,
class,
class,
class,
bool>
148 ContainerType<T, U, V, W, X, B>* val) {
153 template <
typename T,
typename U,
typename V,
typename W,
typename X,
154 template <
class,
class,
class,
class,
class>
class ContainerType>
156 ContainerType<T, U, V, W, X>* val) {
161 template <
typename T,
typename U,
typename V,
typename W,
bool B,
162 template <
class,
class,
class,
class,
bool>
class ContainerType>
164 ContainerType<T, U, V, W, B>* val) {
169 template <
typename T,
typename U,
typename V,
typename W,
170 template <
class,
class,
class,
class>
class ContainerType>
172 ContainerType<T, U, V, W>* val) {
177 template <
typename T,
typename U,
typename V,
178 template <
class,
class,
class>
class ContainerType>
180 ContainerType<T, U, V>* val) {
185 template <
typename T,
typename U,
template <
class,
class>
class ContainerType>
187 ContainerType<T, U>* val) {
193 template <
typename T>
195 std::istringstream in(s);
208 template <
typename T>
210 std::ostringstream out;
218 std::ostringstream out;
219 out << (val ?
"true" :
"false");
226 std::ostringstream out;
233 std::ostringstream out;
240 template <
typename T,
typename U,
typename V>
242 std::ostringstream out;
254 template <
typename T,
typename U>
256 std::ostringstream out;
262 template <
typename ContainerType>
264 std::ostringstream out;
266 for (
typename ContainerType::const_iterator it = c.begin(); it != c.end();
277 template <
typename T,
typename U,
typename V,
typename W,
typename X,
bool B,
278 template <
class,
class,
class,
class,
class,
bool>
281 const ContainerType<T, U, V, W, X, B>& val) {
286 template <
typename T,
typename U,
typename V,
typename W,
typename X,
287 template <
class,
class,
class,
class,
class>
290 const ContainerType<T, U, V, W, X>& val) {
295 template <
typename T,
typename U,
typename V,
typename W,
bool B,
296 template <
class,
class,
class,
class,
bool>
class ContainerType>
298 const ContainerType<T, U, V, W, B>& val) {
303 template <
typename T,
typename U,
typename V,
typename W,
304 template <
class,
class,
class,
class>
class ContainerType>
306 const ContainerType<T, U, V, W>& val) {
311 template <
typename T,
typename U,
typename V,
312 template <
class,
class,
class>
class ContainerType>
318 template <
typename T,
typename U,
template <
class,
class>
class ContainerType>
326 #endif // ION_BASE_SERIALIZE_H_
bool StringToStlContainer(std::istringstream &in, ContainerType *val)
Constructs a STL container from a stream.
std::string StlContainerToString(const ContainerType &c)
Serializes an STL container to a string.
bool StringToValue(std::istringstream &in, T *val)
This file defines two public functions: StringToValue() and ValueToString().
std::string ValueToString(const T &val)
ValueToString.
std::string ION_API EscapeString(const std::string &str)
Returns an escaped version of the passed string.
std::istream & GetExpectedChar(std::istream &in)
Reads a single character from the stream and returns the stream.