Moved 'static' functions into 'parserHelpers' class.
This commit is contained in:
parent
81b11364ed
commit
95b56a7035
@ -2,6 +2,10 @@
|
|||||||
VERSION 0.6.4cvs
|
VERSION 0.6.4cvs
|
||||||
================
|
================
|
||||||
|
|
||||||
|
2005-02-05 Vincent Richard <vincent@vincent-richard.net>
|
||||||
|
|
||||||
|
* parserHelpers.hpp: moved 'static' functions into 'parserHelpers' class.
|
||||||
|
|
||||||
2005-02-05 Vincent Richard <vincent@vincent-richard.net>
|
2005-02-05 Vincent Richard <vincent@vincent-richard.net>
|
||||||
|
|
||||||
* platforms/posix/posixHandler.cpp: removed extra '::' before
|
* platforms/posix/posixHandler.cpp: removed extra '::' before
|
||||||
|
@ -74,7 +74,7 @@ address* address::parseNext(const string& buffer, const string::size_type positi
|
|||||||
|
|
||||||
string::size_type pos = position;
|
string::size_type pos = position;
|
||||||
|
|
||||||
while (pos < end && isspace(buffer[pos]))
|
while (pos < end && parserHelpers::isspace(buffer[pos]))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
const string::size_type start = pos;
|
const string::size_type start = pos;
|
||||||
|
@ -109,7 +109,7 @@ void body::parse(const string& buffer, const string::size_type position,
|
|||||||
// characters from a set of characters known to be very
|
// characters from a set of characters known to be very
|
||||||
// robust through email gateways, and NOT ending with
|
// robust through email gateways, and NOT ending with
|
||||||
// white space..."
|
// white space..."
|
||||||
while (pos != start && isspace(buffer[pos - 1]))
|
while (pos != start && parserHelpers::isspace(buffer[pos - 1]))
|
||||||
--pos;
|
--pos;
|
||||||
|
|
||||||
boundary = string(buffer.begin() + start,
|
boundary = string(buffer.begin() + start,
|
||||||
|
@ -70,22 +70,22 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
const string::value_type* p = buffer.data() + position;
|
const string::value_type* p = buffer.data() + position;
|
||||||
|
|
||||||
// Parse the date and time value
|
// Parse the date and time value
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend)
|
if (p < pend)
|
||||||
{
|
{
|
||||||
if (isalpha(*p))
|
if (parserHelpers::isalpha(*p))
|
||||||
{
|
{
|
||||||
// Ignore week day
|
// Ignore week day
|
||||||
while (p < pend && isalpha(*p)) ++p;
|
while (p < pend && parserHelpers::isalpha(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
if (p < pend && *p == ',') ++p;
|
if (p < pend && *p == ',') ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p < pend && !isdigit(*p)) ++p;
|
while (p < pend && !parserHelpers::isdigit(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend && isdigit(*p))
|
if (p < pend && parserHelpers::isdigit(*p))
|
||||||
{
|
{
|
||||||
// Month day
|
// Month day
|
||||||
int day = 0;
|
int day = 0;
|
||||||
@ -95,23 +95,23 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
day = day * 10 + (*p - '0');
|
day = day * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
m_day = (day >= 1 && day <= 31) ? day : 1;
|
m_day = (day >= 1 && day <= 31) ? day : 1;
|
||||||
|
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_day = 1;
|
m_day = 1;
|
||||||
|
|
||||||
// Skip everything to the next field
|
// Skip everything to the next field
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p < pend && isalpha(*p))
|
if (p < pend && parserHelpers::isalpha(*p))
|
||||||
{
|
{
|
||||||
// Month
|
// Month
|
||||||
char_t month[4] = { 0 };
|
char_t month[4] = { 0 };
|
||||||
@ -122,9 +122,9 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
month[monthLength++] = *p;
|
month[monthLength++] = *p;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (monthLength < 3 && p < pend && isalpha(*p));
|
while (monthLength < 3 && p < pend && parserHelpers::isalpha(*p));
|
||||||
|
|
||||||
while (p < pend && isalpha(*p)) ++p;
|
while (p < pend && parserHelpers::isalpha(*p)) ++p;
|
||||||
|
|
||||||
switch (month[0])
|
switch (month[0])
|
||||||
{
|
{
|
||||||
@ -208,19 +208,19 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_month = JANUARY;
|
m_month = JANUARY;
|
||||||
|
|
||||||
// Skip everything to the next field
|
// Skip everything to the next field
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p < pend && isdigit(*p))
|
if (p < pend && parserHelpers::isdigit(*p))
|
||||||
{
|
{
|
||||||
// Year
|
// Year
|
||||||
int year = 0;
|
int year = 0;
|
||||||
@ -230,25 +230,25 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
year = year * 10 + (*p - '0');
|
year = year * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
if (year < 70) m_year = year + 2000;
|
if (year < 70) m_year = year + 2000;
|
||||||
else if (year < 1000) m_year = year + 1900;
|
else if (year < 1000) m_year = year + 1900;
|
||||||
else m_year = year;
|
else m_year = year;
|
||||||
|
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_year = 1970;
|
m_year = 1970;
|
||||||
|
|
||||||
// Skip everything to the next field
|
// Skip everything to the next field
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p < pend && isdigit(*p))
|
if (p < pend && parserHelpers::isdigit(*p))
|
||||||
{
|
{
|
||||||
// Hour
|
// Hour
|
||||||
int hour = 0;
|
int hour = 0;
|
||||||
@ -258,19 +258,19 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
hour = hour * 10 + (*p - '0');
|
hour = hour * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
m_hour = (hour >= 0 && hour <= 23) ? hour : 0;
|
m_hour = (hour >= 0 && hour <= 23) ? hour : 0;
|
||||||
|
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend && *p == ':')
|
if (p < pend && *p == ':')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend && isdigit(*p))
|
if (p < pend && parserHelpers::isdigit(*p))
|
||||||
{
|
{
|
||||||
// Minute
|
// Minute
|
||||||
int minute = 0;
|
int minute = 0;
|
||||||
@ -280,19 +280,19 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
minute = minute * 10 + (*p - '0');
|
minute = minute * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
m_minute = (minute >= 0 && minute <= 59) ? minute : 0;
|
m_minute = (minute >= 0 && minute <= 59) ? minute : 0;
|
||||||
|
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend && *p == ':')
|
if (p < pend && *p == ':')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend && isdigit(*p))
|
if (p < pend && parserHelpers::isdigit(*p))
|
||||||
{
|
{
|
||||||
// Second
|
// Second
|
||||||
int second = 0;
|
int second = 0;
|
||||||
@ -302,12 +302,12 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
second = second * 10 + (*p - '0');
|
second = second * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
m_second = (second >= 0 && second <= 59) ? second : 0;
|
m_second = (second >= 0 && second <= 59) ? second : 0;
|
||||||
|
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -334,11 +334,11 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
m_hour = 0;
|
m_hour = 0;
|
||||||
|
|
||||||
// Skip everything to the next field
|
// Skip everything to the next field
|
||||||
while (p < pend && !isspace(*p)) ++p;
|
while (p < pend && !parserHelpers::isspace(*p)) ++p;
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p + 1 < pend && (*p == '+' || *p == '-') && isdigit(*(p + 1)))
|
if (p + 1 < pend && (*p == '+' || *p == '-') && parserHelpers::isdigit(*(p + 1)))
|
||||||
{
|
{
|
||||||
const char_t sign = *p;
|
const char_t sign = *p;
|
||||||
++p;
|
++p;
|
||||||
@ -351,7 +351,7 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
offset = offset * 10 + (*p - '0');
|
offset = offset * 10 + (*p - '0');
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (p < pend && isdigit(*p));
|
while (p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
const int hourOff = offset / 100;
|
const int hourOff = offset / 100;
|
||||||
const int minOff = offset % 100;
|
const int minOff = offset % 100;
|
||||||
@ -374,7 +374,7 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
zone[zoneLength++] = *p;
|
zone[zoneLength++] = *p;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
while (zoneLength < 3 && p < pend && isdigit(*p));
|
while (zoneLength < 3 && p < pend && parserHelpers::isdigit(*p));
|
||||||
|
|
||||||
switch (zone[0])
|
switch (zone[0])
|
||||||
{
|
{
|
||||||
@ -495,7 +495,7 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
|||||||
::vmime::end(offsetMapInit));
|
::vmime::end(offsetMapInit));
|
||||||
|
|
||||||
Map::const_iterator pos =
|
Map::const_iterator pos =
|
||||||
offsetMap.find(tolower(z));
|
offsetMap.find(parserHelpers::tolower(z));
|
||||||
|
|
||||||
if (pos != offsetMap.end())
|
if (pos != offsetMap.end())
|
||||||
m_zone = (*pos).second;
|
m_zone = (*pos).second;
|
||||||
|
@ -205,7 +205,7 @@ const utility::stream::size_type encoderB64::decode(utility::inputStream& in, ut
|
|||||||
{
|
{
|
||||||
const unsigned char c = buffer[bufferPos++];
|
const unsigned char c = buffer[bufferPos++];
|
||||||
|
|
||||||
if (!isspace(c))
|
if (!parserHelpers::isspace(c))
|
||||||
bytes[count++] = c;
|
bytes[count++] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ const utility::stream::size_type encoderB64::decode(utility::inputStream& in, ut
|
|||||||
{
|
{
|
||||||
const unsigned char c = buffer[bufferPos++];
|
const unsigned char c = buffer[bufferPos++];
|
||||||
|
|
||||||
if (!isspace(c))
|
if (!parserHelpers::isspace(c))
|
||||||
bytes[count++] = c;
|
bytes[count++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ const utility::stream::size_type encoderUUE::decode(utility::inputStream& in, ut
|
|||||||
inBuffer[1] == 'g' &&
|
inBuffer[1] == 'g' &&
|
||||||
inBuffer[2] == 'i' &&
|
inBuffer[2] == 'i' &&
|
||||||
inBuffer[3] == 'n' &&
|
inBuffer[3] == 'n' &&
|
||||||
isspace(inBuffer[4]))
|
parserHelpers::isspace(inBuffer[4]))
|
||||||
{
|
{
|
||||||
utility::stream::value_type c = 0;
|
utility::stream::value_type c = 0;
|
||||||
|
|
||||||
@ -201,15 +201,15 @@ const utility::stream::size_type encoderUUE::decode(utility::inputStream& in, ut
|
|||||||
|
|
||||||
utility::stream::value_type* p = buffer;
|
utility::stream::value_type* p = buffer;
|
||||||
|
|
||||||
while (*p && isspace(*p)) ++p;
|
while (*p && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
utility::stream::value_type* modeStart = buffer;
|
utility::stream::value_type* modeStart = buffer;
|
||||||
|
|
||||||
while (*p && !isspace(*p)) ++p;
|
while (*p && !parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
getResults()["mode"] = string(modeStart, p);
|
getResults()["mode"] = string(modeStart, p);
|
||||||
|
|
||||||
while (*p && isspace(*p)) ++p;
|
while (*p && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
utility::stream::value_type* filenameStart = buffer;
|
utility::stream::value_type* filenameStart = buffer;
|
||||||
|
|
||||||
|
@ -81,16 +81,16 @@ void header::parse(const string& buffer, const string::size_type position,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This line may be a field description
|
// This line may be a field description
|
||||||
if (!isspace(c))
|
if (!parserHelpers::isspace(c))
|
||||||
{
|
{
|
||||||
const string::size_type nameStart = pos; // remember the start position of the line
|
const string::size_type nameStart = pos; // remember the start position of the line
|
||||||
|
|
||||||
while (pos < end && (buffer[pos] != ':' && !isspace(buffer[pos])))
|
while (pos < end && (buffer[pos] != ':' && !parserHelpers::isspace(buffer[pos])))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
const string::size_type nameEnd = pos;
|
const string::size_type nameEnd = pos;
|
||||||
|
|
||||||
while (pos < end && isspace(buffer[pos]))
|
while (pos < end && parserHelpers::isspace(buffer[pos]))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
if (buffer[pos] != ':')
|
if (buffer[pos] != ':')
|
||||||
|
@ -69,7 +69,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
const string::value_type* p = pstart;
|
const string::value_type* p = pstart;
|
||||||
|
|
||||||
// Ignore blank spaces at the beginning
|
// Ignore blank spaces at the beginning
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
// Current state for parsing machine
|
// Current state for parsing machine
|
||||||
enum States
|
enum States
|
||||||
@ -161,12 +161,12 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
{
|
{
|
||||||
// Erase any space between display name and <address>
|
// Erase any space between display name and <address>
|
||||||
string::iterator q = name.end();
|
string::iterator q = name.end();
|
||||||
for ( ; q != name.begin() && isspace(*(q - 1)) ; --q);
|
for ( ; q != name.begin() && parserHelpers::isspace(*(q - 1)) ; --q);
|
||||||
name.erase(q, name.end());
|
name.erase(q, name.end());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (/* isspace(*p) || */ *p == '@')
|
else if (/* parserHelpers::isspace(*p) || */ *p == '@')
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
{
|
{
|
||||||
++comment;
|
++comment;
|
||||||
}
|
}
|
||||||
else if (isspace(*p))
|
else if (parserHelpers::isspace(*p))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
state = State_None;
|
state = State_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!isspace(*p))
|
else if (!parserHelpers::isspace(*p))
|
||||||
{
|
{
|
||||||
address += *p;
|
address += *p;
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
if (p < pend)
|
if (p < pend)
|
||||||
{
|
{
|
||||||
@ -310,7 +310,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
|
|
||||||
for (string::size_type i = 0 ; i < name.size() ; ++i)
|
for (string::size_type i = 0 ; i < name.size() ; ++i)
|
||||||
{
|
{
|
||||||
if (!isspace(name[i]))
|
if (!parserHelpers::isspace(name[i]))
|
||||||
m_email += name[i];
|
m_email += name[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
|||||||
|
|
||||||
for (string::size_type i = 0 ; i < address.size() ; ++i)
|
for (string::size_type i = 0 ; i < address.size() ; ++i)
|
||||||
{
|
{
|
||||||
if (!isspace(address[i]))
|
if (!parserHelpers::isspace(address[i]))
|
||||||
m_email += address[i];
|
m_email += address[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void mailboxGroup::parse(const string& buffer, const string::size_type position,
|
|||||||
const string::value_type* const pstart = buffer.data() + position;
|
const string::value_type* const pstart = buffer.data() + position;
|
||||||
const string::value_type* p = pstart;
|
const string::value_type* p = pstart;
|
||||||
|
|
||||||
while (p < pend && isspace(*p))
|
while (p < pend && parserHelpers::isspace(*p))
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
|
@ -206,7 +206,7 @@ void url::parse(const string& str)
|
|||||||
for (string::const_iterator it = port.begin() ;
|
for (string::const_iterator it = port.begin() ;
|
||||||
onlyDigit && it != port.end() ; ++it)
|
onlyDigit && it != port.end() ; ++it)
|
||||||
{
|
{
|
||||||
onlyDigit = isdigit(*it);
|
onlyDigit = parserHelpers::isdigit(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!onlyDigit)
|
if (!onlyDigit)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "vmime/messaging/urlUtils.hpp"
|
#include "vmime/messaging/urlUtils.hpp"
|
||||||
|
#include "vmime/parserHelpers.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace vmime {
|
namespace vmime {
|
||||||
@ -33,7 +34,7 @@ const string urlUtils::encode(const string& s)
|
|||||||
{
|
{
|
||||||
const char_t c = *it;
|
const char_t c = *it;
|
||||||
|
|
||||||
if (isprint(c) && c != '%')
|
if (parserHelpers::isprint(c) && c != '%')
|
||||||
{
|
{
|
||||||
result += c;
|
result += c;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
|
|||||||
// Skip ';'
|
// Skip ';'
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
const string::size_type attrStart = position + (p - pstart);
|
const string::size_type attrStart = position + (p - pstart);
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
|
|||||||
// Extract the attribute name
|
// Extract the attribute name
|
||||||
string::size_type attrEnd = position + (p - pstart);
|
string::size_type attrEnd = position + (p - pstart);
|
||||||
|
|
||||||
while (attrEnd != attrStart && isspace(buffer[attrEnd - 1]))
|
while (attrEnd != attrStart && parserHelpers::isspace(buffer[attrEnd - 1]))
|
||||||
--attrEnd;
|
--attrEnd;
|
||||||
|
|
||||||
// Skip '='
|
// Skip '='
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
// Skip white-spaces between '=' and the value
|
// Skip white-spaces between '=' and the value
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
|
|
||||||
// Extract the value
|
// Extract the value
|
||||||
string value;
|
string value;
|
||||||
@ -173,7 +173,7 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
|
|||||||
|
|
||||||
string::size_type valEnd = position + (p - pstart);
|
string::size_type valEnd = position + (p - pstart);
|
||||||
|
|
||||||
while (valEnd != valStart && isspace(buffer[valEnd - 1]))
|
while (valEnd != valStart && parserHelpers::isspace(buffer[valEnd - 1]))
|
||||||
--valEnd;
|
--valEnd;
|
||||||
|
|
||||||
value = string(buffer.begin() + valStart,
|
value = string(buffer.begin() + valStart,
|
||||||
@ -190,7 +190,7 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip white-spaces after this parameter
|
// Skip white-spaces after this parameter
|
||||||
while (p < pend && isspace(*p)) ++p;
|
while (p < pend && parserHelpers::isspace(*p)) ++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "vmime/propertySet.hpp"
|
#include "vmime/propertySet.hpp"
|
||||||
|
#include "vmime/parserHelpers.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace vmime
|
namespace vmime
|
||||||
@ -92,7 +93,7 @@ void propertySet::parse(const string& props)
|
|||||||
for ( ; pos != end ; )
|
for ( ; pos != end ; )
|
||||||
{
|
{
|
||||||
// Skip white-spaces
|
// Skip white-spaces
|
||||||
for ( ; pos != end && isspace(*pos) ; ++pos);
|
for ( ; pos != end && parserHelpers::isspace(*pos) ; ++pos);
|
||||||
|
|
||||||
if (pos != end)
|
if (pos != end)
|
||||||
{
|
{
|
||||||
@ -109,7 +110,7 @@ void propertySet::parse(const string& props)
|
|||||||
|
|
||||||
string::const_iterator optEnd = pos;
|
string::const_iterator optEnd = pos;
|
||||||
|
|
||||||
for ( ; optEnd != optStart && isspace(*(optEnd - 1)) ; --optEnd);
|
for ( ; optEnd != optStart && parserHelpers::isspace(*(optEnd - 1)) ; --optEnd);
|
||||||
|
|
||||||
const string option(optStart, optEnd);
|
const string option(optStart, optEnd);
|
||||||
string value = "1";
|
string value = "1";
|
||||||
@ -119,7 +120,7 @@ void propertySet::parse(const string& props)
|
|||||||
++pos; // skip '='
|
++pos; // skip '='
|
||||||
|
|
||||||
// Extract the value
|
// Extract the value
|
||||||
for ( ; pos != end && isspace(*pos) ; ++pos);
|
for ( ; pos != end && parserHelpers::isspace(*pos) ; ++pos);
|
||||||
|
|
||||||
if (pos != end)
|
if (pos != end)
|
||||||
{
|
{
|
||||||
@ -158,7 +159,7 @@ void propertySet::parse(const string& props)
|
|||||||
{
|
{
|
||||||
const string::const_iterator valStart = pos;
|
const string::const_iterator valStart = pos;
|
||||||
|
|
||||||
for ( ; pos != end && !isspace(*pos) ; ++pos);
|
for ( ; pos != end && !parserHelpers::isspace(*pos) ; ++pos);
|
||||||
|
|
||||||
value = string(valStart, pos);
|
value = string(valStart, pos);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ text* text::newFromString(const string& in, const charset& ch, text* generateInE
|
|||||||
|
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
if (p == end || isspace(*p))
|
if (p == end || parserHelpers::isspace(*p))
|
||||||
{
|
{
|
||||||
if (p != end)
|
if (p != end)
|
||||||
++p;
|
++p;
|
||||||
@ -309,7 +309,7 @@ text* text::newFromString(const string& in, const charset& ch, text* generateInE
|
|||||||
is8bit = false;
|
is8bit = false;
|
||||||
start = p;
|
start = p;
|
||||||
}
|
}
|
||||||
else if (!isascii(*p))
|
else if (!parserHelpers::isascii(*p))
|
||||||
{
|
{
|
||||||
is8bit = true;
|
is8bit = true;
|
||||||
++p;
|
++p;
|
||||||
@ -784,7 +784,7 @@ void text::decodeAndUnfold(const string::const_iterator& inStart, const string::
|
|||||||
{
|
{
|
||||||
// Check whether there are only white-spaces between
|
// Check whether there are only white-spaces between
|
||||||
// the two encoded words
|
// the two encoded words
|
||||||
for ( ; (p != wordPos) && isspace(*p) ; ++p);
|
for ( ; (p != wordPos) && parserHelpers::isspace(*p) ; ++p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != wordPos) // if not empty
|
if (p != wordPos) // if not empty
|
||||||
|
@ -94,8 +94,8 @@ const string stringUtils::trim(const string& str)
|
|||||||
|
|
||||||
if (b != e)
|
if (b != e)
|
||||||
{
|
{
|
||||||
for ( ; b != e && isspace(*b) ; ++b);
|
for ( ; b != e && parserHelpers::isspace(*b) ; ++b);
|
||||||
for ( ; e != b && isspace(*(e - 1)) ; --e);
|
for ( ; e != b && parserHelpers::isspace(*(e - 1)) ; --e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string(b, e));
|
return (string(b, e));
|
||||||
@ -109,7 +109,7 @@ const string::size_type stringUtils::countASCIIchars
|
|||||||
|
|
||||||
for (string::const_iterator i = begin ; i != end ; ++i)
|
for (string::const_iterator i = begin ; i != end ; ++i)
|
||||||
{
|
{
|
||||||
if (isascii(*i))
|
if (parserHelpers::isascii(*i))
|
||||||
{
|
{
|
||||||
if (*i != '=' || *(i + 1) != '?') // To avoid bad behaviour...
|
if (*i != '=' || *(i + 1) != '?') // To avoid bad behaviour...
|
||||||
++count;
|
++count;
|
||||||
|
@ -32,49 +32,54 @@ namespace vmime
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
inline const bool isspace(const char_t c)
|
class parserHelpers
|
||||||
{
|
{
|
||||||
return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
|
public:
|
||||||
}
|
|
||||||
|
static const bool isspace(const char_t c)
|
||||||
|
{
|
||||||
|
return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const bool isdigit(const char_t c)
|
static const bool isdigit(const char_t c)
|
||||||
{
|
{
|
||||||
return (c >= '0' && c <= '9');
|
return (c >= '0' && c <= '9');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const bool isalpha(const char_t c)
|
static const bool isalpha(const char_t c)
|
||||||
{
|
{
|
||||||
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
|
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const char_t tolower(const char_t c)
|
static const char_t tolower(const char_t c)
|
||||||
{
|
{
|
||||||
if (c >= 'A' && c <= 'Z')
|
if (c >= 'A' && c <= 'Z')
|
||||||
return ('a' + (c - 'A'));
|
return ('a' + (c - 'A'));
|
||||||
else
|
else
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks whether a character is in the 7-bit US-ASCII charset
|
// Checks whether a character is in the 7-bit US-ASCII charset
|
||||||
|
|
||||||
inline const bool isascii(const char_t c)
|
static const bool isascii(const char_t c)
|
||||||
{
|
{
|
||||||
const unsigned int x = static_cast <unsigned int>(c);
|
const unsigned int x = static_cast <unsigned int>(c);
|
||||||
return (x <= 127);
|
return (x <= 127);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks whether a character has a visual representation
|
// Checks whether a character has a visual representation
|
||||||
|
|
||||||
inline const bool isprint(const char_t c)
|
static const bool isprint(const char_t c)
|
||||||
{
|
{
|
||||||
const unsigned int x = static_cast <unsigned int>(c);
|
const unsigned int x = static_cast <unsigned int>(c);
|
||||||
return (x >= 0x20 && x <= 0x7E);
|
return (x >= 0x20 && x <= 0x7E);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // vmime
|
} // vmime
|
||||||
|
Loading…
Reference in New Issue
Block a user