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