added support for hex strings and binary strings
added FT::hexadecimal, FT::binary and FT::dont_use_utf8
This commit is contained in:
@@ -318,71 +318,95 @@ void BaseExpression::after_second_part_long_field_name()
|
||||
|
||||
|
||||
|
||||
void BaseExpression::before_field_value(const std::wstring &)
|
||||
void BaseExpression::before_field_value(const std::wstring &, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::before_field_value(const std::string &)
|
||||
void BaseExpression::before_field_value(const std::string &, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::after_field_value(const std::wstring &)
|
||||
void BaseExpression::after_field_value(const std::wstring &, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::after_field_value(const std::string &)
|
||||
void BaseExpression::after_field_value(const std::string &, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::before_field_value(const wchar_t *)
|
||||
void BaseExpression::before_field_value(const wchar_t *, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::after_field_value(const wchar_t *)
|
||||
void BaseExpression::after_field_value(const wchar_t *, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::before_field_value(const char *)
|
||||
void BaseExpression::before_field_value(const char *, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::after_field_value(const char *)
|
||||
void BaseExpression::after_field_value(const char *, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::before_field_value(const PT::Date &)
|
||||
|
||||
void BaseExpression::before_field_value(wchar_t, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::after_field_value(const PT::Date &)
|
||||
|
||||
void BaseExpression::after_field_value(wchar_t, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::before_field_value(const PT::Space &)
|
||||
|
||||
void BaseExpression::before_field_value(char, FT field_type)
|
||||
{
|
||||
before_field_value_string();
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::after_field_value(const PT::Space &)
|
||||
|
||||
void BaseExpression::after_field_value(char, FT field_type)
|
||||
{
|
||||
after_field_value_string();
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::before_field_value(const PT::Date &, FT field_type)
|
||||
{
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::after_field_value(const PT::Date &, FT field_type)
|
||||
{
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::before_field_value(const PT::Space &, FT field_type)
|
||||
{
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
void BaseExpression::after_field_value(const PT::Space &, FT field_type)
|
||||
{
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -392,82 +416,120 @@ void BaseExpression::put_name_value_separator()
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(char val, PT::TextStream & stream)
|
||||
char BaseExpression::char_to_hex_part(char c)
|
||||
{
|
||||
stream << val;
|
||||
if( c < 10 )
|
||||
return c + '0';
|
||||
|
||||
return c - 10 + 'A';
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned char val, PT::TextStream & stream)
|
||||
void BaseExpression::char_to_hex(char c, PT::TextStream & stream)
|
||||
{
|
||||
esc(static_cast<char>(val), stream);
|
||||
stream << char_to_hex_part(((unsigned char)c) >> 4);
|
||||
stream << char_to_hex_part(((unsigned char)c) & 0x0f);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(wchar_t val, PT::TextStream & stream)
|
||||
|
||||
|
||||
void BaseExpression::esc(char val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
char utf8_buf[10];
|
||||
|
||||
size_t utf8_len = PT::IntToUTF8((int)val, utf8_buf, sizeof(utf8_buf));
|
||||
|
||||
for(size_t a = 0 ; a < utf8_len ; ++a)
|
||||
if( field_type.is_binary() || field_type.is_hexadecimal() )
|
||||
{
|
||||
esc(utf8_buf[a], stream);
|
||||
char_to_hex(val, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const std::wstring & val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(unsigned char val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
char utf8_buf[10];
|
||||
esc(static_cast<char>(val), stream, field_type);
|
||||
}
|
||||
|
||||
for(size_t i = 0 ; i < val.size() ; ++i)
|
||||
|
||||
void BaseExpression::esc(wchar_t val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
if( field_type.use_utf8() )
|
||||
{
|
||||
size_t utf8_len = PT::IntToUTF8((int)val[i], utf8_buf, sizeof(utf8_buf));
|
||||
char utf8_buf[10];
|
||||
|
||||
size_t utf8_len = PT::IntToUTF8((int)val, utf8_buf, sizeof(utf8_buf));
|
||||
|
||||
for(size_t a = 0 ; a < utf8_len ; ++a)
|
||||
{
|
||||
esc(utf8_buf[a], stream);
|
||||
esc(utf8_buf[a], stream, field_type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
esc(static_cast<char>(val), stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
if( field_type.use_utf8() )
|
||||
{
|
||||
char utf8_buf[10];
|
||||
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
size_t utf8_len = PT::IntToUTF8((int)val[i], utf8_buf, sizeof(utf8_buf));
|
||||
|
||||
for(size_t a = 0 ; a < utf8_len ; ++a)
|
||||
{
|
||||
esc(utf8_buf[a], stream, field_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
esc(static_cast<char>(val[i]), stream, field_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const wchar_t * val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const std::wstring & val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
char utf8_buf[10];
|
||||
|
||||
for(size_t i = 0 ; val[i] != 0 ; ++i)
|
||||
{
|
||||
size_t utf8_len = PT::IntToUTF8((int)val[i], utf8_buf, sizeof(utf8_buf));
|
||||
|
||||
for(size_t a = 0 ; a < utf8_len ; ++a)
|
||||
{
|
||||
esc(utf8_buf[a], stream);
|
||||
}
|
||||
}
|
||||
esc(val.c_str(), true, val.size(), stream, field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const std::string & val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const wchar_t * val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
esc(val, false, 0, stream, field_type);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const std::string & val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
for(size_t i = 0 ; i < val.size() ; ++i)
|
||||
{
|
||||
esc(val[i], stream);
|
||||
esc(val[i], stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const char * val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const char * val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
for(size_t i = 0 ; val[i] != 0 ; ++i)
|
||||
{
|
||||
esc(val[i], stream);
|
||||
esc(val[i], stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(bool val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(bool val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
if( val )
|
||||
stream << "true";
|
||||
@@ -476,105 +538,105 @@ void BaseExpression::esc(bool val, PT::TextStream & stream)
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(short val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(short val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned short val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(unsigned short val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(int val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(int val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned int val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(unsigned int val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(long val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(long val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned long val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(unsigned long val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(long long val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(long long val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
// not implemented in PT::TextStream yet
|
||||
//stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned long long val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(unsigned long long val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
//stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(float val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(float val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(double val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(double val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(long double val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(long double val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
// IMPLEMENT ME in PT::TextStream
|
||||
//stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const PT::Date & date, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const PT::Date & date, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
stream << date;
|
||||
}
|
||||
|
||||
void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
PT::TextStream::const_iterator i = val.begin();
|
||||
|
||||
for(; i != val.end() ; ++i)
|
||||
{
|
||||
esc(*i, stream);
|
||||
esc(*i, stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
PT::WTextStream::const_iterator i = val.begin();
|
||||
|
||||
for(; i != val.end() ; ++i)
|
||||
{
|
||||
esc(*i, stream);
|
||||
esc(*i, stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream)
|
||||
void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream, FT field_type)
|
||||
{
|
||||
PT::WTextStream tmp_stream;
|
||||
|
||||
space.serialize_to_space_stream(tmp_stream, true);
|
||||
esc(tmp_stream, stream);
|
||||
esc(tmp_stream, stream, field_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -687,11 +749,11 @@ void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream)
|
||||
//}
|
||||
|
||||
|
||||
void BaseExpression::before_field_value_string()
|
||||
void BaseExpression::before_field_value_string(FT field_type)
|
||||
{
|
||||
}
|
||||
|
||||
void BaseExpression::after_field_value_string()
|
||||
void BaseExpression::after_field_value_string(FT field_type)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user