CProperty.h 786 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <nlohmann/json.hpp>
  3. namespace WallpaperEngine::Core::Projects
  4. {
  5. using json = nlohmann::json;
  6. class CPropertyColor;
  7. class CProperty
  8. {
  9. public:
  10. static CProperty* fromJSON (json data, const std::string& name);
  11. template<class T> const T As () const { assert (Is<T> ()); return (const T*) this; }
  12. template<class T> T As () { assert (Is<T> ()); return (T*) this; }
  13. template<class T> bool Is () { return this->m_type == T::Type; }
  14. std::string& getName ();
  15. std::string& getType ();
  16. std::string& getText ();
  17. protected:
  18. CProperty (std::string name, std::string type, std::string text);
  19. std::string m_type;
  20. std::string m_name;
  21. std::string m_text;
  22. };
  23. }