parser.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2013-2014, Alberto Corona <alberto@0x1a.us>
  2. // All rights reserved. This file is part of yabs, distributed under the BSD
  3. // 3-Clause license. For full terms please see the LICENSE file.
  4. #ifndef _PARSER_H
  5. #define _PARSER_H
  6. #include <yaml.h>
  7. #include <vector>
  8. #include "profile.h"
  9. class Parser
  10. {
  11. private:
  12. std::vector<Profile *> Profiles;
  13. int e_num, p_num;
  14. enum spec {
  15. error = 0,
  16. key,
  17. value,
  18. doc_start,
  19. doc_end,
  20. block_entry,
  21. block_seq_strt,
  22. block_seq_end,
  23. block_map_strt,
  24. block_map_end,
  25. } prs;
  26. spec token_return;
  27. FILE *conf;
  28. std::string key_value;
  29. yaml_parser_t parser;
  30. yaml_token_t token;
  31. public:
  32. Parser();
  33. ~Parser();
  34. int AssertYML(const char *build_file);
  35. int ParseConfig();
  36. int OpenConfig(const char *build_file, int verb_flag);
  37. int CloseConfig();
  38. int ReadValues();
  39. int ParseValues(int verb_flag);
  40. void VerboseParser(int format);
  41. void VoidToken();
  42. void DeleteProfiles();
  43. void CheckDocStart();
  44. void PrintAllProfiles();
  45. void WriteProfileMakes();
  46. void BuildProfiles();
  47. };
  48. #endif