A generic container that can represent a value ( containing a string, double, bool or int), an object ("associative array", "dictionary") with children or an array (children indexed by numeric properties).
More...
|
| SerializerElement () |
| Create an empty element with no value, no children and no attributes.
|
|
| SerializerElement (const SerializerValue &value) |
| Create an element with the specified value.
|
|
| SerializerElement (const gd::SerializerElement &object) |
|
SerializerElement & | operator= (const gd::SerializerElement &object) |
|
|
Methods related to the value of the element, if any.
|
void | SetValue (const SerializerValue &value) |
| Set the value of the element.
|
|
void | SetValue (bool val) |
| Set the value of the element, as a boolean.
|
|
void | SetBoolValue (bool val) |
| Set the value of the element, as a boolean.
|
|
void | SetValue (const gd::String &val) |
| Set the value of the element, as a string.
|
|
void | SetStringValue (const gd::String &val) |
| Set the value of the element, as a string.
|
|
void | SetValue (int val) |
| Set the value of the element, as an integer.
|
|
void | SetIntValue (int val) |
| Set the value of the element, as an integer.
|
|
void | SetValue (unsigned int val) |
| Set the value of the element, as an unsigned integer.
|
|
void | SetValue (double val) |
| Set the value of the element, as a double precision floating point number.
|
|
void | SetDoubleValue (double val) |
| Set the value of the element, as a double precision floating point number.
|
|
void | SetValue (float val) |
| Set the value of the element, as a floating point number.
|
|
void | SetFloatValue (float val) |
| Set the value of the element, as a floating point number.
|
|
const SerializerValue & | GetValue () const |
| Get the value of the element, as a generic gd::SerializerValue. More...
|
|
bool | GetBoolValue () const |
| Get the value, its type being a boolean.
|
|
gd::String | GetStringValue () const |
| Get the value, its type being a gd::String.
|
|
int | GetIntValue () const |
| Get the value, its type being an int.
|
|
double | GetDoubleValue () const |
| Get the value, its type being a double.
|
|
bool | IsValueUndefined () const |
| Return true if no value was set for the element.
|
|
void | SetMultilineStringValue (const gd::String &value) |
| Save the value either as a string or as an array of strings if it has line breaks.
|
|
gd::String | GetMultilineStringValue () |
| Read the value, either represented as a string or as an array of strings, into a string.
|
|
|
Methods related to the attributes of the element.
- Deprecated:
- Prefer using AddChild/GetChild methods.
Attributes are stored differently than children elements, but are serialized to the same in JSON. Hence, the attribute getters will also search in children elements.
|
SerializerElement & | SetAttribute (const gd::String &name, bool value) |
| Set the boolean value of an attribute of the element. More...
|
|
SerializerElement & | SetBoolAttribute (const gd::String &name, bool value) |
| Set the boolean value of an attribute of the element. More...
|
|
SerializerElement & | SetAttribute (const gd::String &name, const gd::String &value) |
| Set the string value of an attribute of the element. More...
|
|
SerializerElement & | SetStringAttribute (const gd::String &name, const gd::String &value) |
| Set the string value of an attribute of the element. More...
|
|
SerializerElement & | SetAttribute (const gd::String &name, const char *value) |
| Set the string value of an attribute of the element. More...
|
|
SerializerElement & | SetAttribute (const gd::String &name, int value) |
| Set the integer value of an attribute of the element. More...
|
|
SerializerElement & | SetIntAttribute (const gd::String &name, int value) |
| Set the integer value of an attribute of the element. More...
|
|
SerializerElement & | SetAttribute (const gd::String &name, double value) |
| Set the double precision floating point number value of an attribute of the element. More...
|
|
SerializerElement & | SetDoubleAttribute (const gd::String &name, double value) |
| Set the double precision floating point number value of an attribute of the element. More...
|
|
bool | GetBoolAttribute (const gd::String &name, bool defaultValue=false, gd::String deprecatedName="") const |
|
gd::String | GetStringAttribute (const gd::String &name, gd::String defaultValue="", gd::String deprecatedName="") const |
|
int | GetIntAttribute (const gd::String &name, int defaultValue=0, gd::String deprecatedName="") const |
|
double | GetDoubleAttribute (const gd::String &name, double defaultValue=0.0, gd::String deprecatedName="") const |
|
bool | HasAttribute (const gd::String &name) const |
| Return true if the specified attribute exists. More...
|
|
const std::map< gd::String, SerializerValue > & | GetAllAttributes () const |
| Return all the attributes of the element.
|
|
|
Methods related to the children elements
|
void | ConsiderAsArray () const |
| Consider that the element is an array of elements, without specific name for the children element. More...
|
|
bool | ConsideredAsArray () const |
| Check if the element is considered as an array containing its children. More...
|
|
void | ConsiderAsArrayOf (const gd::String &name, const gd::String &deprecatedName="") const |
| Consider that the element is an array for elements with the given name. More...
|
|
const gd::String & | ConsideredAsArrayOf () const |
| Return the name of the children the element is considered an array of. More...
|
|
SerializerElement & | AddChild (gd::String name) |
| Add a child at the end of the children list with the given name and return a reference to it. More...
|
|
SerializerElement & | GetChild (gd::String name, std::size_t index=0, gd::String deprecatedName="") const |
| Get a child of the element using its name. More...
|
|
SerializerElement & | GetChild (std::size_t index) const |
| Get a child of the element using its index (when the element is considered as an array). More...
|
|
std::size_t | GetChildrenCount (gd::String name="", gd::String deprecatedName="") const |
| Get the number of children having a specific name. More...
|
|
bool | HasChild (const gd::String &name, gd::String deprecatedName="") const |
| Return true if the specified child exists. More...
|
|
void | RemoveChild (const gd::String &name) |
| Remove the child with the specified name. More...
|
|
const std::vector< std::pair< gd::String, std::shared_ptr< SerializerElement > > > & | GetAllChildren () const |
| Return all the children of the element.
|
|
A generic container that can represent a value ( containing a string, double, bool or int), an object ("associative array", "dictionary") with children or an array (children indexed by numeric properties).
It is used for serialization (to JSON or XML), or as a generic container for properties of objects (see for example gd::Behavior).
It also has specialized methods in GDevelop.js (see postjs.js) to be converted to a JavaScript object.
- Note
- Children are stored with their order preserved, but this also means that their access/removal is O(number of children). This class is not appropriated for a use in game where fast access is required.
- See also
- gd::Serializer