一:官方文档地址
https://www.codesynthesis.com/products/odb/doc/manual.xhtml#23.5.1
二:使用示例
https://git.codesynthesis.com/cgit/odb/odb-tests/tree/boost/mysql/date-time
#ifndef TEST_HXX
#define TEST_HXX
#include <vector>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <odb/core.hxx>
#pragma db object
struct object
{
object ()
{
}
bool
operator== (const object& x) const
{
return
id == x.id &&
dates == x.dates &&
times == x.times &&
timestamps == x.timestamps &&
durations == x.durations;
}
#pragma db id auto
unsigned long id;
std::vector<boost::gregorian::date> dates;
std::vector<boost::posix_time::ptime> times;
// Make timestamp NULL-able to suppress the auto-initialization and
// auto-update characteristics of the TIMESTAMP datatype, and to
// allow NULL values.
//
#pragma db value_type ("TIMESTAMP") value_null
std::vector<boost::posix_time::ptime> timestamps;
std::vector<boost::posix_time::time_duration> durations;
};
三:编译生成odb文件需要加参数
–profile boost/date-time
odb -d mysql --generate-query --generate-schema --profile boost/date-time person.hxx