renamed: JSONToSpaceParser -> SpaceParser

pull/4/head
Tomasz Sowa 2 years ago
parent 961a02ab39
commit ba82ac7cbe

@ -19,24 +19,18 @@
./mainspaceparser/mainspaceparser.o: membuffer/membuffer.h textstream/types.h
./mainspaceparser/mainspaceparser.o: utf8/utf8_templates.h
./mainspaceparser/mainspaceparser.o: utf8/utf8_private.h
./space/jsontospaceparser.o: ./space/jsontospaceparser.h ./space/space.h
./space/jsontospaceparser.o: textstream/types.h convert/inttostr.h
./space/jsontospaceparser.o: utf8/utf8.h textstream/textstream.h
./space/jsontospaceparser.o: space/space.h date/date.h membuffer/membuffer.h
./space/jsontospaceparser.o: textstream/types.h utf8/utf8_templates.h
./space/jsontospaceparser.o: utf8/utf8_private.h convert/strtoint.h
./space/jsontospaceparser.o: ./convert/text.h ./convert/misc.h
./space/spaceparser.o: ./space/spaceparser.h ./space/space.h
./space/spaceparser.o: textstream/types.h convert/inttostr.h utf8/utf8.h
./space/spaceparser.o: textstream/textstream.h space/space.h date/date.h
./space/spaceparser.o: membuffer/membuffer.h textstream/types.h
./space/spaceparser.o: utf8/utf8_templates.h utf8/utf8_private.h
./space/spaceparser.o: convert/strtoint.h ./convert/text.h ./convert/misc.h
./space/space.o: ./space/space.h textstream/types.h convert/inttostr.h
./space/space.o: utf8/utf8.h textstream/textstream.h space/space.h
./space/space.o: date/date.h membuffer/membuffer.h textstream/types.h
./space/space.o: utf8/utf8_templates.h utf8/utf8_private.h convert/convert.h
./space/space.o: ./convert/inttostr.h convert/patternreplacer.h
./space/space.o: convert/strtoint.h ./convert/text.h ./convert/misc.h
./space/spaceparser.o: ./space/spaceparser.h ./space/space.h
./space/spaceparser.o: textstream/types.h convert/inttostr.h utf8/utf8.h
./space/spaceparser.o: textstream/textstream.h space/space.h date/date.h
./space/spaceparser.o: membuffer/membuffer.h textstream/types.h
./space/spaceparser.o: utf8/utf8_templates.h utf8/utf8_private.h
./space/spacetojson.o: ./space/spacetojson.h ./space/space.h
./space/spacetojson.o: textstream/types.h convert/inttostr.h
./utf8/utf8.o: ./utf8/utf8.h textstream/textstream.h space/space.h

@ -37,7 +37,7 @@
#include <cstdlib>
#include <wchar.h>
#include "jsontospaceparser.h"
#include "spaceparser.h"
#include "utf8/utf8.h"
#include "convert/strtoint.h"
@ -48,26 +48,26 @@ namespace PT
JSONToSpaceParser::JSONToSpaceParser()
SpaceParser::SpaceParser()
{
root_space = 0;
SetDefault();
}
void JSONToSpaceParser::SetSpace(Space * pspace)
void SpaceParser::SetSpace(Space * pspace)
{
root_space = pspace;
}
void JSONToSpaceParser::SetSpace(Space & pspace)
void SpaceParser::SetSpace(Space & pspace)
{
root_space = &pspace;
}
void JSONToSpaceParser::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)
@ -85,32 +85,32 @@ void JSONToSpaceParser::SetDefault()
void JSONToSpaceParser::SkipEmpty(bool skip)
void SpaceParser::SkipEmpty(bool skip)
{
skip_empty = skip;
}
void JSONToSpaceParser::UseEscapeChar(bool escape)
void SpaceParser::UseEscapeChar(bool escape)
{
use_escape_char = escape;
}
void JSONToSpaceParser::UTF8(bool utf)
void SpaceParser::UTF8(bool utf)
{
input_as_utf8 = utf;
}
int JSONToSpaceParser::get_last_parsed_line()
int SpaceParser::get_last_parsed_line()
{
return line;
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const char * file_name)
SpaceParser::Status SpaceParser::ParseJSONFile(const char * file_name)
{
reading_from_file = true;
parsing_space = false;
@ -133,7 +133,7 @@ return status;
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const std::string & file_name)
SpaceParser::Status SpaceParser::ParseJSONFile(const std::string & file_name)
{
return ParseJSONFile(file_name.c_str());
}
@ -141,7 +141,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const std::string & f
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const wchar_t * file_name)
SpaceParser::Status SpaceParser::ParseJSONFile(const wchar_t * file_name)
{
std::string file_name_utf8;
@ -151,7 +151,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const wchar_t * file_
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const std::wstring & file_name)
SpaceParser::Status SpaceParser::ParseJSONFile(const std::wstring & file_name)
{
return ParseJSONFile(file_name.c_str());
}
@ -160,7 +160,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseJSONFile(const std::wstring &
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const char * file_name)
SpaceParser::Status SpaceParser::ParseSpaceFile(const char * file_name)
{
reading_from_file = true;
parsing_space = true;
@ -183,7 +183,7 @@ return status;
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const std::string & file_name)
SpaceParser::Status SpaceParser::ParseSpaceFile(const std::string & file_name)
{
return ParseSpaceFile(file_name.c_str());
}
@ -191,7 +191,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const std::string &
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const wchar_t * file_name)
SpaceParser::Status SpaceParser::ParseSpaceFile(const wchar_t * file_name)
{
std::string file_name_utf8;
@ -201,14 +201,14 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const wchar_t * file
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpaceFile(const std::wstring & file_name)
SpaceParser::Status SpaceParser::ParseSpaceFile(const std::wstring & file_name)
{
return ParseSpaceFile(file_name.c_str());
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSON(const char * str)
SpaceParser::Status SpaceParser::ParseJSON(const char * str)
{
reading_from_file = false;
reading_from_wchar_string = false;
@ -222,13 +222,13 @@ return status;
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSON(const std::string & str)
SpaceParser::Status SpaceParser::ParseJSON(const std::string & str)
{
return ParseJSON(str.c_str());
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSON(const wchar_t * str)
SpaceParser::Status SpaceParser::ParseJSON(const wchar_t * str)
{
reading_from_file = false;
reading_from_wchar_string = true;
@ -242,7 +242,7 @@ return status;
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseJSON(const std::wstring & str)
SpaceParser::Status SpaceParser::ParseJSON(const std::wstring & str)
{
return ParseJSON(str.c_str());
}
@ -251,7 +251,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseJSON(const std::wstring & str)
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpace(const char * str)
SpaceParser::Status SpaceParser::ParseSpace(const char * str)
{
reading_from_file = false;
reading_from_wchar_string = false;
@ -265,13 +265,13 @@ return status;
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpace(const std::string & str)
SpaceParser::Status SpaceParser::ParseSpace(const std::string & str)
{
return ParseSpace(str.c_str());
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpace(const wchar_t * str)
SpaceParser::Status SpaceParser::ParseSpace(const wchar_t * str)
{
reading_from_file = false;
reading_from_wchar_string = true;
@ -285,7 +285,7 @@ return status;
}
JSONToSpaceParser::Status JSONToSpaceParser::ParseSpace(const std::wstring & str)
SpaceParser::Status SpaceParser::ParseSpace(const std::wstring & str)
{
return ParseSpace(str.c_str());
}
@ -294,7 +294,7 @@ JSONToSpaceParser::Status JSONToSpaceParser::ParseSpace(const std::wstring & str
void JSONToSpaceParser::ParseRootSpace()
void SpaceParser::ParseRootSpace()
{
line = 1;
status = ok;
@ -327,7 +327,7 @@ void JSONToSpaceParser::ParseRootSpace()
}
void JSONToSpaceParser::Parse(Space * space, bool is_object_value, bool is_table_value)
void SpaceParser::Parse(Space * space, bool is_object_value, bool is_table_value)
{
SkipWhite();
@ -391,7 +391,7 @@ void JSONToSpaceParser::Parse(Space * space, bool is_object_value, bool is_table
void JSONToSpaceParser::ParseSpace(Space * space)
void SpaceParser::ParseSpace(Space * space)
{
/*
* in Space format in global namespace the space start character is not required
@ -423,7 +423,7 @@ void JSONToSpaceParser::ParseSpace(Space * space)
void JSONToSpaceParser::ParseTextValue(Space * space)
void SpaceParser::ParseTextValue(Space * space)
{
space->set_empty_wstring();
std::wstring * str = space->get_wstring();
@ -435,7 +435,7 @@ void JSONToSpaceParser::ParseTextValue(Space * space)
}
void JSONToSpaceParser::ParseIntegerValue(Space * space)
void SpaceParser::ParseIntegerValue(Space * space)
{
const wchar_t * after_str = nullptr;
bool was_overflow = false;
@ -458,7 +458,7 @@ void JSONToSpaceParser::ParseIntegerValue(Space * space)
}
void JSONToSpaceParser::ParseFloatingPointValue(Space * space)
void SpaceParser::ParseFloatingPointValue(Space * space)
{
wchar_t * after_str = nullptr;
double val = wcstod(token.c_str(), &after_str);
@ -481,7 +481,7 @@ void JSONToSpaceParser::ParseFloatingPointValue(Space * space)
void JSONToSpaceParser::ParseTable(Space * space)
void SpaceParser::ParseTable(Space * space)
{
space->set_empty_table();
@ -503,7 +503,7 @@ void JSONToSpaceParser::ParseTable(Space * space)
void JSONToSpaceParser::ParseKeyValuePairs(Space * space)
void SpaceParser::ParseKeyValuePairs(Space * space)
{
bool is_first = true;
SkipWhite();
@ -571,7 +571,7 @@ void JSONToSpaceParser::ParseKeyValuePairs(Space * space)
void JSONToSpaceParser::ParseValuesList(Space * space)
void SpaceParser::ParseValuesList(Space * space)
{
bool is_first = true;
SkipWhite();
@ -616,7 +616,7 @@ void JSONToSpaceParser::ParseValuesList(Space * space)
bool JSONToSpaceParser::is_integer_token()
bool SpaceParser::is_integer_token()
{
if( token.empty() )
return false;
@ -643,7 +643,7 @@ bool JSONToSpaceParser::is_integer_token()
}
bool JSONToSpaceParser::is_floating_point_token()
bool SpaceParser::is_floating_point_token()
{
bool was_dot = false;
bool was_exponential = false;
@ -707,7 +707,7 @@ bool JSONToSpaceParser::is_floating_point_token()
bool JSONToSpaceParser::IsWhite(int c)
bool SpaceParser::IsWhite(int c)
{
// 13 (\r) is at the end of a line in a dos file \r\n
// 160 is an unbreakable space
@ -718,7 +718,7 @@ return false;
}
bool JSONToSpaceParser::is_alfa_numeric_char(int c)
bool SpaceParser::is_alfa_numeric_char(int c)
{
return (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
@ -727,7 +727,7 @@ bool JSONToSpaceParser::is_alfa_numeric_char(int c)
}
void JSONToSpaceParser::SkipLine()
void SpaceParser::SkipLine()
{
while( lastc != -1 && (char_was_escaped || lastc != '\n') )
ReadChar();
@ -735,7 +735,7 @@ void JSONToSpaceParser::SkipLine()
void JSONToSpaceParser::SkipWhite()
void SpaceParser::SkipWhite()
{
if( parsing_space )
{
@ -757,7 +757,7 @@ void JSONToSpaceParser::SkipWhite()
}
void JSONToSpaceParser::TrimLastWhite(std::wstring & s)
void SpaceParser::TrimLastWhite(std::wstring & s)
{
std::wstring::size_type i;
@ -773,7 +773,7 @@ void JSONToSpaceParser::TrimLastWhite(std::wstring & s)
/*
void JSONToSpaceParser::Trim(std::wstring & s)
void SpaceParser::Trim(std::wstring & s)
{
std::wstring::size_type i;
@ -804,7 +804,7 @@ std::wstring::size_type i;
*/
void JSONToSpaceParser::ReadTokenUntilDelimiter(std::wstring & token, int delimiter1, int delimiter2)
void SpaceParser::ReadTokenUntilDelimiter(std::wstring & token, int delimiter1, int delimiter2)
{
token.clear();
@ -818,7 +818,7 @@ void JSONToSpaceParser::ReadTokenUntilDelimiter(std::wstring & token, int delimi
}
void JSONToSpaceParser::ReadAlfaNumericToken(std::wstring & token)
void SpaceParser::ReadAlfaNumericToken(std::wstring & token)
{
token.clear();
@ -830,7 +830,7 @@ void JSONToSpaceParser::ReadAlfaNumericToken(std::wstring & token)
}
void JSONToSpaceParser::ReadStringValue(std::wstring & token, bool is_object_value, bool is_table_value)
void SpaceParser::ReadStringValue(std::wstring & token, bool is_object_value, bool is_table_value)
{
if( parsing_space )
{
@ -856,7 +856,7 @@ void JSONToSpaceParser::ReadStringValue(std::wstring & token, bool is_object_val
// rename to something like ReadSpaceFieldToken???
void JSONToSpaceParser::ReadSpaceFieldToken(std::wstring & token)
void SpaceParser::ReadSpaceFieldToken(std::wstring & token)
{
token.clear();
@ -871,7 +871,7 @@ void JSONToSpaceParser::ReadSpaceFieldToken(std::wstring & token)
// IMPROVEME in JSON we should not allow non-escaped a new line character
void JSONToSpaceParser::ReadTokenQuoted(std::wstring & token)
void SpaceParser::ReadTokenQuoted(std::wstring & token)
{
token.clear();
ReadChar(); // skipping the first quotation mark
@ -893,7 +893,7 @@ void JSONToSpaceParser::ReadTokenQuoted(std::wstring & token)
}
void JSONToSpaceParser::ReadMultilineTokenQuoted(std::wstring & token)
void SpaceParser::ReadMultilineTokenQuoted(std::wstring & token)
{
token.clear();
ReadChar(); // skipping the first quotation mark
@ -916,7 +916,7 @@ void JSONToSpaceParser::ReadMultilineTokenQuoted(std::wstring & token)
void JSONToSpaceParser::ReadKey()
void SpaceParser::ReadKey()
{
SkipWhite();
@ -947,7 +947,7 @@ void JSONToSpaceParser::ReadKey()
int JSONToSpaceParser::ReadUTF8Char()
int SpaceParser::ReadUTF8Char()
{
int c;
bool correct;
@ -973,7 +973,7 @@ return lastc;
int JSONToSpaceParser::ReadASCIIChar()
int SpaceParser::ReadASCIIChar()
{
lastc = file.get();
@ -986,7 +986,7 @@ return lastc;
int JSONToSpaceParser::ReadCharFromWcharString()
int SpaceParser::ReadCharFromWcharString()
{
if( *pchar_unicode == 0 )
lastc = -1;
@ -1000,7 +1000,7 @@ return lastc;
}
int JSONToSpaceParser::ReadCharFromUTF8String()
int SpaceParser::ReadCharFromUTF8String()
{
int c;
bool correct;
@ -1025,7 +1025,7 @@ return lastc;
}
int JSONToSpaceParser::ReadCharFromAsciiString()
int SpaceParser::ReadCharFromAsciiString()
{
if( *pchar_ascii == 0 )
lastc = -1;
@ -1039,7 +1039,7 @@ return lastc;
}
int JSONToSpaceParser::ReadCharNoEscape()
int SpaceParser::ReadCharNoEscape()
{
if( reading_from_file )
{
@ -1064,7 +1064,7 @@ int JSONToSpaceParser::ReadCharNoEscape()
}
}
bool JSONToSpaceParser::IsHexDigit(wchar_t c)
bool SpaceParser::IsHexDigit(wchar_t c)
{
return ((c>='0' && c<='9') ||
(c>='a' && c<='f') ||
@ -1072,7 +1072,7 @@ bool JSONToSpaceParser::IsHexDigit(wchar_t c)
}
int JSONToSpaceParser::HexToInt(wchar_t c)
int SpaceParser::HexToInt(wchar_t c)
{
if( c>='0' && c<='9' )
return c - '0';
@ -1087,7 +1087,7 @@ return 0;
}
void JSONToSpaceParser::ReadUnicodeCodePoint()
void SpaceParser::ReadUnicodeCodePoint()
{
wchar_t c;
int value = 0;
@ -1109,7 +1109,7 @@ int value = 0;
}
int JSONToSpaceParser::ReadChar()
int SpaceParser::ReadChar()
{
char_was_escaped = false;
ReadCharNoEscape();

@ -49,7 +49,7 @@ namespace PT
class JSONToSpaceParser
class SpaceParser
{
public:
@ -57,7 +57,7 @@ public:
/*
ctor -- setting default values (SetDefault() method)
*/
JSONToSpaceParser();
SpaceParser();
/*
Loading…
Cancel
Save