mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Remove beast's sqdb module.
Conflicts: src/beast/beast/module/sqdb/api/backend.h src/beast/beast/module/sqdb/api/blob.h src/beast/beast/module/sqdb/api/into.h src/beast/beast/module/sqdb/api/session.h src/beast/beast/module/sqdb/api/statement.h src/beast/beast/module/sqdb/api/transaction.h src/beast/beast/module/sqdb/api/type_conversion_traits.h src/beast/beast/module/sqdb/api/use.h src/beast/beast/module/sqdb/detail/error_codes.h src/beast/beast/module/sqdb/detail/exchange_traits.h src/beast/beast/module/sqdb/detail/into_type.h src/beast/beast/module/sqdb/detail/once_temp_type.h src/beast/beast/module/sqdb/detail/prepare_temp_type.h src/beast/beast/module/sqdb/detail/ref_counted_prepare_info.h src/beast/beast/module/sqdb/detail/ref_counted_statement.h src/beast/beast/module/sqdb/detail/statement_imp.h src/beast/beast/module/sqdb/detail/type_conversion.h src/beast/beast/module/sqdb/detail/type_ptr.h src/beast/beast/module/sqdb/detail/use_type.h src/beast/beast/module/sqdb/sqdb.h
This commit is contained in:
@@ -795,16 +795,6 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
|
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\sqlite\sqlite.unity.c">
|
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\sqlite\sqlite\sqlite3.c">
|
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite\sqlite3.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\net\detail\Parse.h">
|
<ClInclude Include="..\..\src\beast\beast\net\detail\Parse.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\net\DynamicBuffer.h">
|
<ClInclude Include="..\..\src\beast\beast\net\DynamicBuffer.h">
|
||||||
@@ -4497,8 +4487,18 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\sqlite\sqlite.h">
|
||||||
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\sqlite\sqlite.unity.c">
|
||||||
|
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
|
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\sqlite\sqlite\sqlite3.c">
|
||||||
|
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
|
<ClInclude Include="..\..\src\sqlite\sqlite\sqlite3.h">
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
|
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\websocketpp\websocketpp\close.hpp">
|
<ClInclude Include="..\..\src\websocketpp\websocketpp\close.hpp">
|
||||||
|
|||||||
@@ -139,12 +139,6 @@
|
|||||||
<Filter Include="beast\module\core\time">
|
<Filter Include="beast\module\core\time">
|
||||||
<UniqueIdentifier>{FEAEA931-9FBB-1723-2676-9115C88A7A91}</UniqueIdentifier>
|
<UniqueIdentifier>{FEAEA931-9FBB-1723-2676-9115C88A7A91}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="beast\module\sqlite">
|
|
||||||
<UniqueIdentifier>{81C8331F-4768-BDE6-D058-29BDEE8F322C}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="beast\module\sqlite\sqlite">
|
|
||||||
<UniqueIdentifier>{43A67E22-F261-00BB-B657-C9427E7F2615}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="beast\net">
|
<Filter Include="beast\net">
|
||||||
<UniqueIdentifier>{02B45E0B-A3F5-ECE5-B83C-AF06DC73AF14}</UniqueIdentifier>
|
<UniqueIdentifier>{02B45E0B-A3F5-ECE5-B83C-AF06DC73AF14}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -556,6 +550,9 @@
|
|||||||
<Filter Include="sqlite">
|
<Filter Include="sqlite">
|
||||||
<UniqueIdentifier>{FA8496D0-0D5F-AC6F-3422-DEAB4BA19ACA}</UniqueIdentifier>
|
<UniqueIdentifier>{FA8496D0-0D5F-AC6F-3422-DEAB4BA19ACA}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="sqlite\sqlite">
|
||||||
|
<UniqueIdentifier>{D2A046B6-8986-92AC-082F-15B3A01B8E40}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
<Filter Include="websocketpp">
|
<Filter Include="websocketpp">
|
||||||
<UniqueIdentifier>{EE7AC8C9-27EB-C05E-C986-EECB0174B997}</UniqueIdentifier>
|
<UniqueIdentifier>{EE7AC8C9-27EB-C05E-C986-EECB0174B997}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -1380,18 +1377,6 @@
|
|||||||
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
|
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
|
||||||
<Filter>beast\module\core\time</Filter>
|
<Filter>beast\module\core\time</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite.h">
|
|
||||||
<Filter>beast\module\sqlite</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\sqlite\sqlite.unity.c">
|
|
||||||
<Filter>beast\module\sqlite</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\sqlite\sqlite\sqlite3.c">
|
|
||||||
<Filter>beast\module\sqlite\sqlite</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite\sqlite3.h">
|
|
||||||
<Filter>beast\module\sqlite\sqlite</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\net\detail\Parse.h">
|
<ClInclude Include="..\..\src\beast\beast\net\detail\Parse.h">
|
||||||
<Filter>beast\net\detail</Filter>
|
<Filter>beast\net\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -5283,9 +5268,21 @@
|
|||||||
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
||||||
<Filter>soci\src\core</Filter>
|
<Filter>soci\src\core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\sqlite\sqlite.h">
|
||||||
|
<Filter>sqlite</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\sqlite\sqlite.unity.c">
|
||||||
|
<Filter>sqlite</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
|
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
|
||||||
<Filter>sqlite</Filter>
|
<Filter>sqlite</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\sqlite\sqlite\sqlite3.c">
|
||||||
|
<Filter>sqlite\sqlite</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClInclude Include="..\..\src\sqlite\sqlite\sqlite3.h">
|
||||||
|
<Filter>sqlite\sqlite</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
|
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
|
||||||
<Filter>websocketpp\websocketpp\base64</Filter>
|
<Filter>websocketpp\websocketpp\base64</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_BACKEND_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_BACKEND_H_INCLUDED
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
//signed char
|
|
||||||
//wchar_t
|
|
||||||
|
|
||||||
// supported standard types for intos and uses
|
|
||||||
enum exchange_type
|
|
||||||
{
|
|
||||||
x_null, // only for input variables
|
|
||||||
|
|
||||||
x_bool,
|
|
||||||
x_char, x_uchar,
|
|
||||||
x_short, x_ushort,
|
|
||||||
x_int, x_uint,
|
|
||||||
x_long, x_ulong,
|
|
||||||
x_longlong, x_ulonglong,
|
|
||||||
x_float, x_double, x_longdouble,
|
|
||||||
|
|
||||||
x_cstring, // null terminated char*, only valid for use_type
|
|
||||||
x_cwstring, // null terminated wchar*, only valid for use_type
|
|
||||||
x_stdstring,
|
|
||||||
x_stdwstring,
|
|
||||||
x_beastString,
|
|
||||||
|
|
||||||
x_stdtm,
|
|
||||||
|
|
||||||
x_blob
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
// the enum type for indicator variables
|
|
||||||
enum indicator
|
|
||||||
{
|
|
||||||
i_ok,
|
|
||||||
i_null,
|
|
||||||
i_truncated
|
|
||||||
};
|
|
||||||
|
|
||||||
// sqlite row id
|
|
||||||
|
|
||||||
//typedef sqlite3_int64 rowid;
|
|
||||||
typedef std::int64_t rowid;
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_BLOB_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_BLOB_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
// BLOB interface
|
|
||||||
class blob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
blob();
|
|
||||||
~blob();
|
|
||||||
|
|
||||||
Error select(session& s,
|
|
||||||
char const* zTable,
|
|
||||||
char const* zColumn,
|
|
||||||
rowid id,
|
|
||||||
bool readAndWrite = false) noexcept;
|
|
||||||
|
|
||||||
int get_len();
|
|
||||||
Error read(int offset, void* buf, int toRead);
|
|
||||||
Error write(int offset, void const* buf, int toWrite);
|
|
||||||
void close();
|
|
||||||
|
|
||||||
private:
|
|
||||||
session* m_session;
|
|
||||||
sqlite3_blob* m_blob;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_INTO_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_INTO_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
detail::into_type_ptr into(T& t)
|
|
||||||
{
|
|
||||||
return detail::do_into(t,
|
|
||||||
typename detail::exchange_traits<T>::type_family());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
detail::into_type_ptr into(T& t, indicator& ind)
|
|
||||||
{
|
|
||||||
return detail::do_into(t, ind,
|
|
||||||
typename detail::exchange_traits<T>::type_family());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_SESSION_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_SESSION_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/smart_ptr/SharedPtr.h>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
/*============================================================================*/
|
|
||||||
/**
|
|
||||||
@brief A session for the embedded database.
|
|
||||||
|
|
||||||
@ingroup vf_db
|
|
||||||
*/
|
|
||||||
class session
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
session();
|
|
||||||
~session();
|
|
||||||
|
|
||||||
// DEPRECATED!
|
|
||||||
// opens the deferred clone
|
|
||||||
explicit session(session const& deferredClone);
|
|
||||||
Error clone();
|
|
||||||
|
|
||||||
/**
|
|
||||||
Open a database.
|
|
||||||
|
|
||||||
The database at the specified path is opened. The connection string is
|
|
||||||
a set of "{key}={value}" pairs separated with the pipe symbol ('|').
|
|
||||||
Choices for key and value are:
|
|
||||||
|
|
||||||
@code
|
|
||||||
|
|
||||||
timeout = (number) || "infinite"
|
|
||||||
|
|
||||||
mode = "read" || "write" || "create"
|
|
||||||
|
|
||||||
cache = "shared" || "private"
|
|
||||||
|
|
||||||
threads = "single" || "multi"
|
|
||||||
|
|
||||||
@endcode
|
|
||||||
*/
|
|
||||||
Error open(String fileName,
|
|
||||||
std::string options = "timeout=infinite|mode=create|threads=multi");
|
|
||||||
|
|
||||||
void close();
|
|
||||||
|
|
||||||
void begin();
|
|
||||||
Error commit();
|
|
||||||
void rollback();
|
|
||||||
|
|
||||||
bool in_transaction()
|
|
||||||
{
|
|
||||||
return m_bInTransaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
detail::once_type once(Error& error);
|
|
||||||
detail::prepare_type prepare;
|
|
||||||
|
|
||||||
rowid last_insert_rowid();
|
|
||||||
|
|
||||||
std::ostringstream& get_query_stream();
|
|
||||||
|
|
||||||
void log_query(std::string const& query);
|
|
||||||
|
|
||||||
void set_got_data(bool bGotData);
|
|
||||||
bool got_data() const;
|
|
||||||
|
|
||||||
sqlite3* get_connection()
|
|
||||||
{
|
|
||||||
return m_connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Error hard_exec(std::string const& query);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_bInTransaction;
|
|
||||||
sqlite3* m_connection;
|
|
||||||
String m_fileName;
|
|
||||||
std::string m_connectString;
|
|
||||||
|
|
||||||
std::ostringstream m_query_stream;
|
|
||||||
bool m_bGotData;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_STATEMENT_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_STATEMENT_H_INCLUDED
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
//
|
|
||||||
// Lightweight copyable handle to a statement. This
|
|
||||||
// is just a wrapper around the actual statement implementation.
|
|
||||||
//
|
|
||||||
class statement
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
statement(session& s);
|
|
||||||
statement(detail::prepare_temp_type const& prep);
|
|
||||||
~statement();
|
|
||||||
|
|
||||||
statement(statement const& o);
|
|
||||||
void operator= (statement const& o);
|
|
||||||
|
|
||||||
void exchange(detail::into_type_ptr const& i);
|
|
||||||
void exchange(detail::use_type_ptr const& u);
|
|
||||||
|
|
||||||
void prepare(std::string const& query, bool bRepeatable = true);
|
|
||||||
|
|
||||||
Error execute();
|
|
||||||
bool execute_and_fetch(Error& error);
|
|
||||||
bool fetch(Error& error);
|
|
||||||
|
|
||||||
bool got_data() const;
|
|
||||||
rowid last_insert_rowid();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class detail::ref_counted_statement;
|
|
||||||
|
|
||||||
void clean_up();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr <detail::statement_imp> m_imp;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_TRANSACTION_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_TRANSACTION_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/utility/Error.h>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
class transaction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit transaction(session& s);
|
|
||||||
~transaction();
|
|
||||||
transaction& operator= (transaction const&) = delete;
|
|
||||||
Error commit();
|
|
||||||
void rollback();
|
|
||||||
|
|
||||||
private:
|
|
||||||
session& m_session;
|
|
||||||
bool m_bHandled;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_TYPE_CONVERSION_TRAITS_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_TYPE_CONVERSION_TRAITS_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/module/core/time/Time.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
// default conversion (copy in to out)
|
|
||||||
template<typename T>
|
|
||||||
struct type_conversion
|
|
||||||
{
|
|
||||||
typedef T base_type;
|
|
||||||
|
|
||||||
static void from_base(base_type const& in, indicator ind, T& out)
|
|
||||||
{
|
|
||||||
// null not allowed
|
|
||||||
assert (ind != i_null);
|
|
||||||
out = in;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void to_base(T const& in, base_type& out, indicator& ind)
|
|
||||||
{
|
|
||||||
out = in;
|
|
||||||
ind = i_ok;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Time
|
|
||||||
template <>
|
|
||||||
struct type_conversion <Time>
|
|
||||||
{
|
|
||||||
//typedef sqlite3_int64 base_type;
|
|
||||||
typedef std::int64_t base_type;
|
|
||||||
|
|
||||||
static void from_base(const base_type v, indicator ind, Time& result)
|
|
||||||
{
|
|
||||||
if (ind == i_null)
|
|
||||||
{
|
|
||||||
// bassertfalse
|
|
||||||
result = Time(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = Time(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void to_base(const Time& v, base_type& result, indicator& ind)
|
|
||||||
{
|
|
||||||
result = v.toMilliseconds();
|
|
||||||
ind = i_ok;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_API_USE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_API_USE_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
inline detail::use_type_ptr use_null()
|
|
||||||
{
|
|
||||||
return detail::do_use_null();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
detail::use_type_ptr use(T& t)
|
|
||||||
{
|
|
||||||
return detail::do_use(t,
|
|
||||||
typename detail::exchange_traits<T>::type_family());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
detail::use_type_ptr use(T const& t)
|
|
||||||
{
|
|
||||||
return detail::do_use(t,
|
|
||||||
typename detail::exchange_traits<T>::type_family());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
detail::use_type_ptr use(T& t, indicator& ind)
|
|
||||||
{
|
|
||||||
return detail::do_use(t, ind,
|
|
||||||
typename detail::exchange_traits<T>::type_family());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_ERROR_CODES_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_ERROR_CODES_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// Converts SQLITE error codes into an Error object
|
|
||||||
extern const Error sqliteError(const char* sourceFileName,
|
|
||||||
int lineNumber,
|
|
||||||
int sqliteErrorCode);
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_EXCHANGE_TRAITS_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_EXCHANGE_TRAITS_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
struct basic_type_tag {};
|
|
||||||
struct user_type_tag {};
|
|
||||||
|
|
||||||
// converts a type to exchange_type
|
|
||||||
template<typename T>
|
|
||||||
struct exchange_traits
|
|
||||||
{
|
|
||||||
typedef user_type_tag type_family;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
x_type = exchange_traits<typename type_conversion<T>::base_type>::x_type
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <bool>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_bool };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <char>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_char };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <unsigned char>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_uchar };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <short>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_short };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <unsigned short>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_ushort };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <int>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_int };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <unsigned int>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_uint };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <long>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_long };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <unsigned long>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_ulong };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <long long>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_longlong };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <unsigned long long>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_ulonglong };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <float>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_float};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <double>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_double };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct exchange_traits <long double>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_longdouble };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<char*>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_cstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<char const*>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_cstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<wchar_t*>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_cwstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<wchar_t const*>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_cwstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<std::string>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_stdstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<std::wstring>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_stdwstring };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<String>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_beastString };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<std::tm>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_stdtm };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct exchange_traits<blob>
|
|
||||||
{
|
|
||||||
typedef basic_type_tag type_family;
|
|
||||||
enum { x_type = x_blob };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_INTO_TYPE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_INTO_TYPE_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// base class for defining output data
|
|
||||||
class into_type_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~into_type_base() {}
|
|
||||||
virtual void bind(statement_imp& st, int& iCol) = 0;
|
|
||||||
virtual void do_into() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef type_ptr<into_type_base> into_type_ptr;
|
|
||||||
|
|
||||||
// standard output types
|
|
||||||
class standard_into_type : public into_type_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
standard_into_type(void* data, exchange_type type)
|
|
||||||
: m_data(data), m_type(type), m_ind(0) {}
|
|
||||||
standard_into_type(void* data, exchange_type type, indicator& ind)
|
|
||||||
: m_data(data), m_type(type), m_ind(&ind) {}
|
|
||||||
virtual ~standard_into_type();
|
|
||||||
virtual void bind(statement_imp& st, int& iCol);
|
|
||||||
virtual void do_into();
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void convert_from_base() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void* m_data;
|
|
||||||
exchange_type m_type;
|
|
||||||
indicator* m_ind;
|
|
||||||
statement_imp* m_st;
|
|
||||||
int m_iCol;
|
|
||||||
};
|
|
||||||
|
|
||||||
// implementation for built-in types without conversions
|
|
||||||
template<typename T>
|
|
||||||
class into_type : public standard_into_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
into_type(T& t) : standard_into_type(&t,
|
|
||||||
static_cast <exchange_type>(exchange_traits<T>::x_type)) {}
|
|
||||||
|
|
||||||
into_type(T& t, indicator& ind) : standard_into_type(&t,
|
|
||||||
static_cast<exchange_type>(exchange_traits<T>::x_type), ind) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
into_type_ptr do_into(T& t, basic_type_tag)
|
|
||||||
{
|
|
||||||
return into_type_ptr(new into_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
into_type_ptr do_into(T& t, indicator& ind, basic_type_tag)
|
|
||||||
{
|
|
||||||
return into_type_ptr(new into_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_ONCE_TEMP_TYPE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_ONCE_TEMP_TYPE_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
class once_temp_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
once_temp_type(session& s, Error& error);
|
|
||||||
once_temp_type(once_temp_type const& o);
|
|
||||||
once_temp_type& operator=(once_temp_type const& o);
|
|
||||||
~once_temp_type();
|
|
||||||
|
|
||||||
once_temp_type& operator, (into_type_ptr const& i);
|
|
||||||
once_temp_type& operator, (use_type_ptr const& u);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
once_temp_type& operator<<(T const& t)
|
|
||||||
{
|
|
||||||
m_rcst->accumulate(t);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ref_counted_statement* m_rcst;
|
|
||||||
};
|
|
||||||
|
|
||||||
class once_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
once_type(const once_type& other);
|
|
||||||
once_type(session* s, Error& error);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
once_temp_type operator<<(T const& t)
|
|
||||||
{
|
|
||||||
once_temp_type o(m_session, m_error);
|
|
||||||
o << t;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
once_type& operator= (const once_type&);
|
|
||||||
|
|
||||||
session& m_session;
|
|
||||||
Error& m_error;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_PREPARE_TEMP_TYPE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_PREPARE_TEMP_TYPE_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// lightweight copyable wrapper around the prepare info
|
|
||||||
class prepare_temp_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
prepare_temp_type(session& s);
|
|
||||||
prepare_temp_type(prepare_temp_type const& o);
|
|
||||||
prepare_temp_type& operator=(prepare_temp_type const& o);
|
|
||||||
|
|
||||||
~prepare_temp_type();
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
prepare_temp_type& operator<<(T const& t)
|
|
||||||
{
|
|
||||||
m_rcpi->accumulate(t);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type& operator, (into_type_ptr const& i);
|
|
||||||
prepare_temp_type& operator, (use_type_ptr const& u);
|
|
||||||
|
|
||||||
ref_counted_prepare_info& get_prepare_info() const
|
|
||||||
{
|
|
||||||
return *m_rcpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ref_counted_prepare_info* m_rcpi;
|
|
||||||
};
|
|
||||||
|
|
||||||
class prepare_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
prepare_type() : m_session(NULL) {}
|
|
||||||
prepare_type(session* s) : m_session(s) {}
|
|
||||||
|
|
||||||
template<typename T> prepare_temp_type operator<<(T const& t)
|
|
||||||
{
|
|
||||||
prepare_temp_type p(*m_session);
|
|
||||||
p << t;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
session* m_session;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_REF_COUNTED_PREPARE_INFO_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_REF_COUNTED_PREPARE_INFO_H_INCLUDED
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// helper that collects statement text and bindings to create the statement
|
|
||||||
class ref_counted_prepare_info : public ref_counted_statement_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ref_counted_prepare_info(session& s);
|
|
||||||
void exchange(into_type_ptr const& i);
|
|
||||||
void exchange(use_type_ptr const& u);
|
|
||||||
virtual void final_action();
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::string get_query() const;
|
|
||||||
|
|
||||||
std::vector <into_type_base*> m_intos;
|
|
||||||
std::vector <use_type_base*> m_uses;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_REF_COUNTED_STATEMENT_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_REF_COUNTED_STATEMENT_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// used for "once" and "prepare"
|
|
||||||
class ref_counted_statement_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ref_counted_statement_base(session& s);
|
|
||||||
virtual ~ref_counted_statement_base();
|
|
||||||
|
|
||||||
virtual void final_action() = 0;
|
|
||||||
|
|
||||||
void addref();
|
|
||||||
void release();
|
|
||||||
|
|
||||||
template<typename T> void accumulate(T const& t)
|
|
||||||
{
|
|
||||||
get_query_stream() << t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
ref_counted_statement_base (
|
|
||||||
ref_counted_statement_base const&) = delete;
|
|
||||||
ref_counted_statement_base& operator= (
|
|
||||||
ref_counted_statement_base const&) = delete;
|
|
||||||
|
|
||||||
// break circular header dependency
|
|
||||||
std::ostringstream& get_query_stream();
|
|
||||||
|
|
||||||
Error* m_perror;
|
|
||||||
int m_refs;
|
|
||||||
session& m_session;
|
|
||||||
};
|
|
||||||
|
|
||||||
// used for "once"
|
|
||||||
class ref_counted_statement : public ref_counted_statement_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ref_counted_statement(session& s, Error& error);
|
|
||||||
void exchange(into_type_ptr const& i);
|
|
||||||
void exchange(use_type_ptr const& u);
|
|
||||||
|
|
||||||
void final_action();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Error& m_error;
|
|
||||||
statement m_st;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_STATEMENT_IMP_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_STATEMENT_IMP_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// statement implementation
|
|
||||||
class statement_imp : public SharedObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit statement_imp(session& s);
|
|
||||||
explicit statement_imp(prepare_temp_type const& prep);
|
|
||||||
~statement_imp();
|
|
||||||
|
|
||||||
void erase_bindings();
|
|
||||||
void exchange(detail::into_type_ptr const& i);
|
|
||||||
void exchange(detail::use_type_ptr const& u);
|
|
||||||
void clean_up();
|
|
||||||
|
|
||||||
void prepare(std::string const& query, bool bRepeatable = true);
|
|
||||||
Error execute();
|
|
||||||
bool fetch(Error& error);
|
|
||||||
bool got_data() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void do_intos();
|
|
||||||
void pre_use();
|
|
||||||
void do_uses();
|
|
||||||
void post_use();
|
|
||||||
void release_resources();
|
|
||||||
rowid last_insert_rowid();
|
|
||||||
|
|
||||||
public:
|
|
||||||
session& m_session;
|
|
||||||
sqlite3_stmt* m_stmt;
|
|
||||||
std::string m_query;
|
|
||||||
bool m_bReady;
|
|
||||||
bool m_bGotData;
|
|
||||||
bool m_bFirstTime;
|
|
||||||
rowid m_last_insert_rowid;
|
|
||||||
|
|
||||||
typedef std::vector <detail::into_type_base*> intos_t;
|
|
||||||
typedef std::vector <detail::use_type_base*> uses_t;
|
|
||||||
|
|
||||||
intos_t m_intos;
|
|
||||||
uses_t m_uses;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_TYPE_CONVERSION_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_TYPE_CONVERSION_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// used to order into and uses that need conversions
|
|
||||||
template<typename T>
|
|
||||||
struct base_value_holder
|
|
||||||
{
|
|
||||||
typename type_conversion<T>::base_type m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// create into_type from type_conversion
|
|
||||||
template <typename T>
|
|
||||||
class conversion_into_type
|
|
||||||
: private base_value_holder<T>
|
|
||||||
, public into_type <typename type_conversion<T>::base_type>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename type_conversion<T>::base_type BASE_TYPE;
|
|
||||||
|
|
||||||
conversion_into_type(T& value)
|
|
||||||
: into_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, m_own_ind)
|
|
||||||
, m_value(value), m_ind(m_own_ind) {}
|
|
||||||
|
|
||||||
conversion_into_type(T& value, indicator& ind)
|
|
||||||
: into_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, ind)
|
|
||||||
, m_value(value), m_ind(ind) {}
|
|
||||||
|
|
||||||
conversion_into_type (conversion_into_type const&) = delete;
|
|
||||||
conversion_into_type& operator= (conversion_into_type const&) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void convert_from_base()
|
|
||||||
{
|
|
||||||
type_conversion<T>::from_base(
|
|
||||||
detail::base_value_holder<T>::m_value, m_ind, m_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
T& m_value;
|
|
||||||
|
|
||||||
indicator m_own_ind;
|
|
||||||
indicator& m_ind;
|
|
||||||
};
|
|
||||||
|
|
||||||
// used to create a use_type from a type_conversion
|
|
||||||
template<typename T>
|
|
||||||
class conversion_use_type
|
|
||||||
: private base_value_holder<T>
|
|
||||||
, public use_type<typename type_conversion<T>::base_type>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename type_conversion<T>::base_type BASE_TYPE;
|
|
||||||
|
|
||||||
conversion_use_type(T& value)
|
|
||||||
: use_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, m_own_ind)
|
|
||||||
, m_value(value), m_ind(m_own_ind), m_bReadOnly(false) {}
|
|
||||||
|
|
||||||
conversion_use_type(T const& value)
|
|
||||||
: use_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, m_own_ind)
|
|
||||||
, m_value(const_cast<T&>(value)), m_ind(m_own_ind), m_bReadOnly(true) {}
|
|
||||||
|
|
||||||
conversion_use_type(T& value, indicator& ind)
|
|
||||||
: use_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, ind)
|
|
||||||
, m_value(value), m_ind(ind), m_bReadOnly(false) {}
|
|
||||||
|
|
||||||
conversion_use_type(T const& value, indicator& ind)
|
|
||||||
: use_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, ind)
|
|
||||||
, m_value(const_cast<T&>(value)), m_ind(ind), m_bReadOnly(true) {}
|
|
||||||
|
|
||||||
conversion_use_type (conversion_use_type const&) = delete;
|
|
||||||
conversion_use_type& operator= (conversion_use_type const&) = delete;
|
|
||||||
|
|
||||||
void convert_from_base()
|
|
||||||
{
|
|
||||||
if (!m_bReadOnly)
|
|
||||||
{
|
|
||||||
type_conversion<T>::from_base(
|
|
||||||
detail::base_value_holder<T>::m_value, m_ind, m_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void convert_to_base()
|
|
||||||
{
|
|
||||||
type_conversion<T>::to_base(m_value,
|
|
||||||
detail::base_value_holder<T>::m_value, m_ind);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T& m_value;
|
|
||||||
indicator m_own_ind;
|
|
||||||
indicator& m_ind;
|
|
||||||
bool m_bReadOnly;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
into_type_ptr do_into(T& t, user_type_tag)
|
|
||||||
{
|
|
||||||
return into_type_ptr(new conversion_into_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
into_type_ptr do_into(T& t, indicator& ind, user_type_tag)
|
|
||||||
{
|
|
||||||
return into_type_ptr(new conversion_into_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
use_type_ptr do_use(T& t, user_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new conversion_use_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
use_type_ptr do_use(T const& t, user_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new conversion_use_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
use_type_ptr do_use(T& t, indicator& ind, user_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new conversion_use_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
use_type_ptr do_use(T const& t, indicator& ind, user_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new conversion_use_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_TYPE_PTR_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_TYPE_PTR_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// helper for managing the lifetime of into and use objects
|
|
||||||
template <typename T>
|
|
||||||
class type_ptr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
type_ptr(T* p) : m_p(p) { }
|
|
||||||
~type_ptr()
|
|
||||||
{
|
|
||||||
delete m_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
T* get() const
|
|
||||||
{
|
|
||||||
return m_p;
|
|
||||||
}
|
|
||||||
void release() const
|
|
||||||
{
|
|
||||||
m_p = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable T* m_p;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_DETAIL_USE_TYPE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_DETAIL_USE_TYPE_H_INCLUDED
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// base class for defining input data
|
|
||||||
class use_type_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~use_type_base() {}
|
|
||||||
virtual void bind(statement_imp& st, int& iParam) = 0;
|
|
||||||
virtual void do_use() = 0;
|
|
||||||
virtual void post_use() = 0;
|
|
||||||
virtual void clean_up() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef type_ptr<use_type_base> use_type_ptr;
|
|
||||||
|
|
||||||
// handles builtin types
|
|
||||||
class standard_use_type : public use_type_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
standard_use_type(void* data, exchange_type type, bool bReadOnly)
|
|
||||||
: m_data(data), m_type(type), m_ind(0), m_bReadOnly(bReadOnly) {}
|
|
||||||
standard_use_type(void* data, exchange_type type, indicator& ind, bool bReadOnly)
|
|
||||||
: m_data(data), m_type(type), m_ind(&ind), m_bReadOnly(bReadOnly) {}
|
|
||||||
virtual ~standard_use_type();
|
|
||||||
virtual void bind(statement_imp& st, int& iParam);
|
|
||||||
virtual void do_use();
|
|
||||||
virtual void post_use();
|
|
||||||
virtual void clean_up();
|
|
||||||
|
|
||||||
virtual void convert_to_base() {}
|
|
||||||
virtual void convert_from_base() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void clean_up_backend();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void* m_data;
|
|
||||||
exchange_type m_type;
|
|
||||||
indicator* m_ind;
|
|
||||||
bool m_bReadOnly;
|
|
||||||
statement_imp* m_st;
|
|
||||||
int m_iParam;
|
|
||||||
};
|
|
||||||
|
|
||||||
// worker for use
|
|
||||||
template<typename T>
|
|
||||||
class use_type : public standard_use_type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
use_type(T& t)
|
|
||||||
: standard_use_type(&t, static_cast<exchange_type>
|
|
||||||
(exchange_traits<T>::x_type), false) {}
|
|
||||||
|
|
||||||
use_type(T const& t)
|
|
||||||
: standard_use_type(const_cast<T*>(&t), static_cast<exchange_type>
|
|
||||||
(exchange_traits<T>::x_type), true) {}
|
|
||||||
|
|
||||||
use_type(T& t, indicator& ind)
|
|
||||||
: standard_use_type(&t, static_cast<exchange_type>
|
|
||||||
(exchange_traits<T>::x_type), ind, false) {}
|
|
||||||
|
|
||||||
use_type(T const& t, indicator& ind)
|
|
||||||
: standard_use_type(const_cast<T*>(&t), static_cast<exchange_type>
|
|
||||||
(exchange_traits<T>::x_type), ind, true) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// helpers for builtins
|
|
||||||
inline use_type_ptr do_use_null()
|
|
||||||
{
|
|
||||||
return use_type_ptr(new standard_use_type(0, x_null, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
use_type_ptr do_use(T& t, basic_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new use_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
use_type_ptr do_use(T const& t, basic_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new use_type<T>(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
use_type_ptr do_use(T& t, indicator& ind, basic_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new use_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
use_type_ptr do_use(T const& t, indicator& ind, basic_type_tag)
|
|
||||||
{
|
|
||||||
return use_type_ptr(new use_type<T>(t, ind));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
blob::blob()
|
|
||||||
: m_blob(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
blob::~blob()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Error blob::select(session& s,
|
|
||||||
char const* zTable,
|
|
||||||
char const* zColumn,
|
|
||||||
rowid id,
|
|
||||||
bool readAndWrite) noexcept
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
|
|
||||||
m_session = &s;
|
|
||||||
|
|
||||||
int result = sqlite3_blob_open(s.get_connection(),
|
|
||||||
"main",
|
|
||||||
zTable,
|
|
||||||
zColumn,
|
|
||||||
id,
|
|
||||||
readAndWrite ? 1 : 0,
|
|
||||||
&m_blob);
|
|
||||||
|
|
||||||
return detail::sqliteError(__FILE__, __LINE__, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
int blob::get_len()
|
|
||||||
{
|
|
||||||
return sqlite3_blob_bytes(m_blob);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error blob::read(int offset, void* buf, int toRead)
|
|
||||||
{
|
|
||||||
return detail::sqliteError(__FILE__, __LINE__,
|
|
||||||
sqlite3_blob_read(m_blob, static_cast<char*>(buf), toRead, offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
Error blob::write(int offset, void const* buf, int toWrite)
|
|
||||||
{
|
|
||||||
return detail::sqliteError(__FILE__, __LINE__,
|
|
||||||
sqlite3_blob_write(m_blob, buf, toWrite, offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
void blob::close()
|
|
||||||
{
|
|
||||||
if (m_blob)
|
|
||||||
{
|
|
||||||
sqlite3_blob_close(m_blob);
|
|
||||||
m_blob = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// VFALCO What the heck is this?!
|
|
||||||
#ifdef c
|
|
||||||
#undef c
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const Error sqliteError(const char* sourceFileName,
|
|
||||||
int lineNumber,
|
|
||||||
int sqliteErrorCode)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
bassert (sqliteErrorCode != SQLITE_ROW &&
|
|
||||||
sqliteErrorCode != SQLITE_DONE);
|
|
||||||
*/
|
|
||||||
|
|
||||||
Error e;
|
|
||||||
String s;
|
|
||||||
Error::Code c;
|
|
||||||
|
|
||||||
switch (sqliteErrorCode)
|
|
||||||
{
|
|
||||||
// should never get these two here but include them just in case
|
|
||||||
case SQLITE_ROW:
|
|
||||||
case SQLITE_DONE:
|
|
||||||
|
|
||||||
case SQLITE_OK:
|
|
||||||
// this is fine, and lets us avoid having to explicitly
|
|
||||||
// check for SQLITE_OK and just deal in terms of the Error object.
|
|
||||||
c = Error::success;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_ERROR:
|
|
||||||
s = "an sqlite error or missing database was encountered";
|
|
||||||
c = Error::general;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_INTERNAL:
|
|
||||||
s = "sqlite encountered an internal logic error";
|
|
||||||
c = Error::unexpected;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_PERM:
|
|
||||||
s = "sqlite was denied file access permission";
|
|
||||||
c = Error::fileNoPerm;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_ABORT:
|
|
||||||
s = "the sqlite operation was canceled due to a callback";
|
|
||||||
c = Error::canceled;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_BUSY:
|
|
||||||
s = "the sqlite database file is locked";
|
|
||||||
c = Error::fileInUse;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_LOCKED:
|
|
||||||
s = "the sqlite database table was locked";
|
|
||||||
c = Error::fileInUse;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_NOMEM:
|
|
||||||
s = "sqlite ran out of memory";
|
|
||||||
c = Error::noMemory;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_READONLY:
|
|
||||||
s = "sqlite tried to write to a read-only database";
|
|
||||||
c = Error::fileNoPerm;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_INTERRUPT:
|
|
||||||
s = "the sqlite operation was interrupted";
|
|
||||||
c = Error::canceled;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_IOERR:
|
|
||||||
s = "sqlite encountered a device I/O error";
|
|
||||||
c = Error::fileIOError;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_CORRUPT:
|
|
||||||
s = "the sqlite database is corrupt";
|
|
||||||
c = Error::invalidData;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_FULL:
|
|
||||||
s = "the sqlite database is full";
|
|
||||||
c = Error::fileNoSpace;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_CANTOPEN:
|
|
||||||
s = "the sqlite database could not be opened";
|
|
||||||
c = Error::fileNotFound;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_PROTOCOL:
|
|
||||||
s = "sqlite encountered a lock protocol error";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_EMPTY:
|
|
||||||
s = "the sqlite database is empty";
|
|
||||||
c = Error::noMoreData;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_SCHEMA:
|
|
||||||
s = "the sqlite database scheme was changed";
|
|
||||||
c = Error::invalidData;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_TOOBIG:
|
|
||||||
s = "the sqlite string or blob was too large";
|
|
||||||
c = Error::fileNoSpace;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_CONSTRAINT:
|
|
||||||
s = "the sqlite operation was aborted due to a constraint violation";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_MISMATCH:
|
|
||||||
s = "the sqlite data was mismatched";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_MISUSE:
|
|
||||||
s = "the sqlite library parameter was invalid";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_NOLFS:
|
|
||||||
s = "the sqlite platform feature is unavailable";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_AUTH:
|
|
||||||
s = "sqlite authorization was denied";
|
|
||||||
c = Error::fileNoPerm;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_FORMAT:
|
|
||||||
s = "the auxiliary sqlite database has an invalid format";
|
|
||||||
c = Error::invalidData;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_RANGE:
|
|
||||||
s = "the sqlite parameter was invalid";
|
|
||||||
c = Error::badParameter;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_NOTADB:
|
|
||||||
s = "the file is not a sqlite database";
|
|
||||||
c = Error::invalidData;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
s << "an unknown sqlite3 error code #"
|
|
||||||
<< String(sqliteErrorCode)
|
|
||||||
<< "was returned";
|
|
||||||
c = Error::general;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c != Error::success)
|
|
||||||
e.fail(sourceFileName, lineNumber, s, c);
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T& as(void* data)
|
|
||||||
{
|
|
||||||
return *static_cast<T*>(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static void integer_into(void* data, sqlite3_int64 v)
|
|
||||||
{
|
|
||||||
*(static_cast<T*>(data)) = T(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
standard_into_type::~standard_into_type()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_into_type::bind(statement_imp& st, int& iCol)
|
|
||||||
{
|
|
||||||
m_st = &st;
|
|
||||||
m_iCol = iCol++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_into_type::do_into()
|
|
||||||
{
|
|
||||||
int colType = sqlite3_column_type(m_st->m_stmt, m_iCol);
|
|
||||||
|
|
||||||
if (colType == SQLITE_NULL)
|
|
||||||
{
|
|
||||||
// null encountered with no indicator
|
|
||||||
assert (m_ind != nullptr);
|
|
||||||
|
|
||||||
*m_ind = i_null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_ind)
|
|
||||||
*m_ind = i_ok;
|
|
||||||
|
|
||||||
switch (colType)
|
|
||||||
{
|
|
||||||
case SQLITE_INTEGER:
|
|
||||||
{
|
|
||||||
sqlite3_int64 v = sqlite3_column_int64(m_st->m_stmt, m_iCol);
|
|
||||||
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case x_bool: as <bool> (m_data) = v != 0; break;
|
|
||||||
case x_char: integer_into <char> (m_data, v); break;
|
|
||||||
case x_uchar: integer_into <unsigned char> (m_data, v); break;
|
|
||||||
case x_short: integer_into <short> (m_data, v); break;
|
|
||||||
case x_ushort: integer_into <unsigned short> (m_data, v); break;
|
|
||||||
case x_int: integer_into <int> (m_data, v); break;
|
|
||||||
case x_uint: integer_into <unsigned int> (m_data, v); break;
|
|
||||||
case x_long: integer_into <long> (m_data, v); break;
|
|
||||||
case x_ulong: integer_into <unsigned long> (m_data, v); break;
|
|
||||||
case x_longlong: integer_into <long long> (m_data, v); break;
|
|
||||||
case x_ulonglong: integer_into <unsigned long long> (m_data, v); break;
|
|
||||||
|
|
||||||
case x_beastString:
|
|
||||||
as <String> (m_data) = String(v);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument ("unknown case");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_FLOAT:
|
|
||||||
{
|
|
||||||
double const v (sqlite3_column_double (
|
|
||||||
m_st->m_stmt, m_iCol));
|
|
||||||
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case x_float: as <float> (m_data) = static_cast <float> (v); break;
|
|
||||||
case x_double: as <double> (m_data) = v; break;
|
|
||||||
case x_longdouble: as <long double> (m_data) = v; break;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_beastString:
|
|
||||||
as <String> (m_data) = String(v);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument ("unknown case");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_TEXT:
|
|
||||||
{
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case x_stdstring:
|
|
||||||
{
|
|
||||||
// excludes terminator
|
|
||||||
int bytes = sqlite3_column_bytes(m_st->m_stmt, m_iCol);
|
|
||||||
unsigned char const* v = sqlite3_column_text(m_st->m_stmt, m_iCol);
|
|
||||||
std::string& result = as<std::string>(m_data);
|
|
||||||
result.assign(reinterpret_cast<char const*>(v), bytes);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_stdwstring:
|
|
||||||
throw std::invalid_argument ("invalid case");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_beastString:
|
|
||||||
{
|
|
||||||
// excludes terminator
|
|
||||||
int bytes = sqlite3_column_bytes(m_st->m_stmt, m_iCol);
|
|
||||||
|
|
||||||
const CharPointer_UTF8::CharType* c = reinterpret_cast
|
|
||||||
<const CharPointer_UTF8::CharType*>
|
|
||||||
(sqlite3_column_text(m_st->m_stmt, m_iCol));
|
|
||||||
|
|
||||||
String& s = as <String> (m_data);
|
|
||||||
s = String(CharPointer_UTF8(c), CharPointer_UTF8(c + bytes));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
sqlite3_int64 v = sqlite3_column_int64(m_st->m_stmt, m_iCol);
|
|
||||||
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case x_bool: as <bool> (m_data) = v != 0; break;
|
|
||||||
case x_char: integer_into <char> (m_data, v); break;
|
|
||||||
case x_uchar: integer_into <unsigned char> (m_data, v); break;
|
|
||||||
case x_short: integer_into <short> (m_data, v); break;
|
|
||||||
case x_ushort: integer_into <unsigned short> (m_data, v); break;
|
|
||||||
case x_int: integer_into <int> (m_data, v); break;
|
|
||||||
case x_uint: integer_into <unsigned int> (m_data, v); break;
|
|
||||||
case x_long: integer_into <long> (m_data, v); break;
|
|
||||||
case x_ulong: integer_into <unsigned long> (m_data, v); break;
|
|
||||||
case x_longlong: integer_into <long long> (m_data, v); break;
|
|
||||||
case x_ulonglong: integer_into <unsigned long long> (m_data, v); break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument ("unknown case");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SQLITE_BLOB:
|
|
||||||
throw std::invalid_argument ("invalid case");
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument ("unknown case");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
convert_from_base();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
once_type::once_type(const once_type& other)
|
|
||||||
: m_session(other.m_session)
|
|
||||||
, m_error(other.m_error)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type::once_temp_type(session& s, Error& error)
|
|
||||||
: m_rcst(new ref_counted_statement(s, error))
|
|
||||||
{
|
|
||||||
// new query
|
|
||||||
s.get_query_stream().str("");
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type::once_temp_type(once_temp_type const& o)
|
|
||||||
: m_rcst(o.m_rcst)
|
|
||||||
{
|
|
||||||
m_rcst->addref();
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type& once_temp_type::operator= (once_temp_type const& o)
|
|
||||||
{
|
|
||||||
o.m_rcst->addref();
|
|
||||||
m_rcst->release();
|
|
||||||
m_rcst = o.m_rcst;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type::~once_temp_type()
|
|
||||||
{
|
|
||||||
m_rcst->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type& once_temp_type::operator, (into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_rcst->exchange(i);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
once_temp_type& once_temp_type::operator, (use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_rcst->exchange(u);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
once_type::once_type(session* s, Error& error)
|
|
||||||
: m_session(*s)
|
|
||||||
, m_error(error)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
prepare_temp_type::prepare_temp_type(session& s)
|
|
||||||
: m_rcpi(new ref_counted_prepare_info(s))
|
|
||||||
{
|
|
||||||
// new query
|
|
||||||
s.get_query_stream().str("");
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type::prepare_temp_type(prepare_temp_type const& o)
|
|
||||||
: m_rcpi(o.m_rcpi)
|
|
||||||
{
|
|
||||||
m_rcpi->addref();
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type& prepare_temp_type::operator=(prepare_temp_type const& o)
|
|
||||||
{
|
|
||||||
o.m_rcpi->addref();
|
|
||||||
m_rcpi->release();
|
|
||||||
m_rcpi = o.m_rcpi;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type::~prepare_temp_type()
|
|
||||||
{
|
|
||||||
m_rcpi->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type& prepare_temp_type::operator, (into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_rcpi->exchange(i);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_temp_type& prepare_temp_type::operator, (use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_rcpi->exchange(u);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
ref_counted_prepare_info::ref_counted_prepare_info(session& s)
|
|
||||||
: ref_counted_statement_base(s)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_prepare_info::exchange(into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_intos.push_back(i.get());
|
|
||||||
i.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_prepare_info::exchange(use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_uses.push_back(u.get());
|
|
||||||
u.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_prepare_info::final_action()
|
|
||||||
{
|
|
||||||
for (std::size_t i = m_intos.size(); i > 0; --i)
|
|
||||||
{
|
|
||||||
delete m_intos[i - 1];
|
|
||||||
m_intos.resize(i - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::size_t i = m_uses.size(); i > 0; --i)
|
|
||||||
{
|
|
||||||
delete m_uses[i - 1];
|
|
||||||
m_uses.resize(i - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ref_counted_prepare_info::get_query() const
|
|
||||||
{
|
|
||||||
return m_session.get_query_stream().str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
ref_counted_statement_base::ref_counted_statement_base(session& s)
|
|
||||||
: m_refs(1)
|
|
||||||
, m_session(s)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ref_counted_statement_base ::~ref_counted_statement_base()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_statement_base::addref()
|
|
||||||
{
|
|
||||||
++m_refs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_statement_base::release()
|
|
||||||
{
|
|
||||||
if (--m_refs == 0)
|
|
||||||
{
|
|
||||||
final_action();
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream& ref_counted_statement_base::get_query_stream()
|
|
||||||
{
|
|
||||||
return m_session.get_query_stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ref_counted_statement::ref_counted_statement(session& s, Error& error)
|
|
||||||
: ref_counted_statement_base(s)
|
|
||||||
, m_error(error)
|
|
||||||
, m_st(s)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_statement::exchange(into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_st.exchange(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_statement::exchange(use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_st.exchange(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref_counted_statement::final_action()
|
|
||||||
{
|
|
||||||
m_st.prepare(m_session.get_query_stream().str(), false);
|
|
||||||
|
|
||||||
Error error;
|
|
||||||
m_st.execute_and_fetch(error);
|
|
||||||
m_error = error;
|
|
||||||
|
|
||||||
m_st.clean_up();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,371 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
class Sqlite3Instance
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Sqlite3Instance()
|
|
||||||
{
|
|
||||||
assert (sqlite3_threadsafe() != 0);
|
|
||||||
sqlite3_initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Sqlite3Instance()
|
|
||||||
{
|
|
||||||
sqlite3_shutdown();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Sqlite3Instance sqlite3_instance;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
session::session()
|
|
||||||
: prepare (this)
|
|
||||||
, m_bInTransaction (false)
|
|
||||||
, m_connection (nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
session::session(const session& deferredClone)
|
|
||||||
: prepare (this)
|
|
||||||
, m_bInTransaction (false)
|
|
||||||
, m_connection (nullptr)
|
|
||||||
, m_fileName (deferredClone.m_fileName)
|
|
||||||
, m_connectString (deferredClone.m_connectString)
|
|
||||||
{
|
|
||||||
// shouldn't be needed since deferredClone did it
|
|
||||||
//Sqlite::initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
session::~session()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Error session::clone()
|
|
||||||
{
|
|
||||||
assert (! m_connection);
|
|
||||||
|
|
||||||
return open(m_fileName, m_connectString);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error session::open(String fileName, std::string options)
|
|
||||||
{
|
|
||||||
Error err;
|
|
||||||
|
|
||||||
// can't open twice
|
|
||||||
assert (! m_connection);
|
|
||||||
|
|
||||||
int mode = 0;
|
|
||||||
int flags = 0;
|
|
||||||
int timeout = 0;
|
|
||||||
|
|
||||||
std::stringstream ssconn(options);
|
|
||||||
|
|
||||||
while (!err && !ssconn.eof() &&
|
|
||||||
ssconn.str().find('=') != std::string::npos)
|
|
||||||
{
|
|
||||||
std::string key, val;
|
|
||||||
std::getline(ssconn, key, '=');
|
|
||||||
std::getline(ssconn, val, '|');
|
|
||||||
|
|
||||||
if ("timeout" == key)
|
|
||||||
{
|
|
||||||
if ("infinite" == val)
|
|
||||||
{
|
|
||||||
//timeout = -1;
|
|
||||||
timeout = 0x7fffffff;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::istringstream converter(val);
|
|
||||||
converter >> timeout;
|
|
||||||
|
|
||||||
if (timeout < 1)
|
|
||||||
timeout = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ("mode" == key)
|
|
||||||
{
|
|
||||||
if (!(mode & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)))
|
|
||||||
{
|
|
||||||
if ("read" == val)
|
|
||||||
{
|
|
||||||
mode = SQLITE_OPEN_READONLY;
|
|
||||||
}
|
|
||||||
else if ("write" == val)
|
|
||||||
{
|
|
||||||
mode = SQLITE_OPEN_READWRITE;
|
|
||||||
}
|
|
||||||
else if ("create" == val)
|
|
||||||
{
|
|
||||||
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("bad parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("duplicate parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Most native SQLite libraries don't have these experimental features.
|
|
||||||
*/
|
|
||||||
#if ! VF_USE_NATIVE_SQLITE
|
|
||||||
else if ("cache" == key)
|
|
||||||
{
|
|
||||||
if (!(flags & (SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE)))
|
|
||||||
{
|
|
||||||
if ("shared" == val)
|
|
||||||
{
|
|
||||||
flags |= SQLITE_OPEN_SHAREDCACHE;
|
|
||||||
}
|
|
||||||
else if ("private" == val)
|
|
||||||
{
|
|
||||||
flags |= SQLITE_OPEN_PRIVATECACHE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("bad parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("duplicate parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
else if ("threads" == key)
|
|
||||||
{
|
|
||||||
if (!(flags & (SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_FULLMUTEX)))
|
|
||||||
{
|
|
||||||
if ("single" == val)
|
|
||||||
{
|
|
||||||
flags |= SQLITE_OPEN_FULLMUTEX;
|
|
||||||
}
|
|
||||||
else if ("multi" == val)
|
|
||||||
{
|
|
||||||
flags |= SQLITE_OPEN_NOMUTEX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("bad parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("duplicate parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::invalid_argument ("unknown parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
{
|
|
||||||
if (! mode)
|
|
||||||
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
|
||||||
|
|
||||||
flags |= mode;
|
|
||||||
|
|
||||||
err = detail::sqliteError(__FILE__, __LINE__,
|
|
||||||
sqlite3_open_v2(fileName.toUTF8(), &m_connection, flags, 0));
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
{
|
|
||||||
if (timeout > 0)
|
|
||||||
{
|
|
||||||
err = detail::sqliteError(__FILE__, __LINE__,
|
|
||||||
sqlite3_busy_timeout(m_connection, timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = detail::sqliteError (__FILE__, __LINE__,
|
|
||||||
sqlite3_busy_handler(m_connection, infiniteBusyHandler, 0));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
{
|
|
||||||
m_fileName = fileName;
|
|
||||||
m_connectString = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::close()
|
|
||||||
{
|
|
||||||
if (m_connection)
|
|
||||||
{
|
|
||||||
sqlite3_close(m_connection);
|
|
||||||
m_connection = 0;
|
|
||||||
m_fileName = String::empty;
|
|
||||||
m_connectString = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::begin()
|
|
||||||
{
|
|
||||||
bassert(!m_bInTransaction);
|
|
||||||
m_bInTransaction = true;
|
|
||||||
|
|
||||||
//Error error = hard_exec("BEGIN EXCLUSIVE");
|
|
||||||
Error error = hard_exec("BEGIN");
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error session::commit()
|
|
||||||
{
|
|
||||||
bassert(m_bInTransaction);
|
|
||||||
m_bInTransaction = false;
|
|
||||||
return hard_exec("COMMIT");
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::rollback()
|
|
||||||
{
|
|
||||||
bassert(m_bInTransaction);
|
|
||||||
m_bInTransaction = false;
|
|
||||||
Error error = hard_exec("ROLLBACK");
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
detail::once_type session::once(Error& error)
|
|
||||||
{
|
|
||||||
return detail::once_type(this, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
rowid session::last_insert_rowid()
|
|
||||||
{
|
|
||||||
return sqlite3_last_insert_rowid(m_connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream& session::get_query_stream()
|
|
||||||
{
|
|
||||||
return m_query_stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::log_query(std::string const& query)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::set_got_data(bool bGotData)
|
|
||||||
{
|
|
||||||
m_bGotData = bGotData;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool session::got_data() const
|
|
||||||
{
|
|
||||||
return m_bGotData;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error session::hard_exec(std::string const& query)
|
|
||||||
{
|
|
||||||
Error error;
|
|
||||||
sqlite3_stmt* stmt;
|
|
||||||
char const* tail = 0;
|
|
||||||
|
|
||||||
int result = sqlite3_prepare_v2(
|
|
||||||
m_connection,
|
|
||||||
query.c_str(),
|
|
||||||
static_cast<int>(query.size()),
|
|
||||||
&stmt,
|
|
||||||
&tail);
|
|
||||||
|
|
||||||
if (result == SQLITE_OK)
|
|
||||||
{
|
|
||||||
result = sqlite3_step(stmt);
|
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != SQLITE_DONE)
|
|
||||||
error = detail::sqliteError(__FILE__, __LINE__, result);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
statement::statement(session& s)
|
|
||||||
: m_imp(new detail::statement_imp(s))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
statement::statement(detail::prepare_temp_type const& prep)
|
|
||||||
: m_imp(new detail::statement_imp(prep))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
statement::~statement()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
statement::statement(statement const& o)
|
|
||||||
: m_imp(o.m_imp)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement::operator= (statement const& o)
|
|
||||||
{
|
|
||||||
m_imp = o.m_imp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement::exchange(detail::into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_imp->exchange(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement::exchange(detail::use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_imp->exchange(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement::prepare(std::string const& query, bool bRepeatable)
|
|
||||||
{
|
|
||||||
m_imp->prepare(query, bRepeatable);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error statement::execute()
|
|
||||||
{
|
|
||||||
return m_imp->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool statement::execute_and_fetch(Error& error)
|
|
||||||
{
|
|
||||||
bool gotData = false;
|
|
||||||
|
|
||||||
error = m_imp->execute();
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
gotData = fetch(error);
|
|
||||||
|
|
||||||
return gotData;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool statement::fetch(Error& error)
|
|
||||||
{
|
|
||||||
return m_imp->fetch(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool statement::got_data() const
|
|
||||||
{
|
|
||||||
return m_imp->got_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
rowid statement::last_insert_rowid()
|
|
||||||
{
|
|
||||||
return m_imp->last_insert_rowid();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement::clean_up()
|
|
||||||
{
|
|
||||||
m_imp->clean_up();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,308 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Running a new prepared statement:
|
|
||||||
|
|
||||||
sqlite3_prepare() // create prepared statement
|
|
||||||
sqlite3_bind() // define input variables
|
|
||||||
sqlite3_step() // retrieve next row
|
|
||||||
sqlite3_column() // extract output value
|
|
||||||
sqlite3_finalize() // destroy prepared statement
|
|
||||||
|
|
||||||
Re-using an existing prepared statement
|
|
||||||
|
|
||||||
sqlite3_reset() // reset the statement (input bindings are not cleared)
|
|
||||||
sqlite3_clear_bindings() // set all input variables to NULL
|
|
||||||
AND/OR
|
|
||||||
sqlite3_bind() // define input variables
|
|
||||||
sqlite3_step() // retrieve next row
|
|
||||||
sqlite3_column() // extract output value
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
statement_imp::statement_imp(session& s)
|
|
||||||
: m_session(s)
|
|
||||||
, m_stmt(0)
|
|
||||||
, m_bReady(false)
|
|
||||||
, m_bGotData(false)
|
|
||||||
, m_last_insert_rowid(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
statement_imp::statement_imp(prepare_temp_type const& prep)
|
|
||||||
: m_session(prep.get_prepare_info().m_session)
|
|
||||||
, m_stmt(0)
|
|
||||||
, m_bReady(false)
|
|
||||||
, m_bGotData(false)
|
|
||||||
{
|
|
||||||
ref_counted_prepare_info& rcpi = prep.get_prepare_info();
|
|
||||||
|
|
||||||
m_intos.swap(rcpi.m_intos);
|
|
||||||
m_uses.swap(rcpi.m_uses);
|
|
||||||
|
|
||||||
prepare(rcpi.get_query());
|
|
||||||
}
|
|
||||||
|
|
||||||
statement_imp::~statement_imp()
|
|
||||||
{
|
|
||||||
clean_up();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::erase_bindings()
|
|
||||||
{
|
|
||||||
// delete intos
|
|
||||||
for (std::size_t i = m_intos.size(); i != 0; --i)
|
|
||||||
{
|
|
||||||
into_type_base* p = m_intos[i - 1];
|
|
||||||
delete p;
|
|
||||||
m_intos.resize(i - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete uses
|
|
||||||
for (std::size_t i = m_uses.size(); i != 0; --i)
|
|
||||||
{
|
|
||||||
use_type_base* p = m_uses[i - 1];
|
|
||||||
p->clean_up();
|
|
||||||
delete p;
|
|
||||||
m_uses.resize(i - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::exchange(detail::into_type_ptr const& i)
|
|
||||||
{
|
|
||||||
m_intos.push_back(i.get());
|
|
||||||
i.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::exchange(detail::use_type_ptr const& u)
|
|
||||||
{
|
|
||||||
m_uses.push_back(u.get());
|
|
||||||
u.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::clean_up()
|
|
||||||
{
|
|
||||||
erase_bindings();
|
|
||||||
release_resources();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::prepare(std::string const& query, bool bRepeatable)
|
|
||||||
{
|
|
||||||
m_query = query;
|
|
||||||
m_session.log_query(query);
|
|
||||||
m_last_insert_rowid = 0;
|
|
||||||
|
|
||||||
release_resources();
|
|
||||||
|
|
||||||
char const* tail = 0;
|
|
||||||
int result = sqlite3_prepare_v2(
|
|
||||||
m_session.get_connection(),
|
|
||||||
query.c_str(),
|
|
||||||
static_cast<int>(query.size()),
|
|
||||||
&m_stmt,
|
|
||||||
&tail);
|
|
||||||
|
|
||||||
if (result == SQLITE_OK)
|
|
||||||
{
|
|
||||||
m_bReady = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw detail::sqliteError(__FILE__, __LINE__, result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error statement_imp::execute()
|
|
||||||
{
|
|
||||||
Error error;
|
|
||||||
|
|
||||||
assert (m_stmt != nullptr);
|
|
||||||
|
|
||||||
// ???
|
|
||||||
m_bGotData = false;
|
|
||||||
m_session.set_got_data(m_bGotData);
|
|
||||||
|
|
||||||
// binds
|
|
||||||
|
|
||||||
int iCol = 0;
|
|
||||||
|
|
||||||
for (intos_t::iterator iter = m_intos.begin(); iter != m_intos.end(); ++iter)
|
|
||||||
(*iter)->bind(*this, iCol);
|
|
||||||
|
|
||||||
int iParam = 1;
|
|
||||||
|
|
||||||
for (uses_t::iterator iter = m_uses.begin(); iter != m_uses.end(); ++iter)
|
|
||||||
(*iter)->bind(*this, iParam);
|
|
||||||
|
|
||||||
// reset
|
|
||||||
error = detail::sqliteError(__FILE__, __LINE__, sqlite3_reset(m_stmt));
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
{
|
|
||||||
// set input variables
|
|
||||||
do_uses();
|
|
||||||
|
|
||||||
m_bReady = true;
|
|
||||||
m_bFirstTime = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool statement_imp::fetch(Error& error)
|
|
||||||
{
|
|
||||||
int result = sqlite3_step(m_stmt);
|
|
||||||
|
|
||||||
if (result == SQLITE_ROW ||
|
|
||||||
result == SQLITE_DONE)
|
|
||||||
{
|
|
||||||
if (m_bFirstTime)
|
|
||||||
{
|
|
||||||
m_last_insert_rowid = m_session.last_insert_rowid();
|
|
||||||
m_bFirstTime = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == SQLITE_ROW)
|
|
||||||
{
|
|
||||||
m_bGotData = true;
|
|
||||||
m_session.set_got_data(m_bGotData);
|
|
||||||
|
|
||||||
do_intos();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_bGotData = false;
|
|
||||||
m_session.set_got_data(m_bGotData);
|
|
||||||
|
|
||||||
if (result == SQLITE_DONE)
|
|
||||||
{
|
|
||||||
m_bReady = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (result != SQLITE_OK)
|
|
||||||
{
|
|
||||||
m_bGotData = false;
|
|
||||||
error = detail::sqliteError(__FILE__, __LINE__, result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// should never get SQLITE_OK here
|
|
||||||
throw std::invalid_argument ("invalid result");
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_bGotData;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool statement_imp::got_data() const
|
|
||||||
{
|
|
||||||
return m_bGotData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::do_intos()
|
|
||||||
{
|
|
||||||
for (intos_t::iterator iter = m_intos.begin(); iter != m_intos.end(); ++iter)
|
|
||||||
(*iter)->do_into();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::do_uses()
|
|
||||||
{
|
|
||||||
Error error = detail::sqliteError(__FILE__, __LINE__,
|
|
||||||
sqlite3_clear_bindings(m_stmt));
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
for (uses_t::iterator iter = m_uses.begin(); iter != m_uses.end(); ++iter)
|
|
||||||
(*iter)->do_use();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::post_use()
|
|
||||||
{
|
|
||||||
// reverse order
|
|
||||||
for (uses_t::reverse_iterator iter = m_uses.rbegin(); iter != m_uses.rend(); ++iter)
|
|
||||||
(*iter)->post_use();
|
|
||||||
}
|
|
||||||
|
|
||||||
void statement_imp::release_resources()
|
|
||||||
{
|
|
||||||
if (m_stmt)
|
|
||||||
{
|
|
||||||
sqlite3_finalize(m_stmt);
|
|
||||||
m_stmt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bReady = false;
|
|
||||||
m_bGotData = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
rowid statement_imp::last_insert_rowid()
|
|
||||||
{
|
|
||||||
return m_last_insert_rowid;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
|
|
||||||
transaction::transaction(session& s)
|
|
||||||
: m_session(s), m_bHandled(false)
|
|
||||||
{
|
|
||||||
m_session.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
transaction::~transaction()
|
|
||||||
{
|
|
||||||
if (!m_bHandled)
|
|
||||||
rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
Error transaction::commit()
|
|
||||||
{
|
|
||||||
Error error;
|
|
||||||
|
|
||||||
// already handled
|
|
||||||
assert (!m_bHandled);
|
|
||||||
|
|
||||||
// if commit() throws, m_bHandled will remain false
|
|
||||||
// and the destructor will attempt a rollback.
|
|
||||||
|
|
||||||
m_bHandled = true;
|
|
||||||
|
|
||||||
error = m_session.commit();
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
void transaction::rollback()
|
|
||||||
{
|
|
||||||
// already handled
|
|
||||||
assert (!m_bHandled);
|
|
||||||
|
|
||||||
m_session.rollback();
|
|
||||||
m_bHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
standard_use_type::~standard_use_type()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_use_type::bind(statement_imp& st, int& iParam)
|
|
||||||
{
|
|
||||||
m_st = &st;
|
|
||||||
m_iParam = iParam++;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T const& as(void const* v)
|
|
||||||
{
|
|
||||||
return *static_cast <T const*>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename L>
|
|
||||||
inline T const& as(void const* v)
|
|
||||||
{
|
|
||||||
T const& val = *static_cast <T const*>(v);
|
|
||||||
|
|
||||||
assert (val <= T(std::numeric_limits<L>::max()));
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_use_type::do_use()
|
|
||||||
{
|
|
||||||
int result = SQLITE_OK;
|
|
||||||
|
|
||||||
convert_to_base();
|
|
||||||
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case x_null:
|
|
||||||
result = sqlite3_bind_null(m_st->m_stmt, m_iParam);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_bool:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <bool> (m_data) ? 1 : 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_char:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <char> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_uchar:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <unsigned char> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_short:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <short> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_ushort:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <unsigned short> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_int:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <int> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_uint:
|
|
||||||
result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as <unsigned int> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_long:
|
|
||||||
result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as <long> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_ulong:
|
|
||||||
result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as <unsigned long> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_longlong:
|
|
||||||
result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as <long long> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_ulonglong:
|
|
||||||
result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as <unsigned long long> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_float:
|
|
||||||
result = sqlite3_bind_double(m_st->m_stmt, m_iParam, as <float> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_double:
|
|
||||||
result = sqlite3_bind_double(m_st->m_stmt, m_iParam, as <double> (m_data));
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case x_longdouble:
|
|
||||||
result = sqlite3_bind_double(m_st->m_stmt, m_iParam, as <long double> (m_data));
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case x_cstring:
|
|
||||||
result = sqlite3_bind_text(m_st->m_stmt, m_iParam, as <char*> (m_data), -1, SQLITE_STATIC);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_cwstring:
|
|
||||||
result = sqlite3_bind_text16(m_st->m_stmt, m_iParam, as <wchar_t*> (m_data), -1, SQLITE_STATIC);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_stdstring:
|
|
||||||
{
|
|
||||||
std::string const& s = as <std::string> (m_data);
|
|
||||||
result = sqlite3_bind_text(m_st->m_stmt,
|
|
||||||
m_iParam,
|
|
||||||
s.c_str(),
|
|
||||||
int(s.size() * sizeof(s[0])),
|
|
||||||
SQLITE_STATIC);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_stdwstring:
|
|
||||||
{
|
|
||||||
std::wstring const& s = as <std::wstring> (m_data);
|
|
||||||
result = sqlite3_bind_text16(m_st->m_stmt,
|
|
||||||
m_iParam,
|
|
||||||
s.c_str(),
|
|
||||||
int(s.size() * sizeof(s[0])),
|
|
||||||
SQLITE_STATIC);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_beastString:
|
|
||||||
{
|
|
||||||
String const& s = as <String> (m_data);
|
|
||||||
result = sqlite3_bind_text(m_st->m_stmt,
|
|
||||||
m_iParam,
|
|
||||||
s.toUTF8(),
|
|
||||||
-1,
|
|
||||||
SQLITE_STATIC);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case x_stdtm:
|
|
||||||
case x_blob:
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument ("bad parameter");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != SQLITE_OK)
|
|
||||||
throw detail::sqliteError(__FILE__, __LINE__, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_use_type::post_use()
|
|
||||||
{
|
|
||||||
convert_from_base();
|
|
||||||
}
|
|
||||||
|
|
||||||
void standard_use_type::clean_up()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // sqdb
|
|
||||||
} // beast
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
Portions based on SOCI - The C++ Database Access Library:
|
|
||||||
|
|
||||||
SOCI: http://soci.sourceforge.net/
|
|
||||||
|
|
||||||
This file incorporates work covered by the following copyright
|
|
||||||
and permission notice:
|
|
||||||
|
|
||||||
Copyright (C) 2004 Maciej Sobczak, Stephen Hutton, Mateusz Loskot,
|
|
||||||
Pawel Aleksander Fedorynski, David Courtney, Rafal Bobrowski,
|
|
||||||
Julian Taylor, Henning Basold, Ilia Barahovski, Denis Arnaud,
|
|
||||||
Daniel Lidstr<74>m, Matthieu Kermagoret, Artyom Beilis, Cory Bennett,
|
|
||||||
Chris Weed, Michael Davidsaver, Jakub Stachowski, Alex Ott, Rainer Bauer,
|
|
||||||
Martin Muenstermann, Philip Pemberton, Eli Green, Frederic Chateau,
|
|
||||||
Artyom Tonkikh, Roger Orr, Robert Massaioli, Sergey Nikulov,
|
|
||||||
Shridhar Daithankar, S<>ren Meyer-Eppler, Mario Valesco.
|
|
||||||
|
|
||||||
Boost Software License - Version 1.0, August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQDB_SQDB_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQDB_SQDB_H_INCLUDED
|
|
||||||
|
|
||||||
/** An embedded database wrapper with an intuitive, type-safe interface.
|
|
||||||
|
|
||||||
This collection of classes let's you access embedded SQLite databases
|
|
||||||
using C++ syntax that is very similar to regular SQL.
|
|
||||||
|
|
||||||
This module requires the @ref beast_sqlite external module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
// forward declares
|
|
||||||
struct sqlite3;
|
|
||||||
struct sqlite3_blob;
|
|
||||||
struct sqlite3_stmt;
|
|
||||||
namespace beast {
|
|
||||||
namespace sqdb {
|
|
||||||
namespace detail {
|
|
||||||
class prepare_temp_type;
|
|
||||||
class ref_counted_statement; // statement.h
|
|
||||||
class statement_imp; // into_type.h, use_type.h
|
|
||||||
}
|
|
||||||
class blob; // exchange_traits.h
|
|
||||||
class session; // statement.h
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning (push)
|
|
||||||
#pragma warning (disable: 4355) // 'this' : used in base member initializer list
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/api/backend.h>
|
|
||||||
#include <beast/module/sqdb/api/transaction.h>
|
|
||||||
#include <beast/module/sqdb/detail/type_ptr.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/api/blob.h>
|
|
||||||
#include <beast/module/sqdb/api/type_conversion_traits.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/detail/exchange_traits.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/detail/into_type.h>
|
|
||||||
#include <beast/module/sqdb/detail/use_type.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/api/statement.h>
|
|
||||||
#include <beast/module/sqdb/detail/type_conversion.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/detail/ref_counted_statement.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/api/into.h>
|
|
||||||
#include <beast/module/sqdb/api/use.h>
|
|
||||||
#include <beast/module/sqdb/detail/ref_counted_prepare_info.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/detail/prepare_temp_type.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/detail/once_temp_type.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/api/session.h>
|
|
||||||
|
|
||||||
#if _MSC_VER
|
|
||||||
#pragma warning (pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#if BEAST_INCLUDE_BEASTCONFIG
|
|
||||||
#include <BeastConfig.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/sqdb.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqlite/sqlite.h>
|
|
||||||
|
|
||||||
#if BEAST_MSVC
|
|
||||||
#pragma warning (push)
|
|
||||||
#pragma warning (disable: 4100) // unreferenced formal parmaeter
|
|
||||||
#pragma warning (disable: 4355) // 'this' used in base member
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// implementation headers
|
|
||||||
#include <beast/module/sqdb/detail/error_codes.h>
|
|
||||||
#include <beast/module/sqdb/detail/statement_imp.h>
|
|
||||||
|
|
||||||
#include <beast/module/sqdb/source/blob.cpp>
|
|
||||||
#include <beast/module/sqdb/source/error_codes.cpp>
|
|
||||||
#include <beast/module/sqdb/source/into_type.cpp>
|
|
||||||
#include <beast/module/sqdb/source/once_temp_type.cpp>
|
|
||||||
#include <beast/module/sqdb/source/prepare_temp_type.cpp>
|
|
||||||
#include <beast/module/sqdb/source/ref_counted_prepare_info.cpp>
|
|
||||||
#include <beast/module/sqdb/source/ref_counted_statement.cpp>
|
|
||||||
#include <beast/module/sqdb/source/session.cpp>
|
|
||||||
#include <beast/module/sqdb/source/statement.cpp>
|
|
||||||
#include <beast/module/sqdb/source/statement_imp.cpp>
|
|
||||||
#include <beast/module/sqdb/source/transaction.cpp>
|
|
||||||
#include <beast/module/sqdb/source/use_type.cpp>
|
|
||||||
|
|
||||||
#if BEAST_MSVC
|
|
||||||
#pragma warning (pop)
|
|
||||||
#endif
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_SQLITE_SQLITE_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_SQLITE_SQLITE_H_INCLUDED
|
|
||||||
|
|
||||||
/** A self-contained, serverless, zero configuration, transactional SQL engine.
|
|
||||||
|
|
||||||
This external module provides the SQLite embedded database library.
|
|
||||||
|
|
||||||
SQLite is public domain software, visit http://sqlite.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <beast/config/PlatformConfig.h>
|
|
||||||
|
|
||||||
#if BEAST_IOS || BEAST_MAC
|
|
||||||
# define BEAST_HAVE_NATIVE_SQLITE 1
|
|
||||||
#else
|
|
||||||
# define BEAST_HAVE_NATIVE_SQLITE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BEAST_SQLITE_CPP_INCLUDED
|
|
||||||
# if BEAST_USE_NATIVE_SQLITE && BEAST_HAVE_NATIVE_SQLITE
|
|
||||||
#include <sqlite3.h>
|
|
||||||
# else
|
|
||||||
#include <beast/module/sqlite/sqlite/sqlite3.h> // Amalgamated
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <ripple/app/data/Database.h>
|
#include <ripple/app/data/Database.h>
|
||||||
#include <ripple/basics/Blob.h>
|
#include <ripple/basics/Blob.h>
|
||||||
#include <ripple/core/JobQueue.h>
|
#include <ripple/core/JobQueue.h>
|
||||||
#include <beast/module/sqlite/sqlite.h>
|
#include <sqlite/sqlite.h>
|
||||||
#include <beast/threads/Thread.h>
|
#include <beast/threads/Thread.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
|||||||
@@ -30,4 +30,4 @@
|
|||||||
#error "Whoops! This file must be compiled with a C compiler!"
|
#error "Whoops! This file must be compiled with a C compiler!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <beast/module/sqlite/sqlite.unity.c>
|
#include <sqlite/sqlite.unity.c>
|
||||||
|
|||||||
34
src/sqlite/sqlite.h
Normal file
34
src/sqlite/sqlite.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of rippled: https://github.com/ripple/rippled
|
||||||
|
Copyright (c) 2012-2015 Ripple Labs Inc.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#ifndef RIPPLE_SQLITE_SQLITE_H_INCLUDED
|
||||||
|
#define RIPPLE_SQLITE_SQLITE_H_INCLUDED
|
||||||
|
|
||||||
|
/** A self-contained, serverless, zero configuration, transactional SQL engine.
|
||||||
|
|
||||||
|
This external module provides the SQLite embedded database library.
|
||||||
|
|
||||||
|
SQLite is public domain software, visit http://sqlite.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RIPPLE_SQLITE_CPP_INCLUDED
|
||||||
|
#include <sqlite/sqlite/sqlite3.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,40 +1,32 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*
|
/*
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
This file is part of rippled: https://github.com/ripple/rippled
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
Copyright (c) 2012-2015 Ripple Labs Inc.
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
copyright notice and this permission notice appear in all copies.
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
/** Add this to get the @ref vf_sqlite external module.
|
|
||||||
|
|
||||||
@file beast_sqlite.c
|
|
||||||
@ingroup beast_sqlite
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if BEAST_INCLUDE_BEASTCONFIG
|
#if BEAST_INCLUDE_BEASTCONFIG
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prevents sqlite.h from being included, since it screws up the .c
|
// Prevents sqlite.h from being included, since it screws up the .c
|
||||||
#define BEAST_SQLITE_CPP_INCLUDED
|
#define RIPPLE_SQLITE_CPP_INCLUDED
|
||||||
|
|
||||||
#include <beast/module/sqlite/sqlite.h>
|
#include <sqlite/sqlite.h>
|
||||||
|
|
||||||
#if ! (BEAST_USE_NATIVE_SQLITE && BEAST_HAVE_NATIVE_SQLITE)
|
#ifdef _MSC_VER // MSVC
|
||||||
|
|
||||||
#if BEAST_MSVC
|
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable: 4100) /* unreferenced formal parameter */
|
#pragma warning (disable: 4100) /* unreferenced formal parameter */
|
||||||
#pragma warning (disable: 4127) /* conditional expression is constant */
|
#pragma warning (disable: 4127) /* conditional expression is constant */
|
||||||
@@ -60,14 +52,13 @@
|
|||||||
*/
|
*/
|
||||||
//#define SQLITE_THREADSAFE 2
|
//#define SQLITE_THREADSAFE 2
|
||||||
|
|
||||||
#if defined (BEAST_SQLITE_USE_NDEBUG) && BEAST_SQLITE_USE_NDEBUG && !defined (NDEBUG)
|
#if defined RIPPLE_SQLITE_USE_NDEBUG && !defined (NDEBUG)
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <beast/module/sqlite/sqlite/sqlite3.c>
|
#include <sqlite/sqlite/sqlite3.c>
|
||||||
|
|
||||||
#if BEAST_MSVC
|
#ifdef _MSC_VER
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1 +1 @@
|
|||||||
#include <beast/module/sqlite/sqlite/sqlite3.h>
|
#include <sqlite/sqlite/sqlite3.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user