added "add" methods with vector/list of models to Vars
This commit is contained in:
parent
7caddeedbf
commit
46bc5c35a1
|
@ -60,6 +60,7 @@ patternparser.o: ../../pikotools/src/convert/patternreplacer.h
|
||||||
patternparser.o: ../../pikotools/src/convert/strtoint.h
|
patternparser.o: ../../pikotools/src/convert/strtoint.h
|
||||||
patternparser.o: ../../pikotools/src/convert/text.h
|
patternparser.o: ../../pikotools/src/convert/text.h
|
||||||
patternparser.o: ../../pikotools/src/convert/misc.h
|
patternparser.o: ../../pikotools/src/convert/misc.h
|
||||||
|
patternparser.o: ../../pikotools/src/utf8/utf8_stream.h
|
||||||
patternparser.o: ../../pikotools/src/convert/double.h
|
patternparser.o: ../../pikotools/src/convert/double.h
|
||||||
var.o: var.h ../../pikotools/src/date/date.h
|
var.o: var.h ../../pikotools/src/date/date.h
|
||||||
var.o: ../../pikotools/src/convert/inttostr.h
|
var.o: ../../pikotools/src/convert/inttostr.h
|
||||||
|
|
|
@ -1897,10 +1897,14 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::EvaluateV
|
||||||
|
|
||||||
if( !find_helper.found )
|
if( !find_helper.found )
|
||||||
{
|
{
|
||||||
find_helper.result->clear();
|
find_helper.result->clear(); // is this clear here needed?
|
||||||
find_helper.current_var = FindInScope(name);
|
find_helper.current_var = FindInScope(name);
|
||||||
|
find_helper.found = (find_helper.current_var != nullptr);
|
||||||
|
|
||||||
if( find_helper.current_var )
|
if( find_helper.current_var )
|
||||||
|
*find_helper.result = *find_helper.current_var;
|
||||||
|
|
||||||
|
if( find_helper.found )
|
||||||
{
|
{
|
||||||
if( find_helper.current_var->type == Var<StreamType>::TYPE_FUNCTION && find_helper.current_var->user_function )
|
if( find_helper.current_var->type == Var<StreamType>::TYPE_FUNCTION && find_helper.current_var->user_function )
|
||||||
{
|
{
|
||||||
|
@ -1935,6 +1939,11 @@ void Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::EvaluateV
|
||||||
{
|
{
|
||||||
find_helper.result->model_container_wrapper->increment_iterator();
|
find_helper.result->model_container_wrapper->increment_iterator();
|
||||||
find_helper.result->clear_childs();
|
find_helper.result->clear_childs();
|
||||||
|
|
||||||
|
// find_helper.result was copied from currrent_var so it doesn't have childs here...(childs are not copied)
|
||||||
|
if( find_helper.current_var )
|
||||||
|
find_helper.current_var->clear_childs();
|
||||||
|
|
||||||
// but it only clears child in the first level, is it correct?
|
// but it only clears child in the first level, is it correct?
|
||||||
// childs from different vars will not be cleared
|
// childs from different vars will not be cleared
|
||||||
}
|
}
|
||||||
|
|
23
src/var.h
23
src/var.h
|
@ -146,7 +146,11 @@ public:
|
||||||
|
|
||||||
void set(morm::ModelContainerWrapper & model_container_wrapper);
|
void set(morm::ModelContainerWrapper & model_container_wrapper);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
void set(std::vector<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
void set(std::list<ModelType> & model_container);
|
||||||
|
|
||||||
|
|
||||||
bool is_equal(const char * str) const;
|
bool is_equal(const char * str) const;
|
||||||
|
@ -594,6 +598,25 @@ void Var<StreamType>::set(morm::ModelContainerWrapper & model_container_wrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
void Var<StreamType>::set(std::vector<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||||
|
this->model_container_wrapper = new morm::ModelWrapperVector<ModelType>(&model_container);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
void Var<StreamType>::set(std::list<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||||
|
this->model_container_wrapper = new morm::ModelWrapperList<ModelType>(&model_container);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename StreamType>
|
template<typename StreamType>
|
||||||
bool Var<StreamType>::is_equal(const char * str) const
|
bool Var<StreamType>::is_equal(const char * str) const
|
||||||
|
|
101
src/vars.h
101
src/vars.h
|
@ -78,6 +78,30 @@ public:
|
||||||
Var<StreamType> & add(const std::string & name, morm::Model & model);
|
Var<StreamType> & add(const std::string & name, morm::Model & model);
|
||||||
Var<StreamType> & add(const std::wstring & name, morm::Model & model);
|
Var<StreamType> & add(const std::wstring & name, morm::Model & model);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const char * name, std::vector<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const wchar_t * name, std::vector<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const std::string & name, std::vector<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const std::wstring & name, std::vector<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const char * name, std::list<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const wchar_t * name, std::list<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const std::string & name, std::list<ModelType> & model_container);
|
||||||
|
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & add(const std::wstring & name, std::list<ModelType> & model_container);
|
||||||
|
|
||||||
Var<StreamType> * find(const char * name) const;
|
Var<StreamType> * find(const char * name) const;
|
||||||
Var<StreamType> * find(const wchar_t * name) const;
|
Var<StreamType> * find(const wchar_t * name) const;
|
||||||
Var<StreamType> * find(const std::string & name) const;
|
Var<StreamType> * find(const std::string & name) const;
|
||||||
|
@ -238,6 +262,83 @@ Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, morm::Model &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const char * name, std::vector<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::vector<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::vector<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::vector<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const char * name, std::list<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::list<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::list<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StreamType>
|
||||||
|
template<typename ModelType>
|
||||||
|
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::list<ModelType> & model_container)
|
||||||
|
{
|
||||||
|
Var<StreamType> & var = add(name);
|
||||||
|
var.set(model_container);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename StreamType>
|
template<typename StreamType>
|
||||||
Var<StreamType> * Vars<StreamType>::find(const char * name) const
|
Var<StreamType> * Vars<StreamType>::find(const char * name) const
|
||||||
|
|
Loading…
Reference in New Issue