mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Mostly finished refactoring the scalar scanning.
This commit is contained in:
28
scanscalar.h
28
scanscalar.h
@@ -7,35 +7,29 @@
|
||||
namespace YAML
|
||||
{
|
||||
enum CHOMP { STRIP = -1, CLIP, KEEP };
|
||||
enum ACTION { NONE, BREAK, THROW };
|
||||
|
||||
struct ScanScalarInfo {
|
||||
ScanScalarInfo(): eatEnd(false), indent(0), eatLeadingWhitespace(0), escape(0), fold(false), trimTrailingSpaces(0), chomp(CLIP) {}
|
||||
ScanScalarInfo(): eatEnd(false), indent(0), detectIndent(false), eatLeadingWhitespace(0), escape(0), fold(false),
|
||||
trimTrailingSpaces(0), chomp(CLIP), onDocIndicator(NONE), onTabInIndentation(NONE), leadingSpaces(false) {}
|
||||
|
||||
// input:
|
||||
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?
|
||||
bool detectIndent; // should we try to autodetect the indent?
|
||||
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
|
||||
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
|
||||
|
||||
// output:
|
||||
bool leadingSpaces;
|
||||
};
|
||||
|
||||
void GetBlockIndentation(Stream& INPUT, int& indent, std::string& breaks, int topIndent);
|
||||
std::string ScanScalar(Stream& INPUT, ScanScalarInfo info);
|
||||
|
||||
struct WhitespaceInfo {
|
||||
WhitespaceInfo();
|
||||
|
||||
void SetChompers(char ch);
|
||||
void AddBlank(char ch);
|
||||
void AddBreak(const std::string& line);
|
||||
std::string Join(bool lastline = false);
|
||||
|
||||
bool leadingBlanks;
|
||||
bool fold;
|
||||
std::string whitespace, leadingBreaks, trailingBreaks;
|
||||
int chomp, increment;
|
||||
};
|
||||
std::string ScanScalar(Stream& INPUT, ScanScalarInfo& info);
|
||||
}
|
||||
|
Reference in New Issue
Block a user