improve escaping characters from multibyte strings
Read the whole character from a multibyte string and then escape it. while here: - add more virtual methods for escaping strings to BaseExpression
This commit is contained in:
@@ -768,29 +768,26 @@ protected:
|
||||
virtual void before_field_value_string(const FT & field_type, ModelEnv * model_env);
|
||||
virtual void after_field_value_string(const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
char char_to_hex_part(char c);
|
||||
void char_to_hex(char c, pt::Stream & stream);
|
||||
void char_to_hex(char32_t c, pt::Stream & stream);
|
||||
|
||||
void esc(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
void esc(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
bool is_empty_field(const wchar_t * value);
|
||||
virtual char char_to_hex_part(char c);
|
||||
virtual void char_to_hex(char c, pt::Stream & stream);
|
||||
virtual void char_to_hex(char32_t c, pt::Stream & stream);
|
||||
|
||||
virtual void esc_numeric_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_numeric_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_hex_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_hex_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_bin_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_bin_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_ordinary_string(const char * val, size_t val_len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_ordinary_string(const char * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_ordinary_string(const wchar_t * val, size_t val_len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
virtual void esc_ordinary_string(const wchar_t * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
// virtual void esc(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
// virtual void esc(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
template<typename CharType>
|
||||
void esc_normal_string(CharType * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
esc(val[i], stream, field_type, model_env);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename CharType>
|
||||
void esc_numeric_string(CharType * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
void esc_numeric_string_generic(const CharType * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
bool was_comma = false;
|
||||
bool was_something_printed = false;
|
||||
@@ -833,6 +830,49 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
template<typename CharType>
|
||||
void esc_hex_string_generic(const CharType * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
esc(val[i], stream, field_type, model_env);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename CharType>
|
||||
void esc_string(const CharType * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_numeric() )
|
||||
{
|
||||
esc_numeric_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( field_type.is_hexadecimal() )
|
||||
{
|
||||
esc_hex_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
if( field_type.is_binary() )
|
||||
{
|
||||
esc_bin_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( has_known_length )
|
||||
{
|
||||
esc_ordinary_string(val, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
esc_ordinary_string(val, stream, field_type, model_env);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename FieldValue>
|
||||
void put_field_value_or_null(const FieldValue & field_value, void (Model::*getter_method)(pt::Stream &), const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
@@ -939,6 +979,8 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
bool is_empty_field(const wchar_t * value);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user