|
There is a method DataConvert::convertColumnData() which contains a huge switch handing all data types:
boost::any
|
DataConvert::convertColumnData(cscDataType typeCode,
|
const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
const std::string& dataOrig, bool& pushWarning,
|
const std::string& timeZone, bool nulFlag,
|
bool noRoundup, bool isUpdate)
|
{
|
...
|
switch (typeCode)
|
{
|
case datatypes::SystemCatalog::TINYINT:
|
...
|
case datatypes::SystemCatalog::SMALLINT:
|
...
|
|
}
|
...
|
}
|
Let's remove this method from DataConvert add:
- a new virtual method TypeHandler::convertFromString()
- a new class datatypes::ConvertFromStringParam (to pass parameters to easier)
about as follows:
class ConvertFromStringParam
|
{
|
const std::string& m_timeZone;
|
const bool m_noRoundup;
|
const bool m_isUpdate;
|
public:
|
ConvertFromStringParam(const std::string& timeZone,
|
bool noRoundup, bool isUpdate)
|
:m_timeZone(timeZone),
|
m_noRoundup(noRoundup),
|
m_isUpdate(isUpdate)
|
{ }
|
const std::string& timeZone() const { return m_timeZone; }
|
bool noRoundup() const { return m_noRoundup; }
|
bool isUpdate() const { return m_isUpdate; }
|
};
|
|
virtual boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
const ConvertFromStringParam& prm,
|
const std::string& str,
|
bool& pushWarning) const = 0;
|
|