emitfromevents.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
  2. #define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
  3. #if defined(_MSC_VER) || \
  4. (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
  5. (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
  6. #pragma once
  7. #endif
  8. #include <stack>
  9. #include "yaml-cpp/anchor.h"
  10. #include "yaml-cpp/emitterstyle.h"
  11. #include "yaml-cpp/eventhandler.h"
  12. namespace YAML {
  13. struct Mark;
  14. } // namespace YAML
  15. namespace YAML {
  16. class Emitter;
  17. class EmitFromEvents : public EventHandler {
  18. public:
  19. EmitFromEvents(Emitter& emitter);
  20. virtual void OnDocumentStart(const Mark& mark);
  21. virtual void OnDocumentEnd();
  22. virtual void OnNull(const Mark& mark, anchor_t anchor);
  23. virtual void OnAlias(const Mark& mark, anchor_t anchor);
  24. virtual void OnScalar(const Mark& mark, const std::string& tag,
  25. anchor_t anchor, const std::string& value);
  26. virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
  27. anchor_t anchor, EmitterStyle::value style);
  28. virtual void OnSequenceEnd();
  29. virtual void OnMapStart(const Mark& mark, const std::string& tag,
  30. anchor_t anchor, EmitterStyle::value style);
  31. virtual void OnMapEnd();
  32. private:
  33. void BeginNode();
  34. void EmitProps(const std::string& tag, anchor_t anchor);
  35. private:
  36. Emitter& m_emitter;
  37. struct State {
  38. enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue };
  39. };
  40. std::stack<State::value> m_stateStack;
  41. };
  42. }
  43. #endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66