changed: Pattern class has been split into two classes: Pattern and PatternParser
in Pattern we have only the tree
in PatternParser there is the whole logic used to parse a file
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@969 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
+18
-4
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2013, Tomasz Sowa
|
||||
* Copyright (c) 2007-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -222,6 +222,7 @@ private:
|
||||
const wchar_t * PrintSpecialChar(const wchar_t * start, const wchar_t * end);
|
||||
void PrintSpecialText(const wchar_t * start, const wchar_t * end);
|
||||
void PrintNormalText(const wchar_t * start, const wchar_t * end);
|
||||
bool IsWhite(wchar_t c);
|
||||
void TrimWhite(const wchar_t *& start, const wchar_t *& end);
|
||||
void SkipWhite(const wchar_t *& str);
|
||||
size_t StrToSize(const wchar_t * str, const wchar_t ** str_end = 0);
|
||||
@@ -886,13 +887,26 @@ void Generator<StreamType>::PrintNormalText(const wchar_t * start, const wchar_t
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType>
|
||||
bool Generator<StreamType>::IsWhite(wchar_t c)
|
||||
{
|
||||
// 13 (\r) is from a dos file at the end of a line (\r\n)
|
||||
// 160 is a non-breaking space
|
||||
|
||||
if( c==' ' || c=='\t' || c==13 || c==160 || c==10 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType>
|
||||
void Generator<StreamType>::TrimWhite(const wchar_t *& start, const wchar_t *& end)
|
||||
{
|
||||
while( start != end && pattern->IsWhite(*start) )
|
||||
while( start != end && IsWhite(*start) )
|
||||
++start;
|
||||
|
||||
while( start != end && pattern->IsWhite(*(end-1)) )
|
||||
while( start != end && IsWhite(*(end-1)) )
|
||||
--end;
|
||||
}
|
||||
|
||||
@@ -900,7 +914,7 @@ void Generator<StreamType>::TrimWhite(const wchar_t *& start, const wchar_t *& e
|
||||
template<class StreamType>
|
||||
void Generator<StreamType>::SkipWhite(const wchar_t *& str)
|
||||
{
|
||||
while( pattern->IsWhite(*str) )
|
||||
while( IsWhite(*str) )
|
||||
str += 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user