jsonElement.hh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 SearchPattern;
  10. class JSonElement
  11. {
  12. public:
  13. JSonElement(JSonElement *parent);
  14. virtual ~JSonElement();
  15. /**
  16. * return string-representative of this JSonElement
  17. **/
  18. virtual std::string stringify() const =0;
  19. /**
  20. * return number of parents this item has
  21. **/
  22. unsigned int getLevel() const;
  23. /**
  24. * Get the parent element
  25. **/
  26. JSonElement *getParent();
  27. const JSonElement *getParent() const;
  28. /**
  29. * set parent.
  30. * Used for lazy-init
  31. **/
  32. void setParent(JSonElement *parent);
  33. /**
  34. * return previous child
  35. **/
  36. const JSonElement *findPrev() const;
  37. const JSonElement *findNext() const;
  38. /**
  39. * check if this element match SearchQuery
  40. **/
  41. virtual bool match(const SearchPattern &) const;
  42. private:
  43. JSonElement();
  44. /**
  45. * parent container
  46. * Not a JSonContainer because JSonObjectEntry can be a parent and isn't a JSonContainer either
  47. **/
  48. JSonElement *parent;
  49. };