added support for PT::Space as a field in a Model
methods before_field_value_string() and after_field_value_string() moved from DbExpression and JsonExpression to BaseExpression and made virtual and now methods before_field_value(const std::wstring &) and after_field_value(const std::wstring &) (and the rest of them with string arguments) can be removed from DbExpression, PostgreSqlExpression and JsonExpression
This commit is contained in:
parent
f7490594ad
commit
7bef1d5ead
|
@ -13,18 +13,20 @@ baseexpression.o: finderhelper.h fieldvaluehelper.h ft.h model.h
|
||||||
baseexpression.o: modelconnector.h clearer.h dbconnector.h flatconnector.h
|
baseexpression.o: modelconnector.h clearer.h dbconnector.h flatconnector.h
|
||||||
baseexpression.o: dbexpression.h flatexpression.h ../../pikotools/utf8/utf8.h
|
baseexpression.o: dbexpression.h flatexpression.h ../../pikotools/utf8/utf8.h
|
||||||
clearer.o: clearer.h ../../pikotools/date/date.h
|
clearer.o: clearer.h ../../pikotools/date/date.h
|
||||||
clearer.o: ../../pikotools/convert/inttostr.h model.h
|
clearer.o: ../../pikotools/convert/inttostr.h ../../pikotools/space/space.h
|
||||||
|
clearer.o: ../../pikotools/textstream/types.h model.h
|
||||||
clearer.o: ../../pikotools/textstream/textstream.h
|
clearer.o: ../../pikotools/textstream/textstream.h
|
||||||
clearer.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
|
||||||
clearer.o: ../../pikotools/membuffer/membuffer.h
|
clearer.o: ../../pikotools/membuffer/membuffer.h
|
||||||
clearer.o: ../../pikotools/textstream/types.h modelconnector.h dbconnector.h
|
clearer.o: ../../pikotools/textstream/types.h modelconnector.h dbconnector.h
|
||||||
clearer.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
clearer.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||||
clearer.o: queryresult.h flatconnector.h dbexpression.h baseexpression.h
|
clearer.o: queryresult.h flatconnector.h dbexpression.h baseexpression.h
|
||||||
clearer.o: morm_types.h modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
clearer.o: morm_types.h modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
||||||
clearer.o: fieldvaluehelper.h ft.h flatexpression.h
|
clearer.o: fieldvaluehelper.h ft.h flatexpression.h
|
||||||
dbconnector.o: dbconnector.h ../../pikotools/textstream/textstream.h
|
dbconnector.o: ../../pikotools/space/spaceparser.h
|
||||||
dbconnector.o: ../../pikotools/space/space.h
|
dbconnector.o: ../../pikotools/space/space.h
|
||||||
dbconnector.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
|
dbconnector.o: ../../pikotools/textstream/types.h dbconnector.h
|
||||||
|
dbconnector.o: ../../pikotools/textstream/textstream.h
|
||||||
|
dbconnector.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||||
dbconnector.o: ../../pikotools/convert/inttostr.h
|
dbconnector.o: ../../pikotools/convert/inttostr.h
|
||||||
dbconnector.o: ../../pikotools/membuffer/membuffer.h
|
dbconnector.o: ../../pikotools/membuffer/membuffer.h
|
||||||
dbconnector.o: ../../pikotools/textstream/types.h ../../pikotools/log/log.h
|
dbconnector.o: ../../pikotools/textstream/types.h ../../pikotools/log/log.h
|
||||||
|
@ -105,10 +107,10 @@ model.o: dbexpression.h baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||||
model.o: cursorhelper.h finderhelper.h fieldvaluehelper.h ft.h
|
model.o: cursorhelper.h finderhelper.h fieldvaluehelper.h ft.h
|
||||||
model.o: flatexpression.h
|
model.o: flatexpression.h
|
||||||
modelconnector.o: modelconnector.h clearer.h ../../pikotools/date/date.h
|
modelconnector.o: modelconnector.h clearer.h ../../pikotools/date/date.h
|
||||||
modelconnector.o: ../../pikotools/convert/inttostr.h dbconnector.h
|
modelconnector.o: ../../pikotools/convert/inttostr.h
|
||||||
modelconnector.o: ../../pikotools/textstream/textstream.h
|
|
||||||
modelconnector.o: ../../pikotools/space/space.h
|
modelconnector.o: ../../pikotools/space/space.h
|
||||||
modelconnector.o: ../../pikotools/textstream/types.h
|
modelconnector.o: ../../pikotools/textstream/types.h dbconnector.h
|
||||||
|
modelconnector.o: ../../pikotools/textstream/textstream.h
|
||||||
modelconnector.o: ../../pikotools/membuffer/membuffer.h
|
modelconnector.o: ../../pikotools/membuffer/membuffer.h
|
||||||
modelconnector.o: ../../pikotools/textstream/types.h
|
modelconnector.o: ../../pikotools/textstream/types.h
|
||||||
modelconnector.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
modelconnector.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||||
|
|
|
@ -313,51 +313,70 @@ void BaseExpression::after_second_part_long_field_name()
|
||||||
|
|
||||||
void BaseExpression::before_field_value(const std::wstring &)
|
void BaseExpression::before_field_value(const std::wstring &)
|
||||||
{
|
{
|
||||||
|
before_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::before_field_value(const std::string &)
|
void BaseExpression::before_field_value(const std::string &)
|
||||||
{
|
{
|
||||||
|
before_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::after_field_value(const std::wstring &)
|
void BaseExpression::after_field_value(const std::wstring &)
|
||||||
{
|
{
|
||||||
|
after_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::after_field_value(const std::string &)
|
void BaseExpression::after_field_value(const std::string &)
|
||||||
{
|
{
|
||||||
|
after_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::before_field_value(const wchar_t *)
|
void BaseExpression::before_field_value(const wchar_t *)
|
||||||
{
|
{
|
||||||
|
before_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::after_field_value(const wchar_t *)
|
void BaseExpression::after_field_value(const wchar_t *)
|
||||||
{
|
{
|
||||||
|
after_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::before_field_value(const char *)
|
void BaseExpression::before_field_value(const char *)
|
||||||
{
|
{
|
||||||
|
before_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::after_field_value(const char *)
|
void BaseExpression::after_field_value(const char *)
|
||||||
{
|
{
|
||||||
|
after_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseExpression::before_field_value(const PT::Date &)
|
void BaseExpression::before_field_value(const PT::Date &)
|
||||||
{
|
{
|
||||||
|
before_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseExpression::after_field_value(const PT::Date &)
|
void BaseExpression::after_field_value(const PT::Date &)
|
||||||
{
|
{
|
||||||
|
after_field_value_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseExpression::before_field_value(const PT::Space &)
|
||||||
|
{
|
||||||
|
before_field_value_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseExpression::after_field_value(const PT::Space &)
|
||||||
|
{
|
||||||
|
after_field_value_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_name_value_separator()
|
void BaseExpression::put_name_value_separator()
|
||||||
|
@ -543,114 +562,138 @@ void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseExpression::put_type(char val, PT::TextStream & stream)
|
void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream)
|
||||||
{
|
{
|
||||||
stream << "char";
|
PT::WTextStream tmp_stream;
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(unsigned char val, PT::TextStream & stream)
|
if( space.table.size() > 0 )
|
||||||
{
|
{
|
||||||
stream << "unsigned char";
|
tmp_stream.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
space.Serialize(tmp_stream, true);
|
||||||
|
esc(tmp_stream, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_type(const std::wstring & val, PT::TextStream & stream)
|
//void BaseExpression::put_type(char val, PT::TextStream & stream)
|
||||||
{
|
|
||||||
stream << "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(const wchar_t * val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_type(const std::string & val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(const char * val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_type(bool val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "boolean";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(short val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "short integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(unsigned short val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "unsigned short integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(int val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(unsigned int val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "unsigned integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(long val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "long integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(unsigned long val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "unsigned long integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(long long val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "very long integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(unsigned long long val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "unsigned very long integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(float val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "float";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(double val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "double";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseExpression::put_type(long double val, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "long double";
|
|
||||||
}
|
|
||||||
|
|
||||||
//void BaseExpression::put_type(void* val, PT::TextStream & stream)
|
|
||||||
//{
|
//{
|
||||||
|
// stream << "char";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(unsigned char val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "unsigned char";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const std::wstring & val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "text";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const wchar_t * val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "text";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const std::string & val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "text";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const char * val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "text";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(bool val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "boolean";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(short val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "short integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(unsigned short val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "unsigned short integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(int val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(unsigned int val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "unsigned integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(long val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "long integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(unsigned long val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "unsigned long integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(long long val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "very long integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(unsigned long long val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "unsigned very long integer";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(float val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "float";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(double val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "double";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(long double val, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "long double";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////void BaseExpression::put_type(void* val, PT::TextStream & stream)
|
||||||
|
////{
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const PT::Date & date, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "date";
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void BaseExpression::put_type(const Model & model, PT::TextStream & stream)
|
||||||
|
//{
|
||||||
|
// stream << "object";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_type(const PT::Date & date, PT::TextStream & stream)
|
void BaseExpression::before_field_value_string()
|
||||||
{
|
{
|
||||||
stream << "date";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseExpression::put_type(const Model & model, PT::TextStream & stream)
|
void BaseExpression::after_field_value_string()
|
||||||
{
|
{
|
||||||
stream << "object";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ public:
|
||||||
virtual void esc(const PT::Date & date, PT::TextStream & stream);
|
virtual void esc(const PT::Date & date, PT::TextStream & stream);
|
||||||
virtual void esc(const PT::TextStream & val,PT::TextStream & stream);
|
virtual void esc(const PT::TextStream & val,PT::TextStream & stream);
|
||||||
virtual void esc(const PT::WTextStream & val,PT::TextStream & stream);
|
virtual void esc(const PT::WTextStream & val,PT::TextStream & stream);
|
||||||
|
virtual void esc(const PT::Space & space, PT::TextStream & stream);
|
||||||
|
|
||||||
virtual bool is_long_field_name(const wchar_t * field_name);
|
virtual bool is_long_field_name(const wchar_t * field_name);
|
||||||
virtual bool is_long_field_name(const PT::TextStream & table_name);
|
virtual bool is_long_field_name(const PT::TextStream & table_name);
|
||||||
|
@ -631,6 +632,8 @@ protected:
|
||||||
virtual void before_field_value(const PT::Date &);
|
virtual void before_field_value(const PT::Date &);
|
||||||
virtual void after_field_value(const PT::Date &);
|
virtual void after_field_value(const PT::Date &);
|
||||||
|
|
||||||
|
virtual void before_field_value(const PT::Space &);
|
||||||
|
virtual void after_field_value(const PT::Space &);
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void before_field_value(const FieldValue &)
|
void before_field_value(const FieldValue &)
|
||||||
|
@ -650,43 +653,51 @@ protected:
|
||||||
* put_type for: signed char, wchar_t, char16_t, char32_t
|
* put_type for: signed char, wchar_t, char16_t, char32_t
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void put_type(char val, PT::TextStream & stream);
|
// virtual void put_type(char val, PT::TextStream & stream);
|
||||||
virtual void put_type(unsigned char val, PT::TextStream & stream);
|
// virtual void put_type(unsigned char val, PT::TextStream & stream);
|
||||||
|
//
|
||||||
virtual void put_type(const std::wstring & val, PT::TextStream & stream);
|
// virtual void put_type(const std::wstring & val, PT::TextStream & stream);
|
||||||
virtual void put_type(const wchar_t * val, PT::TextStream & stream);
|
// virtual void put_type(const wchar_t * val, PT::TextStream & stream);
|
||||||
|
//
|
||||||
virtual void put_type(const std::string & val, PT::TextStream & stream);
|
// virtual void put_type(const std::string & val, PT::TextStream & stream);
|
||||||
virtual void put_type(const char * val, PT::TextStream & stream);
|
// virtual void put_type(const char * val, PT::TextStream & stream);
|
||||||
|
//
|
||||||
virtual void put_type(bool val, PT::TextStream & stream);
|
// virtual void put_type(bool val, PT::TextStream & stream);
|
||||||
virtual void put_type(short val, PT::TextStream & stream);
|
// virtual void put_type(short val, PT::TextStream & stream);
|
||||||
virtual void put_type(unsigned short val, PT::TextStream & stream);
|
// virtual void put_type(unsigned short val, PT::TextStream & stream);
|
||||||
virtual void put_type(int val, PT::TextStream & stream);
|
// virtual void put_type(int val, PT::TextStream & stream);
|
||||||
virtual void put_type(unsigned int val, PT::TextStream & stream);
|
// virtual void put_type(unsigned int val, PT::TextStream & stream);
|
||||||
virtual void put_type(long val, PT::TextStream & stream);
|
// virtual void put_type(long val, PT::TextStream & stream);
|
||||||
virtual void put_type(unsigned long val, PT::TextStream & stream);
|
// virtual void put_type(unsigned long val, PT::TextStream & stream);
|
||||||
virtual void put_type(long long val, PT::TextStream & stream);
|
// virtual void put_type(long long val, PT::TextStream & stream);
|
||||||
virtual void put_type(unsigned long long val, PT::TextStream & stream);
|
// virtual void put_type(unsigned long long val, PT::TextStream & stream);
|
||||||
virtual void put_type(float val, PT::TextStream & stream);
|
// virtual void put_type(float val, PT::TextStream & stream);
|
||||||
virtual void put_type(double val, PT::TextStream & stream);
|
// virtual void put_type(double val, PT::TextStream & stream);
|
||||||
virtual void put_type(long double val, PT::TextStream & stream);
|
// virtual void put_type(long double val, PT::TextStream & stream);
|
||||||
//virtual void put_type(void* val, PT::TextStream & stream);
|
//virtual void put_type(void* val, PT::TextStream & stream);
|
||||||
|
|
||||||
virtual void put_type(const PT::Date & date, PT::TextStream & stream);
|
// virtual void put_type(const PT::Date & date, PT::TextStream & stream);
|
||||||
virtual void put_type(const Model & model, PT::TextStream & stream);
|
// virtual void put_type(const Model & model, PT::TextStream & stream);
|
||||||
|
//
|
||||||
|
// template<typename ListType>
|
||||||
|
// void put_type(const std::list<ListType> & model, PT::TextStream & stream)
|
||||||
|
// {
|
||||||
|
// stream << "table"; // may just use std::list?
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// template<typename ListType>
|
||||||
|
// void put_type(const std::vector<ListType> & model, PT::TextStream & stream)
|
||||||
|
// {
|
||||||
|
// stream << "table"; // may just just std::vector?
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual void before_field_value_string();
|
||||||
|
virtual void after_field_value_string();
|
||||||
|
|
||||||
template<typename ListType>
|
|
||||||
void put_type(const std::list<ListType> & model, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "table"; // may just use std::list?
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ListType>
|
|
||||||
void put_type(const std::vector<ListType> & model, PT::TextStream & stream)
|
|
||||||
{
|
|
||||||
stream << "table"; // may just just std::vector?
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Tomasz Sowa
|
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -139,6 +139,11 @@ void Clearer::clear_value(PT::Date & field_value)
|
||||||
field_value.Clear();
|
field_value.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Clearer::clear_value(PT::Space & field_value)
|
||||||
|
{
|
||||||
|
field_value.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Clearer::clear_model(Model & field_value)
|
void Clearer::clear_model(Model & field_value)
|
||||||
{
|
{
|
||||||
field_value.clear();
|
field_value.clear();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Tomasz Sowa
|
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "date/date.h"
|
#include "date/date.h"
|
||||||
|
#include "space/space.h"
|
||||||
|
|
||||||
|
|
||||||
namespace morm
|
namespace morm
|
||||||
|
@ -68,6 +69,7 @@ public:
|
||||||
virtual void clear_value(double & field_value);
|
virtual void clear_value(double & field_value);
|
||||||
virtual void clear_value(long double & field_value);
|
virtual void clear_value(long double & field_value);
|
||||||
virtual void clear_value(PT::Date & field_value);
|
virtual void clear_value(PT::Date & field_value);
|
||||||
|
virtual void clear_value(PT::Space & field_value);
|
||||||
|
|
||||||
virtual void clear_model(Model & field_value);
|
virtual void clear_model(Model & field_value);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "space/spaceparser.h"
|
||||||
#include "dbconnector.h"
|
#include "dbconnector.h"
|
||||||
#include "dbexpression.h"
|
#include "dbexpression.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
@ -427,6 +428,29 @@ void DbConnector::get_value(const char * value_str, PT::Date & field_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DbConnector::get_value(const char * value_str, PT::Space & field_value)
|
||||||
|
{
|
||||||
|
field_value.Clear();
|
||||||
|
|
||||||
|
if( *value_str != '\0' )
|
||||||
|
{
|
||||||
|
PT::SpaceParser space_parser;
|
||||||
|
space_parser.SetSpace(field_value);
|
||||||
|
|
||||||
|
if( space_parser.ParseString(value_str) != PT::SpaceParser::ok )
|
||||||
|
{
|
||||||
|
field_value.Clear();
|
||||||
|
|
||||||
|
if( log )
|
||||||
|
{
|
||||||
|
(*log) << PT::Log::log1 << "Morm: I cannot correctly parse the Space struct from the datebase"
|
||||||
|
<< ", the raw string is: " << value_str << PT::Log::logend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * DbConnector::query_last_sequence(const wchar_t * sequence_table_name)
|
const char * DbConnector::query_last_sequence(const wchar_t * sequence_table_name)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2019, Tomasz Sowa
|
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -107,6 +107,7 @@ public:
|
||||||
virtual void get_value(const char * value_str, double & field_value);
|
virtual void get_value(const char * value_str, double & field_value);
|
||||||
virtual void get_value(const char * value_str, long double & field_value);
|
virtual void get_value(const char * value_str, long double & field_value);
|
||||||
virtual void get_value(const char * value_str, PT::Date & field_value);
|
virtual void get_value(const char * value_str, PT::Date & field_value);
|
||||||
|
virtual void get_value(const char * value_str, PT::Space & field_value);
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
|
|
|
@ -185,75 +185,13 @@ void DbExpression::put_name_value_separator()
|
||||||
|
|
||||||
void DbExpression::before_field_value_string()
|
void DbExpression::before_field_value_string()
|
||||||
{
|
{
|
||||||
// if( output_type == MORM_OUTPUT_TYPE_SELECT_COLUMNS ||
|
(*out_stream) << "'";
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_INSERT ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_UPDATE ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_PRIMARY_KEY )
|
|
||||||
{
|
|
||||||
(*out_stream) << "'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DbExpression::after_field_value_string()
|
void DbExpression::after_field_value_string()
|
||||||
{
|
{
|
||||||
// if( output_type == MORM_OUTPUT_TYPE_SELECT_COLUMNS ||
|
(*out_stream) << "'";
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_INSERT ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_UPDATE ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_PRIMARY_KEY )
|
|
||||||
{
|
|
||||||
(*out_stream) << "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DbExpression::before_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::after_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::before_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::after_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::before_field_value(const wchar_t *)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::after_field_value(const wchar_t *)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::before_field_value(const char *)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::after_field_value(const char *)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::before_field_value(const PT::Date &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbExpression::after_field_value(const PT::Date &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,21 +88,6 @@ protected:
|
||||||
|
|
||||||
void field_before();
|
void field_before();
|
||||||
|
|
||||||
void before_field_value(const std::wstring &);
|
|
||||||
void after_field_value(const std::wstring &);
|
|
||||||
|
|
||||||
void before_field_value(const std::string &);
|
|
||||||
void after_field_value(const std::string &);
|
|
||||||
|
|
||||||
void before_field_value(const wchar_t *);
|
|
||||||
void after_field_value(const wchar_t *);
|
|
||||||
|
|
||||||
void before_field_value(const char *);
|
|
||||||
void after_field_value(const char *);
|
|
||||||
|
|
||||||
void before_field_value(const PT::Date &);
|
|
||||||
void after_field_value(const PT::Date &);
|
|
||||||
|
|
||||||
void put_name_value_separator();
|
void put_name_value_separator();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,38 +116,6 @@ void JSONExpression::after_field_value_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSONExpression::before_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSONExpression::before_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSONExpression::after_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSONExpression::after_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSONExpression::before_field_value(const PT::Date &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSONExpression::after_field_value(const PT::Date &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void JSONExpression::put_name_value_separator()
|
void JSONExpression::put_name_value_separator()
|
||||||
{
|
{
|
||||||
(*out_stream) << ':';
|
(*out_stream) << ':';
|
||||||
|
|
|
@ -61,15 +61,8 @@ protected:
|
||||||
void before_second_part_long_field_name();
|
void before_second_part_long_field_name();
|
||||||
void after_second_part_long_field_name();
|
void after_second_part_long_field_name();
|
||||||
|
|
||||||
void before_field_value(const std::wstring &);
|
|
||||||
void before_field_value(const std::string &);
|
|
||||||
void after_field_value(const std::wstring &);
|
|
||||||
void after_field_value(const std::string &);
|
|
||||||
void put_name_value_separator();
|
void put_name_value_separator();
|
||||||
|
|
||||||
void before_field_value(const PT::Date &);
|
|
||||||
void after_field_value(const PT::Date &);
|
|
||||||
|
|
||||||
void before_field_value_list();
|
void before_field_value_list();
|
||||||
void after_field_value_list();
|
void after_field_value_list();
|
||||||
|
|
||||||
|
|
17
src/model.h
17
src/model.h
|
@ -42,6 +42,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "textstream/textstream.h"
|
#include "textstream/textstream.h"
|
||||||
|
#include "space/space.h"
|
||||||
#include "modelconnector.h"
|
#include "modelconnector.h"
|
||||||
#include "dbexpression.h"
|
#include "dbexpression.h"
|
||||||
#include "flatexpression.h"
|
#include "flatexpression.h"
|
||||||
|
@ -306,6 +307,11 @@ protected:
|
||||||
field_generic(field_name, field_name, field_value, field_type);
|
field_generic(field_name, field_name, field_value, field_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void field(const wchar_t * field_name, PT::Space & field_value, FT field_type = FT::default_type)
|
||||||
|
{
|
||||||
|
field_generic(field_name, field_name, field_value, field_type);
|
||||||
|
}
|
||||||
|
|
||||||
void field(const wchar_t * field_name, Model & field_value, FT field_type = FT::default_type)
|
void field(const wchar_t * field_name, Model & field_value, FT field_type = FT::default_type)
|
||||||
{
|
{
|
||||||
// has_foreign_key was here
|
// has_foreign_key was here
|
||||||
|
@ -416,6 +422,10 @@ protected:
|
||||||
field_generic(db_field_name, flat_field_name, field_value, field_type);
|
field_generic(db_field_name, flat_field_name, field_value, field_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, PT::Space & field_value, FT field_type = FT::default_type)
|
||||||
|
{
|
||||||
|
field_generic(db_field_name, flat_field_name, field_value, field_type);
|
||||||
|
}
|
||||||
|
|
||||||
void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_value, FT field_type = FT::default_type)
|
void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_value, FT field_type = FT::default_type)
|
||||||
{
|
{
|
||||||
|
@ -480,6 +490,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void field_generic_iterate_primary_key_values(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
void field_generic_iterate_primary_key_values(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
||||||
{
|
{
|
||||||
|
@ -499,6 +510,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void field_generic_generate_flat_string(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
void field_generic_generate_flat_string(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
||||||
{
|
{
|
||||||
|
@ -515,6 +527,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void field_generic_generate_db_sql(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
void field_generic_generate_db_sql(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
||||||
{
|
{
|
||||||
|
@ -531,6 +544,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void field_generic_read_value_from_db_resultset(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
void field_generic_read_value_from_db_resultset(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
||||||
{
|
{
|
||||||
|
@ -553,6 +567,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FieldValue>
|
template<typename FieldValue>
|
||||||
void field_generic_clear_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
void field_generic_clear_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type)
|
||||||
{
|
{
|
||||||
|
@ -1371,6 +1386,8 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,65 +77,15 @@ void PostgreSQLExpression::after_second_part_long_field_name()
|
||||||
|
|
||||||
void PostgreSQLExpression::before_field_value_string()
|
void PostgreSQLExpression::before_field_value_string()
|
||||||
{
|
{
|
||||||
// if( output_type == MORM_OUTPUT_TYPE_DB_INSERT ||
|
(*out_stream) << "E'";
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_UPDATE ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_PRIMARY_KEY )
|
|
||||||
{
|
|
||||||
(*out_stream) << "E'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostgreSQLExpression::after_field_value_string()
|
void PostgreSQLExpression::after_field_value_string()
|
||||||
{
|
{
|
||||||
// if( output_type == MORM_OUTPUT_TYPE_DB_INSERT ||
|
(*out_stream) << "'";
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_UPDATE ||
|
|
||||||
// output_type == MORM_OUTPUT_TYPE_DB_PRIMARY_KEY )
|
|
||||||
{
|
|
||||||
(*out_stream) << "'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PostgreSQLExpression::before_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::after_field_value(const std::wstring &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::before_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::after_field_value(const std::string &)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::before_field_value(const wchar_t *)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::after_field_value(const wchar_t *)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::before_field_value(const char *)
|
|
||||||
{
|
|
||||||
before_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PostgreSQLExpression::after_field_value(const char *)
|
|
||||||
{
|
|
||||||
after_field_value_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PostgreSQLExpression::esc(char val, PT::TextStream & stream)
|
void PostgreSQLExpression::esc(char val, PT::TextStream & stream)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,17 +61,6 @@ protected:
|
||||||
virtual void before_second_part_long_field_name();
|
virtual void before_second_part_long_field_name();
|
||||||
virtual void after_second_part_long_field_name();
|
virtual void after_second_part_long_field_name();
|
||||||
|
|
||||||
void before_field_value(const std::wstring &);
|
|
||||||
void after_field_value(const std::wstring &);
|
|
||||||
|
|
||||||
void before_field_value(const std::string &);
|
|
||||||
void after_field_value(const std::string &);
|
|
||||||
|
|
||||||
void before_field_value(const wchar_t *);
|
|
||||||
void after_field_value(const wchar_t *);
|
|
||||||
|
|
||||||
void before_field_value(const char *);
|
|
||||||
void after_field_value(const char *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue