Skip to content

Commit de75593

Browse files
committed
Moved 'enum WsjcppYamlParserLineStates' to source file
1 parent d1c76a7 commit de75593

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/wsjcpp_yaml.cpp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,16 @@ bool WsjcppYamlParsebleLine::isEmptyLine() {
665665

666666
// ---------------------------------------------------------------------
667667

668+
enum WsjcppYamlParserLineStates {
669+
WSJCPP_YAML_PARSER_LINE_STATE_NO,
670+
WSJCPP_YAML_PARSER_LINE_STATE_VALUE,
671+
WSJCPP_YAML_PARSER_LINE_STATE_COMMENT,
672+
WSJCPP_YAML_PARSER_LINE_STATE_STRING,
673+
WSJCPP_YAML_PARSER_LINE_STATE_STRING_DOUBLE_QUOTES,
674+
WSJCPP_YAML_PARSER_LINE_STATE_STRING_SINGLE_QUOTES,
675+
WSJCPP_YAML_PARSER_LINE_STATE_ESCAPING
676+
};
677+
668678
bool WsjcppYamlParsebleLine::parseLine(const std::string &sLine, std::string &sError) {
669679
// reset variables
670680
m_bArrayItem = false;
@@ -683,57 +693,57 @@ bool WsjcppYamlParsebleLine::parseLine(const std::string &sLine, std::string &sE
683693
return true;
684694
}
685695

686-
WsjcppYamlParserLineStates state = WsjcppYamlParserLineStates::NO;
696+
WsjcppYamlParserLineStates state = WSJCPP_YAML_PARSER_LINE_STATE_NO;
687697
for (int i = 0; i < sLine.length(); i++) {
688698
char c = sLine[i];
689-
if ((c == ' ' || c == '\t') && state == WsjcppYamlParserLineStates::NO) {
699+
if ((c == ' ' || c == '\t') && state == WSJCPP_YAML_PARSER_LINE_STATE_NO) {
690700
m_sPrefix += c;
691-
} else if (c == '#' && (state == WsjcppYamlParserLineStates::NO || state == WsjcppYamlParserLineStates::VALUE)) {
692-
state = WsjcppYamlParserLineStates::COMMENT;
701+
} else if (c == '#' && (state == WSJCPP_YAML_PARSER_LINE_STATE_NO || state == WSJCPP_YAML_PARSER_LINE_STATE_VALUE)) {
702+
state = WSJCPP_YAML_PARSER_LINE_STATE_COMMENT;
693703
m_bHasComment = true;
694-
} else if (state == WsjcppYamlParserLineStates::COMMENT) {
704+
} else if (state == WSJCPP_YAML_PARSER_LINE_STATE_COMMENT) {
695705
if (c != '\r') {
696706
m_sComment += c;
697707
}
698-
} else if (c == '-' && state == WsjcppYamlParserLineStates::NO) {
708+
} else if (c == '-' && state == WSJCPP_YAML_PARSER_LINE_STATE_NO) {
699709
m_bArrayItem = true;
700-
state = WsjcppYamlParserLineStates::VALUE;
701-
} else if ((c != ' ' && c != '\t') && state == WsjcppYamlParserLineStates::NO) {
702-
state = WsjcppYamlParserLineStates::VALUE;
710+
state = WSJCPP_YAML_PARSER_LINE_STATE_VALUE;
711+
} else if ((c != ' ' && c != '\t') && state == WSJCPP_YAML_PARSER_LINE_STATE_NO) {
712+
state = WSJCPP_YAML_PARSER_LINE_STATE_VALUE;
703713
m_sValue += c;
704714
if (c == '"') {
705-
state = WsjcppYamlParserLineStates::STRING;
715+
state = WSJCPP_YAML_PARSER_LINE_STATE_STRING;
706716
}
707-
} else if (c == '"' && state == WsjcppYamlParserLineStates::VALUE) {
708-
state = WsjcppYamlParserLineStates::STRING;
717+
} else if (c == '"' && state == WSJCPP_YAML_PARSER_LINE_STATE_VALUE) {
718+
state = WSJCPP_YAML_PARSER_LINE_STATE_STRING;
709719
m_sValue += c;
710-
} else if (c == '\\' && state == WsjcppYamlParserLineStates::STRING) {
711-
state = WsjcppYamlParserLineStates::ESCAPING;
720+
} else if (c == '\\' && state == WSJCPP_YAML_PARSER_LINE_STATE_STRING) {
721+
state = WSJCPP_YAML_PARSER_LINE_STATE_ESCAPING;
712722
m_sValue += c;
713-
} else if (state == WsjcppYamlParserLineStates::ESCAPING) {
714-
state = WsjcppYamlParserLineStates::STRING;
723+
} else if (state == WSJCPP_YAML_PARSER_LINE_STATE_ESCAPING) {
724+
state = WSJCPP_YAML_PARSER_LINE_STATE_STRING;
715725
m_sValue += c;
716-
} else if (c == '"' && state == WsjcppYamlParserLineStates::STRING) {
717-
state = WsjcppYamlParserLineStates::VALUE;
726+
} else if (c == '"' && state == WSJCPP_YAML_PARSER_LINE_STATE_STRING) {
727+
state = WSJCPP_YAML_PARSER_LINE_STATE_VALUE;
718728
m_sValue += c;
719-
} else if (c == ':' && state == WsjcppYamlParserLineStates::VALUE) {
729+
} else if (c == ':' && state == WSJCPP_YAML_PARSER_LINE_STATE_VALUE) {
720730
if (m_sName.length() == 0) {
721731
m_sName = m_sValue;
722732
m_sValue = ""; // reset value it was param name
723733
} else {
724734
m_sValue += c;
725735
}
726-
} else if (state == WsjcppYamlParserLineStates::STRING) {
736+
} else if (state == WSJCPP_YAML_PARSER_LINE_STATE_STRING) {
727737
m_sValue += c;
728-
} else if (state == WsjcppYamlParserLineStates::VALUE) {
738+
} else if (state == WSJCPP_YAML_PARSER_LINE_STATE_VALUE) {
729739
m_sValue += c;
730740
} else {
731741
// skip
732742
}
733743
}
734744

735-
if (state == WsjcppYamlParserLineStates::STRING
736-
|| state == WsjcppYamlParserLineStates::ESCAPING
745+
if (state == WSJCPP_YAML_PARSER_LINE_STATE_STRING
746+
|| state == WSJCPP_YAML_PARSER_LINE_STATE_ESCAPING
737747
) {
738748
sError = "Line has wrong format.";
739749
return false;

src/wsjcpp_yaml.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ class WsjcppYamlItem { // TODO: rename to node
124124

125125
// ---------------------------------------------------------------------
126126

127-
enum WsjcppYamlParserLineStates {
128-
NO,
129-
VALUE,
130-
COMMENT,
131-
STRING,
132-
ESCAPING
133-
};
134-
135-
// ---------------------------------------------------------------------
136-
137127
class WsjcppYamlParsebleLine {
138128
public:
139129
WsjcppYamlParsebleLine(int nLine);

0 commit comments

Comments
 (0)