added flags FT::json and FT::space for pt::Space class - serializing/parsing to/from json/space
This commit is contained in:
parent
d162ca13bb
commit
f94a9e27db
|
@ -586,8 +586,13 @@ void BaseExpression::esc(const pt::WTextStream & val, pt::TextStream & stream, c
|
||||||
void BaseExpression::esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type)
|
void BaseExpression::esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type)
|
||||||
{
|
{
|
||||||
pt::WTextStream tmp_stream;
|
pt::WTextStream tmp_stream;
|
||||||
|
bool pretty_print = field_type.is_pretty_print();
|
||||||
|
|
||||||
|
if( field_type.is_space() )
|
||||||
|
space.serialize_to_space_stream(tmp_stream, pretty_print);
|
||||||
|
else
|
||||||
|
space.serialize_to_json_stream(tmp_stream, pretty_print);
|
||||||
|
|
||||||
space.serialize_to_space_stream(tmp_stream, true);
|
|
||||||
esc(tmp_stream, stream, field_type);
|
esc(tmp_stream, stream, field_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -722,14 +722,30 @@ void DbConnector::get_value(const char * value_str, pt::Space & field_value, con
|
||||||
{
|
{
|
||||||
pt::SpaceParser space_parser;
|
pt::SpaceParser space_parser;
|
||||||
|
|
||||||
if( space_parser.parse_space(value_str, field_value) != pt::SpaceParser::ok )
|
if( field_type.is_space() )
|
||||||
{
|
{
|
||||||
field_value.clear();
|
if( space_parser.parse_space(value_str, field_value) != pt::SpaceParser::ok )
|
||||||
|
|
||||||
if( log )
|
|
||||||
{
|
{
|
||||||
(*log) << pt::Log::log2 << "Morm: I cannot correctly parse the Space struct from the datebase"
|
field_value.clear();
|
||||||
<< ", the raw string is: " << value_str << pt::Log::logend;
|
|
||||||
|
if( log )
|
||||||
|
{
|
||||||
|
(*log) << pt::Log::log2 << "Morm: I cannot correctly parse the Space struct (space format) from the datebase"
|
||||||
|
<< ", the raw string was: " << value_str << pt::Log::logend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( space_parser.parse_json(value_str, field_value) != pt::SpaceParser::ok )
|
||||||
|
{
|
||||||
|
field_value.clear();
|
||||||
|
|
||||||
|
if( log )
|
||||||
|
{
|
||||||
|
(*log) << pt::Log::log2 << "Morm: I cannot correctly parse the Space struct (json format) from the datebase"
|
||||||
|
<< ", the raw string was: " << value_str << pt::Log::logend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/ft.h
17
src/ft.h
|
@ -61,6 +61,9 @@ public:
|
||||||
dont_use_utf8 = 256,
|
dont_use_utf8 = 256,
|
||||||
hexadecimal = 512,
|
hexadecimal = 512,
|
||||||
binary = 1024,
|
binary = 1024,
|
||||||
|
json = 2048,
|
||||||
|
space = 4096,
|
||||||
|
pretty_print = 8192,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,6 +161,20 @@ public:
|
||||||
return is_flag_set(binary);
|
return is_flag_set(binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_json() const
|
||||||
|
{
|
||||||
|
return is_flag_set(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_space() const
|
||||||
|
{
|
||||||
|
return is_flag_set(space);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_pretty_print() const
|
||||||
|
{
|
||||||
|
return is_flag_set(pretty_print);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue