scanscalar.h 1.64 KB
Newer Older
1
2
3
#pragma once

#include <string>
4
5
#include "regex.h"
#include "stream.h"
6
7
8

namespace YAML
{
9
	enum CHOMP { STRIP = -1, CLIP, KEEP };
10
	enum ACTION { NONE, BREAK, THROW };
11

12
13
	struct ScanScalarParams {
		ScanScalarParams(): eatEnd(false), indent(0), detectIndent(false), eatLeadingWhitespace(0), escape(0), fold(false),
14
			trimTrailingSpaces(0), chomp(CLIP), onDocIndicator(NONE), onTabInIndentation(NONE), leadingSpaces(false) {}
15

16
		// input:
17
18
19
		RegEx end;                      // what condition ends this scalar?
		bool eatEnd;                    // should we eat that condition when we see it?
		int indent;                     // what level of indentation should be eaten and ignored?
20
		bool detectIndent;              // should we try to autodetect the indent?
21
22
23
24
25
26
		bool eatLeadingWhitespace;      // should we continue eating this delicious indentation after 'indent' spaces?
		char escape;                    // what character do we escape on (i.e., slash or single quote) (0 for none)
		bool fold;                      // do we fold line ends?
		bool trimTrailingSpaces;        // do we remove all trailing spaces (at the very end)
		CHOMP chomp;                    // do we strip, clip, or keep trailing newlines (at the very end)
		                                //   Note: strip means kill all, clip means keep at most one, keep means keep all
27
28
		ACTION onDocIndicator;          // what do we do if we see a document indicator?
		ACTION onTabInIndentation;      // what do we do if we see a tab where we should be seeing indentation spaces
29

30
31
		// output:
		bool leadingSpaces;
32
	};
33

34
	std::string ScanScalar(Stream& INPUT, ScanScalarParams& info);
35
}