improve the xml serializer
while here: - do some refactoring in BaseExpression
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022, Tomasz Sowa
|
||||
* Copyright (c) 2022-2023, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -41,46 +41,12 @@ namespace morm
|
||||
{
|
||||
|
||||
|
||||
void XMLExpression::before_generate_from_model()
|
||||
{
|
||||
BaseExpression::before_generate_from_model();
|
||||
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES_FIELDS )
|
||||
{
|
||||
(*out_stream) << "<xml>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::after_generate_from_model()
|
||||
{
|
||||
BaseExpression::after_generate_from_model();
|
||||
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES_FIELDS )
|
||||
{
|
||||
(*out_stream) << "</xml>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void XMLExpression::field_before()
|
||||
{
|
||||
BaseExpression::field_before();
|
||||
|
||||
if( !is_first_field )
|
||||
{
|
||||
//(*out_stream) << ",";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void XMLExpression::before_field_name()
|
||||
{
|
||||
(*out_stream) << "<";
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::after_field_name()
|
||||
{
|
||||
(*out_stream) << ">";
|
||||
@@ -88,17 +54,6 @@ void XMLExpression::after_field_name()
|
||||
|
||||
|
||||
|
||||
void XMLExpression::before_field_value_string(const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
//(*out_stream) << "\"";
|
||||
}
|
||||
|
||||
void XMLExpression::after_field_value_string(const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
//(*out_stream) << "\"";
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::before_field_value(const pt::Space &, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_space() )
|
||||
@@ -116,22 +71,25 @@ void XMLExpression::after_field_value(const pt::Space &, const FT & field_type,
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::put_field_closing_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_raw_field_name() )
|
||||
{
|
||||
(*out_stream) << '/';
|
||||
(*out_stream) << field_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
before_field_name();
|
||||
(*out_stream) << '/';
|
||||
esc(field_name, *out_stream, FT::default_type, nullptr); /* do not use provided field_type here - it would use e.g. binary mode if it was set, similar don't use model_env */
|
||||
after_field_name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::put_name_value_separator()
|
||||
{
|
||||
//(*out_stream) << ':';
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::before_field_value_list()
|
||||
{
|
||||
(*out_stream) << "<table>";
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::after_field_value_list()
|
||||
{
|
||||
(*out_stream) << "</table>";
|
||||
}
|
||||
|
||||
|
||||
@@ -164,4 +122,22 @@ void XMLExpression::esc(const pt::Space & space, pt::TextStream & stream, const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::put_value_list_opening_index(size_t index, const FT & field_type)
|
||||
{
|
||||
(*out_stream) << L"<_" << index << L">";
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::put_value_list_closing_index(size_t index, const FT & field_type)
|
||||
{
|
||||
(*out_stream) << L"</_" << index << L">";
|
||||
}
|
||||
|
||||
|
||||
void XMLExpression::field_value_list_separator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user