diff --git a/SConstruct b/SConstruct
index 6ada71a71b..ae2888e804 100644
--- a/SConstruct
+++ b/SConstruct
@@ -122,6 +122,8 @@ COMPILED_FILES = [
'Subtrees/beast/modules/beast_core/beast_core.cpp',
'Subtrees/beast/modules/beast_crypto/beast_crypto.cpp',
'Subtrees/beast/modules/beast_db/beast_db.cpp',
+ 'Subtrees/beast/modules/beast_sqdb/beast_sqdb.cpp',
+ 'Subtrees/beast/modules/beast_sqlite/beast_sqlite.c',
'modules/ripple_app/ripple_app_pt1.cpp',
'modules/ripple_app/ripple_app_pt2.cpp',
'modules/ripple_app/ripple_app_pt3.cpp',
diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
index 99c88c4500..4d97ef0b3d 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
@@ -257,6 +257,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -948,6 +971,86 @@
true
true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+
+ true
+ true
+ true
+ true
+
diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
index 7f02acb998..b649d0e21e 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -134,6 +134,24 @@
{15a98fee-1b52-45eb-9480-514b8750d755}
+
+ {cbf5f5a3-5d66-4b6d-996d-20ed14b41793}
+
+
+ {acd9ab9d-3ba8-4c60-bfb8-36799d9d7a06}
+
+
+ {67b47aab-8e6a-4acd-9291-d95a8795d6ad}
+
+
+ {e666952d-d490-40a2-aa05-2d63ea23284f}
+
+
+ {3f969218-0a32-41f1-8e05-9a47247cf494}
+
+
+ {10ef778f-6b81-437e-a6ef-558ff4163acc}
+
@@ -647,6 +665,75 @@
beast_db\keyvalue
+
+ beast_sqlite
+
+
+ beast_sqlite\sqlite
+
+
+ beast_sqlite\sqlite
+
+
+ beast_sqdb
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\api
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
+
+ beast_sqdb\detail
+
@@ -1003,6 +1090,51 @@
beast_db\keyvalue
+
+ beast_sqlite
+
+
+ beast_sqlite\sqlite
+
+
+ beast_sqdb
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
+
+ beast_sqdb\source
+
diff --git a/Subtrees/beast/modules/beast_sqdb/api/backend.h b/Subtrees/beast/modules/beast_sqdb/api/backend.h
new file mode 100644
index 0000000000..d36063251c
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/backend.h
@@ -0,0 +1,111 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_BACKEND_H_INCLUDED
+#define BEAST_SQDB_BACKEND_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+// 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_int64, x_uint64,
+ x_float, x_double,
+
+ 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
+};
+
+}
+
+// the enum type for indicator variables
+enum indicator
+{
+ i_ok,
+ i_null,
+ i_truncated
+};
+
+// sqlite row id
+
+//typedef sqlite3_int64 rowid;
+typedef int64 rowid;
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/blob.h b/Subtrees/beast/modules/beast_sqdb/api/blob.h
new file mode 100644
index 0000000000..5e4642fd5a
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/blob.h
@@ -0,0 +1,91 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_BLOB_H_INCLUDED
+#define BEAST_SQDB_BLOB_H_INCLUDED
+
+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;
+
+ std::size_t get_len();
+ Error read(std::size_t offset, void* buf, std::size_t toRead);
+ Error write(std::size_t offset, void const* buf, std::size_t toWrite);
+ void close();
+
+private:
+ session* m_session;
+ sqlite3_blob* m_blob;
+};
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/into.h b/Subtrees/beast/modules/beast_sqdb/api/into.h
new file mode 100644
index 0000000000..7cccd7fc2d
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/into.h
@@ -0,0 +1,82 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_INTO_H_INCLUDED
+#define BEAST_SQDB_INTO_H_INCLUDED
+
+namespace sqdb
+{
+
+template
+detail::into_type_ptr into(T& t)
+{
+ return detail::do_into(t,
+ typename detail::exchange_traits::type_family());
+}
+
+template
+detail::into_type_ptr into(T& t, indicator& ind)
+{
+ return detail::do_into(t, ind,
+ typename detail::exchange_traits::type_family());
+}
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Subtrees/beast/modules/beast_sqdb/api/session.h b/Subtrees/beast/modules/beast_sqdb/api/session.h
new file mode 100644
index 0000000000..49c6970576
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/session.h
@@ -0,0 +1,150 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_SESSION_H_INCLUDED
+#define BEAST_SQDB_SESSION_H_INCLUDED
+
+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:
+ class Sqlite3;
+ SharedObjectPtr m_instance;
+ bool m_bInTransaction;
+ sqlite3* m_connection;
+ String m_fileName;
+ std::string m_connectString;
+
+ std::ostringstream m_query_stream;
+ bool m_bGotData;
+};
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/statement.h b/Subtrees/beast/modules/beast_sqdb/api/statement.h
new file mode 100644
index 0000000000..b440277c96
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/statement.h
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_STATEMENT_H_INCLUDED
+#define BEAST_SQDB_STATEMENT_H_INCLUDED
+
+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:
+ SharedObjectPtr m_imp;
+};
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/transaction.h b/Subtrees/beast/modules/beast_sqdb/api/transaction.h
new file mode 100644
index 0000000000..08775ab84b
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/transaction.h
@@ -0,0 +1,82 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_TRANSACTION_H_INCLUDED
+#define BEAST_SQDB_TRANSACTION_H_INCLUDED
+
+namespace sqdb
+{
+
+class transaction : Uncopyable
+{
+public:
+ explicit transaction(session& s);
+ ~transaction();
+
+ Error commit();
+ void rollback();
+
+private:
+ session& m_session;
+ bool m_bHandled;
+};
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/type_conversion_traits.h b/Subtrees/beast/modules/beast_sqdb/api/type_conversion_traits.h
new file mode 100644
index 0000000000..e81a7319d3
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/type_conversion_traits.h
@@ -0,0 +1,117 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_TYPE_CONVERSION_TRAITS_H_INCLUDED
+#define BEAST_SQDB_TYPE_CONVERSION_TRAITS_H_INCLUDED
+
+namespace sqdb
+{
+
+// default conversion (copy in to out)
+template
+struct type_conversion
+{
+ typedef T base_type;
+
+ static void from_base(base_type const& in, indicator ind, T& out)
+ {
+ // null not allowed
+ if (ind == i_null)
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ out = in;
+ }
+
+ static void to_base(T const& in, base_type& out, indicator& ind)
+ {
+ out = in;
+ ind = i_ok;
+ }
+};
+
+// Time
+template <>
+struct type_conversion
+{
+ //typedef sqlite3_int64 base_type;
+ typedef int64 base_type;
+
+ static void from_base(const base_type v, indicator ind, Time& result)
+ {
+ if (ind == i_null)
+ {
+ // jassertfalse
+ 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;
+ }
+};
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/api/use.h b/Subtrees/beast/modules/beast_sqdb/api/use.h
new file mode 100644
index 0000000000..3b29a1f927
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/api/use.h
@@ -0,0 +1,94 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_USE_H_INCLUDED
+#define BEAST_SQDB_USE_H_INCLUDED
+
+namespace sqdb
+{
+
+inline detail::use_type_ptr use_null()
+{
+ return detail::do_use_null();
+}
+
+template
+detail::use_type_ptr use(T& t)
+{
+ return detail::do_use(t,
+ typename detail::exchange_traits::type_family());
+}
+
+template
+detail::use_type_ptr use(T const& t)
+{
+ return detail::do_use(t,
+ typename detail::exchange_traits::type_family());
+}
+
+template
+detail::use_type_ptr use(T& t, indicator& ind)
+{
+ return detail::do_use(t, ind,
+ typename detail::exchange_traits::type_family());
+}
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Subtrees/beast/modules/beast_sqdb/beast_sqdb.cpp b/Subtrees/beast/modules/beast_sqdb/beast_sqdb.cpp
new file mode 100644
index 0000000000..9c63cc8d85
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/beast_sqdb.cpp
@@ -0,0 +1,57 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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.
+*/
+//==============================================================================
+
+#include "BeastConfig.h"
+
+#include "beast_sqdb.h"
+
+#include "../beast_sqlite/beast_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
+
+namespace beast
+{
+// implementation headers
+#include "detail/error_codes.h"
+#include "detail/statement_imp.h"
+}
+
+namespace beast
+{
+#include "source/blob.cpp"
+#include "source/error_codes.cpp"
+#include "source/into_type.cpp"
+#include "source/once_temp_type.cpp"
+#include "source/prepare_temp_type.cpp"
+#include "source/ref_counted_prepare_info.cpp"
+#include "source/ref_counted_statement.cpp"
+#include "source/session.cpp"
+#include "source/statement.cpp"
+#include "source/statement_imp.cpp"
+#include "source/transaction.cpp"
+#include "source/use_type.cpp"
+}
+
+#if BEAST_MSVC
+#pragma warning (pop)
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/beast_sqdb.h b/Subtrees/beast/modules/beast_sqdb/beast_sqdb.h
new file mode 100644
index 0000000000..10b235902c
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/beast_sqdb.h
@@ -0,0 +1,132 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_H_INCLUDED
+#define BEAST_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
+
+#include "../beast_core/beast_core.h"
+
+// 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
+}
+}
+
+#if BEAST_MSVC
+#pragma warning (push)
+#pragma warning (disable: 4355) // 'this' : used in base member initializer list
+#endif
+
+namespace beast
+{
+
+#include "api/backend.h"
+#include "api/transaction.h"
+#include "detail/type_ptr.h"
+
+#include "api/blob.h"
+#include "api/type_conversion_traits.h"
+
+#include "detail/exchange_traits.h"
+
+#include "detail/into_type.h"
+#include "detail/use_type.h"
+
+#include "api/statement.h"
+#include "detail/type_conversion.h"
+
+#include "detail/ref_counted_statement.h"
+
+#include "api/into.h"
+#include "api/use.h"
+#include "detail/ref_counted_prepare_info.h"
+
+#include "detail/prepare_temp_type.h"
+
+#include "detail/once_temp_type.h"
+
+#include "api/session.h"
+
+}
+
+#if BEAST_MSVC
+#pragma warning (pop)
+#endif
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/error_codes.h b/Subtrees/beast/modules/beast_sqdb/detail/error_codes.h
new file mode 100644
index 0000000000..a4c6873d19
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/error_codes.h
@@ -0,0 +1,77 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_ERROR_CODES_H_INCLUDED
+#define BEAST_SQDB_DETAIL_ERROR_CODES_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+// Converts SQLITE error codes into an Error object
+extern const Error sqliteError(const char* sourceFileName,
+ int lineNumber,
+ int sqliteErrorCode);
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/exchange_traits.h b/Subtrees/beast/modules/beast_sqdb/detail/exchange_traits.h
new file mode 100644
index 0000000000..6b5acd0ed8
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/exchange_traits.h
@@ -0,0 +1,224 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_EXCHANGE_TRAITS_H_INCLUDED
+#define BEAST_SQDB_DETAIL_EXCHANGE_TRAITS_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+struct basic_type_tag {};
+struct user_type_tag {};
+
+// converts a type to exchange_type
+template
+struct exchange_traits
+{
+ typedef user_type_tag type_family;
+
+ enum
+ {
+ x_type = exchange_traits::base_type>::x_type
+ };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_bool };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_char };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_short };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_int };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_long };
+};
+
+//template<> struct exchange_traits
+//template<> struct exchange_traits
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_int64 };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_uchar };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_ushort };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_uint };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_ulong };
+};
+
+//template<> struct exchange_traits
+//template<> struct exchange_traits
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_uint64 };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_float };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_double };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_cstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_cstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_cwstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_cwstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_stdstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_stdwstring };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_beastString };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_stdtm };
+};
+
+template<> struct exchange_traits
+{
+ typedef basic_type_tag type_family;
+ enum { x_type = x_blob };
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/into_type.h b/Subtrees/beast/modules/beast_sqdb/detail/into_type.h
new file mode 100644
index 0000000000..34a448ff97
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/into_type.h
@@ -0,0 +1,131 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_INTO_TYPE_H_INCLUDED
+#define BEAST_SQDB_DETAIL_INTO_TYPE_H_INCLUDED
+
+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_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
+class into_type : public standard_into_type
+{
+public:
+ into_type(T& t) : standard_into_type(&t,
+ static_cast (exchange_traits::x_type)) {}
+
+ into_type(T& t, indicator& ind) : standard_into_type(&t,
+ static_cast(exchange_traits::x_type), ind) {}
+};
+
+template
+into_type_ptr do_into(T& t, basic_type_tag)
+{
+ return into_type_ptr(new into_type(t));
+}
+
+template
+into_type_ptr do_into(T& t, indicator& ind, basic_type_tag)
+{
+ return into_type_ptr(new into_type(t, ind));
+}
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/once_temp_type.h b/Subtrees/beast/modules/beast_sqdb/detail/once_temp_type.h
new file mode 100644
index 0000000000..5be3182586
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/once_temp_type.h
@@ -0,0 +1,116 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_ONCE_TEMP_TYPE_H_INCLUDED
+#define BEAST_SQDB_DETAIL_ONCE_TEMP_TYPE_H_INCLUDED
+
+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
+ 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
+ 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;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/prepare_temp_type.h b/Subtrees/beast/modules/beast_sqdb/detail/prepare_temp_type.h
new file mode 100644
index 0000000000..89f0afd030
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/prepare_temp_type.h
@@ -0,0 +1,119 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_PREPARE_TEMP_TYPE_H_INCLUDED
+#define BEAST_SQDB_DETAIL_PREPARE_TEMP_TYPE_H_INCLUDED
+
+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
+ 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 prepare_temp_type operator<<(T const& t)
+ {
+ prepare_temp_type p(*m_session);
+ p << t;
+ return p;
+ }
+
+private:
+ session* m_session;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_prepare_info.h b/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_prepare_info.h
new file mode 100644
index 0000000000..d3ca5c0034
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_prepare_info.h
@@ -0,0 +1,89 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_REF_COUNTED_PREPARE_INFO_H_INCLUDED
+#define BEAST_SQDB_DETAIL_REF_COUNTED_PREPARE_INFO_H_INCLUDED
+
+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 m_intos;
+ std::vector m_uses;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_statement.h b/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_statement.h
new file mode 100644
index 0000000000..77b51ed159
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/ref_counted_statement.h
@@ -0,0 +1,114 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_REF_COUNTED_STATEMENT_H_INCLUDED
+#define BEAST_SQDB_DETAIL_REF_COUNTED_STATEMENT_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+// used for "once" and "prepare"
+class ref_counted_statement_base : Uncopyable
+{
+public:
+ ref_counted_statement_base(session& s);
+ virtual ~ref_counted_statement_base();
+
+ virtual void final_action() = 0;
+
+ void addref();
+ void release();
+
+ template void accumulate(T const& t)
+ {
+ get_query_stream() << t;
+ }
+
+public:
+ // 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;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/statement_imp.h b/Subtrees/beast/modules/beast_sqdb/detail/statement_imp.h
new file mode 100644
index 0000000000..5ac4d3c070
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/statement_imp.h
@@ -0,0 +1,115 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_STATEMENT_IMP_H_INCLUDED
+#define BEAST_SQDB_DETAIL_STATEMENT_IMP_H_INCLUDED
+
+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 intos_t;
+ typedef std::vector uses_t;
+
+ intos_t m_intos;
+ uses_t m_uses;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/type_conversion.h b/Subtrees/beast/modules/beast_sqdb/detail/type_conversion.h
new file mode 100644
index 0000000000..ddf810edb3
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/type_conversion.h
@@ -0,0 +1,195 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_TYPE_CONVERSION_H_INCLUDED
+#define BEAST_SQDB_DETAIL_TYPE_CONVERSION_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+// used to order into and uses that need conversions
+template
+struct base_value_holder
+{
+ typename type_conversion::base_type m_value;
+};
+
+// create into_type from type_conversion
+template
+class conversion_into_type
+ : private base_value_holder
+ , public into_type ::base_type>
+ , Uncopyable
+{
+public:
+ typedef typename type_conversion::base_type BASE_TYPE;
+
+ conversion_into_type(T& value)
+ : into_type(detail::base_value_holder::m_value, m_own_ind)
+ , m_value(value), m_ind(m_own_ind) {}
+
+ conversion_into_type(T& value, indicator& ind)
+ : into_type(detail::base_value_holder::m_value, ind)
+ , m_value(value), m_ind(ind) {}
+
+private:
+ void convert_from_base()
+ {
+ type_conversion::from_base(
+ detail::base_value_holder::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
+class conversion_use_type
+ : private base_value_holder
+ , public use_type::base_type>
+ , Uncopyable
+{
+public:
+ typedef typename type_conversion::base_type BASE_TYPE;
+
+ conversion_use_type(T& value)
+ : use_type(detail::base_value_holder::m_value, m_own_ind)
+ , m_value(value), m_ind(m_own_ind), m_bReadOnly(false) {}
+
+ conversion_use_type(T const& value)
+ : use_type(detail::base_value_holder::m_value, m_own_ind)
+ , m_value(const_cast(value)), m_ind(m_own_ind), m_bReadOnly(true) {}
+
+ conversion_use_type(T& value, indicator& ind)
+ : use_type(detail::base_value_holder::m_value, ind)
+ , m_value(value), m_ind(ind), m_bReadOnly(false) {}
+
+ conversion_use_type(T const& value, indicator& ind)
+ : use_type(detail::base_value_holder::m_value, ind)
+ , m_value(const_cast(value)), m_ind(ind), m_bReadOnly(true) {}
+
+ void convert_from_base()
+ {
+ if (!m_bReadOnly)
+ {
+ type_conversion::from_base(
+ detail::base_value_holder::m_value, m_ind, m_value);
+ }
+ }
+
+ void convert_to_base()
+ {
+ type_conversion::to_base(m_value,
+ detail::base_value_holder::m_value, m_ind);
+ }
+
+private:
+ T& m_value;
+ indicator m_own_ind;
+ indicator& m_ind;
+ bool m_bReadOnly;
+};
+
+template
+into_type_ptr do_into(T& t, user_type_tag)
+{
+ return into_type_ptr(new conversion_into_type(t));
+}
+
+template
+into_type_ptr do_into(T& t, indicator& ind, user_type_tag)
+{
+ return into_type_ptr(new conversion_into_type(t, ind));
+}
+
+template
+use_type_ptr do_use(T& t, user_type_tag)
+{
+ return use_type_ptr(new conversion_use_type(t));
+}
+
+template
+use_type_ptr do_use(T const& t, user_type_tag)
+{
+ return use_type_ptr(new conversion_use_type(t));
+}
+
+template
+use_type_ptr do_use(T& t, indicator& ind, user_type_tag)
+{
+ return use_type_ptr(new conversion_use_type(t, ind));
+}
+
+template
+use_type_ptr do_use(T const& t, indicator& ind, user_type_tag)
+{
+ return use_type_ptr(new conversion_use_type(t, ind));
+}
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/type_ptr.h b/Subtrees/beast/modules/beast_sqdb/detail/type_ptr.h
new file mode 100644
index 0000000000..d92b2b2132
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/type_ptr.h
@@ -0,0 +1,97 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_TYPE_PTR_H_INCLUDED
+#define BEAST_SQDB_DETAIL_TYPE_PTR_H_INCLUDED
+
+namespace sqdb
+{
+
+namespace detail
+{
+
+// helper for managing the lifetime of into and use objects
+template
+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;
+};
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/detail/use_type.h b/Subtrees/beast/modules/beast_sqdb/detail/use_type.h
new file mode 100644
index 0000000000..7092585fb0
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/detail/use_type.h
@@ -0,0 +1,167 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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_SQDB_DETAIL_USE_TYPE_H_INCLUDED
+#define BEAST_SQDB_DETAIL_USE_TYPE_H_INCLUDED
+
+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_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
+class use_type : public standard_use_type
+{
+public:
+ use_type(T& t)
+ : standard_use_type(&t, static_cast
+ (exchange_traits::x_type), false) {}
+
+ use_type(T const& t)
+ : standard_use_type(const_cast(&t), static_cast
+ (exchange_traits::x_type), true) {}
+
+ use_type(T& t, indicator& ind)
+ : standard_use_type(&t, static_cast
+ (exchange_traits::x_type), ind, false) {}
+
+ use_type(T const& t, indicator& ind)
+ : standard_use_type(const_cast(&t), static_cast
+ (exchange_traits::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
+use_type_ptr do_use(T& t, basic_type_tag)
+{
+ return use_type_ptr(new use_type(t));
+}
+
+template
+use_type_ptr do_use(T const& t, basic_type_tag)
+{
+ return use_type_ptr(new use_type(t));
+}
+
+template
+use_type_ptr do_use(T& t, indicator& ind, basic_type_tag)
+{
+ return use_type_ptr(new use_type(t, ind));
+}
+
+template
+use_type_ptr do_use(T const& t, indicator& ind, basic_type_tag)
+{
+ return use_type_ptr(new use_type(t, ind));
+}
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_sqdb/source/blob.cpp b/Subtrees/beast/modules/beast_sqdb/source/blob.cpp
new file mode 100644
index 0000000000..8c5c78b24e
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/blob.cpp
@@ -0,0 +1,120 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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);
+}
+
+std::size_t blob::get_len()
+{
+ return sqlite3_blob_bytes(m_blob);
+}
+
+Error blob::read(std::size_t offset, void* buf, std::size_t toRead)
+{
+ return detail::sqliteError(__FILE__, __LINE__,
+ sqlite3_blob_read(m_blob, static_cast(buf), toRead, offset));
+}
+
+Error blob::write(std::size_t offset, void const* buf, std::size_t 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;
+ }
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/error_codes.cpp b/Subtrees/beast/modules/beast_sqdb/source/error_codes.cpp
new file mode 100644
index 0000000000..9336c40ff2
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/error_codes.cpp
@@ -0,0 +1,232 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 sqdb
+{
+
+namespace detail
+{
+
+const Error sqliteError(const char* sourceFileName,
+ int lineNumber,
+ int sqliteErrorCode)
+{
+ /*
+ jassert (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 = TRANS("an sqlite error or missing database was encountered");
+ c = Error::general;
+ break;
+
+ case SQLITE_INTERNAL:
+ s = TRANS("sqlite encountered an internal logic error");
+ c = Error::unexpected;
+ break;
+
+ case SQLITE_PERM:
+ s = TRANS("sqlite was denied file access permission");
+ c = Error::fileNoPerm;
+ break;
+
+ case SQLITE_ABORT:
+ s = TRANS("the sqlite operation was canceled due to a callback");
+ c = Error::canceled;
+ break;
+
+ case SQLITE_BUSY:
+ s = TRANS("the sqlite database file is locked");
+ c = Error::fileInUse;
+ break;
+
+ case SQLITE_LOCKED:
+ s = TRANS("the sqlite database table was locked");
+ c = Error::fileInUse;
+ break;
+
+ case SQLITE_NOMEM:
+ s = TRANS("sqlite ran out of memory");
+ c = Error::noMemory;
+ break;
+
+ case SQLITE_READONLY:
+ s = TRANS("sqlite tried to write to a read-only database");
+ c = Error::fileNoPerm;
+ break;
+
+ case SQLITE_INTERRUPT:
+ s = TRANS("the sqlite operation was interrupted");
+ c = Error::canceled;
+ break;
+
+ case SQLITE_IOERR:
+ s = TRANS("sqlite encountered a device I/O error");
+ c = Error::fileIOError;
+ break;
+
+ case SQLITE_CORRUPT:
+ s = TRANS("the sqlite database is corrupt");
+ c = Error::invalidData;
+ break;
+
+ case SQLITE_FULL:
+ s = TRANS("the sqlite database is full");
+ c = Error::fileNoSpace;
+ break;
+
+ case SQLITE_CANTOPEN:
+ s = TRANS("the sqlite database could not be opened");
+ c = Error::fileNotFound;
+ break;
+
+ case SQLITE_PROTOCOL:
+ s = TRANS("sqlite encountered a lock protocol error");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_EMPTY:
+ s = TRANS("the sqlite database is empty");
+ c = Error::noMoreData;
+ break;
+
+ case SQLITE_SCHEMA:
+ s = TRANS("the sqlite database scheme was changed");
+ c = Error::invalidData;
+ break;
+
+ case SQLITE_TOOBIG:
+ s = TRANS("the sqlite string or blob was too large");
+ c = Error::fileNoSpace;
+ break;
+
+ case SQLITE_CONSTRAINT:
+ s = TRANS("the sqlite operation was aborted due to a constraint violation");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_MISMATCH:
+ s = TRANS("the sqlite data was mismatched");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_MISUSE:
+ s = TRANS("the sqlite library parameter was invalid");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_NOLFS:
+ s = TRANS("the sqlite platform feature is unavailable");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_AUTH:
+ s = TRANS("sqlite authorization was denied");
+ c = Error::fileNoPerm;
+ break;
+
+ case SQLITE_FORMAT:
+ s = TRANS("the auxiliary sqlite database has an invalid format");
+ c = Error::invalidData;
+ break;
+
+ case SQLITE_RANGE:
+ s = TRANS("the sqlite parameter was invalid");
+ c = Error::badParameter;
+ break;
+
+ case SQLITE_NOTADB:
+ s = TRANS("the file is not a sqlite database");
+ c = Error::invalidData;
+ break;
+
+ default:
+ s << TRANS("an unknown sqlite3 error code #")
+ << String(sqliteErrorCode)
+ << TRANS("was returned");
+ c = Error::general;
+ break;
+ }
+
+ if (c != Error::success)
+ e.fail(sourceFileName, lineNumber, s, c);
+
+ return e;
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/into_type.cpp b/Subtrees/beast/modules/beast_sqdb/source/into_type.cpp
new file mode 100644
index 0000000000..3eb7c4c2f6
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/into_type.cpp
@@ -0,0 +1,301 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 sqdb
+{
+
+namespace detail
+{
+
+namespace
+{
+
+template
+inline T& as(void* data)
+{
+ return *static_cast(data);
+}
+
+template
+static void integer_into(void* data, sqlite3_int64 v)
+{
+ *(static_cast(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
+ if (!m_ind)
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ *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(m_data) = v != 0;
+ break;
+
+ case x_char:
+ integer_into(m_data, v);
+ break;
+
+ case x_short:
+ integer_into(m_data, v);
+ break;
+
+ case x_int:
+ integer_into(m_data, v);
+ break;
+
+ case x_long:
+ integer_into(m_data, v);
+ break;
+
+ case x_int64:
+ integer_into(m_data, v);
+ break;
+
+ case x_uchar:
+ integer_into(m_data, v);
+ break;
+
+ case x_ushort:
+ integer_into(m_data, v);
+ break;
+
+ case x_uint:
+ integer_into(m_data, v);
+ break;
+
+ case x_ulong:
+ integer_into(m_data, v);
+ break;
+
+ case x_uint64:
+ integer_into(m_data, v);
+ break;
+
+ case x_beastString:
+ as (m_data) = String(v);
+ break;
+
+ default:
+ Throw(Error().fail(__FILE__, __LINE__));
+ }
+ }
+ break;
+
+ case SQLITE_FLOAT:
+ {
+ double v = sqlite3_column_double(m_st->m_stmt, m_iCol);
+
+ switch (m_type)
+ {
+ case x_float:
+ as(m_data) = static_cast(v);
+ break;
+
+ case x_double:
+ as(m_data) = v;
+ break;
+
+ case x_beastString:
+ as (m_data) = String(v);
+ break;
+
+ default:
+ Throw(Error().fail(__FILE__, __LINE__));
+ };
+ }
+ 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(m_data);
+ result.assign(reinterpret_cast(v), bytes);
+ }
+ break;
+
+ case x_stdwstring:
+ Throw(Error().fail(__FILE__, __LINE__));
+ break;
+
+ case x_beastString:
+ {
+ // excludes terminator
+ int bytes = sqlite3_column_bytes(m_st->m_stmt, m_iCol);
+
+ const CharPointer_UTF8::CharType* c = reinterpret_cast
+
+ (sqlite3_column_text(m_st->m_stmt, m_iCol));
+
+ String& s = as (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(m_data) = v != 0;
+ break;
+
+ case x_char:
+ integer_into(m_data, v);
+ break;
+
+ case x_short:
+ integer_into(m_data, v);
+ break;
+
+ case x_int:
+ integer_into(m_data, v);
+ break;
+
+ case x_long:
+ integer_into(m_data, v);
+ break;
+
+ case x_int64:
+ integer_into(m_data, v);
+ break;
+
+ case x_uchar:
+ integer_into(m_data, v);
+ break;
+
+ case x_ushort:
+ integer_into(m_data, v);
+ break;
+
+ case x_uint:
+ integer_into(m_data, v);
+ break;
+
+ case x_ulong:
+ integer_into(m_data, v);
+ break;
+
+ case x_uint64:
+ integer_into(m_data, v);
+ break;
+
+ default:
+ Throw(Error().fail(__FILE__, __LINE__));
+ }
+
+ }
+ break;
+ };
+ }
+ break;
+
+ case SQLITE_BLOB:
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ default:
+ Throw(Error().fail(__FILE__, __LINE__));
+ };
+ }
+
+ convert_from_base();
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/once_temp_type.cpp b/Subtrees/beast/modules/beast_sqdb/source/once_temp_type.cpp
new file mode 100644
index 0000000000..7463e2c3ac
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/once_temp_type.cpp
@@ -0,0 +1,120 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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)
+{
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/prepare_temp_type.cpp b/Subtrees/beast/modules/beast_sqdb/source/prepare_temp_type.cpp
new file mode 100644
index 0000000000..addad08077
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/prepare_temp_type.cpp
@@ -0,0 +1,106 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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;
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/ref_counted_prepare_info.cpp b/Subtrees/beast/modules/beast_sqdb/source/ref_counted_prepare_info.cpp
new file mode 100644
index 0000000000..f05d1f2087
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/ref_counted_prepare_info.cpp
@@ -0,0 +1,105 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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();
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/ref_counted_statement.cpp b/Subtrees/beast/modules/beast_sqdb/source/ref_counted_statement.cpp
new file mode 100644
index 0000000000..5a0676f3e3
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/ref_counted_statement.cpp
@@ -0,0 +1,127 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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();
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/session.cpp b/Subtrees/beast/modules/beast_sqdb/source/session.cpp
new file mode 100644
index 0000000000..de1778472f
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/session.cpp
@@ -0,0 +1,397 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 sqdb
+{
+
+class session::Sqlite3 : public SharedSingleton
+{
+private:
+ friend class SharedSingleton ;
+
+ Sqlite3() : SharedSingleton (SingletonLifetime::persistAfterCreation)
+ {
+ int threadSafe = sqlite3_threadsafe();
+
+ if (threadSafe == 0)
+ Throw(Error().fail(__FILE__, __LINE__, Error::assertFailed));
+
+ int result = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+
+ if (result != SQLITE_OK)
+ Throw(Error().fail(__FILE__, __LINE__, Error::assertFailed));
+
+ sqlite3_initialize();
+ }
+
+ ~Sqlite3()
+ {
+ sqlite3_shutdown();
+ }
+
+ static Sqlite3* createInstance()
+ {
+ return new Sqlite3;
+ }
+};
+
+//------------------------------------------------------------------------------
+
+session::session()
+ : prepare(this)
+ , m_instance(Sqlite3::getInstance())
+ , m_bInTransaction(false)
+ , m_connection(nullptr)
+{
+}
+
+session::session(const session& deferredClone)
+ : prepare(this)
+ , m_instance(Sqlite3::getInstance())
+ , 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()
+{
+ if (m_connection)
+ Throw(Error().fail(__FILE__, __LINE__)); // already open
+
+ return open(m_fileName, m_connectString);
+}
+
+/*
+static int infiniteBusyHandler (void* data, int tries)
+{
+ boost::this_thread::sleep (boost::posix_time::seconds(1));
+ return 1; // try again
+}
+*/
+
+Error session::open(String fileName, std::string options)
+{
+ Error err;
+
+ // can't open twice
+ if (m_connection)
+ Throw(err.fail(__FILE__, __LINE__, Error::fileInUse));
+
+ int mode = 0;
+ int flags = 0;
+ int timeout = 0;
+
+ std::stringstream ssconn(options);
+
+ while (!err && !ssconn.eof() && ssconn.str().find('=') >= 0)
+ {
+ 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(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+ else
+ {
+ // duplicate
+ Throw(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+
+ /* 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(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+ else
+ {
+ // duplicate
+ Throw(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+
+#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(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+ else
+ {
+ // duplicate
+ Throw(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+ else
+ {
+ // unknown option
+ Throw(err.fail(__FILE__, __LINE__, Error::badParameter));
+ }
+ }
+
+ 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(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;
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/statement.cpp b/Subtrees/beast/modules/beast_sqdb/source/statement.cpp
new file mode 100644
index 0000000000..e6c95b5320
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/statement.cpp
@@ -0,0 +1,139 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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();
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/statement_imp.cpp b/Subtrees/beast/modules/beast_sqdb/source/statement_imp.cpp
new file mode 100644
index 0000000000..8c2933d5fa
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/statement_imp.cpp
@@ -0,0 +1,311 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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(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;
+
+ if (!m_stmt)
+ Throw(Error().fail(__FILE__, __LINE__, Error::badParameter));
+
+ // ???
+ 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(Error().fail(__FILE__, __LINE__, Error::assertFailed));
+ }
+
+ 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;
+}
+
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/transaction.cpp b/Subtrees/beast/modules/beast_sqdb/source/transaction.cpp
new file mode 100644
index 0000000000..6d767e1f72
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/transaction.cpp
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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
+ if (m_bHandled)
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ // 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
+ if (m_bHandled)
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ m_session.rollback();
+ m_bHandled = true;
+}
+
+}
diff --git a/Subtrees/beast/modules/beast_sqdb/source/use_type.cpp b/Subtrees/beast/modules/beast_sqdb/source/use_type.cpp
new file mode 100644
index 0000000000..3c8b052279
--- /dev/null
+++ b/Subtrees/beast/modules/beast_sqdb/source/use_type.cpp
@@ -0,0 +1,224 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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ö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 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
+inline T const& as(void const* v)
+{
+ return *static_cast (v);
+}
+
+template
+inline T const& as(void const* v)
+{
+ T const& val = *static_cast (v);
+
+ if (val > T(std::numeric_limits::max()))
+ Throw(Error().fail(__FILE__, __LINE__));
+
+ 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 (m_data) ? 1 : 0);
+ break;
+
+ case x_char:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_short:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_int:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_long:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_int64:
+ result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_uchar:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_ushort:
+ result = sqlite3_bind_int(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_uint:
+ result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_ulong:
+ result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_uint64:
+ result = sqlite3_bind_int64(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_float:
+ result = sqlite3_bind_double(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_double:
+ result = sqlite3_bind_double(m_st->m_stmt, m_iParam, as (m_data));
+ break;
+
+ case x_cstring:
+ result = sqlite3_bind_text(m_st->m_stmt, m_iParam, as (m_data), -1, SQLITE_STATIC);
+ break;
+
+ case x_cwstring:
+ result = sqlite3_bind_text16(m_st->m_stmt, m_iParam, as (m_data), -1, SQLITE_STATIC);
+ break;
+
+ case x_stdstring:
+ {
+ std::string const& s = as (m_data);
+ result = sqlite3_bind_text(m_st->m_stmt,
+ m_iParam,
+ s.c_str(),
+ s.size() * sizeof(s[0]),
+ SQLITE_STATIC);
+ }
+ break;
+
+ case x_stdwstring:
+ {
+ std::wstring const& s = as (m_data);
+ result = sqlite3_bind_text16(m_st->m_stmt,
+ m_iParam,
+ s.c_str(),
+ s.size() * sizeof(s[0]),
+ SQLITE_STATIC);
+ }
+ break;
+
+ case x_beastString:
+ {
+ String const& s = as (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(Error().fail(__FILE__, __LINE__, Error::badParameter));
+ }
+
+ 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()
+{
+}
+
+}
+
+}