removed from SpaceParser: SetDefault(), SkipEmpty(bool skip) and UseEscapeChar(bool escape) methods

This commit is contained in:
Tomasz Sowa 2021-05-21 04:28:31 +02:00
parent 82a21f6d85
commit 6e4a0f68b3
2 changed files with 11 additions and 83 deletions

View File

@ -50,42 +50,16 @@ namespace pt
SpaceParser::SpaceParser() SpaceParser::SpaceParser()
{ {
root_space = 0; root_space = nullptr;
SetDefault();
}
void SpaceParser::SetDefault()
{
// you can change this separators to what you want
// you shoud not use only white characters here (as expected by IsWhite() method)
// and new line characters ('\n')
separator = ':';
space_start = '{'; space_start = '{';
space_end = '}'; space_end = '}';
table_start = '[';
table_end = ']';
option_delimiter = ','; option_delimiter = ',';
skip_empty = false;
use_escape_char = true;
input_as_utf8 = true; input_as_utf8 = true;
} }
void SpaceParser::SkipEmpty(bool skip) void SpaceParser::use_utf8(bool utf)
{
skip_empty = skip;
}
void SpaceParser::UseEscapeChar(bool escape)
{
use_escape_char = escape;
}
void SpaceParser::UTF8(bool utf)
{ {
input_as_utf8 = utf; input_as_utf8 = utf;
} }
@ -1090,7 +1064,7 @@ int SpaceParser::ReadChar()
char_was_escaped = false; char_was_escaped = false;
ReadCharNoEscape(); ReadCharNoEscape();
if( use_escape_char && lastc == '\\' ) if( lastc == '\\' )
{ {
char_was_escaped = true; char_was_escaped = true;
ReadCharNoEscape(); ReadCharNoEscape();

View File

@ -60,15 +60,6 @@ public:
SpaceParser(); SpaceParser();
/*
setting options of the parser to the default values
utf8 etc.
*/
void SetDefault();
/* /*
status of parsing status of parsing
*/ */
@ -133,33 +124,16 @@ public:
*/ */
/*
if true then empty values and lists, e.g:
option =
option2 = ()
will be omitted (not inserted to 'table')
default: false
*/
void SkipEmpty(bool skip);
/* /*
'\' character is used to escape other characters in a quoted string * if true then the input file or string (char* or std::string) is treated as UTF-8
so "some \t t\"ext" will produce "some t t"ext" * default true
default: true *
*/ * the internal storage for strings is std::wstring so if you call set_utf8(false) then
void UseEscapeChar(bool escape); * the characters of input string will be simple static_cast<> from char to wchar_t
*
*/
/* void use_utf8(bool utf);
if true then the input file or string (char* or std::string) is treated as UTF-8
default true
the internal storage for strings is std::wstring so if you call UTF8(false) then
the characters of input string will be simple static_cast<> from char to wchar_t
*/
// rename to use_utf8(bool)
void UTF8(bool utf);
/* /*
@ -271,16 +245,6 @@ private:
std::ifstream file; std::ifstream file;
/*
if true then empty lists, e.g:
option =
option2 = ()
will be omitted (not inserted to 'table')
default: false
*/
bool skip_empty;
/* /*
input file is in UTF-8 input file is in UTF-8
default: true default: true
@ -289,17 +253,8 @@ private:
/* /*
if true you can use an escape character '\' in quoted values
*/
bool use_escape_char;
/*
*
* if parsing_space is false then it means we are parsing JSON format * if parsing_space is false then it means we are parsing JSON format
* *
*
*/ */
bool parsing_space; bool parsing_space;
@ -347,7 +302,6 @@ private:
void SkipLine(); void SkipLine();
void SkipWhite(); void SkipWhite();
void TrimLastWhite(std::wstring & s); void TrimLastWhite(std::wstring & s);
//void Trim(std::wstring & s);
bool IsHexDigit(wchar_t c); bool IsHexDigit(wchar_t c);
int HexToInt(wchar_t c); int HexToInt(wchar_t c);
void ReadUnicodeCodePoint(); void ReadUnicodeCodePoint();