1
0

hierarchyparser.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __PARAMPARSE_H
  2. #define __PARAMPARSE_H
  3. #include <bfc/parse/pathparse.h>
  4. #include <bfc/node.h>
  5. #include <bfc/string/StringW.h>
  6. // typedef NodeC<String> HPNode // OH YAH, YOU CAN'T FWD REF TYPEDEFS. STOOOOOOPID.
  7. class HPNode : public NodeC<StringW> {
  8. public:
  9. HPNode( const StringW & myPayload, NodeC<StringW> * myParent = NULL ) : NodeC<StringW>(myPayload, myParent) {}
  10. };
  11. class HierarchyParser {
  12. public:
  13. HierarchyParser(const wchar_t *str = NULL, const wchar_t *_sibling=L";", const wchar_t *_escape=L"\\", const wchar_t *_parent_open=L"(", const wchar_t *_parent_close=L")") ;
  14. ~HierarchyParser();
  15. HPNode *findGuid(GUID g);
  16. HPNode *findString(const wchar_t *str);
  17. int hasGuid(GUID g) { return findGuid(g) != NULL; }
  18. int hasString(const wchar_t *str) { return findString(str) != NULL; }
  19. HPNode *rootNode() { return rootnode; }
  20. private:
  21. HPNode *rootnode;
  22. int myalloc;
  23. StringW sibling;
  24. StringW escape;
  25. StringW parent_open;
  26. StringW parent_close;
  27. HierarchyParser(HPNode *_rootnode, const wchar_t *_sibling=L";", const wchar_t *_escape=L"\\", const wchar_t *_parent_open=L"(", const wchar_t *_parent_close=L")");
  28. void processSibling(const wchar_t *sibling);
  29. inline int isSibling(wchar_t c) {
  30. return sibling.lFindChar(c) != -1;
  31. }
  32. inline int isEscape(wchar_t c) {
  33. return escape.lFindChar(c) != -1;
  34. }
  35. inline int isParentOpen(wchar_t c) {
  36. return parent_open.lFindChar(c) != -1;
  37. }
  38. inline int isParentClose(wchar_t c) {
  39. return parent_close.lFindChar(c) != -1;
  40. }
  41. };
  42. #endif