From c4c88fd97c3eab682b56cc30493a63e2e3bd2fd4 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 4 Mar 2021 22:00:19 +0200 Subject: [PATCH] Allow RecordSet to be constructed from statements. --- module/PocoLib/Data.cpp | 1 + module/PocoLib/Data.hpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/module/PocoLib/Data.cpp b/module/PocoLib/Data.cpp index 18bbdf27..22e7f307 100644 --- a/module/PocoLib/Data.cpp +++ b/module/PocoLib/Data.cpp @@ -581,6 +581,7 @@ void Register_POCO_Data(HSQUIRRELVM vm, Table &) ns.Bind(_SC("RecordSet"), Class< SqDataRecordSet >(vm, SqPcDataRecordSet::Str) // Constructors + .Ctor< SqDataStatement & >() .Ctor< SqDataSession &, StackStrF & >() // Meta-methods .SquirrelFunc(_SC("_typename"), &SqPcDataRecordSet::Fn) diff --git a/module/PocoLib/Data.hpp b/module/PocoLib/Data.hpp index 012c7e60..c9738e7a 100644 --- a/module/PocoLib/Data.hpp +++ b/module/PocoLib/Data.hpp @@ -1230,7 +1230,7 @@ struct SqDataStatement : public Statement void UseInst_(LightObj & obj, const std::string & name, Poco::Data::AbstractBinding::Direction dir); /* -------------------------------------------------------------------------------------------- - * Bind a value to the statement and mark it as input (i.e alias of Use). + * Bind a reference to the statement and mark it as input (i.e alias of Use). */ SqDataStatement & In(LightObj & obj) { @@ -1238,7 +1238,7 @@ struct SqDataStatement : public Statement } /* -------------------------------------------------------------------------------------------- - * Bind a named value to the statement mark it as input (i.e alias of UseAs). + * Bind a named reference to the statement mark it as input (i.e alias of UseAs). */ SqDataStatement & InAs(LightObj & obj, StackStrF & name) { @@ -1292,7 +1292,7 @@ struct SqDataStatement : public Statement void BindInst_(LightObj & obj, const std::string & name, Poco::Data::AbstractBinding::Direction dir); /* -------------------------------------------------------------------------------------------- - * Bind a value to the statement and mark it as input/output. + * Bind a value/reference to the statement and mark it as input/output. */ SqDataStatement & Io(LightObj & obj) { @@ -1373,6 +1373,14 @@ template < class T > inline SqDataBinding< T > & SqDataBinding< T >::BindAs(SqDa */ struct SqDataRecordSet : public RecordSet { + /* -------------------------------------------------------------------------------------------- + * Creates the RecordSet for the given statement. + */ + SqDataRecordSet(SqDataStatement & stmt) + : RecordSet(stmt) + { + } + /* -------------------------------------------------------------------------------------------- * Creates the RecordSet for the given query. */