add a CSVConnector/CSVExpression classes to serialize to csv format
Current limitation: list/vectors are not serialized. while here: - move the output_type flag from the DbExpression to BaseExpression class - add Model::to_text(...) methods with an Export parameter
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "morm_types.h"
|
||||
#include "modelenv.h"
|
||||
#include "ft.h"
|
||||
#include "export.h"
|
||||
#include "convert/text.h"
|
||||
|
||||
#ifdef MORM_HAS_EZC_LIBRARY
|
||||
@@ -69,6 +70,9 @@ public:
|
||||
virtual void set_work_mode(int work_mode);
|
||||
virtual int get_work_mode();
|
||||
|
||||
virtual void set_output_type(int output_type);
|
||||
virtual int get_output_type();
|
||||
|
||||
virtual pt::TextStream * get_text_stream();
|
||||
virtual void set_text_stream(pt::TextStream * out_stream);
|
||||
|
||||
@@ -160,7 +164,7 @@ public:
|
||||
void field_list(const wchar_t * field_name, ModelContainer & field_value, ModelContainerType * model_container_type,
|
||||
const FT & field_type, ModelConnector * model_connector, ModelEnv * model_env, IsContainerByValueRenameMe * foo)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
if( out_stream && can_field_be_generated(field_type) && can_field_list_be_generated(field_type) )
|
||||
{
|
||||
field_before();
|
||||
|
||||
@@ -192,12 +196,15 @@ public:
|
||||
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
||||
{
|
||||
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||
if( output_type == MORM_OUTPUT_TYPE_FIELDS_RECURSIVE )
|
||||
generate_from_model(field_model, field_type);
|
||||
else
|
||||
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
|
||||
{
|
||||
generate_from_model(field_model, field_type); // is it ok as a value?
|
||||
generate_from_model(field_model, field_type);
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
||||
@@ -341,6 +348,7 @@ public:
|
||||
protected:
|
||||
|
||||
int work_mode; /* what to do: generating fields list, values list or fields-values list */
|
||||
int output_type;
|
||||
bool is_first_field;
|
||||
pt::TextStream * out_stream;
|
||||
bool use_prefix;
|
||||
@@ -354,6 +362,7 @@ protected:
|
||||
|
||||
virtual bool can_field_be_generated(const FT &);
|
||||
virtual bool can_field_model_be_generated(bool has_model_primary_key, const FT & field_type);
|
||||
virtual bool can_field_list_be_generated(const FT &);
|
||||
virtual bool should_field_model_be_generated_as_null(bool has_model_primary_key, const FT & field_type);
|
||||
|
||||
virtual void field_before();
|
||||
|
Reference in New Issue
Block a user