jsonPrimitive.hh 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "jsonElement.hh"
  3. class AJsonPrimitive
  4. {
  5. public:
  6. virtual ~AJsonPrimitive();
  7. };
  8. template <typename T>
  9. class JSonPrimitive: public JSonElement, public AJsonPrimitive
  10. {
  11. public:
  12. JSonPrimitive(JSonContainer *parent, T const &v);
  13. virtual ~JSonPrimitive();
  14. T getValue() const;
  15. virtual std::string stringify() const;
  16. bool operator<(const JSonPrimitive<T> &other) const;
  17. bool operator==(const JSonPrimitive<T> &other) const;
  18. protected:
  19. const T value;
  20. };
  21. template<typename T>
  22. JSonPrimitive<T>::JSonPrimitive(JSonContainer *parent, T const &v): JSonElement(parent), value(v)
  23. { }
  24. template<typename T>
  25. T JSonPrimitive<T>::getValue() const
  26. {
  27. return value;
  28. }
  29. template<typename T>
  30. bool JSonPrimitive<T>::operator<(const JSonPrimitive<T> &other) const
  31. {
  32. return value < other.value;
  33. }
  34. template<typename T>
  35. bool JSonPrimitive<T>::operator==(const JSonPrimitive<T> &other) const
  36. {
  37. return value == other.value;
  38. }