jsonElement.hh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * jsonElement.hh for jsonstroller
  3. *
  4. * Author: isundil <isundill@gmail.com>
  5. **/
  6. #pragma once
  7. #include <string>
  8. class JSonContainer;
  9. class JSonElement
  10. {
  11. public:
  12. JSonElement(JSonElement *parent);
  13. virtual ~JSonElement();
  14. /**
  15. * return string-representative of this JSonElement
  16. **/
  17. virtual std::string stringify() const =0;
  18. /**
  19. * return number of parents this item has
  20. **/
  21. unsigned int getLevel() const;
  22. /**
  23. * Get the parent element
  24. **/
  25. JSonElement *getParent();
  26. const JSonElement *getParent() const;
  27. /**
  28. * set parent.
  29. * Used for lazy-init
  30. **/
  31. void setParent(JSonElement *parent);
  32. /**
  33. * return previous child
  34. **/
  35. const JSonElement *findPrev() const;
  36. const JSonElement *findNext() const;
  37. /**
  38. * check if this element match SearchQuery
  39. **/
  40. virtual bool match(const std::string &) const;
  41. private:
  42. JSonElement();
  43. /**
  44. * parent container
  45. * Not a JSonContainer because JSonObjectEntry can be a parent and isn't a JSonContainer either
  46. **/
  47. JSonElement *parent;
  48. };