scanscalar.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
  2. #define SCANSCALAR_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 <string>
  9. #include "regex_yaml.h"
  10. #include "stream.h"
  11. namespace YAML {
  12. enum CHOMP { STRIP = -1, CLIP, KEEP };
  13. enum ACTION { NONE, BREAK, THROW };
  14. enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW };
  15. struct ScanScalarParams {
  16. ScanScalarParams()
  17. : end(nullptr),
  18. eatEnd(false),
  19. indent(0),
  20. detectIndent(false),
  21. eatLeadingWhitespace(0),
  22. escape(0),
  23. fold(DONT_FOLD),
  24. trimTrailingSpaces(0),
  25. chomp(CLIP),
  26. onDocIndicator(NONE),
  27. onTabInIndentation(NONE),
  28. leadingSpaces(false) {}
  29. // input:
  30. const RegEx* end; // what condition ends this scalar?
  31. // unowned.
  32. bool eatEnd; // should we eat that condition when we see it?
  33. int indent; // what level of indentation should be eaten and ignored?
  34. bool detectIndent; // should we try to autodetect the indent?
  35. bool eatLeadingWhitespace; // should we continue eating this delicious
  36. // indentation after 'indent' spaces?
  37. char escape; // what character do we escape on (i.e., slash or single quote)
  38. // (0 for none)
  39. FOLD fold; // how do we fold line ends?
  40. bool trimTrailingSpaces; // do we remove all trailing spaces (at the very
  41. // end)
  42. CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very
  43. // end)
  44. // Note: strip means kill all, clip means keep at most one, keep means keep
  45. // all
  46. ACTION onDocIndicator; // what do we do if we see a document indicator?
  47. ACTION onTabInIndentation; // what do we do if we see a tab where we should
  48. // be seeing indentation spaces
  49. // output:
  50. bool leadingSpaces;
  51. };
  52. std::string ScanScalar(Stream& INPUT, ScanScalarParams& info);
  53. }
  54. #endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66