added: Patterns class (in templates)

ezc patterns are managed by this class
added: some work in groupitem plugin (not finished yet)
changed: ConfParser can read a string from memory now
         (need some testing yet)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@757 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-08-25 23:53:49 +00:00
parent ee6500ac65
commit 5b8a9c0108
46 changed files with 2896 additions and 1715 deletions

View File

@@ -60,6 +60,7 @@ void ConfParser::UseEscapeChar(bool escape)
ConfParser::Status ConfParser::Parse(const char * file_name)
{
reading_from_file = true;
line = 1;
table.clear();
table_single.clear();
@@ -105,6 +106,49 @@ ConfParser::Status ConfParser::Parse(const std::wstring & file_name)
ConfParser::Status ConfParser::ParseString(const char * str)
{
reading_from_file = false;
reading_from_wchar_string = false;
line = 1;
table.clear();
table_single.clear();
pchar_ascii = str;
pchar_unicode = 0;
status = ParseFile();
return status;
}
ConfParser::Status ConfParser::ParseString(const std::string & str)
{
return ParseString(str.c_str());
}
ConfParser::Status ConfParser::ParseString(const wchar_t * str)
{
reading_from_file = false;
reading_from_wchar_string = true;
line = 1;
table.clear();
table_single.clear();
pchar_ascii = 0;
pchar_unicode = str;
status = ParseFile();
return status;
}
ConfParser::Status ConfParser::ParseString(const std::wstring & str)
{
return ParseString(str.c_str());
}
ConfParser::Status ConfParser::ParseFile()
{
@@ -363,12 +407,86 @@ return lastc;
}
int ConfParser::ReadCharFromWcharString()
{
if( *pchar_unicode == 0 )
lastc = -1;
else
lastc = *(pchar_unicode++);
if( lastc == '\n' )
++line;
return lastc;
}
int ConfParser::ReadCharFromUTF8String()
{
int c;
bool correct;
lastc = -1;
do
{
size_t len = Ezc::UTF8ToInt(pchar_ascii, c, correct);
pchar_ascii += len;
if( *pchar_ascii == 0 )
return lastc;
}
while( !correct );
lastc = c;
if( lastc == '\n' )
++line;
return lastc;
}
int ConfParser::ReadCharFromAsciiString()
{
if( *pchar_ascii == 0 )
lastc = -1;
else
lastc = *(pchar_ascii++);
if( lastc == '\n' )
++line;
return lastc;
}
int ConfParser::ReadChar()
{
if( input_as_utf8 )
return ReadUTF8Char();
return ReadASCIIChar();
if( reading_from_file )
{
if( input_as_utf8 )
return ReadUTF8Char();
else
return ReadASCIIChar();
}
else
{
if( reading_from_wchar_string )
{
return ReadCharFromWcharString();
}
else
{
if( input_as_utf8 )
return ReadCharFromUTF8String();
else
return ReadCharFromAsciiString();
}
}
}