I need to convert a DateTime value stored in a Dynamic::Var to a custom string format. ( std::string ColumnInfo::DATETIME_FORMAT("%Y-%m-%d %H:%M:%S"); )
(I am using trunk).
I need to use generic code, because my database is defined by metadata, so when using I don't really know the field names on extraction time.
VarHolderImpl<DateTime> always converts to ISO8601:
- Code: Select all
void convert(std::string& val) const
{
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
}
I am exporting to XML, so my code basically loops over all the fields, converting them to std::string (removed some xml code for brevity - _value is a map<Dynamic::Any>):
- Code: Select all
for (TableInfo::columns_t::const_iterator i=_tableInfo->columns().begin(); i!=_tableInfo->columns().end(); i++)
{
if (_values.find(i->second->name()) != _values.end())
{
ostr << "<![CDATA[" << _values[i->second->name()]->convert<string>() << "]]>";
}
}
Is there any strategy for this to work automatically, without needing to pass the value thru a custom formatter?
I tried creating a custom VarHolderImpl, but the data from RecordSet always come as DateTime, I can't change it.
Also I tried to create my own "fmtstring" derived from std::string, but I can't add a new "convert" method to VarHolderImpl<DateTime>, as this class can't be overriden (or can it?)





