jsonPrimitive.hh 848 B

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