some concept about serializing space from a model
This commit is contained in:
parent
e442ee4720
commit
7d390eb312
|
@ -179,6 +179,7 @@ private:
|
||||||
size_t field_index;
|
size_t field_index;
|
||||||
morm::ModelWrapper * model_wrapper;
|
morm::ModelWrapper * model_wrapper;
|
||||||
morm::Model * model;
|
morm::Model * model;
|
||||||
|
pt::Space * space;
|
||||||
|
|
||||||
|
|
||||||
CallModelHelper()
|
CallModelHelper()
|
||||||
|
@ -186,6 +187,7 @@ private:
|
||||||
field_index = 0;
|
field_index = 0;
|
||||||
model_wrapper = nullptr;
|
model_wrapper = nullptr;
|
||||||
model = nullptr;
|
model = nullptr;
|
||||||
|
space = nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -331,10 +333,14 @@ private:
|
||||||
|
|
||||||
void CallObject(BaseObj<StreamType> & base_obj, int method_index, FunInfo<StreamType> & info);
|
void CallObject(BaseObj<StreamType> & base_obj, int method_index, FunInfo<StreamType> & info);
|
||||||
|
|
||||||
|
void CallSpace(pt::Space & space, FindHelper & find_helper, std::vector<std::wstring> & fields, size_t field_index,
|
||||||
|
std::vector<Var> & parameters, StreamType & out_stream);
|
||||||
|
|
||||||
|
|
||||||
#ifdef EZC_HAS_MORM_LIBRARY
|
#ifdef EZC_HAS_MORM_LIBRARY
|
||||||
bool CallModel(morm::Model & model, const std::wstring & field, std::vector<Var> parameters, StreamType & out_stream, const StreamType & in_stream);
|
bool CallModel(morm::Model & model, const std::wstring & field, std::vector<Var> parameters, StreamType & out_stream, const StreamType & in_stream);
|
||||||
CallModelHelper FindLastModelWrapper(morm::ModelWrapper & models_base, std::vector<std::wstring> & fields);
|
CallModelHelper FindLastModelWrapper(morm::ModelWrapper & models_base, std::vector<std::wstring> & fields);
|
||||||
void CallModelWrapper(FindHelper & find_helper, std::vector<std::wstring> & fields, std::vector<Var> parameters, StreamType & out_stream, const StreamType & in_stream);
|
void CallModelWrapper(FindHelper & find_helper, std::vector<std::wstring> & fields, std::vector<Var> & parameters, StreamType & out_stream, const StreamType & in_stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CallObject(BaseObj<StreamType> & base_obj,
|
void CallObject(BaseObj<StreamType> & base_obj,
|
||||||
|
@ -1203,6 +1209,27 @@ bool Generator<StreamType>::ShouldEscapeValue(std::vector<Var> parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StreamType>
|
||||||
|
void Generator<StreamType>::CallSpace(pt::Space & space, FindHelper & find_helper, std::vector<std::wstring> & fields, size_t field_index,
|
||||||
|
std::vector<Var> & parameters, StreamType & out_stream)
|
||||||
|
{
|
||||||
|
pt::Space * child = &space;
|
||||||
|
|
||||||
|
for(size_t i=field_index ; i + 1 < fields.size() && child ; ++i)
|
||||||
|
{
|
||||||
|
std::wstring & field = fields[i];
|
||||||
|
child = child->get_object_field(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( child )
|
||||||
|
{
|
||||||
|
const std::wstring & str = child->to_wstr();
|
||||||
|
out_stream << str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EZC_HAS_MORM_LIBRARY
|
#ifdef EZC_HAS_MORM_LIBRARY
|
||||||
|
|
||||||
|
@ -1249,6 +1276,7 @@ typename Generator<StreamType>::CallModelHelper Generator<StreamType>::FindLastM
|
||||||
helper.field_index = 0;
|
helper.field_index = 0;
|
||||||
helper.model_wrapper = &models_base;
|
helper.model_wrapper = &models_base;
|
||||||
helper.model = nullptr;
|
helper.model = nullptr;
|
||||||
|
helper.space = nullptr;
|
||||||
|
|
||||||
for(; helper.field_index < fields.size() ; ++helper.field_index)
|
for(; helper.field_index < fields.size() ; ++helper.field_index)
|
||||||
{
|
{
|
||||||
|
@ -1262,7 +1290,16 @@ typename Generator<StreamType>::CallModelHelper Generator<StreamType>::FindLastM
|
||||||
|
|
||||||
if( helper.model )
|
if( helper.model )
|
||||||
{
|
{
|
||||||
child_models_base = helper.model->get_model_wrapper(nullptr, field.c_str(), false);
|
//child_models_base = helper.model->get_model_wrapper(nullptr, field.c_str(), false);
|
||||||
|
morm::ModelHelper model_helper = helper.model->get_model_helper(nullptr, field.c_str(), false);
|
||||||
|
|
||||||
|
child_models_base = model_helper.model_wrapper;
|
||||||
|
|
||||||
|
if( !child_models_base )
|
||||||
|
{
|
||||||
|
helper.space = model_helper.space;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( child_models_base )
|
if( child_models_base )
|
||||||
{
|
{
|
||||||
|
@ -1284,7 +1321,7 @@ typename Generator<StreamType>::CallModelHelper Generator<StreamType>::FindLastM
|
||||||
|
|
||||||
template<class StreamType>
|
template<class StreamType>
|
||||||
void Generator<StreamType>::CallModelWrapper(FindHelper & find_helper, std::vector<std::wstring> & fields,
|
void Generator<StreamType>::CallModelWrapper(FindHelper & find_helper, std::vector<std::wstring> & fields,
|
||||||
std::vector<Var> parameters, StreamType & out_stream, const StreamType & in_stream)
|
std::vector<Var> & parameters, StreamType & out_stream, const StreamType & in_stream)
|
||||||
{
|
{
|
||||||
last_res = false;
|
last_res = false;
|
||||||
CallModelHelper helper = FindLastModelWrapper(*find_helper.model_wrapper, fields);
|
CallModelHelper helper = FindLastModelWrapper(*find_helper.model_wrapper, fields);
|
||||||
|
@ -1296,9 +1333,17 @@ void Generator<StreamType>::CallModelWrapper(FindHelper & find_helper, std::vect
|
||||||
|
|
||||||
if( helper.field_index + 1 < fields.size() )
|
if( helper.field_index + 1 < fields.size() )
|
||||||
{
|
{
|
||||||
CreateMsg(L"cannot find ", *find_helper.fun_name, fields, L", ", fields[helper.field_index].c_str(), L" is not a model nor a model container");
|
if( helper.space )
|
||||||
last_res = false;
|
{
|
||||||
return;
|
CallSpace(*helper.space, find_helper, fields, helper.field_index + 1, parameters, out_stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreateMsg(L"cannot find ", *find_helper.fun_name, fields, L", ", fields[helper.field_index].c_str(), L" is not a model nor a model container");
|
||||||
|
last_res = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( helper.field_index + 1 == fields.size() )
|
if( helper.field_index + 1 == fields.size() )
|
||||||
|
|
Loading…
Reference in New Issue