GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ExtensionProperties.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 #ifndef GDCORE_EXTENSIONPROPERTIES_H
7 #define GDCORE_EXTENSIONPROPERTIES_H
8 #include <map>
9 
10 #include "GDCore/Serialization/SerializerElement.h"
11 #include "GDCore/String.h"
12 
13 namespace gd {
14 class Project;
15 class PropertyDescriptor;
16 } // namespace gd
17 
18 namespace gd {
19 class GD_CORE_API ExtensionProperties {
20  static const gd::String defaultValue;
21 
22  public:
23  const gd::String& GetValue(const gd::String& extension,
24  const gd::String& property) const {
25  if (properties.count(extension) == 0 ||
26  properties.at(extension).count(property) == 0) {
27  return ExtensionProperties::defaultValue;
28  }
29  return properties.at(extension).at(property);
30  };
31 
32  void SetValue(const gd::String& extension,
33  const gd::String& property,
34  const gd::String& newValue) {
35  properties[extension][property] = newValue;
36  };
37 
38  bool HasProperty(const gd::String& extension, const gd::String& property) {
39  for (std::pair<gd::String, gd::String> propertyPair :
40  properties[extension]) {
41  if (propertyPair.first == property) {
42  return true;
43  }
44  }
45  return false;
46  }
47 
48  std::map<gd::String, gd::PropertyDescriptor> GetAllExtensionProperties(
49  const gd::String& extensionName, gd::Project& project);
50 
52 
55  void SerializeTo(SerializerElement& element) const;
56 
60  void UnserializeFrom(const SerializerElement& element);
62 
63  private:
64  std::map<gd::String, std::map<gd::String, gd::String>>
65  properties;
66 };
67 } // namespace gd
68 
69 #endif // EXTENSIONPROPERTIES_H
Definition: ExtensionProperties.h:19
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24