From d9a35ec5d8d6063df8469600e20323f654246f94 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 3 Apr 2021 16:30:08 +0300 Subject: [PATCH] BLOB and CLOB support. --- module/Library/Utils/String.hpp | 8 ++++++++ module/PocoLib/Data.hpp | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/module/Library/Utils/String.hpp b/module/Library/Utils/String.hpp index 99f4c6f5..576ad55f 100644 --- a/module/Library/Utils/String.hpp +++ b/module/Library/Utils/String.hpp @@ -53,6 +53,14 @@ struct SqString mS.resize(ClampL< SQInteger, size_t >(n), v); } + /* -------------------------------------------------------------------------------------------- + * Construct with forwarded native arguments. + */ + template < class... Args > SqString(SqInPlace SQ_UNUSED_ARG(x), Args&&... args) + : mS(std::forward< Args >(args)...) + { + } + /* -------------------------------------------------------------------------------------------- * Copy constructor from reference. */ diff --git a/module/PocoLib/Data.hpp b/module/PocoLib/Data.hpp index 52a528d0..2eb926f8 100644 --- a/module/PocoLib/Data.hpp +++ b/module/PocoLib/Data.hpp @@ -1,8 +1,8 @@ #pragma once // ------------------------------------------------------------------------------------------------ -#include "Core/Buffer.hpp" -#include "Core/Utility.hpp" +#include "Library/IO/Buffer.hpp" +#include "Library/Utils/String.hpp" #include "Library/Utils/Vector.hpp" // ------------------------------------------------------------------------------------------------ @@ -10,6 +10,7 @@ #include #include #include +#include // ------------------------------------------------------------------------------------------------ namespace std { // NOLINT(cert-dcl58-cpp) @@ -1686,8 +1687,15 @@ protected: case Poco::Data::MetaColumn::FDT_STRING: case Poco::Data::MetaColumn::FDT_WSTRING: return LightObj(SqInPlace{}, SqVM(), v.convert< std::string >()); - case Poco::Data::MetaColumn::FDT_BLOB: - case Poco::Data::MetaColumn::FDT_CLOB: + case Poco::Data::MetaColumn::FDT_BLOB: { + auto & b = v.extract< Poco::Data::BLOB >(); + return LightObj(SqTypeIdentity< SqBuffer >{}, SqVM(), + reinterpret_cast< Buffer::ConstPtr >(b.rawContent()), static_cast< SQInteger >(b.size())); + } + case Poco::Data::MetaColumn::FDT_CLOB: { + auto & b = v.extract< Poco::Data::CLOB >(); + return LightObj(SqTypeIdentity< SqString >{}, SqVM(), SqInPlace{}, b.rawContent(), b.size()); + } case Poco::Data::MetaColumn::FDT_DATE: case Poco::Data::MetaColumn::FDT_TIME: case Poco::Data::MetaColumn::FDT_TIMESTAMP: