mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Refactored common scalar scanning code (from plain, quoted, and block) to one function.
This commit is contained in:
10
exp.cpp
10
exp.cpp
@@ -62,7 +62,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
// Escape
|
||||
// . Escapes the sequence starting 'in' (it must begin with a '\')
|
||||
// . Escapes the sequence starting 'in' (it must begin with a '\' or single quote)
|
||||
// and returns the result.
|
||||
// . Fills 'length' with how many characters we ate.
|
||||
// . Throws if it's an unknown escape character.
|
||||
@@ -72,10 +72,16 @@ namespace YAML
|
||||
length = 2;
|
||||
|
||||
// eat slash
|
||||
in.get();
|
||||
char escape = in.get();
|
||||
|
||||
// switch on escape character
|
||||
char ch = in.get();
|
||||
|
||||
// first do single quote, since it's easier
|
||||
if(escape == '\'' && ch == '\'')
|
||||
return "\'";
|
||||
|
||||
// now do the slash (we're not gonna check if it's a slash - you better pass one!)
|
||||
switch(ch) {
|
||||
case '0': return "\0";
|
||||
case 'a': return "\x07";
|
||||
|
Reference in New Issue
Block a user