From 01b963dd311b37418722d2a1d0c685478ffea06c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 1 Nov 2020 15:43:31 +0000 Subject: Wrap boost::posix_time string conversions They're oddly big and inlined. --- slicer/test/conversions.cpp | 14 ++++++++++++++ slicer/test/conversions.h | 4 ++++ slicer/test/optionals.ice | 2 +- slicer/test/types.ice | 4 ++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index 8af0f0f..8b0f0ab 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -106,6 +106,20 @@ namespace Slicer { } return std::to_string(*i); } + + DLL_PUBLIC + std::string + ptimeToString(const boost::posix_time::ptime & pt) + { + return boost::posix_time::to_iso_extended_string(pt); + } + + DLL_PUBLIC + boost::posix_time::ptime + stringToPtime(const std::string & s) + { + return boost::posix_time::from_iso_string(s); + } } namespace TestModule { diff --git a/slicer/test/conversions.h b/slicer/test/conversions.h index dfb18d6..8bd376f 100644 --- a/slicer/test/conversions.h +++ b/slicer/test/conversions.h @@ -32,6 +32,10 @@ namespace Slicer { Ice::optional str2int(const std::string &); DLL_PUBLIC std::string int2str(const Ice::optional &); + DLL_PUBLIC + std::string ptimeToString(const boost::posix_time::ptime &); + DLL_PUBLIC + boost::posix_time::ptime stringToPtime(const std::string &); } #endif diff --git a/slicer/test/optionals.ice b/slicer/test/optionals.ice index c4c7436..7831cf6 100644 --- a/slicer/test/optionals.ice +++ b/slicer/test/optionals.ice @@ -12,7 +12,7 @@ module TestModule { optional(2) DateTimeContainer optClass; optional(3) Classes optSeq; optional(4) ClassMap optDict; - [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ] + [ "slicer:conversion:boost.posix_time.ptime:ptimeToString:stringToPtime:nodeclare" ] optional(5) string optConverted; }; class Optionals2 { diff --git a/slicer/test/types.ice b/slicer/test/types.ice index a48f380..ac050b4 100644 --- a/slicer/test/types.ice +++ b/slicer/test/types.ice @@ -30,11 +30,11 @@ module TestModule2 { TestModule::Base base; }; class Conv { - [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ] + [ "slicer:conversion:boost.posix_time.ptime:ptimeToString:stringToPtime:nodeclare" ] string conv; }; class MissingConv { - [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare", + [ "slicer:conversion:boost.posix_time.ptime:ptimeToString:stringToPtime:nodeclare", "slicer:nodefaultconversion" ] string conv; }; -- cgit v1.2.3