GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Serializer.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #ifndef GDCORE_SERIALIZER_H
8 #define GDCORE_SERIALIZER_H
9 #include <string>
10 #include "GDCore/Serialization/SerializerElement.h"
11 
12 namespace gd {
13 
18 class GD_CORE_API Serializer {
19  public:
24 
28  static gd::String ToEscapedXMLString(const gd::String& str);
30 
37 
40  static gd::String ToJSON(const SerializerElement& element);
41 
45  static SerializerElement FromJSON(const char* json);
46 
50  static SerializerElement FromJSON(const gd::String& json) {
51  return FromJSON(json.c_str());
52  }
54 
65 
71  static void SetCanonicalMode(bool canonical) { canonicalMode = canonical; }
72 
76  static bool IsCanonicalMode() { return canonicalMode; }
78 
79  virtual ~Serializer(){};
80 
81  private:
82  Serializer(){};
83 
84  static bool canonicalMode;
85 };
86 
87 } // namespace gd
88 
89 #endif
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
The class used to save/load projects and GDCore classes from/to XML or JSON.
Definition: Serializer.h:18
static bool IsCanonicalMode()
Returns true if canonical serialization mode is currently active.
Definition: Serializer.h:76
static SerializerElement FromJSON(const gd::String &json)
Construct a gd::SerializerElement from a JSON string.
Definition: Serializer.h:50
static void SetCanonicalMode(bool canonical)
Enable/disable canonical serialization mode globally.
Definition: Serializer.h:71
String represents an UTF8 encoded string.
Definition: String.h:33
const char * c_str() const
Get the C-string.
Definition: String.h:360
Definition: CommonTools.h:24