Model and BaseExpression: changed the template taking a container to std::list

git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1121 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2018-07-05 09:51:26 +00:00
parent d6e428d929
commit 38b85722b8
8 changed files with 23 additions and 93 deletions

View File

@ -116,8 +116,8 @@ public:
field_in_generic<FieldValue, std::vector<FieldValue>>(stream, field_name, container);
}
template<typename ModelClass>
void field_list(const wchar_t * field_name, const std::list<ModelClass> & field_value, bool insertable, bool updatable, bool is_primary_key,
template<typename ModelContainer>
void field_list(const wchar_t * field_name, ModelContainer & field_value, bool insertable, bool updatable, bool is_primary_key,
ModelConnector * model_connector, int model_connector_mode)
{
if( out_stream && can_field_be_generated(insertable, updatable, is_primary_key) )
@ -251,8 +251,8 @@ protected:
}
template<typename ModelClass>
void put_field_value_list(const std::list<ModelClass> & field_value, ModelConnector * model_connector, int model_connector_mode)
template<typename ModelContainer>
void put_field_value_list(ModelContainer & field_value, ModelConnector * model_connector, int model_connector_mode)
{
if( out_stream )
{
@ -261,7 +261,7 @@ protected:
bool is_first = true;
for(ModelClass m : field_value)
for(auto & m : field_value)
{
if( out_stream )
{
@ -354,73 +354,6 @@ protected:
/*
template<typename Container>
void field_container(const wchar_t * field_name, Container container, bool insertable = true, bool updatable = true)
{
typename Container::value Value; // czy tu jest Container::value? sprawdzic
if( !is_first_field )
(*out_stream) << ",";
if( work_mode == ORM_STREAM_MODE_CREATING_JSON )
{
(*out_stream) << "[";
boolean is_first = true;
for(Value v : container)
{
if( !is_first )
(*out_stream) << ",";
v.map_fields(this);
is_first = false;
}
(*out_stream) << "]";
}
// a co z bazą danych?
is_first_field = false;
}
*/
/*
template<typename Container>
virtual void field_container(const wchar_t * field_name, Container container, bool insertable = true, bool updatable = true)
{
typename Container::value Value; // czy tu jest Container::value? sprawdzic
if( !is_first_field )
(*out_stream) << ",";
if( work_mode == ORM_STREAM_MODE_CREATING_JSON )
{
(*out_stream) << "[";
boolean is_first = true;
for(Value v : container)
{
if( !is_first )
(*out_stream) << ",";
v.map_fields(this);
is_first = false;
}
(*out_stream) << "]";
}
// a co z bazą danych?
is_first_field = false;
}
*/
};
}

View File

@ -34,6 +34,7 @@
#include <cstdlib>
#include "dbconnector.h"
#include "dbexpression.h"
#include "model.h"
#include "utf8/utf8.h"

View File

@ -35,7 +35,6 @@
#ifndef headerfile_morm_dbconnector
#define headerfile_morm_dbconnector
#include "dbexpression.h"
#include "textstream/textstream.h"
#include "logger/logger.h"
@ -43,7 +42,7 @@
namespace morm
{
class Model;
class DbExpression;
class DbConnector
{
@ -116,11 +115,11 @@ public:
virtual void clear_value(Model & field_value);
template<typename ModelClass>
void clear_value(std::list<ModelClass> & list)
{
list.clear();
}
// template<typename ModelClass>
// void clear_value(std::list<ModelClass> & list)
// {
// list.clear();
// }
virtual void get_value(const char * value_str, char & field_value);
virtual void get_value(const char * value_str, unsigned char & field_value);

View File

@ -33,6 +33,7 @@
*/
#include "flatconnector.h"
#include "flatexpression.h"
#include "morm_types.h"
#include "model.h"

View File

@ -35,13 +35,13 @@
#ifndef headerfile_morm_flatconnector
#define headerfile_morm_flatconnector
#include "flatexpression.h"
#include "textstream/textstream.h"
namespace morm
{
class Model;
class FlatExpression;
class FlatConnector

View File

@ -39,7 +39,8 @@
#include "textstream/textstream.h"
#include "modelconnector.h"
#include "dbexpression.h"
#include "flatexpression.h"
@ -457,8 +458,10 @@ protected:
}
template<typename ModelClass>
void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::list<ModelClass> & field_list, bool insertable, bool updatable, bool is_primary_key)
// template<typename ModelClass>
// void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::list<ModelClass> & field_list, bool insertable, bool updatable, bool is_primary_key)
template<typename ModelContainer>
void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelContainer & field_container, bool insertable, bool updatable, bool is_primary_key)
{
// IMPLEMENTME what about db?
if( model_connector )
@ -476,14 +479,14 @@ protected:
// IMPROVE ME
// what about model_data and save_mode?
// may it should be placed inside some structure?
flat_expression->field_list(flat_field_name, field_list, insertable, updatable, is_primary_key, model_connector, model_connector_mode);
flat_expression->field_list(flat_field_name, field_container, insertable, updatable, is_primary_key, model_connector, model_connector_mode);
}
}
}
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_CLEARING_VALUE )
{
field_list.clear();
field_container.clear();
}
}
}

View File

@ -33,9 +33,7 @@
*/
#include "modelconnector.h"
#include "model.h"
#include "flatconnector.h"
#include "dbconnector.h"
namespace morm
@ -47,9 +45,6 @@ ModelConnector::ModelConnector()
db_connector = nullptr;
logger = nullptr;
//expression_callback = nullptr;
//db_connector_callback = nullptr;
out_stream = nullptr;
out_stream_allocated = false;
}

View File

@ -35,9 +35,7 @@
#ifndef headerfile_morm_modelconnector
#define headerfile_morm_modelconnector
#include "baseexpression.h"
#include "dbconnector.h"
#include "flatexpression.h"
#include "flatconnector.h"
#include "logger/logger.h"