From cd3a1b853fd93b64d680fc4f1e843ca663550543 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Mon, 30 Apr 2012 13:10:55 +0000 Subject: [PATCH] changed: class name: ConfParser -> SpaceParser git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@402 e52654a7-88a9-db11-a3e9-0013d4bc506e --- Makefile | 10 +-- space/Makefile | 2 +- space/Makefile.dep | 2 +- space/Makefile.o.dep | 2 +- space/space.h | 4 +- space/{confparser.cpp => spaceparser.cpp} | 87 ++++++++++++----------- space/{confparser.h => spaceparser.h} | 4 +- 7 files changed, 56 insertions(+), 55 deletions(-) rename space/{confparser.cpp => spaceparser.cpp} (82%) rename space/{confparser.h => spaceparser.h} (99%) diff --git a/Makefile b/Makefile index 5353861..0f5d76a 100755 --- a/Makefile +++ b/Makefile @@ -13,10 +13,10 @@ export CXX export CXXFLAGS -all: confparser mainparser utf8 +all: space mainparser utf8 -confparser: FORCE - @cd confparser ; $(MAKE) -e +space: FORCE + @cd space ; $(MAKE) -e mainparser: FORCE @cd mainparser ; $(MAKE) -e @@ -29,11 +29,11 @@ FORCE: clean: - @cd confparser ; $(MAKE) -e clean + @cd space ; $(MAKE) -e clean @cd mainparser ; $(MAKE) -e clean @cd utf8 ; $(MAKE) -e clean depend: - @cd confparser ; $(MAKE) -e depend + @cd space ; $(MAKE) -e depend @cd mainparser ; $(MAKE) -e depend @cd utf8 ; $(MAKE) -e depend diff --git a/space/Makefile b/space/Makefile index 631c784..bc35b46 100755 --- a/space/Makefile +++ b/space/Makefile @@ -1,6 +1,6 @@ include Makefile.o.dep -libname=confparser.a +libname=space.a all: $(libname) diff --git a/space/Makefile.dep b/space/Makefile.dep index 5753f95..3272ebb 100755 --- a/space/Makefile.dep +++ b/space/Makefile.dep @@ -1,4 +1,4 @@ # DO NOT DELETE -confparser.o: confparser.h space.h ../utf8/utf8.h space.o: space.h ../utf8/utf8.h +spaceparser.o: ../utf8/utf8.h diff --git a/space/Makefile.o.dep b/space/Makefile.o.dep index 3bb09a2..2f519c5 100755 --- a/space/Makefile.o.dep +++ b/space/Makefile.o.dep @@ -1 +1 @@ -o = confparser.o space.o +o = space.o spaceparser.o diff --git a/space/space.h b/space/space.h index 67f2ee6..5cc2a67 100755 --- a/space/space.h +++ b/space/space.h @@ -58,10 +58,10 @@ A config file can look like this: variable4 = (" value 1 " , "value2", value 3) sample of use: - ConfParser parser; + SpaceParser parser; parser.Parse("/path/to/config"); - if( parser.status == ConfParser::ok ) + if( parser.status == SpaceParser::ok ) { // the whole config we have in parser.table (parser.table_single) } diff --git a/space/confparser.cpp b/space/spaceparser.cpp similarity index 82% rename from space/confparser.cpp rename to space/spaceparser.cpp index a5c7524..87124fa 100755 --- a/space/confparser.cpp +++ b/space/spaceparser.cpp @@ -46,26 +46,26 @@ namespace PT -ConfParser::ConfParser() +SpaceParser::SpaceParser() { root_space = 0; SetDefault(); } -void ConfParser::SetSpace(Space * pspace) +void SpaceParser::SetSpace(Space * pspace) { root_space = pspace; } -void ConfParser::SetSpace(Space & pspace) +void SpaceParser::SetSpace(Space & pspace) { root_space = &pspace; } -void ConfParser::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) @@ -82,25 +82,25 @@ void ConfParser::SetDefault() } -void ConfParser::SplitSingle(bool split) +void SpaceParser::SplitSingle(bool split) { split_single = split; } -void ConfParser::SkipEmpty(bool skip) +void SpaceParser::SkipEmpty(bool skip) { skip_empty = skip; } -void ConfParser::UseEscapeChar(bool escape) +void SpaceParser::UseEscapeChar(bool escape) { use_escape_char = escape; } -void ConfParser::UTF8(bool utf) +void SpaceParser::UTF8(bool utf) { input_as_utf8 = utf; } @@ -108,7 +108,7 @@ void ConfParser::UTF8(bool utf) -ConfParser::Status ConfParser::Parse(const char * file_name) +SpaceParser::Status SpaceParser::Parse(const char * file_name) { reading_from_file = true; @@ -130,7 +130,7 @@ return status; -ConfParser::Status ConfParser::Parse(const std::string & file_name) +SpaceParser::Status SpaceParser::Parse(const std::string & file_name) { return Parse(file_name.c_str()); } @@ -138,7 +138,7 @@ ConfParser::Status ConfParser::Parse(const std::string & file_name) -ConfParser::Status ConfParser::Parse(const wchar_t * file_name) +SpaceParser::Status SpaceParser::Parse(const wchar_t * file_name) { PT::WideToUTF8(file_name, afile_name); return Parse(afile_name.c_str()); @@ -146,14 +146,14 @@ ConfParser::Status ConfParser::Parse(const wchar_t * file_name) -ConfParser::Status ConfParser::Parse(const std::wstring & file_name) +SpaceParser::Status SpaceParser::Parse(const std::wstring & file_name) { return Parse(file_name.c_str()); } -ConfParser::Status ConfParser::ParseString(const char * str) +SpaceParser::Status SpaceParser::ParseString(const char * str) { reading_from_file = false; reading_from_wchar_string = false; @@ -166,13 +166,13 @@ return status; } -ConfParser::Status ConfParser::ParseString(const std::string & str) +SpaceParser::Status SpaceParser::ParseString(const std::string & str) { return ParseString(str.c_str()); } -ConfParser::Status ConfParser::ParseString(const wchar_t * str) +SpaceParser::Status SpaceParser::ParseString(const wchar_t * str) { reading_from_file = false; reading_from_wchar_string = true; @@ -185,13 +185,13 @@ return status; } -ConfParser::Status ConfParser::ParseString(const std::wstring & str) +SpaceParser::Status SpaceParser::ParseString(const std::wstring & str) { return ParseString(str.c_str()); } -void ConfParser::Parse() +void SpaceParser::Parse() { if( !root_space ) { @@ -215,7 +215,7 @@ void ConfParser::Parse() } -void ConfParser::ParseLoop() +void SpaceParser::ParseLoop() { while( status == ok && lastc != -1 ) { @@ -248,7 +248,7 @@ void ConfParser::ParseLoop() } -void ConfParser::SpaceEnds() +void SpaceParser::SpaceEnds() { if( space == root_space ) { @@ -263,7 +263,7 @@ void ConfParser::SpaceEnds() } -void ConfParser::SpaceStarts() +void SpaceParser::SpaceStarts() { Space * new_space = new Space(); space->spaces.push_back(new_space); @@ -275,7 +275,7 @@ void ConfParser::SpaceStarts() } -void ConfParser::ReadAddValue() +void SpaceParser::ReadAddValue() { ReadChar(); // skipping separator '=' @@ -290,7 +290,7 @@ void ConfParser::ReadAddValue() } -bool ConfParser::IsVariableChar(int c) +bool SpaceParser::IsVariableChar(int c) { if( (c>='a' && c<='z') || (c>='A' && c<='Z') || @@ -302,7 +302,7 @@ return false; } -bool ConfParser::IsWhite(int c) +bool SpaceParser::IsWhite(int c) { // dont use '\n' here // 13 (\r) is at the end of a line in a dos file \r\n @@ -315,7 +315,7 @@ return false; -void ConfParser::SkipWhite() +void SpaceParser::SkipWhite() { while( IsWhite(lastc) || lastc == commentary ) { @@ -327,7 +327,7 @@ void ConfParser::SkipWhite() } -void ConfParser::SkipWhiteLines() +void SpaceParser::SkipWhiteLines() { while( IsWhite(lastc) || lastc == commentary || lastc=='\n' ) { @@ -339,7 +339,7 @@ void ConfParser::SkipWhiteLines() } -void ConfParser::SkipLine() +void SpaceParser::SkipLine() { while( lastc != -1 && lastc != '\n' ) ReadChar(); @@ -347,7 +347,7 @@ void ConfParser::SkipLine() -void ConfParser::Trim(std::wstring & s) +void SpaceParser::Trim(std::wstring & s) { std::wstring::size_type i; @@ -380,7 +380,7 @@ std::wstring::size_type i; -void ConfParser::AddOption() +void SpaceParser::AddOption() { if( value.empty() && skip_empty ) { @@ -403,7 +403,7 @@ void ConfParser::AddOption() -void ConfParser::DeleteFromTable(const std::wstring & var) +void SpaceParser::DeleteFromTable(const std::wstring & var) { Space::Table::iterator i = space->table.find(var); @@ -413,7 +413,7 @@ void ConfParser::DeleteFromTable(const std::wstring & var) -void ConfParser::DeleteFromTableSingle(const std::wstring & var) +void SpaceParser::DeleteFromTableSingle(const std::wstring & var) { Space::TableSingle::iterator i = space->table_single.find(var); @@ -423,7 +423,7 @@ void ConfParser::DeleteFromTableSingle(const std::wstring & var) -void ConfParser::ReadVariable() +void SpaceParser::ReadVariable() { variable.clear(); SkipWhite(); @@ -439,7 +439,7 @@ void ConfParser::ReadVariable() -bool ConfParser::ReadValue() +bool SpaceParser::ReadValue() { value.clear(); SkipWhite(); @@ -452,7 +452,7 @@ bool ConfParser::ReadValue() -bool ConfParser::ReadValueList() +bool SpaceParser::ReadValueList() { ReadChar(); // skipping first list character '(' SkipWhiteLines(); // lists can be split into several lines @@ -479,7 +479,7 @@ return true; -bool ConfParser::ReadValueNoList(bool use_list_delimiter) +bool SpaceParser::ReadValueNoList(bool use_list_delimiter) { bool res; @@ -505,11 +505,12 @@ return res; -bool ConfParser::ReadValueQuoted() +bool SpaceParser::ReadValueQuoted() { ReadChar(); // skipping the first quote -// !! dodac obsluge innych escapowanych znakow w szczegolnosci \0 (serializator Space juz tak zapisuje) + // !! IMPROVE ME + // add some other escaped characters especialy \0 (the serializator is working that way now) while( lastc != '"' && lastc != -1 ) { @@ -531,7 +532,7 @@ return true; -bool ConfParser::ReadValueSimple(bool use_list_delimiter) +bool SpaceParser::ReadValueSimple(bool use_list_delimiter) { int list_delimiter1 = -1; int list_delimiter2 = -1; @@ -556,7 +557,7 @@ return true; } -int ConfParser::ReadUTF8Char() +int SpaceParser::ReadUTF8Char() { int c; bool correct; @@ -582,7 +583,7 @@ return lastc; -int ConfParser::ReadASCIIChar() +int SpaceParser::ReadASCIIChar() { lastc = file.get(); @@ -595,7 +596,7 @@ return lastc; -int ConfParser::ReadCharFromWcharString() +int SpaceParser::ReadCharFromWcharString() { if( *pchar_unicode == 0 ) lastc = -1; @@ -609,7 +610,7 @@ return lastc; } -int ConfParser::ReadCharFromUTF8String() +int SpaceParser::ReadCharFromUTF8String() { int c; bool correct; @@ -636,7 +637,7 @@ return lastc; } -int ConfParser::ReadCharFromAsciiString() +int SpaceParser::ReadCharFromAsciiString() { if( *pchar_ascii == 0 ) lastc = -1; @@ -650,7 +651,7 @@ return lastc; } -int ConfParser::ReadChar() +int SpaceParser::ReadChar() { if( reading_from_file ) { diff --git a/space/confparser.h b/space/spaceparser.h similarity index 99% rename from space/confparser.h rename to space/spaceparser.h index 9dcf00b..6d4d71f 100755 --- a/space/confparser.h +++ b/space/spaceparser.h @@ -48,7 +48,7 @@ namespace PT -class ConfParser +class SpaceParser { public: @@ -56,7 +56,7 @@ public: /* ctor -- setting default values (SetDefault() method) */ - ConfParser(); + SpaceParser(); /*