new config option: compression_encoding (integer) 1 - use deflate if available (or raw deflate for Internet Explorer) or don't compress 2 - use gzip if available or don't compress 10 - prefer deflate -- use deflate (or raw deflate for IE) if both deflate and gzip are available 20 - prefer gzip -- use gzip if both deflate and gzip are available default: 20 git-svn-id: svn://ttmath.org/publicrep/winix/trunk@727 e52654a7-88a9-db11-a3e9-0013d4bc506e
114 lines
1.4 KiB
C++
Executable File
114 lines
1.4 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "acceptbaseparser.h"
|
|
|
|
|
|
|
|
bool AcceptBaseParser::IsWhite(int c)
|
|
{
|
|
if( c==' ' || c=='\t' )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
void AcceptBaseParser::SkipWhite()
|
|
{
|
|
while( IsWhite(*text) )
|
|
++text;
|
|
}
|
|
|
|
|
|
void AcceptBaseParser::RemoveWhiteFromEnd(std::string & str)
|
|
{
|
|
if( str.empty() )
|
|
return;
|
|
|
|
size_t i = str.size() - 1;
|
|
|
|
for( ; i!=0 && IsWhite(str[i]) ; --i);
|
|
|
|
if( !IsWhite(str[i]) )
|
|
++i;
|
|
|
|
if( i < str.size() )
|
|
str.erase(i); // erasing until the end of the string
|
|
}
|
|
|
|
|
|
|
|
void AcceptBaseParser::ReadParameter()
|
|
{
|
|
param.clear();
|
|
|
|
SkipWhite();
|
|
|
|
while( *text!=0 && *text!=',' && *text!=';' )
|
|
{
|
|
param += *text;
|
|
++text;
|
|
}
|
|
|
|
RemoveWhiteFromEnd(param);
|
|
}
|
|
|
|
|
|
void AcceptBaseParser::ReadQ()
|
|
{
|
|
q = 1.0;
|
|
|
|
SkipWhite();
|
|
|
|
if( *text != ';' )
|
|
return;
|
|
|
|
++text; // skipping a semicolon
|
|
|
|
while( *text!=0 && *text!=',' && *text!='=' )
|
|
// skipping until ',' or '='
|
|
++text;
|
|
|
|
if( *text==0 || *text==',' )
|
|
return;
|
|
|
|
++text; // skipping '='
|
|
|
|
SkipWhite();
|
|
q = strtod(text, (char**)&text);
|
|
}
|
|
|
|
|
|
void AcceptBaseParser::SkipParam()
|
|
{
|
|
SkipWhite();
|
|
|
|
if( *text == ',' )
|
|
++text;
|
|
}
|
|
|
|
|
|
|
|
void AcceptBaseParser::Parse(const char * str)
|
|
{
|
|
text = str;
|
|
Init();
|
|
|
|
while( *text != 0 )
|
|
{
|
|
ReadParameter();
|
|
ReadQ();
|
|
SkipParam();
|
|
Param(param, q);
|
|
}
|
|
}
|
|
|
|
|