XmlTemplate.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : CXmlTemplate declaration.
  9. #ifndef CRYINCLUDE_EDITOR_UTIL_XMLTEMPLATE_H
  10. #define CRYINCLUDE_EDITOR_UTIL_XMLTEMPLATE_H
  11. #pragma once
  12. /*!
  13. * CXmlTemplate is XML base template of parameters.
  14. *
  15. */
  16. class CXmlTemplate
  17. {
  18. public:
  19. //! Scans properties of XML template,
  20. //! for each property try to find corresponding attribute in specified XML node, and copy
  21. //! value to Value attribute of template.
  22. static void GetValues(XmlNodeRef& templateNode, const XmlNodeRef& fromNode);
  23. //! Scans properties of XML template, fetch Value attribute of each and put as Attribute in
  24. //! specified XML node.
  25. static void SetValues(const XmlNodeRef& templateNode, XmlNodeRef& toNode);
  26. static bool SetValues(const XmlNodeRef& templateNode, XmlNodeRef& toNode, const XmlNodeRef& modifiedNode);
  27. //! Add parameter to template.
  28. static void AddParam(XmlNodeRef& templ, const char* paramName, bool value);
  29. static void AddParam(XmlNodeRef& templ, const char* paramName, int value, int min = 0, int max = 10000);
  30. static void AddParam(XmlNodeRef& templ, const char* paramName, float value, float min = -10000, float max = 10000);
  31. static void AddParam(XmlNodeRef& templ, const char* paramName, const char* sValue);
  32. };
  33. /*!
  34. * CXmlTemplateRegistry is a collection of all registred templates.
  35. */
  36. class CXmlTemplateRegistry
  37. {
  38. public:
  39. CXmlTemplateRegistry();
  40. void LoadTemplates(const QString& path);
  41. void AddTemplate(const QString& name, XmlNodeRef& tmpl);
  42. XmlNodeRef FindTemplate(const QString& name);
  43. private:
  44. StdMap<QString, XmlNodeRef> m_templates;
  45. };
  46. #endif // CRYINCLUDE_EDITOR_UTIL_XMLTEMPLATE_H