From ac887840ca5c27da9f3f61fb5bc32cb05a6748b1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 10:49:41 +0200 Subject: Add .gitignore file --- .gitignore | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b9998d --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Compiler/linker output. +# +*.o +*.o.d +*.so +*.a +*.l +*.l.cpp-options + +# Generated documentation. +# +*.pdf +*.ps + +# Generated build system files. +# +*-dynamic.make + +# Generated .gitignore files. +# +.gitignore -- cgit v1.1 From 35c31a19f90608df19f0c4aa077dcbbe5150d3e4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 11:48:07 +0200 Subject: Add standard package files --- GPLv2 | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INSTALL-GIT | 73 +++++++++++++ LICENSE | 12 +++ NEWS | 1 + README | 20 ++++ version | 1 + 6 files changed, 447 insertions(+) create mode 100644 GPLv2 create mode 100644 INSTALL-GIT create mode 100644 LICENSE create mode 100644 NEWS create mode 100644 README create mode 100644 version diff --git a/GPLv2 b/GPLv2 new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/GPLv2 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/INSTALL-GIT b/INSTALL-GIT new file mode 100644 index 0000000..fc6d7fe --- /dev/null +++ b/INSTALL-GIT @@ -0,0 +1,73 @@ +The following instructions describe how to work with the source code that was +checked out from the git repository. + +The major difference between using a released source code package and source +code from the repository is that the former does not contain autotools-based +makefiles or Visual Studio project files. Instead, it contains templates for +these files as well as its own, custom build system. This build system is +used for development as well as to automatically generate the autotools and +Visual Studio files. + +This file describes how to use this build system to build the package as well +as to create a release-ready source distribution which contains the autotools +build system and Visual Studio project files. + + +Prerequisites +============= + +Besides the prerequisites listed in the INSTALL file, you will need the +following additional packages: + + - GNU bash >= 2.0.0 http://www.gnu.org/software/bash/ + - GNU make >= 3.81 http://www.gnu.org/software/make/ + - build >= latest http://www.codesynthesis.com/projects/build/ + - cli >= latest http://www.codesynthesis.com/projects/cli/ + +If you are planning to create the source code distributions, then you will +also need the following packages: + + - GNU m4 >= 1.4.0 http://www.gnu.org/software/m4/ + - GNU sed >= 4.0.0 http://www.gnu.org/software/sed/ + - tofrodos >= 1.7.0 http://www.thefreecountry.com/tofrodos/ + +Any reasonably up to date GNU/Linux installation would normally have all of +the above packages already present, except for build and maybe tofrodos. + + +Configuring and Building +======================== + +To build the source code simply run make in the root directory of the package. +The first time you run make, the build process will also configure the +package by asking you several questions. On the subsequent runs, make will +only rebuild what has changed. + +To run the automated test suite (if any), run 'make test'. To clean the object +files, executables, etc., run 'make clean'. To de-configure the package (that +is, to remove configuration files in addition to objects, executables, etc.), +run 'make disfigure'. + + +Creating Distribution +===================== + +To create the source code distribution, use the dist make target as well as +the dist_prefix variable to specify the directory where the distribution files +should be placed. For example: + +make dist dist_prefix=/tmp/package-1.1.0 + +Once the distribution files are ready, change to the distribution directory +and run the bootstrap script to bootstrap the autotools build system, for +example: + +cd /tmp/package-1.1.0 +./bootsrap + +To create the source code archives, use the autotools build system. First +configuring the package (see the INSTALL file for more information on this +step) and then use the dist target to make the archives, for example: + +./configure +make dist diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ed9c55c --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..72d0f8b --- /dev/null +++ b/NEWS @@ -0,0 +1 @@ +See the common NEWS file in the ODB compiler package. diff --git a/README b/README new file mode 100644 index 0000000..ffd4049 --- /dev/null +++ b/README @@ -0,0 +1,20 @@ +ODB is an object-relational mapping (ORM) system for C++. It provides +tools, APIs, and library support that allow you to persist C++ objects +to a relational database (RDBMS) without having to deal with tables, +columns, or SQL and without manually writing any of the mapping code. +For more information see: + +http://www.codesynthesis.com/products/odb/ + +This package contains the SQLite ODB runtime library. Every application +that includes code generated for the SQLite database will need to link +to this library. + +See the NEWS file for the user-visible changes from the previous release. + +See the LICENSE file for distribution conditions. + +See the INSTALL file for prerequisites and installation instructions. + +Send questions, bug reports, or any other feedback to the +odb-users@codesynthesis.com mailing list. diff --git a/version b/version new file mode 100644 index 0000000..9084fa2 --- /dev/null +++ b/version @@ -0,0 +1 @@ +1.1.0 -- cgit v1.1 From acff75b62b48f9a121d935e1f59ddc465145618c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 12:35:53 +0200 Subject: Development build system setup --- build/bootstrap.make | 72 ++++++++++++++++ build/import/cli/LICENSE | 21 +++++ build/import/cli/cli-cxx.make | 49 +++++++++++ build/import/cli/configuration-rules.make | 15 ++++ build/import/cli/configure | 55 ++++++++++++ build/import/cli/stub.make | 30 +++++++ build/import/libodb/LICENSE | 12 +++ build/import/libodb/configuration-rules.make | 15 ++++ build/import/libodb/configure | 55 ++++++++++++ build/import/libodb/stub.make | 30 +++++++ makefile | 36 ++++++++ odb/sqlite/details/config.h.in | 14 +++ odb/sqlite/details/config.hxx | 20 +++++ odb/sqlite/details/export.hxx | 41 +++++++++ odb/sqlite/details/options.cli | 48 +++++++++++ odb/sqlite/forward.hxx | 37 ++++++++ odb/sqlite/makefile | 124 +++++++++++++++++++++++++++ odb/sqlite/version.hxx | 44 ++++++++++ 18 files changed, 718 insertions(+) create mode 100644 build/bootstrap.make create mode 100644 build/import/cli/LICENSE create mode 100644 build/import/cli/cli-cxx.make create mode 100644 build/import/cli/configuration-rules.make create mode 100755 build/import/cli/configure create mode 100644 build/import/cli/stub.make create mode 100644 build/import/libodb/LICENSE create mode 100644 build/import/libodb/configuration-rules.make create mode 100755 build/import/libodb/configure create mode 100644 build/import/libodb/stub.make create mode 100644 makefile create mode 100644 odb/sqlite/details/config.h.in create mode 100644 odb/sqlite/details/config.hxx create mode 100644 odb/sqlite/details/export.hxx create mode 100644 odb/sqlite/details/options.cli create mode 100644 odb/sqlite/forward.hxx create mode 100644 odb/sqlite/makefile create mode 100644 odb/sqlite/version.hxx diff --git a/build/bootstrap.make b/build/bootstrap.make new file mode 100644 index 0000000..b5f87a7 --- /dev/null +++ b/build/bootstrap.make @@ -0,0 +1,72 @@ +# file : build/bootstrap.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project_name := libodb-sqlite + +# First try to include the bundled bootstrap.make if it exist. If that +# fails, let make search for the external bootstrap.make. +# +build := build-0.3 + +-include $(dir $(lastword $(MAKEFILE_LIST)))../../$(build)/bootstrap.make + +ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),) +include $(build)/bootstrap.make +endif + + +# Aliases +# +.PHONY: $(out_base)/ \ + $(out_base)/.test \ + $(out_base)/.dist \ + $(out_base)/.clean + +ifdef %interactive% + +.PHONY: test dist clean + +test: $(out_base)/.test +dist: $(out_base)/.dist +clean: $(out_base)/.clean + +ifneq ($(filter $(.DEFAULT_GOAL),test dist clean),) +.DEFAULT_GOAL := +endif + +endif + +# Make sure the distribution prefix is set if the goal is dist. +# +ifneq ($(filter $(MAKECMDGOALS),dist),) +ifeq ($(dist_prefix),) +$(error dist_prefix is not set) +endif +endif + +# If we don't have dependency auto-generation then we need to manually +# make sure that generated files are generated before C++ file are +# compiler. To do this we make the object files ($2) depend in order- +# only on generated files ($3). +# +ifeq ($(cxx_id),generic) + +define include-dep +$(if $2,$(eval $2: | $3)) +endef + +else + +define include-dep +$(call -include,$1) +endef + +endif + +# Don't include dependency info for certain targets. +# +ifneq ($(filter $(MAKECMDGOALS),clean disfigure dist),) +include-dep = +endif diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE new file mode 100644 index 0000000..3fe3ab2 --- /dev/null +++ b/build/import/cli/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2009-2011 Code Synthesis Tools CC. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +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 AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make new file mode 100644 index 0000000..5d4293e --- /dev/null +++ b/build/import/cli/cli-cxx.make @@ -0,0 +1,49 @@ +# file : build/import/cli/cli-cxx.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +# Here we are operating in the importing project's space, not in +# cli's. +# + +# Get the C++ file extensions. +# +$(call include,$(bld_root)/cxx/configuration-static.make) + +cli_pattern := \ +$(out_base)/%.$(cxx_s_suffix) \ +$(out_base)/%.$(cxx_h_suffix) \ +$(out_base)/%.$(cxx_i_suffix) + +$(cli_pattern): cli_options := \ +--hxx-suffix .$(cxx_h_suffix) \ +--ixx-suffix .$(cxx_i_suffix) \ +--cxx-suffix .$(cxx_s_suffix) + +.PRECIOUS: $(cli_pattern) + +ifeq ($(out_base),$(src_base)) + +$(cli_pattern): $(src_base)/%.cli + $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) + +else + +$(cli_pattern): $(src_base)/%.cli | $$(dir $$@). + $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) + +$(cli_pattern): $(out_base)/%.cli | $$(dir $$@). + $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) +endif + +.PHONY: $(out_base)/%.cxx.cli.clean + +$(out_base)/%.cxx.cli.clean: cxx_s_suffix := $(cxx_s_suffix) +$(out_base)/%.cxx.cli.clean: cxx_h_suffix := $(cxx_h_suffix) +$(out_base)/%.cxx.cli.clean: cxx_i_suffix := $(cxx_i_suffix) + +$(out_base)/%.cxx.cli.clean: + $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_s_suffix))) + $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_h_suffix))) + $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_i_suffix))) diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make new file mode 100644 index 0000000..e5a77f2 --- /dev/null +++ b/build/import/cli/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/import/cli/configuration-rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +$(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. + $(call message,,$(scf_root)/import/cli/configure $@) + +ifndef %foreign% + +$(dcf_root)/.disfigure:: + $(call message,rm $(dcf_root)/import/cli/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/cli/configuration-dynamic.make) + +endif diff --git a/build/import/cli/configure b/build/import/cli/configure new file mode 100755 index 0000000..612301c --- /dev/null +++ b/build/import/cli/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/import/cli/configure +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + + +# $1 - out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'cli' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed " +$echo "version of 'cli' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= + +if [ "$installed" = "n" ]; then + +$echo +$echo "Please enter the src_root for 'cli'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'cli'." +$eche + +out_root=`read_path --directory $src_root` + +fi + +echo cli_installed := $installed >$1 + +if [ "$installed" = "n" ]; then + +echo src_root := $src_root >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root >>$1 + +fi diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make new file mode 100644 index 0000000..20cf45a --- /dev/null +++ b/build/import/cli/stub.make @@ -0,0 +1,30 @@ +# file : build/import/cli/stub.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) + +cli_installed := + +$(call -include,$(dcf_root)/import/cli/configuration-dynamic.make) + +ifdef cli_installed + +ifeq ($(cli_installed),y) + +$(call export,cli: cli,cli-rules: $(scf_root)/import/cli/cli-cxx.make) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/cli/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/build/import/libodb/LICENSE b/build/import/libodb/LICENSE new file mode 100644 index 0000000..ed9c55c --- /dev/null +++ b/build/import/libodb/LICENSE @@ -0,0 +1,12 @@ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make new file mode 100644 index 0000000..9263bb0 --- /dev/null +++ b/build/import/libodb/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/import/libodb/configuration-rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. + $(call message,,$(scf_root)/import/libodb/configure $@) + +ifndef %foreign% + +$(dcf_root)/.disfigure:: + $(call message,rm $(dcf_root)/import/libodb/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libodb/configuration-dynamic.make) + +endif diff --git a/build/import/libodb/configure b/build/import/libodb/configure new file mode 100755 index 0000000..90e21d4 --- /dev/null +++ b/build/import/libodb/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/import/libodb/configure +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +# $1 - out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'libodb' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed " +$echo "version of 'libodb' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= + +if [ "$installed" = "n" ]; then + +$echo +$echo "Please enter the src_root for 'libodb'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'libodb'." +$echo + +out_root=`read_path --directory $src_root` + +fi + +echo libodb_installed := $installed >$1 + +if [ "$installed" = "n" ]; then + +echo src_root := $src_root >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root >>$1 + +fi diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make new file mode 100644 index 0000000..97bb5ff --- /dev/null +++ b/build/import/libodb/stub.make @@ -0,0 +1,30 @@ +# file : build/import/libodb/stub.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) + +libodb_installed := + +$(call -include,$(dcf_root)/import/libodb/configuration-dynamic.make) + +ifdef libodb_installed + +ifeq ($(libodb_installed),y) + +$(call export,l: -lodb,cpp-options: ) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/libodb/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/makefile b/makefile new file mode 100644 index 0000000..6112879 --- /dev/null +++ b/makefile @@ -0,0 +1,36 @@ +# file : makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +dirs := odb/sqlite + +default := $(out_base)/ +dist := $(out_base)/.dist +clean := $(out_base)/.clean + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) + +$(dist): export dirs := $(dirs) +$(dist): export docs := GPLv2 LICENSE README NEWS version +$(dist): data_dist := INSTALL libodb-sqlite-vc9.sln libodb-sqlite-vc10.sln +$(dist): exec_dist := bootstrap +$(dist): export extra_dist := $(data_dist) $(exec_dist) +$(dist): export version = $(shell cat $(src_root)/version) + +$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs))) + $(call dist-data,$(docs) $(data_dist) libodb-sqlite.pc.in) + $(call dist-exec,$(exec_dist)) + $(call dist-dir,m4) + $(call meta-automake) + $(call meta-autoconf) + +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs))) + +$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/automake.make) +$(call include,$(bld_root)/meta/autoconf.make) + +$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile)) diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in new file mode 100644 index 0000000..ff8c029 --- /dev/null +++ b/odb/sqlite/details/config.h.in @@ -0,0 +1,14 @@ +/* file : odb/sqlite/details/config.h.in + * author : Boris Kolpackov + * copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* This file is automatically processed by configure. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_H +#define ODB_SQLITE_DETAILS_CONFIG_H + +#undef LIBODB_SQLITE_STATIC_LIB + +#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx new file mode 100644 index 0000000..26aeaf3 --- /dev/null +++ b/odb/sqlite/details/config.hxx @@ -0,0 +1,20 @@ +// file : odb/sqlite/details/config.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_CONFIG_HXX +#define ODB_SQLITE_DETAILS_CONFIG_HXX + +// no pre + +#ifdef _MSC_VER +#elif defined(ODB_COMPILER) +# error libodb-sqlite header included in odb-compiled header +#else +# include +#endif + +// no post + +#endif // ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx new file mode 100644 index 0000000..dd17e33 --- /dev/null +++ b/odb/sqlite/details/export.hxx @@ -0,0 +1,41 @@ +// file : odb/sqlite/details/export.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_EXPORT_HXX +#define ODB_SQLITE_DETAILS_EXPORT_HXX + +#include + +#include + +#ifdef LIBODB_SQLITE_STATIC_LIB +# define LIBODB_SQLITE_EXPORT +#else +# ifdef _WIN32 +# ifdef _MSC_VER +# ifdef LIBODB_SQLITE_DYNAMIC_LIB +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# endif +# else +# ifdef LIBODB_SQLITE_DYNAMIC_LIB +# ifdef DLL_EXPORT +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +# else +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# endif +# endif +# else +# define LIBODB_SQLITE_EXPORT +# endif +#endif + +#include + +#endif // ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli new file mode 100644 index 0000000..a0af101 --- /dev/null +++ b/odb/sqlite/details/options.cli @@ -0,0 +1,48 @@ +// file : odb/sqlite/details/options.cli +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +include ; + +namespace odb +{ + namespace sqlite + { + namespace details + { + class options + { + std::string --database + { + "", + "SQLite database file name. If the database file is not specified + then a private, temporary on-disk database will be created. Use + the \cb{:memory:} special name to create a private, temporary + in-memory database." + }; + + bool --database-create + { + "Create the SQLite database if it does not already exist. By default + opening the database fails if it does not already exist." + }; + + bool --database-readonly + { + "Open the SQLite database in read-only mode. By default the database + is opened for reading and writing if possible, or reading only if + the file is write-protected by the operating system." + }; + + std::string --options-file + { + "", + "Read additional options from . Each option appearing on a + separate line optionally followed by space and an option value. + Empty lines and lines starting with \cb{#} are ignored." + }; + }; + } + } +} diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx new file mode 100644 index 0000000..d141534 --- /dev/null +++ b/odb/sqlite/forward.hxx @@ -0,0 +1,37 @@ +// file : odb/sqlite/forward.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_FORWARD_HXX +#define ODB_SQLITE_FORWARD_HXX + +#include + +namespace odb +{ + namespace sqlite + { + // @@ Any garbage here? + // + class database; + class connection; + class connection_factory; + class transaction; + class query; + + // Implementation details. + // + class select_statement; + + template + class object_statements; + + template + class container_statements; + } +} + +#include + +#endif // ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile new file mode 100644 index 0000000..4a25dee --- /dev/null +++ b/odb/sqlite/makefile @@ -0,0 +1,124 @@ +# file : odb/sqlite/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +cxx := \ + +cli_tun := details/options.cli +cxx_tun := $(cxx) +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +odb_sqlite.l := $(out_base)/odb-sqlite.l +odb_sqlite.l.cpp-options := $(out_base)/odb-sqlite.l.cpp-options + +default := $(out_base)/ +dist := $(out_base)/.dist +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/cli/stub.make,\ + cli: cli,cli-rules: cli_rules) + +$(call import,\ + $(scf_root)/import/libodb/stub.make,\ + l: odb.l,cpp-options: odb.l.cpp-options) + +#$(call import,\ +# $(scf_root)/import/libsqlite/stub.make,\ +# l: sqlite.l,cpp-options: sqlite.l.cpp-options) + +# Build. +# +$(odb_sqlite.l): $(cxx_obj) $(odb.l) $(sqlite.l) +$(odb_sqlite.l.cpp-options): value := -I$(out_root) -I$(src_root) +$(odb_sqlite.l.cpp-options): $(odb.l.cpp-options) $(sqlite.l.cpp-options) + +$(cxx_obj) $(cxx_od): $(odb_sqlite.l.cpp-options) $(out_base)/details/config.h + +genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(cli) +$(gen): cli := $(cli) +$(gen): cli_options += \ +--long-usage \ +--generate-file-scanner \ +--cli-namespace odb::sqlite::details::cli \ +--guard-prefix LIBODB_SQLITE_DETAILS + +$(out_base)/details/config.h: + @echo '/* file : odb/sqlite/details/config.h' >$@ + @echo ' * author : automatically generated' >>$@ + @echo ' */' >>$@ + @echo '' >>$@ + @echo '#ifndef ODB_SQLITE_DETAILS_CONFIG_H' >>$@ + @echo '#define ODB_SQLITE_DETAILS_CONFIG_H' >>$@ + @echo '' >>$@ + @echo '' >>$@ + @echo '#endif /* ODB_SQLITE_DETAILS_CONFIG_H */' >>$@ + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen) $(out_base)/details/config.h) + +# Convenience alias for default target. +# +$(out_base)/: $(odb_sqlite.l) + +# Dist. +# +$(dist): sources_dist := $(cxx) +$(dist): export sources := $(sources_dist) $(cli_tun:.cli=.cxx) +$(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \ +-name '*.hxx' -o -name '*.ixx' -o -name '*.txx')) +$(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) +$(dist): export headers = $(sort $(headers_dist) $(gen_headers)) +$(dist): gen_dist := $(gen) +$(dist): data_dist := $(cli_tun) details/config.h.in +$(dist): export extra_dist := $(data_dist) libodb-sqlite-vc9.vcproj \ +libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters +$(dist): export interface_version = $(shell sed -e \ +'s/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) + +$(dist): $(gen) + $(call dist-data,$(sources_dist) $(headers_dist) $(data_dist)) + $(call dist-data,$(gen_dist),$(dist_prefix)/odb/sqlite/details) + $(call meta-vc9proj,$(src_base)/libodb-sqlite-vc9.vcproj) + $(call meta-vc10proj,$(src_base)/libodb-sqlite-vc10.vcxproj) + $(call meta-automake) + +# Clean. +# +$(clean): $(odb_sqlite.l).o.clean \ + $(odb_sqlite.l.cpp-options).clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean)) + $(call message,rm $$1,rm -f $$1,$(out_base)/details/config.h) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(odb_sqlite.l): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := details/config.h $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + +# How to. +# +$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) +$(call include,$(bld_root)/meta/automake.make) + +$(call include,$(cli_rules)) +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx new file mode 100644 index 0000000..4759d6d --- /dev/null +++ b/odb/sqlite/version.hxx @@ -0,0 +1,44 @@ +// file : odb/sqlite/version.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_VERSION_HXX +#define ODB_SQLITE_VERSION_HXX + +#include + +#include + +// Version format is AABBCCDD where +// +// AA - major version number +// BB - minor version number +// CC - bugfix version number +// DD - alpha / beta (DD + 50) version number +// +// When DD is not 00, 1 is subtracted from AABBCC. For example: +// +// Version AABBCCDD +// 2.0.0 02000000 +// 2.1.0 02010000 +// 2.1.1 02010100 +// 2.2.0.a1 02019901 +// 3.0.0.b2 02999952 +// + +// Check that we have compatible ODB version. +// +#if ODB_VERSION != 10100 +# error incompatible odb interface version detected +#endif + +// libodb-sqlite version: odb interface version plus the bugfix +// version. +// +#define LIBODB_SQLITE_VERSION 1010000 +#define LIBODB_SQLITE_VERSION_STR "1.1.0" + +#include + +#endif // ODB_SQLITE_VERSION_HXX -- cgit v1.1 From b0f1eb606642f300eb42095127dd6fbd8ad1f41a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 12:43:28 +0200 Subject: Add import stub --- build/export/libodb-sqlite/stub.make | 10 ++++ build/import/libodb-sqlite/LICENSE | 1 + .../import/libodb-sqlite/configuration-rules.make | 15 ++++++ build/import/libodb-sqlite/configure | 55 ++++++++++++++++++++++ build/import/libodb-sqlite/stub.make | 30 ++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 build/export/libodb-sqlite/stub.make create mode 120000 build/import/libodb-sqlite/LICENSE create mode 100644 build/import/libodb-sqlite/configuration-rules.make create mode 100755 build/import/libodb-sqlite/configure create mode 100644 build/import/libodb-sqlite/stub.make diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make new file mode 100644 index 0000000..6beb3be --- /dev/null +++ b/build/export/libodb-sqlite/stub.make @@ -0,0 +1,10 @@ +# file : build/export/libodb-sqlite/stub.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) + +$(call export,\ + l: $(out_root)/odb/sqlite/odb-sqlite.l,\ + cpp-options: $(out_root)/odb/sqlite/odb-sqlite.l.cpp-options) diff --git a/build/import/libodb-sqlite/LICENSE b/build/import/libodb-sqlite/LICENSE new file mode 120000 index 0000000..5853aae --- /dev/null +++ b/build/import/libodb-sqlite/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make new file mode 100644 index 0000000..420f1ef --- /dev/null +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/import/libodb-sqlite/configuration-rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. + $(call message,,$(scf_root)/import/libodb-sqlite/configure $@) + +ifndef %foreign% + +$(dcf_root)/.disfigure:: + $(call message,rm $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make) + +endif diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure new file mode 100755 index 0000000..ee067ca --- /dev/null +++ b/build/import/libodb-sqlite/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/import/libodb-sqlite/configure +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +# $1 - out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'libodb-sqlite' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed version" +$echo "of 'libodb-sqlite' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= + +if [ "$installed" = "n" ]; then + +$echo +$echo "Please enter the src_root for 'libodb-sqlite'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'libodb-sqlite'." +$echo + +out_root=`read_path --directory $src_root` + +fi + +echo libodb_sqlite_installed := $installed >$1 + +if [ "$installed" = "n" ]; then + +echo src_root := $src_root >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root >>$1 + +fi diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make new file mode 100644 index 0000000..43f0e11 --- /dev/null +++ b/build/import/libodb-sqlite/stub.make @@ -0,0 +1,30 @@ +# file : build/import/libodb-sqlite/stub.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) + +libodb_sqlite_installed := + +$(call -include,$(dcf_root)/import/libodb-sqlite/configuration-dynamic.make) + +ifdef libodb_sqlite_installed + +ifeq ($(libodb_sqlite_installed),y) + +$(call export,l: -lodb-sqlite -lodb -lsqlite3,cpp-options: ) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/libodb-sqlite/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif -- cgit v1.1 From 62e7abd564f6f9c7a3ab9e7e469853c93bd0e4c9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 14:31:14 +0200 Subject: Add libsqlite import stub --- build/import/libsqlite/LICENSE | 340 ++++++++++++++++++++++++ build/import/libsqlite/configuration-rules.make | 15 ++ build/import/libsqlite/configure | 55 ++++ build/import/libsqlite/rules.make | 29 ++ build/import/libsqlite/stub.make | 32 +++ build/import/libsqlite/version | 1 + odb/sqlite/makefile | 6 +- 7 files changed, 475 insertions(+), 3 deletions(-) create mode 100644 build/import/libsqlite/LICENSE create mode 100644 build/import/libsqlite/configuration-rules.make create mode 100755 build/import/libsqlite/configure create mode 100644 build/import/libsqlite/rules.make create mode 100644 build/import/libsqlite/stub.make create mode 100644 build/import/libsqlite/version diff --git a/build/import/libsqlite/LICENSE b/build/import/libsqlite/LICENSE new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/build/import/libsqlite/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make new file mode 100644 index 0000000..6752b77 --- /dev/null +++ b/build/import/libsqlite/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/import/libsqlite/configuration-rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. + $(call message,,$(scf_root)/import/libsqlite/configure $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/import/libsqlite/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libsqlite/configuration-dynamic.make) + +endif diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure new file mode 100755 index 0000000..3bbf936 --- /dev/null +++ b/build/import/libsqlite/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/import/libsqlite/configure +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# license : GNU GPL v2; see accompanying LICENSE file + + +# $1 - out config file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'SQLite library' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed version" +$echo "of 'SQLite library' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= +type= + +if [ "$installed" = "n" ]; then + + $echo + $echo "Please enter the 'SQLite library' root directory." + $echo + + root=`read_path --directory --exist` + + $echo + $echo "Please select the library type you would like to use:" + $echo + $echo "(1) archive" + $echo "(2) shared object" + $echo + + type=`read_option "archive shared" "shared"` +fi + +echo libsqlite_installed := $installed >$1 + +if [ "$installed" = "n" ]; then + echo libsqlite_root := $root >>$1 + echo libsqlite_type := $type >>$1 +fi diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make new file mode 100644 index 0000000..4bc279b --- /dev/null +++ b/build/import/libsqlite/rules.make @@ -0,0 +1,29 @@ +# file : build/import/libsqlite/rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) + +ifeq ($(libsqlite_type),archive) + +$(dcf_root)/import/libsqlite/sqlite.l: $(libsqlite_root)/.libs/libsqlite3.a + @echo $< >$@ +else + +$(dcf_root)/import/libsqlite/sqlite.l: $(libsqlite_root)/.libs/libsqlite3.so + @echo $< >$@ + @echo rpath:$(root) >>$@ +endif + +$(dcf_root)/import/libsqlite/sqlite.l.cpp-options: + @echo include: -I$(root) >$@ + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/import/libsqlite/sqlite.l,\ +rm -f $(dcf_root)/import/libsqlite/sqlite.l) + $(call message,,rm -f $(dcf_root)/import/libsqlite/sqlite.l.cpp-options) + +endif diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make new file mode 100644 index 0000000..a6ae87d --- /dev/null +++ b/build/import/libsqlite/stub.make @@ -0,0 +1,32 @@ +# file : build/import/libsqlite/stub.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) + +libsqlite_installed := + +$(call -include,$(dcf_root)/import/libsqlite/configuration-dynamic.make) + +ifdef libsqlite_installed + +ifeq ($(libsqlite_installed),y) + +$(call export,l: -lsqlite3,cpp-options: ) + +else + +$(call include-once,$(scf_root)/import/libsqlite/rules.make,$(dcf_root)) + +$(call export,\ + l: $(dcf_root)/import/libsqlite/sqlite.l,\ + cpp-options: $(dcf_root)/import/libsqlite/sqlite.l.cpp-options) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/build/import/libsqlite/version b/build/import/libsqlite/version new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/build/import/libsqlite/version @@ -0,0 +1 @@ +0.1.0 diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 4a25dee..6b8c4a2 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -29,9 +29,9 @@ $(call import,\ $(scf_root)/import/libodb/stub.make,\ l: odb.l,cpp-options: odb.l.cpp-options) -#$(call import,\ -# $(scf_root)/import/libsqlite/stub.make,\ -# l: sqlite.l,cpp-options: sqlite.l.cpp-options) +$(call import,\ + $(scf_root)/import/libsqlite/stub.make,\ + l: sqlite.l,cpp-options: sqlite.l.cpp-options) # Build. # -- cgit v1.1 From 41c7293bf991e4449c41224e812634b414ec5b83 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Mar 2011 15:30:06 +0200 Subject: Autotools and VC++ build systems setup --- INSTALL | 0 Makefile.am | 12 + bootstrap | 18 ++ configure.ac | 58 +++++ libodb-sqlite-vc10.sln | 26 ++ libodb-sqlite-vc9.sln | 26 ++ libodb-sqlite.pc.in | 16 ++ m4/acx-pthread.m4 | 257 ++++++++++++++++++ m4/disable-rpath.m4 | 26 ++ m4/libodb.m4 | 83 ++++++ m4/libsqlite.m4 | 47 ++++ m4/libtool-link.m4 | 47 ++++ m4/pkgconfig.m4 | 13 + m4/static-lib.m4 | 19 ++ m4/threads.m4 | 61 +++++ odb/sqlite/Makefile.am | 16 ++ odb/sqlite/libodb-sqlite-vc10.vcxproj | 174 +++++++++++++ odb/sqlite/libodb-sqlite-vc10.vcxproj.filters | 19 ++ odb/sqlite/libodb-sqlite-vc9.vcproj | 359 ++++++++++++++++++++++++++ 19 files changed, 1277 insertions(+) create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100755 bootstrap create mode 100644 configure.ac create mode 100644 libodb-sqlite-vc10.sln create mode 100644 libodb-sqlite-vc9.sln create mode 100644 libodb-sqlite.pc.in create mode 100644 m4/acx-pthread.m4 create mode 100644 m4/disable-rpath.m4 create mode 100644 m4/libodb.m4 create mode 100644 m4/libsqlite.m4 create mode 100644 m4/libtool-link.m4 create mode 100644 m4/pkgconfig.m4 create mode 100644 m4/static-lib.m4 create mode 100644 m4/threads.m4 create mode 100644 odb/sqlite/Makefile.am create mode 100644 odb/sqlite/libodb-sqlite-vc10.vcxproj create mode 100644 odb/sqlite/libodb-sqlite-vc10.vcxproj.filters create mode 100644 odb/sqlite/libodb-sqlite-vc9.vcproj diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..031bf8b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,12 @@ +# file : Makefile.am +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +SUBDIRS = __path__(dirs) +dist_doc_DATA = __file__(docs) +EXTRA_DIST = __file__(extra_dist) +ACLOCAL_AMFLAGS = -I m4 + +pkgconfigdir = @pkgconfigdir@ +pkgconfig_DATA= libodb-sqlite.pc diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..777bd86 --- /dev/null +++ b/bootstrap @@ -0,0 +1,18 @@ +#! /bin/sh + +# file : bootstrap +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# +# Bootstrap the automake build system. +# + +rm -f config.cache + +if test ! -d m4; then + mkdir m4 +fi + +autoreconf --install diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..c99dab6 --- /dev/null +++ b/configure.ac @@ -0,0 +1,58 @@ +# file : configure.ac +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +AC_PREREQ(2.60) +AC_INIT([libodb-sqlite], [__value__(version)], [odb-users@codesynthesis.com]) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([odb/sqlite/version.hxx]) + +AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc subdir-objects dist-bzip2 dist-zip tar-ustar]) + +LT_INIT([win32-dll]) + +AC_CANONICAL_HOST + +# Check for C++ compiler and use it to compile the tests. +# +AC_PROG_CXX +AC_LANG(C++) + +# Create the libtool executable so that we can use it in further tests. +# +LT_OUTPUT + +# Check for threads. +# +THREADS + +# Check for libsqlite. +# +LIBSQLITE( + [], + [AC_MSG_ERROR([libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to specify its location])]) + +# Check for libodb. +# +LIBODB([],[AC_MSG_ERROR([libodb is not found; consider using --with-libodb=DIR])]) + +# Define LIBODB_SQLITE_STATIC_LIB if we are build static library on certain +# platforms. +# +STATIC_LIB([LIBODB_SQLITE_STATIC_LIB], [Static library interface.]) + +# Allow the user to specify the pkgconfig directory. +# +PKGCONFIG + +# Check if we should disable rpath. +# +DISABLE_RPATH + +# Output. +# +AC_CONFIG_HEADERS([odb/sqlite/config.h odb/sqlite/details/config.h]) +AC_CONFIG_FILES([__path__(config_files)]) +AC_OUTPUT diff --git a/libodb-sqlite-vc10.sln b/libodb-sqlite-vc10.sln new file mode 100644 index 0000000..cef2f8a --- /dev/null +++ b/libodb-sqlite-vc10.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc10.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libodb-sqlite-vc9.sln b/libodb-sqlite-vc9.sln new file mode 100644 index 0000000..15f4ac0 --- /dev/null +++ b/libodb-sqlite-vc9.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc9.vcproj", "{E4055842-E6F1-4305-9FD2-EF70A92290C9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.ActiveCfg = Debug|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.Build.0 = Debug|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.ActiveCfg = Debug|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.Build.0 = Debug|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.ActiveCfg = Release|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.Build.0 = Release|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.ActiveCfg = Release|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in new file mode 100644 index 0000000..0871c16 --- /dev/null +++ b/libodb-sqlite.pc.in @@ -0,0 +1,16 @@ +# file : libodb-sqlite.pc.in +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libodb-sqlite +Description: Object-relational mapping (ORM) system for C++, SQLite runtime library +URL: http://www.codesynthesis.com/products/odb/ +Version: @VERSION@ +Libs: -L${libdir} -lodb-sqlite +Cflags: -I${includedir} diff --git a/m4/acx-pthread.m4 b/m4/acx-pthread.m4 new file mode 100644 index 0000000..ffa3dfa --- /dev/null +++ b/m4/acx-pthread.m4 @@ -0,0 +1,257 @@ +dnl +dnl NOTE: This file was modified. See the comments starting with 'CS:' +dnl for more information. In particular, it was changed to use C++ +dnl instead of C. +dnl +dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl @summary figure out how to build C++ programs using POSIX threads +dnl +dnl This macro figures out how to build C++ programs using POSIX threads. +dnl It sets the PTHREAD_LIBS output variable to the threads library and +dnl linker flags, and the PTHREAD_CXXFLAGS output variable to any special +dnl C++ compiler flags that are needed. (The user can also force certain +dnl compiler flags/libs to be tested by setting these environment +dnl variables.) +dnl +dnl Also sets PTHREAD_CXX to any special C++ compiler that is needed for +dnl multi-threaded programs (defaults to the value of CXX otherwise). +dnl (This is necessary on AIX to use the special xlC_r compiler alias.) +dnl +dnl NOTE: You are assumed to not only compile your program with these +dnl flags, but also link it with them as well. e.g. you should link +dnl with $PTHREAD_CXX $CXXFLAGS $PTHREAD_CXXFLAGS $LDFLAGS ... $PTHREAD_LIBS +dnl $LIBS +dnl +dnl If you are only building threads programs, you may wish to use +dnl these variables in your default LIBS, CXXFLAGS, and CXX: +dnl +dnl LIBS="$PTHREAD_LIBS $LIBS" +dnl CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" +dnl CXX="$PTHREAD_CXX" +dnl +dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute +dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to +dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +dnl +dnl ACTION-IF-FOUND is a list of shell commands to run if a threads +dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to +dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the +dnl default action will define HAVE_PTHREAD. +dnl +dnl Please let the authors know if this macro fails on any platform, or +dnl if you have any other suggestions or comments. This macro was based +dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with +dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros +dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. +dnl We are also grateful for the helpful feedback of numerous users. +dnl +dnl @category InstalledPackages +dnl @author Steven G. Johnson +dnl @version 2006-05-29 +dnl @license GPLWithACException + +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG(C++) +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CXXFLAGS" != x; then + save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CXXFLAGS=$PTHREAD_CXXFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CXXFLAGS="" + fi + LIBS="$save_LIBS" + CXXFLAGS="$save_CXXFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +# CS: On GNU/Linux with gcc both -pthread and -lpthread are valid. +# However, libtool links libraries with -nostdlib which results in +# -pthread being stripped from the linker command line. To resolve +# this we move pthread from after -mthreads to after pthreads. +# +acx_pthread_flags="pthreads pthread none -Kthread -kthread lthread -pthread -pthreads -mthreads --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + # CS: Move -mt to the front of the list; Sun CC will use -mt, + # gcc will use -pthreads. + # + acx_pthread_flags="-mt -pthreads pthread -pthread $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CXXFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) + if test x"$acx_pthread_config" = xno; then continue; fi + PTHREAD_CXXFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CXXFLAGS="$CXXFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + # + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0);], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CXXFLAGS="$save_CXXFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CXXFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" + +dnl # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. +dnl AC_MSG_CHECKING([for joinable pthread attribute]) +dnl attr_name=unknown +dnl for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do +dnl AC_TRY_LINK([#include ], [int attr=$attr; return attr;], +dnl [attr_name=$attr; break]) +dnl done +dnl AC_MSG_RESULT($attr_name) +dnl if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then +dnl AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, +dnl [Define to necessary symbol if this constant +dnl uses a non-standard name on your system.]) +dnl fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CXXFLAGS="$flag $PTHREAD_CXXFLAGS" + fi + + LIBS="$save_LIBS" + CXXFLAGS="$save_CXXFLAGS" + +dnl # More AIX lossage: must compile with xlC_r +dnl if test x"$GXX" != xyes; then +dnl AC_CHECK_PROGS(PTHREAD_CXX, xlC_r, ${CXX}) +dnl else +dnl PTHREAD_CXX=$CXX +dnl fi + +else + PTHREAD_CXX="$CXX" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CXXFLAGS) +AC_SUBST(PTHREAD_CXX) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 new file mode 100644 index 0000000..376599e --- /dev/null +++ b/m4/disable-rpath.m4 @@ -0,0 +1,26 @@ +dnl file : m4/disable-rpath.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([DISABLE_RPATH],[ + +AC_MSG_CHECKING([whether to use rpath]) +AC_ARG_ENABLE( + [rpath], + [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])], + [libtool_rpath="$enable_rpath"], + [libtool_rpath="yes"]) +AC_MSG_RESULT($libtool_rpath) + +# Patch libtool to not use rpath if requested. +# +AC_CONFIG_COMMANDS( + [libtool-rpath-patch], + [if test "$libtool_use_rpath" = "no"; then + sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/' + mv libtool-2 libtool + chmod 755 libtool + fi], + [libtool_use_rpath=$libtool_rpath]) +])dnl diff --git a/m4/libodb.m4 b/m4/libodb.m4 new file mode 100644 index 0000000..fb11859 --- /dev/null +++ b/m4/libodb.m4 @@ -0,0 +1,83 @@ +dnl file : m4/libodb.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl +AC_DEFUN([LIBODB], [ +libodb_found=no + +AC_ARG_WITH( + [libodb], + [AC_HELP_STRING([--with-libodb=DIR],[location of libodb build directory])], + [libodb_dir=${withval}], + [libodb_dir=]) + +AC_MSG_CHECKING([for libodb]) + +# If libodb_dir was given, add the necessary preprocessor and linker flags. +# +if test x"$libodb_dir" != x; then + save_CPPFLAGS="$CPPFLAGS" + save_LDFLAGS="$LDFLAGS" + + AS_SET_CATFILE([abs_libodb_dir], [$ac_pwd], [$libodb_dir]) + + CPPFLAGS="$CPPFLAGS -I$abs_libodb_dir" + LDFLAGS="$LDFLAGS -L$abs_libodb_dir/odb" +fi + +save_LIBS="$LIBS" +LIBS="-lodb $LIBS" + +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#include + +void +f () +{ +} + +const char* +g () +{ + try + { + f (); + } + catch (const odb::exception& e) + { + return e.what (); + } + return 0; +} + +int +main () +{ + const char* m (g ()); + return m != 0; +} +]]), +[libodb_found=yes]) + +if test x"$libodb_found" = xno; then + LIBS="$save_LIBS" + + if test x"$libodb_dir" != x; then + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + fi +fi + +if test x"$libodb_found" = xyes; then + AC_MSG_RESULT([yes]) + $1 +else + AC_MSG_RESULT([no]) + $2 +fi +])dnl diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 new file mode 100644 index 0000000..2ad9eb1 --- /dev/null +++ b/m4/libsqlite.m4 @@ -0,0 +1,47 @@ +dnl file : m4/libsqlite.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) +dnl +dnl +AC_DEFUN([LIBSQLITE], [ +libsqlite_found=no + +AC_MSG_CHECKING([for libsqlite3]) + +save_LIBS="$LIBS" +LIBS="-lsqlite3 $LIBS" + +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#include + +int +main () +{ + sqlite3* handle; + sqlite3_open_v2 ("", &handle, 0, 0); + sqlite3_stmt* stmt; + sqlite3_prepare_v2 (handle, "", 0, &stmt, 0); + sqlite3_finalize (stmt); + sqlite3_close (handle); +} +]]), +[ +libsqlite_found=yes +]) + +if test x"$libsqlite_found" = xno; then + LIBS="$save_LIBS" +fi + +if test x"$libsqlite_found" = xyes; then + AC_MSG_RESULT([yes]) + $1 +else + AC_MSG_RESULT([no]) + $2 +fi +])dnl diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 new file mode 100644 index 0000000..d8395d5 --- /dev/null +++ b/m4/libtool-link.m4 @@ -0,0 +1,47 @@ +dnl file : m4/libtool-link.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl +dnl CXX_LIBTOOL_LINK_IFELSE (input, [action-if-true], [action-if-false]) +dnl +dnl Similar to AC_LINK_IFELSE except it uses libtool to perform the +dnl linking and it does this using the C++ compiler. +dnl +AC_DEFUN([CXX_LIBTOOL_LINK_IFELSE],[ +AC_LANG_SAVE +AC_LANG(C++) + +if test -d .libs; then + delete_libs_dir=no +else + delete_libs_dir=yes +fi + +AC_COMPILE_IFELSE([$1], +[ + ac_try='./libtool --tag=CXX --mode=link $CXX -no-install $CXXFLAGS $LDFLAGS -o conftest conftest.$OBJEXT $LIBS >&AS_MESSAGE_LOG_FD' + if _AC_DO_VAR(ac_try); then + libtool_link_ok=yes + else + libtool_link_ok=no + fi +], +[ + libtool_link_ok=no +]) + +if test x"$delete_libs_dir" = xyes; then + rm -rf .libs +fi + +if test x"$libtool_link_ok" = xyes; then +[$2] +: +else +[$3] +: +fi + +AC_LANG_RESTORE])dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 new file mode 100644 index 0000000..11ccb00 --- /dev/null +++ b/m4/pkgconfig.m4 @@ -0,0 +1,13 @@ +dnl file : m4/pkgconfig.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([PKGCONFIG],[ +AC_ARG_WITH( + [pkgconfigdir], + [AC_HELP_STRING([--with-pkgconfigdir=DIR],[location of pkgconfig dir (default is libdir/pkgconfig)])], + [pkgconfigdir=${withval}], + [pkgconfigdir='${libdir}/pkgconfig']) +AC_SUBST([pkgconfigdir]) +])dnl diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 new file mode 100644 index 0000000..f550b7b --- /dev/null +++ b/m4/static-lib.m4 @@ -0,0 +1,19 @@ +dnl file : m4/static-lib.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl STATIC_LIB(MACRO, DESCRIPTION) +dnl +dnl Define MACRO if we are on MinGW and are only building static library. +dnl +AC_DEFUN([STATIC_LIB], +[ +if test x$enable_shared = xno; then + case $host_os in + mingw*) + AC_DEFINE([$1], [1], [$2]) + ;; + esac +fi +])dnl diff --git a/m4/threads.m4 b/m4/threads.m4 new file mode 100644 index 0000000..d4ed7cd --- /dev/null +++ b/m4/threads.m4 @@ -0,0 +1,61 @@ +dnl file : m4/threads.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([THREADS],[ + +threads_thread_keyword=no + +AC_ARG_ENABLE( + [threads], + AS_HELP_STRING([--disable-threads], [disable threads (enabled by default)]), + [AS_IF([test x"$enableval" = xno], [threads=none], [threads=check])], + [threads=check]) + +# If thread support is not disabled by the user, figure out what we can use. +# +if test x$threads = xcheck; then + case $host_os in + windows* | mingw*) + case $host_os in + mingw*) + CXXFLAGS="$CXXFLAGS -mthreads" + ;; + esac + threads=win32 + ;; + *) + ACX_PTHREAD + + if test x$acx_pthread_ok = xyes; then + threads=posix + LIBS="$LIBS $PTHREAD_LIBS" + CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" + + # Check if we can use the __thread keyword. + # + AC_MSG_CHECKING([for __thread keyword]) + + CXX_LIBTOOL_LINK_IFELSE( + AC_LANG_SOURCE([[ + __thread int tls_var; + + int + main () + { + tls_var = 0; + } + ]]), + [threads_thread_keyword=yes]) + + AC_MSG_RESULT([$threads_thread_keyword]) + fi + ;; + esac +fi + +if test x$threads = xcheck; then + AC_MSG_ERROR([thread support not available; use --disable-threads to force single-threaded mode]) +fi +])dnl diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am new file mode 100644 index 0000000..238583d --- /dev/null +++ b/odb/sqlite/Makefile.am @@ -0,0 +1,16 @@ +# file : odb/sqlite/Makefile.am +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +lib_LTLIBRARIES = libodb-sqlite.la +libodb_sqlite_la_SOURCES = __path__(sources) + +odbsqliteincludedir = $(includedir)/odb/sqlite/ +nobase_odbsqliteinclude_HEADERS = __path__(headers) +nobase_nodist_odbsqliteinclude_HEADERS = details/config.h + +EXTRA_DIST = __file__(extra_dist) + +AM_CPPFLAGS= -I'$(top_builddir)' -I'$(top_srcdir)' -DLIBODB_SQLITE_DYNAMIC_LIB +AM_LDFLAGS = -release __value__(interface_version) -no-undefined diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj b/odb/sqlite/libodb-sqlite-vc10.vcxproj new file mode 100644 index 0000000..db13085 --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc10.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} + Win32Proj + libodb-sqlite + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + ..\..\bin\ + odb-sqlite-d-__value__(interface_version)-vc10 + + + true + ..\..\bin64\ + odb-sqlite-d-__value__(interface_version)-vc10 + + + false + ..\..\bin\ + odb-sqlite-__value__(interface_version)-vc10 + + + false + ..\..\bin64\ + odb-sqlite-__value__(interface_version)-vc10 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb-d.lib;sqlite.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib\odb-sqlite-d.lib + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb-d.lib;sqlite.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib64\odb-sqlite-d.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb.lib;sqlite.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib\odb-sqlite.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb.lib;sqlite.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib64\odb-sqlite.lib + + + +__header_entries__(headers) + + +__source_entries__(sources) + + + + + diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters new file mode 100644 index 0000000..6a1e44f --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} + cxx + + + {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} + h;hxx;ixx;txx + + + +__header_filter_entries__(headers) + + +__source_filter_entries__(sources) + + diff --git a/odb/sqlite/libodb-sqlite-vc9.vcproj b/odb/sqlite/libodb-sqlite-vc9.vcproj new file mode 100644 index 0000000..dba87d8 --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc9.vcproj @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entries__(sources) + + +__file_entries__(headers) + + + + + -- cgit v1.1 From 3af997a875e439e71754fddb67fd60de9f60307b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 21 Mar 2011 08:27:01 +0200 Subject: Use shorter option names --- odb/sqlite/details/options.cli | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index a0af101..4105557 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -22,13 +22,13 @@ namespace odb in-memory database." }; - bool --database-create + bool --create { "Create the SQLite database if it does not already exist. By default opening the database fails if it does not already exist." }; - bool --database-readonly + bool --read-only { "Open the SQLite database in read-only mode. By default the database is opened for reading and writing if possible, or reading only if -- cgit v1.1 From dac72baef46897b80fc98632cef182fb266a5d60 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 21 Mar 2011 17:24:35 +0200 Subject: Add base SQLite database classes --- odb/sqlite/connection-factory.cxx | 161 ++++++++++++++++++++++++++++++++++++++ odb/sqlite/connection-factory.hxx | 157 +++++++++++++++++++++++++++++++++++++ odb/sqlite/connection.cxx | 59 ++++++++++++++ odb/sqlite/connection.hxx | 73 +++++++++++++++++ odb/sqlite/database.cxx | 103 ++++++++++++++++++++++++ odb/sqlite/database.hxx | 108 +++++++++++++++++++++++++ odb/sqlite/database.ixx | 16 ++++ odb/sqlite/error.cxx | 61 +++++++++++++++ odb/sqlite/error.hxx | 29 +++++++ odb/sqlite/exceptions.cxx | 56 +++++++++++++ odb/sqlite/exceptions.hxx | 73 +++++++++++++++++ odb/sqlite/makefile | 11 ++- odb/sqlite/statement-cache.cxx | 26 ++++++ odb/sqlite/statement-cache.hxx | 96 +++++++++++++++++++++++ odb/sqlite/statement.cxx | 99 +++++++++++++++++++++++ odb/sqlite/statement.hxx | 66 ++++++++++++++++ odb/sqlite/transaction-impl.cxx | 48 ++++++++++++ odb/sqlite/transaction-impl.hxx | 55 +++++++++++++ odb/sqlite/transaction-impl.ixx | 16 ++++ odb/sqlite/transaction.cxx | 26 ++++++ odb/sqlite/transaction.hxx | 59 ++++++++++++++ odb/sqlite/transaction.ixx | 41 ++++++++++ odb/sqlite/version.hxx | 6 +- 23 files changed, 1441 insertions(+), 4 deletions(-) create mode 100644 odb/sqlite/connection-factory.cxx create mode 100644 odb/sqlite/connection-factory.hxx create mode 100644 odb/sqlite/connection.cxx create mode 100644 odb/sqlite/connection.hxx create mode 100644 odb/sqlite/database.cxx create mode 100644 odb/sqlite/database.hxx create mode 100644 odb/sqlite/database.ixx create mode 100644 odb/sqlite/error.cxx create mode 100644 odb/sqlite/error.hxx create mode 100644 odb/sqlite/exceptions.cxx create mode 100644 odb/sqlite/exceptions.hxx create mode 100644 odb/sqlite/statement-cache.cxx create mode 100644 odb/sqlite/statement-cache.hxx create mode 100644 odb/sqlite/statement.cxx create mode 100644 odb/sqlite/statement.hxx create mode 100644 odb/sqlite/transaction-impl.cxx create mode 100644 odb/sqlite/transaction-impl.hxx create mode 100644 odb/sqlite/transaction-impl.ixx create mode 100644 odb/sqlite/transaction.cxx create mode 100644 odb/sqlite/transaction.hxx create mode 100644 odb/sqlite/transaction.ixx diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx new file mode 100644 index 0000000..4cae67f --- /dev/null +++ b/odb/sqlite/connection-factory.cxx @@ -0,0 +1,161 @@ +// file : odb/sqlite/connection-factory.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include + +using namespace std; + +namespace odb +{ + using namespace details; + + namespace sqlite + { + // + // connection_factory + // + + connection_factory:: + ~connection_factory () + { + } + + // + // new_connection_factory + // + + shared_ptr new_connection_factory:: + connect () + { + return shared_ptr (new (shared) connection (*db_)); + } + + void new_connection_factory:: + database (database_type& db) + { + db_ = &db; + } + + // + // connection_pool_factory + // + + connection_pool_factory:: + ~connection_pool_factory () + { + // Wait for all the connections currently in use to return to the pool. + // + lock l (mutex_); + while (in_use_ != 0) + { + waiters_++; + cond_.wait (); + waiters_--; + } + } + + shared_ptr connection_pool_factory:: + connect () + { + lock l (mutex_); + + while (true) + { + // See if we have a spare connection. + // + if (connections_.size () != 0) + { + shared_ptr c (connections_.back ()); + connections_.pop_back (); + + c->pool_ = this; + in_use_++; + return c; + } + + // See if we can create a new one. + // + if(max_ == 0 || in_use_ < max_) + { + shared_ptr c ( + new (shared) pooled_connection (*db_, this)); + in_use_++; + return c; + } + + // Wait until someone releases a connection. + // + waiters_++; + cond_.wait (); + waiters_--; + } + } + + void connection_pool_factory:: + database (database_type& db) + { + db_ = &db; + + if (min_ > 0) + { + connections_.reserve (min_); + + for(size_t i (0); i < min_; ++i) + { + connections_.push_back ( + shared_ptr ( + new (shared) pooled_connection (*db_, 0))); + } + } + } + + bool connection_pool_factory:: + release (pooled_connection* c) + { + c->pool_ = 0; + + lock l (mutex_); + + // Determine if we need to keep or free this connection. + // + bool keep (waiters_ != 0 || + min_ == 0 || + (connections_.size () + in_use_ <= min_)); + + in_use_--; + + if (keep) + connections_.push_back ( + shared_ptr (inc_ref (c))); + + if (waiters_ != 0) + cond_.signal (); + + return !keep; + } + + // + // connection_pool_factory::pooled_connection + // + + connection_pool_factory::pooled_connection:: + pooled_connection (database_type& db, connection_pool_factory* pool) + : connection (db), pool_ (pool) + { + callback_.arg = this; + callback_.zero_counter = &zero_counter; + shared_base::callback_ = &callback_; + } + + bool connection_pool_factory::pooled_connection:: + zero_counter (void* arg) + { + pooled_connection* c (static_cast (arg)); + return c->pool_ ? c->pool_->release (c) : true; + } + } +} diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx new file mode 100644 index 0000000..6a42c8f --- /dev/null +++ b/odb/sqlite/connection-factory.hxx @@ -0,0 +1,157 @@ +// file : odb/sqlite/connection-factory.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX +#define ODB_SQLITE_CONNECTION_FACTORY_HXX + +#include + +#include +#include // std::size_t + +#include +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT connection_factory + { + public: + virtual details::shared_ptr + connect () = 0; + + public: + typedef sqlite::database database_type; + + virtual void + database (database_type&) = 0; + + virtual + ~connection_factory (); + }; + + class LIBODB_SQLITE_EXPORT new_connection_factory: + public connection_factory + { + public: + new_connection_factory () + : db_ (0) + { + } + + virtual details::shared_ptr + connect (); + + virtual void + database (database_type&); + + private: + new_connection_factory (const new_connection_factory&); + new_connection_factory& operator= (const new_connection_factory&); + + private: + database_type* db_; + }; + + class LIBODB_SQLITE_EXPORT connection_pool_factory: + public connection_factory + { + public: + // The max_connections argument specifies the maximum number of + // concurrent connections this pool will maintain. If this value + // is 0 then the pool will create a new connection every time all + // of the existing connections are in use. + // + // The min_connections argument specifies the minimum number of + // connections that should be maintained by the pool. If the + // number of connections maintained by the pool exceeds this + // number and there are no active waiters for a new connection, + // then the pool will release the excess connections. If this + // value is 0 then the pool will maintain all the connections + // that were ever created. + // + // The ping argument specifies whether to ping the connection to + // make sure it is still alive before returning it to the caller. + // + connection_pool_factory (std::size_t max_connections = 0, + std::size_t min_connections = 0) + : max_ (max_connections), + min_ (min_connections), + in_use_ (0), + waiters_ (0), + db_ (0), + cond_ (mutex_) + { + // @@ check min_ <= max_ + } + + virtual details::shared_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~connection_pool_factory (); + + private: + connection_pool_factory (const connection_pool_factory&); + connection_pool_factory& operator= (const connection_pool_factory&); + + private: + class pooled_connection: public connection + { + public: + // NULL pool value indicates that the connection is not in use. + // + pooled_connection (database_type&, connection_pool_factory*); + + private: + static bool + zero_counter (void*); + + private: + friend class connection_pool_factory; + + shared_base::refcount_callback callback_; + connection_pool_factory* pool_; + }; + + friend class pooled_connection; + typedef std::vector > connections; + + private: + // Return true if the connection should be deleted, false otherwise. + // + bool + release (pooled_connection*); + + private: + const std::size_t max_; + const std::size_t min_; + + std::size_t in_use_; // Number of connections currently in use. + std::size_t waiters_; // Number of threads waiting for a connection. + + database_type* db_; + connections connections_; + + details::mutex mutex_; + details::condition cond_; + }; + } +} + +#include + +#endif // ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx new file mode 100644 index 0000000..37f5e20 --- /dev/null +++ b/odb/sqlite/connection.cxx @@ -0,0 +1,59 @@ +// file : odb/sqlite/connection.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::bad_alloc +#include +#include + +#include +#include +#include +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + connection:: + connection (database_type& db) + : db_ (db) + { + int f (db.flags ()); + const string& n (db.name ()); + + // If we are opening a temporary database, then add the create flag. + // + if (n.empty () || n == ":memory:") + f |= SQLITE_OPEN_CREATE; + + // A connection can only be used by a single thread at a time. So + // disable locking in SQLite unless explicitly requested. + // + if ((f & SQLITE_OPEN_FULLMUTEX) == 0) + f |= SQLITE_OPEN_NOMUTEX; + + if (int e = sqlite3_open_v2 (n.c_str (), &handle_, f, 0)) + { + if (handle_ == 0) + throw bad_alloc (); + + translate_error (e, *this); + } + + statement_cache_.reset (new statement_cache_type (*this)); + } + + connection:: + ~connection () + { + statement_cache_.reset (); // Free prepared statements. + + if (sqlite3_close (handle_) == SQLITE_BUSY) + assert (false); // Connection has outstanding prepared statements. + } + } +} diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx new file mode 100644 index 0000000..0df08b3 --- /dev/null +++ b/odb/sqlite/connection.hxx @@ -0,0 +1,73 @@ +// file : odb/sqlite/connection.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONNECTION_HXX +#define ODB_SQLITE_CONNECTION_HXX + +#include + +#include + +#include // std::auto_ptr + +#include +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class statement_cache; + + class LIBODB_SQLITE_EXPORT connection: public details::shared_base + { + public: + typedef sqlite::statement_cache statement_cache_type; + typedef sqlite::database database_type; + + virtual + ~connection (); + + connection (database_type&); + + database_type& + database () + { + return db_; + } + + public: + sqlite3* + handle () + { + return handle_; + } + + statement_cache_type& + statement_cache () + { + return *statement_cache_; + } + + private: + connection (const connection&); + connection& operator= (const connection&); + + private: + database_type& db_; + sqlite3* handle_; + + std::auto_ptr statement_cache_; + }; + } +} + +#include + +#endif // ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx new file mode 100644 index 0000000..176c392 --- /dev/null +++ b/odb/sqlite/database.cxx @@ -0,0 +1,103 @@ +// file : odb/sqlite/database.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + database:: + ~database () + { + } + + database:: + database (const string& name, + int flags, + auto_ptr factory) + : name_ (name), flags_ (flags), factory_ (factory) + { + if (factory_.get () == 0) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } + + database:: + database (int& argc, + char* argv[], + bool erase, + int flags, + std::auto_ptr factory) + : flags_ (flags), factory_ (factory) + { + using namespace details; + + try + { + cli::argv_file_scanner scan (argc, argv, "--options-file", erase); + options ops (scan, cli::unknown_mode::skip, cli::unknown_mode::skip); + + name_ = ops.database (); + + if (ops.create ()) + flags_ |= SQLITE_OPEN_CREATE; + + if (ops.read_only ()) + flags_ = (flags_ & ~SQLITE_OPEN_READWRITE) | SQLITE_OPEN_READONLY; + } + catch (const cli::exception& e) + { + ostringstream ostr; + ostr << e; + throw cli_exception (ostr.str ()); + } + + if (factory_.get () == 0) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } + + void database:: + print_usage (std::ostream& os) + { + details::options::print_usage (os); + } + + unsigned long long database:: + execute (const char* s, std::size_t n) + { + if (!transaction::has_current ()) + throw not_in_transaction (); + + connection_type& c (transaction::current ().connection ()); + simple_statement st (c, s, n); + return st.execute (); + } + + transaction_impl* database:: + begin () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl (*this); + } + } +} diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx new file mode 100644 index 0000000..121f85c --- /dev/null +++ b/odb/sqlite/database.hxx @@ -0,0 +1,108 @@ +// file : odb/sqlite/database.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DATABASE_HXX +#define ODB_SQLITE_DATABASE_HXX + +#include + +#include + +#include +#include // std::auto_ptr +#include // std::ostream + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT database: public odb::database + { + public: + typedef sqlite::connection connection_type; + + public: + database (const std::string& name, + int flags = SQLITE_OPEN_READWRITE, + std::auto_ptr = + std::auto_ptr (0)); + + // Extract the database parameters from the command line. The + // following options are recognized: + // + // --database + // --create + // --read-only + // --options-file + // + // For more information, see the output of the print_usage() function + // below. If erase is true, the above options are removed from the argv + // array and the argc count is updated accordingly. The command line + // options override the flags passed as an argument. This constructor + // may throw the cli_exception exception. + // + database (int& argc, + char* argv[], + bool erase = false, + int flags = SQLITE_OPEN_READWRITE, + std::auto_ptr = + std::auto_ptr (0)); + + static void + print_usage (std::ostream&); + + + public: + const std::string& + name () const + { + return name_; + } + + int + flags () const + { + return flags_; + } + + public: + virtual unsigned long long + execute (const char* statement, std::size_t length); + + public: + virtual transaction_impl* + begin (); + + public: + details::shared_ptr + connection (); + + public: + virtual + ~database (); + + private: + std::string name_; + int flags_; + std::auto_ptr factory_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx new file mode 100644 index 0000000..7e34e01 --- /dev/null +++ b/odb/sqlite/database.ixx @@ -0,0 +1,16 @@ +// file : odb/sqlite/database.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + inline details::shared_ptr database:: + connection () + { + return factory_->connect (); + } + } +} diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx new file mode 100644 index 0000000..d34f55b --- /dev/null +++ b/odb/sqlite/error.cxx @@ -0,0 +1,61 @@ +// file : odb/sqlite/errors.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include // std::bad_alloc +#include + +#include +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + void + translate_error (int e, connection& c) + { + sqlite3* h (c.handle ()); + int ee (sqlite3_extended_errcode (h)); + string m; + + switch (e) + { + case SQLITE_NOMEM: + { + throw bad_alloc (); + } + case SQLITE_MISUSE: + { + // In case of SQLITE_MISUSE, error code/message may or may not + // be set. + // + ee = e; + m = "SQLite API misuse"; + break; + } + case SQLITE_BUSY: + case SQLITE_LOCKED: + case SQLITE_IOERR: + { + if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) + throw deadlock (); + + // Fall throught. + } + default: + { + m = sqlite3_errmsg (h); + break; + } + } + + throw database_exception (e, ee, m); + } + } +} diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx new file mode 100644 index 0000000..c897988 --- /dev/null +++ b/odb/sqlite/error.hxx @@ -0,0 +1,29 @@ +// file : odb/sqlite/errors.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_ERRORS_HXX +#define ODB_SQLITE_ERRORS_HXX + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Translate SQLite error and throw an appropriate exception. + // + LIBODB_SQLITE_EXPORT void + translate_error (int error, connection&); + } +} + +#include + +#endif // ODB_SQLITE_ERRORS_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx new file mode 100644 index 0000000..6801665 --- /dev/null +++ b/odb/sqlite/exceptions.cxx @@ -0,0 +1,56 @@ +// file : odb/sqlite/exceptions.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + // + // database_exception + // + + database_exception:: + ~database_exception () throw () + { + } + + database_exception:: + database_exception (int e, int ee, const string& m) + : error_ (e), extended_error_ (ee), message_ (m) + { + } + + const char* database_exception:: + what () const throw () + { + return message_.c_str (); + } + + // + // cli_exception + // + + cli_exception:: + cli_exception (const std::string& what) + : what_ (what) + { + } + + cli_exception:: + ~cli_exception () throw () + { + } + + const char* cli_exception:: + what () const throw () + { + return what_.c_str (); + } + } +} diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx new file mode 100644 index 0000000..5e783a5 --- /dev/null +++ b/odb/sqlite/exceptions.hxx @@ -0,0 +1,73 @@ +// file : odb/sqlite/exceptions.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_EXCEPTIONS_HXX +#define ODB_SQLITE_EXCEPTIONS_HXX + +#include + +#include + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception + { + database_exception (int error, + int extended_error, + const std::string& message); + + ~database_exception () throw (); + + int + error () const + { + return error_; + } + + int + extended_error () const + { + return extended_error_; + } + + const std::string& + message () const + { + return message_; + } + + virtual const char* + what () const throw (); + + private: + int error_; + int extended_error_; + std::string message_; + }; + + struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception + { + cli_exception (const std::string& what); + ~cli_exception () throw (); + + virtual const char* + what () const throw (); + + private: + std::string what_; + }; + } +} + +#include + +#endif // ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 6b8c4a2..4f34741 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -5,7 +5,16 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make -cxx := \ +cxx := \ +connection.cxx \ +connection-factory.cxx \ +database.cxx \ +error.cxx \ +exceptions.cxx \ +statement-cache.cxx \ +statement.cxx \ +transaction.cxx \ +transaction-impl.cxx cli_tun := details/options.cli cxx_tun := $(cxx) diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx new file mode 100644 index 0000000..66ef266 --- /dev/null +++ b/odb/sqlite/statement-cache.cxx @@ -0,0 +1,26 @@ +// file : odb/sqlite/statement-cache.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + using namespace details; + + namespace sqlite + { + statement_cache:: + statement_cache (connection& conn) + : conn_ (conn), + // String lengths below include '\0', as per SQLite manual + // suggestions. + // + begin_ (new (shared) simple_statement (conn, "BEGIN", 6)), + commit_ (new (shared) simple_statement (conn, "COMMIT", 7)), + rollback_ (new (shared) simple_statement (conn, "ROLLBACK", 9)) + { + } + } +} diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx new file mode 100644 index 0000000..9ef446d --- /dev/null +++ b/odb/sqlite/statement-cache.hxx @@ -0,0 +1,96 @@ +// file : odb/sqlite/statement-cache.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENT_CACHE_HXX +#define ODB_SQLITE_STATEMENT_CACHE_HXX + +#include + +#include +#include + +#include +#include +#include + +#include +#include +/* +#include +*/ + +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + class LIBODB_SQLITE_EXPORT statement_cache + { + public: + statement_cache (connection&); + + simple_statement& + begin_statement () const + { + return *begin_; + } + + simple_statement& + commit_statement () const + { + return *commit_; + } + + simple_statement& + rollback_statement () const + { + return *rollback_; + } + +/* + @@ + template + object_statements& + find () + { + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast&> (*i->second); + + details::shared_ptr > p ( + new (details::shared) object_statements (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } +*/ + + private: + /* + typedef std::map, + details::type_info_comparator> map; + */ + + connection& conn_; + + details::shared_ptr begin_; + details::shared_ptr commit_; + details::shared_ptr rollback_; + + /* + map map_; + */ + }; + } +} + +#include + +#endif // ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx new file mode 100644 index 0000000..e7d197b --- /dev/null +++ b/odb/sqlite/statement.cxx @@ -0,0 +1,99 @@ +// file : odb/sqlite/statement.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + // statement + // + + statement:: + statement (connection& conn, const string& s) + : conn_ (conn) + { + if (int e = sqlite3_prepare_v2 ( + conn_.handle (), + s.c_str (), + static_cast (s.size () + 1), + &stmt_, + 0)) + { + translate_error (e, conn_); + } + } + + statement:: + statement (connection& conn, const char* s, std::size_t n) + : conn_ (conn) + { + if (int e = sqlite3_prepare_v2 ( + conn_.handle (), + s, + static_cast (n), + &stmt_, + 0)) + { + translate_error (e, conn_); + } + } + + + + statement:: + ~statement () + { + sqlite3_finalize (stmt_); + } + + // simple_statement + // + + simple_statement:: + simple_statement (connection& conn, const string& s) + : statement (conn, s), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + simple_statement:: + simple_statement (connection& conn, const char* s, std::size_t n) + : statement (conn, s, n), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + unsigned long long simple_statement:: + execute () + { + if (stmt_ == 0) // Empty statement or comment. + return 0; + + if (int e = sqlite3_reset (stmt_)) + translate_error (e, conn_); + + unsigned long long r (0); + + int e; + for (e = sqlite3_step (stmt_); e == SQLITE_ROW; e = sqlite3_step (stmt_)) + r++; + + if (e != SQLITE_DONE) + translate_error (e, conn_); + + if (!result_set_) + r = static_cast ( + sqlite3_changes (conn_.handle ())); + + return r; + } + } +} diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx new file mode 100644 index 0000000..3c5ea1c --- /dev/null +++ b/odb/sqlite/statement.hxx @@ -0,0 +1,66 @@ +// file : odb/sqlite/statement.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENT_HXX +#define ODB_SQLITE_STATEMENT_HXX + +#include + +#include + +#include +#include // std::size_t + +#include +#include + +#include +//@@ #include + +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + class LIBODB_SQLITE_EXPORT statement: public details::shared_base + { + public: + virtual + ~statement () = 0; + + protected: + statement (connection&, const std::string& statement); + statement (connection&, const char* statement, std::size_t n); + + protected: + connection& conn_; + sqlite3_stmt* stmt_; + }; + + class LIBODB_SQLITE_EXPORT simple_statement: public statement + { + public: + simple_statement (connection&, const std::string& statement); + simple_statement (connection&, const char* statement, std::size_t n); + + unsigned long long + execute (); + + private: + simple_statement (const simple_statement&); + simple_statement& operator= (const simple_statement&); + + private: + bool result_set_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx new file mode 100644 index 0000000..3730100 --- /dev/null +++ b/odb/sqlite/transaction-impl.cxx @@ -0,0 +1,48 @@ +// file : odb/sqlite/transaction-impl.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + transaction_impl:: + transaction_impl (database_type& db) + : odb::transaction_impl (db), connection_ (db.connection ()) + { + connection_->statement_cache ().begin_statement ().execute (); + } + + transaction_impl:: + ~transaction_impl () + { + } + + void transaction_impl:: + commit () + { + connection_->statement_cache ().commit_statement ().execute (); + + // Release the connection. + // + //connection_.reset (); + } + + void transaction_impl:: + rollback () + { + connection_->statement_cache ().rollback_statement ().execute (); + + // Release the connection. + // + //connection_.reset (); + } + } +} diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx new file mode 100644 index 0000000..cc38039 --- /dev/null +++ b/odb/sqlite/transaction-impl.hxx @@ -0,0 +1,55 @@ +// file : odb/sqlite/transaction-impl.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX +#define ODB_SQLITE_TRANSACTION_IMPL_HXX + +#include + +#include +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT transaction_impl: public odb::transaction_impl + { + protected: + friend class database; + friend class transaction; + + typedef sqlite::database database_type; + typedef sqlite::connection connection_type; + + transaction_impl (database_type&); + + virtual + ~transaction_impl (); + + virtual void + commit (); + + virtual void + rollback (); + + connection_type& + connection (); + + private: + details::shared_ptr connection_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx new file mode 100644 index 0000000..f31f0ab --- /dev/null +++ b/odb/sqlite/transaction-impl.ixx @@ -0,0 +1,16 @@ +// file : odb/sqlite/transaction-impl.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + inline transaction_impl::connection_type& transaction_impl:: + connection () + { + return *connection_; + } + } +} diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx new file mode 100644 index 0000000..6690d92 --- /dev/null +++ b/odb/sqlite/transaction.cxx @@ -0,0 +1,26 @@ +// file : odb/sqlite/transaction.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + transaction& transaction:: + current () + { + // While the impl type can be of the concrete type, the transaction + // object can be created as either odb:: or odb::sqlite:: type. To + // work around that we are going to hard-cast one two the other + // relying on the fact that they have the same representation and + // no virtual functions. The former is checked in the tests. + // + odb::transaction& b (odb::transaction::current ()); + dynamic_cast (b.implementation ()); + return reinterpret_cast (b); + } + } +} diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx new file mode 100644 index 0000000..aecf8aa --- /dev/null +++ b/odb/sqlite/transaction.hxx @@ -0,0 +1,59 @@ +// file : odb/sqlite/transaction.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRANSACTION_HXX +#define ODB_SQLITE_TRANSACTION_HXX + +#include + +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class transaction_impl; + + class LIBODB_SQLITE_EXPORT transaction: public odb::transaction + { + public: + typedef sqlite::database database_type; + typedef sqlite::connection connection_type; + + explicit + transaction (transaction_impl*); + + // Return the database this transaction is on. + // + database_type& + database (); + + // Return the underlying database connection for this transaction. + // + connection_type& + connection (); + + // Return current transaction or throw if there is no transaction + // in effect. + // + static transaction& + current (); + + public: + transaction_impl& + implementation (); + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx new file mode 100644 index 0000000..f2c9cc8 --- /dev/null +++ b/odb/sqlite/transaction.ixx @@ -0,0 +1,41 @@ +// file : odb/sqlite/transaction.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include + +namespace odb +{ + namespace sqlite + { + inline transaction:: + transaction (transaction_impl* impl) + : odb::transaction (impl) + { + } + + inline transaction_impl& transaction:: + implementation () + { + // We can use static_cast here since we have an instance of + // sqlite::transaction. + // + return static_cast ( + odb::transaction::implementation ()); + } + + inline transaction::database_type& transaction:: + database () + { + return static_cast (odb::transaction::database ()); + } + + inline transaction::connection_type& transaction:: + connection () + { + return implementation ().connection (); + } + } +} diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 4759d6d..c308e82 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10100 +#if ODB_VERSION != 10200 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1010000 -#define LIBODB_SQLITE_VERSION_STR "1.1.0" +#define LIBODB_SQLITE_VERSION 1020000 +#define LIBODB_SQLITE_VERSION_STR "1.2.0" #include -- cgit v1.1 From 28207bef7103251b7df1ee24b19d323c17444acd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2011 09:50:04 +0200 Subject: Throw timeout instead of deadlock for SQLITE_{BUSY,LOCKED} --- odb/sqlite/error.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index d34f55b..d223b4e 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -44,7 +44,7 @@ namespace odb case SQLITE_IOERR: { if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) - throw deadlock (); + throw timeout (); // Fall throught. } -- cgit v1.1 From 4a4762c4b8e945dd617034a40f6633e0c9f364c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2011 15:47:09 +0200 Subject: Add types for param/result binding --- odb/sqlite/binding.hxx | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 odb/sqlite/binding.hxx diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx new file mode 100644 index 0000000..70edd28 --- /dev/null +++ b/odb/sqlite/binding.hxx @@ -0,0 +1,65 @@ +// file : odb/sqlite/binding.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BINDING_HXX +#define ODB_SQLITE_BINDING_HXX + +#include + +#include // std::size_t + +#include + +#include + +namespace odb +{ + namespace sqlite + { + // The SQLite parameter/result binding. This data structures is + // modelled after MYSQL_BIND from MySQL. + // + struct bind + { + enum buffer_type + { + integer, // Buffer is long long; size, capacity, truncated are unused. + real, // Buffer is double; size, capacity, truncated are unused. + text, // Buffer is a char array. + blob // Buffer is a char array. + }; + + buffer_type type; + void* buffer; + std::size_t* size; + std::size_t capacity; + bool* is_null; + bool* truncated; + }; + + class LIBODB_SQLITE_EXPORT binding + { + public: + typedef sqlite::bind bind_type; + + binding (bind_type* b, std::size_t n) + : bind (b), count (n), version (0) + { + } + + bind_type* bind; + std::size_t count; + std::size_t version; + + private: + binding (const binding&); + binding& operator= (const binding&); + }; + } +} + +#include + +#endif // ODB_SQLITE_BINDING_HXX -- cgit v1.1 From b1a6710e7d396538617550f1d00b4db2575485c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2011 15:48:14 +0200 Subject: Implement built-in value traits for SQLite --- odb/sqlite/makefile | 1 + odb/sqlite/traits.cxx | 54 ++++++++++++ odb/sqlite/traits.hxx | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 odb/sqlite/traits.cxx create mode 100644 odb/sqlite/traits.hxx diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 4f34741..f46587f 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -13,6 +13,7 @@ error.cxx \ exceptions.cxx \ statement-cache.cxx \ statement.cxx \ +traits.cxx \ transaction.cxx \ transaction-impl.cxx diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx new file mode 100644 index 0000000..de6c792 --- /dev/null +++ b/odb/sqlite/traits.cxx @@ -0,0 +1,54 @@ +// file : odb/sqlite/traits.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memcpy, std::strlen + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + using details::buffer; + + // default_value_traits + // + void default_value_traits:: + set_image (buffer& b, + size_t& n, + bool& is_null, + const string& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v.c_str (), n); + } + + // default_value_traits + // + void default_value_traits:: + set_image (buffer& b, + size_t& n, + bool& is_null, + const char* v) + { + is_null = false; + n = strlen (v); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } + } +} diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx new file mode 100644 index 0000000..e5ef318 --- /dev/null +++ b/odb/sqlite/traits.hxx @@ -0,0 +1,230 @@ +// file : odb/sqlite/traits.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRAITS_HXX +#define ODB_SQLITE_TRAITS_HXX + +#include + +#include +#include // std::size_t + +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + enum database_type_id + { + id_integer, + id_real, + id_text, + id_blob + }; + + // + // value_traits + // + + template + struct default_value_traits; + + template + class value_traits: public default_value_traits + { + }; + + template + struct default_value_traits + { + typedef T value_type; + typedef T query_type; + typedef I image_type; + + static void + set_value (T& v, I i, bool is_null) + { + if (!is_null) + v = T (i); + else + v = T (); + } + + static void + set_image (I& i, bool& is_null, T v) + { + is_null = false; + i = I (v); + } + }; + + // std::string specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits< + std::string, details::buffer, id_text> + { + typedef std::string value_type; + typedef std::string query_type; + typedef details::buffer image_type; + + static void + set_value (std::string& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (b.data (), n); + else + v.erase (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const std::string&); + }; + + // const char* specialization + // + // Specialization for const char* which only supports initialization + // of an image from the value but not the other way around. This way + // we can pass such values to the queries. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits< + const char*, details::buffer, id_text> + { + typedef const char* value_type; + typedef const char* query_type; + typedef details::buffer image_type; + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const char*); + }; + + // + // type_traits + // + + template + struct default_type_traits; + + template + class type_traits: public default_type_traits + { + }; + + // Integral types. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + // Float types. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_real; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_real; + }; + + // String type. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + } +} + +#include + +#endif // ODB_SQLITE_TRAITS_HXX -- cgit v1.1 From 878a448f86ddd60e5eb7778e88edd965003ea480 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2011 15:49:33 +0200 Subject: Implement the rest of statements --- odb/sqlite/statement.cxx | 296 ++++++++++++++++++++++++++++++++++++++++++++++- odb/sqlite/statement.hxx | 144 ++++++++++++++++++++++- 2 files changed, 435 insertions(+), 5 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index e7d197b..417a746 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -3,6 +3,11 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include // std::memcpy +#include + +#include // object_not_persistent + #include #include #include @@ -17,6 +22,12 @@ namespace odb // statement:: + ~statement () + { + sqlite3_finalize (stmt_); + } + + statement:: statement (connection& conn, const string& s) : conn_ (conn) { @@ -46,12 +57,124 @@ namespace odb } } + void statement:: + bind_param (const bind* p, size_t n, size_t start_param) + { + int e (SQLITE_OK); + start_param++; // SQLite parameters are counted from 1. + for (size_t i (0); e == SQLITE_OK && i < n; ++i) + { + const bind& b (p[i]); + int j (static_cast (i + start_param)); - statement:: - ~statement () + if (*b.is_null) + { + e = sqlite3_bind_null (stmt_, j); + continue; + } + + switch (b.type) + { + case bind::integer: + { + long long v (*static_cast (b.buffer)); + e = sqlite3_bind_int64 (stmt_, j, static_cast (v)); + break; + } + case bind::real: + { + double v (*static_cast (b.buffer)); + e = sqlite3_bind_double (stmt_, j, v); + break; + } + case bind::text: + { + e = sqlite3_bind_text (stmt_, + j, + static_cast (b.buffer), + static_cast (*b.size), + SQLITE_STATIC); + break; + } + case bind::blob: + { + e = sqlite3_bind_blob (stmt_, + j, + b.buffer, + static_cast (*b.size), + SQLITE_STATIC); + break; + } + } + } + + if (e != SQLITE_OK) + translate_error (e, conn_); + } + + bool statement:: + bind_result (const bind* p, size_t n, bool truncated) { - sqlite3_finalize (stmt_); + bool r (true); + + for (size_t i (0); i < n; ++i) + { + const bind& b (p[i]); + int j (static_cast (i)); + + if (truncated && !*b.truncated) + continue; + + *b.truncated = false; + + // Check for NULL unless we are reloading a truncated result. + // + if (!truncated) + { + *b.is_null = sqlite3_column_type (stmt_, j) != SQLITE_NULL; + + if (*b.is_null) + continue; + } + + switch (b.type) + { + case bind::integer: + { + *static_cast (b.buffer) = + static_cast (sqlite3_column_int64 (stmt_, j)); + break; + } + case bind::real: + { + *static_cast (b.buffer) = + sqlite3_column_double (stmt_, j); + break; + } + case bind::text: + case bind::blob: + { + *b.size = static_cast (sqlite3_column_bytes (stmt_, j)); + + if (*b.size > b.capacity) + { + *b.truncated = true; + r = false; + continue; + } + + const void* d (b.type == bind::text + ? sqlite3_column_text (stmt_, j) + : sqlite3_column_blob (stmt_, j)); + + memcpy (b.buffer, d, *b.size); + break; + } + } + } + + return r; } // simple_statement @@ -95,5 +218,172 @@ namespace odb return r; } + + // select_statement + // + + select_statement:: + select_statement (connection& conn, + const string& s, + binding& cond, + binding& data) + : statement (conn, s), cond_ (cond), data_ (data) + { + } + + void select_statement:: + execute () + { + done_ = false; + + if (int e = sqlite3_reset (stmt_)) + translate_error (e, conn_); + + bind_param (cond_.bind, cond_.count); + } + + bool select_statement:: + next () + { + if (!done_) + { + int e (sqlite3_step (stmt_)); + + switch (e) + { + case SQLITE_DONE: + { + done_ = true; + break; + } + case SQLITE_ROW: + { + break; + } + default: + { + translate_error (e, conn_); + } + } + } + + return !done_; + } + + select_statement::result select_statement:: + load () + { + if (done_) + return no_data; + + return bind_result (data_.bind, data_.count) ? success : truncated; + } + + void select_statement:: + reload () + { + assert (!done_); + + if (!bind_result (data_.bind, data_.count, true)) + assert (false); + } + + // insert_statement + // + + insert_statement:: + insert_statement (connection& conn, const string& s, binding& data) + : statement (conn, s), data_ (data) + { + } + + bool insert_statement:: + execute () + { + if (int e = sqlite3_reset (stmt_)) + translate_error (e, conn_); + + bind_param (data_.bind, data_.count); + + int e (sqlite3_step (stmt_)); + + if (e != SQLITE_DONE) + { + // SQLITE_CONSTRAINT error code covers more than just a duplicate + // primary key. Unfortunately, there is nothing more precise that + // we can use (even sqlite3_errmsg() returns generic "constraint + // failed"). + // + if (e == SQLITE_CONSTRAINT) + return false; + else + translate_error (e, conn_); + } + + return true; + } + + unsigned long long insert_statement:: + id () + { + return static_cast ( + sqlite3_last_insert_rowid (conn_.handle ())); + } + + // update_statement + // + + update_statement:: + update_statement (connection& conn, + const string& s, + binding& cond, + binding& data) + : statement (conn, s), cond_ (cond), data_ (data) + { + } + + void update_statement:: + execute () + { + if (int e = sqlite3_reset (stmt_)) + translate_error (e, conn_); + + bind_param (data_.bind, data_.count); + bind_param (cond_.bind, cond_.count, data_.count); + + int e (sqlite3_step (stmt_)); + + if (e != SQLITE_DONE) + translate_error (e, conn_); + + if (sqlite3_changes (conn_.handle ()) == 0) + throw object_not_persistent (); + } + + // delete_statement + // + + delete_statement:: + delete_statement (connection& conn, const string& s, binding& cond) + : statement (conn, s), cond_ (cond) + { + } + + unsigned long long delete_statement:: + execute () + { + if (int e = sqlite3_reset (stmt_)) + translate_error (e, conn_); + + bind_param (cond_.bind, cond_.count); + + int e (sqlite3_step (stmt_)); + + if (e != SQLITE_DONE) + translate_error (e, conn_); + + return static_cast ( + sqlite3_changes (conn_.handle ())); + } } } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 3c5ea1c..967ff3d 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -17,8 +17,7 @@ #include #include -//@@ #include - +#include #include namespace odb @@ -37,6 +36,17 @@ namespace odb statement (connection&, const std::string& statement); statement (connection&, const char* statement, std::size_t n); + void + bind_param (const bind*, std::size_t count, std::size_t start_param = 0); + + // Extract row columns into the bound buffers. If the truncated + // argument is true, then only truncated columns are extracted. + // Return true if all the data was extracted successfully and + // false if one or more columns were truncated. + // + bool + bind_result (const bind*, std::size_t count, bool truncated = false); + protected: connection& conn_; sqlite3_stmt* stmt_; @@ -58,6 +68,136 @@ namespace odb private: bool result_set_; }; + + class LIBODB_SQLITE_EXPORT select_statement: public statement + { + public: + select_statement (connection& conn, + const std::string& statement, + binding& cond, + binding& data); + + // Common select interface expected by the generated code. + // + public: + enum result + { + success, + no_data, + truncated + }; + + void + execute (); + + // Load next row columns into bound buffers. + // + result + fetch () + { + return next () ? load () : no_data; + } + + // Reload truncated columns into bound buffers. + // + void + refetch () + { + reload (); + } + + // Free the result set. + // + void + free_result () + { + } + + // More fine-grained SQLite-specific interface that splits fetch() + // into next() and load(). + // + public: + // Return false if there is no more rows. + // + bool + next (); + + result + load (); + + void + reload (); + + private: + select_statement (const select_statement&); + select_statement& operator= (const select_statement&); + + private: + bool done_; + binding& cond_; + binding& data_; + }; + + class LIBODB_SQLITE_EXPORT insert_statement: public statement + { + public: + insert_statement (connection& conn, + const std::string& statement, + binding& data); + + // Return true if successful and false if the row is a duplicate. + // All other errors are reported by throwing exceptions. + // + bool + execute (); + + unsigned long long + id (); + + private: + insert_statement (const insert_statement&); + insert_statement& operator= (const insert_statement&); + + private: + binding& data_; + }; + + class LIBODB_SQLITE_EXPORT update_statement: public statement + { + public: + update_statement (connection& conn, + const std::string& statement, + binding& cond, + binding& data); + void + execute (); + + private: + update_statement (const update_statement&); + update_statement& operator= (const update_statement&); + + private: + binding& cond_; + binding& data_; + }; + + class LIBODB_SQLITE_EXPORT delete_statement: public statement + { + public: + delete_statement (connection& conn, + const std::string& statement, + binding& cond); + + unsigned long long + execute (); + + private: + delete_statement (const delete_statement&); + delete_statement& operator= (const delete_statement&); + + private: + binding& cond_; + }; } } -- cgit v1.1 From be5909a7fc240c007bb0128353d493af947a8749 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2011 16:22:06 +0200 Subject: Add object and container statement caches --- odb/sqlite/container-statements.hxx | 179 +++++++++++++++++++ odb/sqlite/container-statements.txx | 36 ++++ odb/sqlite/makefile | 1 + odb/sqlite/object-statements.cxx | 17 ++ odb/sqlite/object-statements.hxx | 333 ++++++++++++++++++++++++++++++++++++ odb/sqlite/object-statements.ixx | 54 ++++++ odb/sqlite/object-statements.txx | 77 +++++++++ odb/sqlite/statement-cache.hxx | 10 -- 8 files changed, 697 insertions(+), 10 deletions(-) create mode 100644 odb/sqlite/container-statements.hxx create mode 100644 odb/sqlite/container-statements.txx create mode 100644 odb/sqlite/object-statements.cxx create mode 100644 odb/sqlite/object-statements.hxx create mode 100644 odb/sqlite/object-statements.ixx create mode 100644 odb/sqlite/object-statements.txx diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx new file mode 100644 index 0000000..a114990 --- /dev/null +++ b/odb/sqlite/container-statements.hxx @@ -0,0 +1,179 @@ +// file : odb/sqlite/container-statements.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX +#define ODB_SQLITE_CONTAINER_STATEMENTS_HXX + +#include + +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Template argument is the generated container traits type. + // + template + class container_statements + { + public: + typedef T traits; + + typedef typename traits::id_image_type id_image_type; + typedef typename traits::data_image_type data_image_type; + typedef typename traits::cond_image_type cond_image_type; + + typedef typename traits::functions_type functions_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef sqlite::connection connection_type; + + container_statements (connection_type&); + + connection_type& + connection () + { + return conn_; + } + + // Functions. + // + functions_type& + functions () + { + return functions_; + } + + // Id image (external). + // + id_image_type& + id_image () + { + return *id_image_; + } + + void + id_image (id_image_type& i) + { + id_image_ = &i; + } + + // Condition image. + // + cond_image_type& + cond_image () + { + return cond_image_; + } + + binding& + cond_image_binding () + { + return cond_image_binding_; + } + + // Data image. + // + data_image_type& + data_image () + { + return data_image_; + } + + binding& + data_image_binding () + { + return data_image_binding_; + } + + bool* + data_image_truncated () + { + return data_image_truncation_; + } + + // + // Statements. + // + + insert_statement_type& + insert_one_statement () + { + if (insert_one_ == 0) + insert_one_.reset ( + new (details::shared) insert_statement_type ( + conn_, traits::insert_one_statement, data_image_binding_)); + + return *insert_one_; + } + + select_statement_type& + select_all_statement () + { + if (select_all_ == 0) + select_all_.reset ( + new (details::shared) select_statement_type ( + conn_, + traits::select_all_statement, + cond_image_binding_, + data_image_binding_)); + + return *select_all_; + } + + delete_statement_type& + delete_all_statement () + { + if (delete_all_ == 0) + delete_all_.reset ( + new (details::shared) delete_statement_type ( + conn_, traits::delete_all_statement, cond_image_binding_)); + + return *delete_all_; + } + + private: + container_statements (const container_statements&); + container_statements& operator= (const container_statements&); + + private: + connection_type& conn_; + functions_type functions_; + + id_image_type* id_image_; + + cond_image_type cond_image_; + binding cond_image_binding_; + bind cond_image_bind_[traits::cond_column_count]; + + data_image_type data_image_; + binding data_image_binding_; + bind data_image_bind_[traits::data_column_count]; + bool data_image_truncated_[traits::data_column_count]; + + details::shared_ptr insert_one_; + details::shared_ptr select_all_; + details::shared_ptr delete_all_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx new file mode 100644 index 0000000..23466df --- /dev/null +++ b/odb/sqlite/container-statements.txx @@ -0,0 +1,36 @@ +// file : odb/sqlite/container-statements.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +namespace odb +{ + namespace sqlite + { + // container_statements + // + + template + container_statements:: + container_statements (connection_type& conn) + : conn_ (conn), + functions_ (this, + &traits::insert_one, + &traits::load_all, + &traits::delete_all), + id_image_ (0), + cond_image_binding_ (cond_image_bind_, traits::cond_column_count), + data_image_binding_ (data_image_bind_, traits::data_column_count) + { + std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); + std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); + std::memset (data_image_truncated_, 0, sizeof (data_image_truncated_)); + + for (std::size_t i (0); i < traits::data_column_count; ++i) + data_image_bind_[i].truncated = data_image_truncated_ + i; + } + } +} diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index f46587f..3cc9d3c 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -11,6 +11,7 @@ connection-factory.cxx \ database.cxx \ error.cxx \ exceptions.cxx \ +object-statements.cxx \ statement-cache.cxx \ statement.cxx \ traits.cxx \ diff --git a/odb/sqlite/object-statements.cxx b/odb/sqlite/object-statements.cxx new file mode 100644 index 0000000..fd3df50 --- /dev/null +++ b/odb/sqlite/object-statements.cxx @@ -0,0 +1,17 @@ +// file : odb/sqlite/object-statements.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + object_statements_base:: + ~object_statements_base () + { + } + } +} diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx new file mode 100644 index 0000000..73f3162 --- /dev/null +++ b/odb/sqlite/object-statements.hxx @@ -0,0 +1,333 @@ +// file : odb/sqlite/object-statements.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_OBJECT_STATEMENTS_HXX + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + class LIBODB_SQLITE_EXPORT object_statements_base: + public details::shared_base + { + public: + typedef sqlite::connection connection_type; + + connection_type& + connection () + { + return conn_; + } + + // Locking. + // + void + lock () + { + assert (!locked_); + locked_ = true; + } + + void + unlock () + { + assert (locked_); + locked_ = false; + } + + bool + locked () const + { + return locked_; + } + + public: + virtual + ~object_statements_base (); + + protected: + object_statements_base (connection_type& conn) + : conn_ (conn), locked_ (false) + { + } + + protected: + connection_type& conn_; + bool locked_; + }; + + template + class object_statements: public object_statements_base + { + public: + typedef T object_type; + typedef odb::object_traits object_traits; + typedef typename object_traits::id_type id_type; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + typedef typename object_traits::id_image_type id_image_type; + + typedef pointer_cache_traits object_cache_traits; + + typedef + typename object_traits::container_statement_cache_type + container_statement_cache_type; + + typedef sqlite::insert_statement persist_statement_type; + typedef sqlite::select_statement find_statement_type; + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement erase_statement_type; + + // Automatic lock. + // + struct auto_lock + { + // Lock the statements unless they are already locked in which + // case subsequent calls to locked() will return false. + // + auto_lock (object_statements&); + + // Unlock the statemens if we are holding the lock and clear + // the delayed loads. This should only happen in case an + // exception is thrown. In normal circumstances, the user + // should call unlock() explicitly. + // + ~auto_lock (); + + // Return true if this auto_lock instance holds the lock. + // + bool + locked () const; + + // Unlock the statemens. + // + void + unlock (); + + private: + auto_lock (const auto_lock&); + auto_lock& operator= (const auto_lock&); + + private: + object_statements& s_; + bool locked_; + }; + + // + // + object_statements (connection_type&); + + // Delayed loading. + // + void + delay_load (const id_type& id, + object_type& obj, + const typename object_cache_traits::position_type& p) + { + delayed_.push_back (delayed_load (id, obj, p)); + } + + void + load_delayed () + { + assert (locked ()); + + if (!delayed_.empty ()) + load_delayed_ (); + } + + void + clear_delayed () + { + if (!delayed_.empty ()) + clear_delayed_ (); + } + + // Object image. + // + image_type& + image () + { + return image_; + } + + binding& + in_image_binding () + { + return in_image_binding_; + } + + binding& + out_image_binding () + { + return out_image_binding_; + } + + bool* + out_image_truncated () + { + return out_image_truncated_; + } + + // Object id image. + // + id_image_type& + id_image () + { + return id_image_; + } + + binding& + id_image_binding () + { + return id_image_binding_; + } + + // Statements. + // + persist_statement_type& + persist_statement () + { + if (persist_ == 0) + persist_.reset ( + new (details::shared) persist_statement_type ( + conn_, object_traits::persist_statement, in_image_binding_)); + + return *persist_; + } + + find_statement_type& + find_statement () + { + if (find_ == 0) + find_.reset ( + new (details::shared) find_statement_type ( + conn_, + object_traits::find_statement, + id_image_binding_, + out_image_binding_)); + + return *find_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + object_traits::update_statement, + id_image_binding_, + in_image_binding_)); + + return *update_; + } + + erase_statement_type& + erase_statement () + { + if (erase_ == 0) + erase_.reset ( + new (details::shared) erase_statement_type ( + conn_, + object_traits::erase_statement, + id_image_binding_)); + + return *erase_; + } + + // Container statement cache. + // + container_statement_cache_type& + container_statment_cache () + { + return container_statement_cache_; + } + + private: + object_statements (const object_statements&); + object_statements& operator= (const object_statements&); + + private: + void + load_delayed_ (); + + void + clear_delayed_ (); + + private: + container_statement_cache_type container_statement_cache_; + + image_type image_; + + // In (send) binding. The last element is the id parameter. + // + binding in_image_binding_; + bind in_image_bind_[object_traits::in_column_count + 1]; + + // Out (receive) binding. + // + binding out_image_binding_; + bind out_image_bind_[object_traits::out_column_count]; + bool out_image_truncated_[object_traits::out_column_count]; + + // Id image binding (only in). + // + id_image_type id_image_; + binding id_image_binding_; + + details::shared_ptr persist_; + details::shared_ptr find_; + details::shared_ptr update_; + details::shared_ptr erase_; + + // Delayed loading. + // + struct delayed_load + { + typedef typename object_cache_traits::position_type position_type; + + delayed_load () {} + delayed_load (const id_type& i, object_type& o, const position_type& p) + : id (i), obj (&o), pos (p) + { + } + + id_type id; + object_type* obj; + position_type pos; + }; + + typedef std::vector delayed_loads; + delayed_loads delayed_; + }; + } +} + +#include +#include + +#include + +#endif // ODB_SQLITE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/object-statements.ixx b/odb/sqlite/object-statements.ixx new file mode 100644 index 0000000..e1ae3ef --- /dev/null +++ b/odb/sqlite/object-statements.ixx @@ -0,0 +1,54 @@ +// file : odb/sqlite/object-statements.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // auto_lock + // + template + inline object_statements::auto_lock:: + auto_lock (object_statements& s) + : s_ (s) + { + if (!s_.locked ()) + { + s_.lock (); + locked_ = true; + } + else + locked_ = false; + } + + template + inline object_statements::auto_lock:: + ~auto_lock () + { + if (locked_) + { + s_.unlock (); + s_.clear_delayed (); + } + } + + template + inline bool object_statements::auto_lock:: + locked () const + { + return locked_; + } + + template + inline void object_statements::auto_lock:: + unlock () + { + assert (locked_); + s_.unlock (); + locked_ = false; + } + } +} diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx new file mode 100644 index 0000000..88b99e8 --- /dev/null +++ b/odb/sqlite/object-statements.txx @@ -0,0 +1,77 @@ +// file : odb/sqlite/object-statements.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + object_statements:: + object_statements (connection_type& conn) + : object_statements_base (conn), + container_statement_cache_ (conn), + in_image_binding_ (in_image_bind_, object_traits::in_column_count), + out_image_binding_ (out_image_bind_, object_traits::out_column_count), + id_image_binding_ (in_image_bind_ + object_traits::in_column_count, 1) + { + std::memset (in_image_bind_, 0, sizeof (in_image_bind_)); + std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); + std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); + + for (std::size_t i (0); i < object_traits::out_column_count; ++i) + out_image_bind_[i].truncated = out_image_truncated_ + i; + } + + template + void object_statements:: + load_delayed_ () + { + // We should be careful here: the delayed vector can change + // from under us as a result of a recursive load. + // + database& db (connection ().database ()); + + while (!delayed_.empty ()) + { + delayed_load l (delayed_.back ()); + typename object_cache_traits::insert_guard g (l.pos); + delayed_.pop_back (); + + if (!object_traits::find_ (*this, l.id)) + throw object_not_persistent (); + + object_traits::init (*l.obj, image (), db); + object_traits::load_ (*this, *l.obj); // Load containers, etc. + g.release (); + } + } + + template + void object_statements:: + clear_delayed_ () + { + // Remove the objects from the session cache. + // + if (session::has_current ()) + { + for (typename delayed_loads::iterator i (delayed_.begin ()), + e (delayed_.end ()); i != e; ++i) + { + object_cache_traits::erase (i->pos); + } + } + + delayed_.clear (); + } + } +} diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 9ef446d..1b3d4b2 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -17,10 +17,7 @@ #include #include -/* #include -*/ - #include namespace odb @@ -52,8 +49,6 @@ namespace odb return *rollback_; } -/* - @@ template object_statements& find () @@ -69,14 +64,11 @@ namespace odb map_.insert (map::value_type (&typeid (T), p)); return *p; } -*/ private: - /* typedef std::map, details::type_info_comparator> map; - */ connection& conn_; @@ -84,9 +76,7 @@ namespace odb details::shared_ptr commit_; details::shared_ptr rollback_; - /* map map_; - */ }; } } -- cgit v1.1 From 48c1630764665072bbb592f7072e48aa654a1c71 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Mar 2011 12:18:13 +0200 Subject: Factor out bind struct to sqlite-types.hxx --- odb/sqlite/binding.hxx | 24 ++---------------------- odb/sqlite/sqlite-types.hxx | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 odb/sqlite/sqlite-types.hxx diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index 70edd28..426195b 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -12,33 +12,13 @@ #include +#include #include namespace odb { namespace sqlite { - // The SQLite parameter/result binding. This data structures is - // modelled after MYSQL_BIND from MySQL. - // - struct bind - { - enum buffer_type - { - integer, // Buffer is long long; size, capacity, truncated are unused. - real, // Buffer is double; size, capacity, truncated are unused. - text, // Buffer is a char array. - blob // Buffer is a char array. - }; - - buffer_type type; - void* buffer; - std::size_t* size; - std::size_t capacity; - bool* is_null; - bool* truncated; - }; - class LIBODB_SQLITE_EXPORT binding { public: @@ -51,7 +31,7 @@ namespace odb bind_type* bind; std::size_t count; - std::size_t version; + std::size_t version; // @@ Don't really need it (gen code). private: binding (const binding&); diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx new file mode 100644 index 0000000..b0bcde4 --- /dev/null +++ b/odb/sqlite/sqlite-types.hxx @@ -0,0 +1,42 @@ +// file : odb/sqlite/sqlite-types.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SQLITE_TYPES_HXX +#define ODB_SQLITE_SQLITE_TYPES_HXX + +#include + +#include // std::size_t + +namespace odb +{ + namespace sqlite + { + // The SQLite parameter/result binding. This data structures is modelled + // after MYSQL_BIND from MySQL. + // + struct bind + { + enum buffer_type + { + integer, // Buffer is long long; size, capacity, truncated are unused. + real, // Buffer is double; size, capacity, truncated are unused. + text, // Buffer is a char array. + blob // Buffer is a char array. + }; + + buffer_type type; + void* buffer; + std::size_t* size; + std::size_t capacity; + bool* is_null; + bool* truncated; + }; + } +} + +#include + +#endif // ODB_SQLITE_SQLITE_TYPES_HXX -- cgit v1.1 From ea1fb7db74c17ce64403b4350d93f18d41c31f81 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Mar 2011 12:19:54 +0200 Subject: Add image/binding versioning --- odb/sqlite/container-statements.hxx | 56 ++++++++++++++++++++++++++++++++++++- odb/sqlite/container-statements.txx | 8 ++++++ odb/sqlite/object-statements.hxx | 40 ++++++++++++++++++++++++++ odb/sqlite/object-statements.txx | 7 +++++ 4 files changed, 110 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index a114990..5f5caef 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -8,6 +8,8 @@ #include +#include // std::size_t + #include #include @@ -80,6 +82,30 @@ namespace odb return cond_image_; } + std::size_t + cond_image_version () const + { + return cond_image_version_; + } + + void + cond_image_version (std::size_t v) + { + cond_image_version_ = v; + } + + std::size_t + cond_id_image_version () const + { + return cond_id_image_version_; + } + + void + cond_id_image_version (std::size_t v) + { + cond_id_image_version_ = v; + } + binding& cond_image_binding () { @@ -94,6 +120,30 @@ namespace odb return data_image_; } + std::size_t + data_image_version () const + { + return data_image_version_; + } + + void + data_image_version (std::size_t v) + { + data_image_version_ = v; + } + + std::size_t + data_id_image_version () const + { + return data_id_image_version_; + } + + void + data_id_image_version (std::size_t v) + { + data_id_image_version_ = v; + } + binding& data_image_binding () { @@ -103,7 +153,7 @@ namespace odb bool* data_image_truncated () { - return data_image_truncation_; + return data_image_truncated_; } // @@ -157,10 +207,14 @@ namespace odb id_image_type* id_image_; cond_image_type cond_image_; + std::size_t cond_image_version_; + std::size_t cond_id_image_version_; binding cond_image_binding_; bind cond_image_bind_[traits::cond_column_count]; data_image_type data_image_; + std::size_t data_image_version_; + std::size_t data_id_image_version_; binding data_image_binding_; bind data_image_bind_[traits::data_column_count]; bool data_image_truncated_[traits::data_column_count]; diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 23466df..bfef187 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -25,6 +25,14 @@ namespace odb cond_image_binding_ (cond_image_bind_, traits::cond_column_count), data_image_binding_ (data_image_bind_, traits::data_column_count) { + cond_image_.version = 0; + cond_image_version_ = 0; + cond_id_image_version_ = 0; + + data_image_.version = 0; + data_image_version_ = 0; + data_id_image_version_ = 0; + std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); std::memset (data_image_truncated_, 0, sizeof (data_image_truncated_)); diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 73f3162..68fd04e 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -10,6 +10,7 @@ #include #include +#include // std::size_t #include #include @@ -171,6 +172,30 @@ namespace odb return image_; } + std::size_t + in_image_version () const + { + return in_image_version_; + } + + std::size_t + out_image_version () const + { + return out_image_version_; + } + + void + in_image_version (std::size_t v) + { + in_image_version_ = v; + } + + void + out_image_version (std::size_t v) + { + out_image_version_ = v; + } + binding& in_image_binding () { @@ -197,6 +222,18 @@ namespace odb return id_image_; } + std::size_t + id_image_version () const + { + return id_image_version_; + } + + void + id_image_version (std::size_t v) + { + id_image_version_ = v; + } + binding& id_image_binding () { @@ -283,11 +320,13 @@ namespace odb // In (send) binding. The last element is the id parameter. // + std::size_t in_image_version_; binding in_image_binding_; bind in_image_bind_[object_traits::in_column_count + 1]; // Out (receive) binding. // + std::size_t out_image_version_; binding out_image_binding_; bind out_image_bind_[object_traits::out_column_count]; bool out_image_truncated_[object_traits::out_column_count]; @@ -295,6 +334,7 @@ namespace odb // Id image binding (only in). // id_image_type id_image_; + std::size_t id_image_version_; binding id_image_binding_; details::shared_ptr persist_; diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 88b99e8..53a157f 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -24,6 +24,13 @@ namespace odb out_image_binding_ (out_image_bind_, object_traits::out_column_count), id_image_binding_ (in_image_bind_ + object_traits::in_column_count, 1) { + image_.version = 0; + in_image_version_ = 0; + out_image_version_ = 0; + + id_image_.version = 0; + id_image_version_ = 0; + std::memset (in_image_bind_, 0, sizeof (in_image_bind_)); std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); -- cgit v1.1 From 01e70d9a1d49bcb126adc45f85168aa7c9cbad19 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Mar 2011 12:21:06 +0200 Subject: Reset statement after completion Without the reset the statement is considered unfinished and the database lock is help even after COMMIT. --- odb/sqlite/statement.cxx | 34 +++++++++++++++++----------------- odb/sqlite/statement.hxx | 8 ++++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 417a746..fc9e780 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -132,7 +132,7 @@ namespace odb // if (!truncated) { - *b.is_null = sqlite3_column_type (stmt_, j) != SQLITE_NULL; + *b.is_null = sqlite3_column_type (stmt_, j) == SQLITE_NULL; if (*b.is_null) continue; @@ -200,15 +200,14 @@ namespace odb if (stmt_ == 0) // Empty statement or comment. return 0; - if (int e = sqlite3_reset (stmt_)) - translate_error (e, conn_); - unsigned long long r (0); int e; for (e = sqlite3_step (stmt_); e == SQLITE_ROW; e = sqlite3_step (stmt_)) r++; + sqlite3_reset (stmt_); + if (e != SQLITE_DONE) translate_error (e, conn_); @@ -235,13 +234,15 @@ namespace odb execute () { done_ = false; - - if (int e = sqlite3_reset (stmt_)) - translate_error (e, conn_); - bind_param (cond_.bind, cond_.count); } + void select_statement:: + free_result () + { + sqlite3_reset (stmt_); + } + bool select_statement:: next () { @@ -254,6 +255,7 @@ namespace odb case SQLITE_DONE: { done_ = true; + sqlite3_reset (stmt_); break; } case SQLITE_ROW: @@ -262,6 +264,7 @@ namespace odb } default: { + sqlite3_reset (stmt_); translate_error (e, conn_); } } @@ -300,13 +303,12 @@ namespace odb bool insert_statement:: execute () { - if (int e = sqlite3_reset (stmt_)) - translate_error (e, conn_); - bind_param (data_.bind, data_.count); int e (sqlite3_step (stmt_)); + sqlite3_reset (stmt_); + if (e != SQLITE_DONE) { // SQLITE_CONSTRAINT error code covers more than just a duplicate @@ -345,14 +347,13 @@ namespace odb void update_statement:: execute () { - if (int e = sqlite3_reset (stmt_)) - translate_error (e, conn_); - bind_param (data_.bind, data_.count); bind_param (cond_.bind, cond_.count, data_.count); int e (sqlite3_step (stmt_)); + sqlite3_reset (stmt_); + if (e != SQLITE_DONE) translate_error (e, conn_); @@ -372,13 +373,12 @@ namespace odb unsigned long long delete_statement:: execute () { - if (int e = sqlite3_reset (stmt_)) - translate_error (e, conn_); - bind_param (cond_.bind, cond_.count); int e (sqlite3_step (stmt_)); + sqlite3_reset (stmt_); + if (e != SQLITE_DONE) translate_error (e, conn_); diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 967ff3d..fe541e5 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -109,15 +109,15 @@ namespace odb // Free the result set. // void - free_result () - { - } + free_result (); // More fine-grained SQLite-specific interface that splits fetch() // into next() and load(). // public: - // Return false if there is no more rows. + // Return false if there is no more rows. You should call next() + // until it returns false or, alternatively, call free_result (). + // Otherwise the statement will remain unfinished. // bool next (); -- cgit v1.1 From 7939f7972cf22ee9a74518978e4f7d4d77535e09 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Mar 2011 14:02:16 +0200 Subject: Add support for clearing connection from active and uncached statements --- odb/sqlite/connection.cxx | 32 +++++++-- odb/sqlite/connection.hxx | 14 ++++ odb/sqlite/container-statements.hxx | 12 ++++ odb/sqlite/object-statements.hxx | 16 +++++ odb/sqlite/statement-cache.cxx | 3 + odb/sqlite/statement.cxx | 57 ++++++--------- odb/sqlite/statement.hxx | 140 +++++++++++++++++++++++++++++++++++- odb/sqlite/transaction-impl.cxx | 13 ++++ 8 files changed, 243 insertions(+), 44 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 37f5e20..9af5a3b 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -19,8 +20,17 @@ namespace odb namespace sqlite { connection:: + ~connection () + { + statement_cache_.reset (); // Free prepared statements. + + if (sqlite3_close (handle_) == SQLITE_BUSY) + assert (false); // Connection has outstanding prepared statements. + } + + connection:: connection (database_type& db) - : db_ (db) + : db_ (db), statements_ (0) { int f (db.flags ()); const string& n (db.name ()); @@ -47,13 +57,21 @@ namespace odb statement_cache_.reset (new statement_cache_type (*this)); } - connection:: - ~connection () + void connection:: + clear () { - statement_cache_.reset (); // Free prepared statements. - - if (sqlite3_close (handle_) == SQLITE_BUSY) - assert (false); // Connection has outstanding prepared statements. + // The current first statement will remove itself from the list + // and make the second statement (if any) the new first. + // + while (statement* s = statements_) + { + if (!s->cached ()) + s->finilize (); + else if (s->active ()) + s->reset (); + else + assert (false); // Statement is neither active nor unached. + } } } } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 0df08b3..5390609 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -23,6 +23,7 @@ namespace odb { namespace sqlite { + class statement; class statement_cache; class LIBODB_SQLITE_EXPORT connection: public details::shared_base @@ -55,14 +56,27 @@ namespace odb return *statement_cache_; } + public: + // Reset active and finalize uncached statements. + // + void + clear (); + private: connection (const connection&); connection& operator= (const connection&); private: + friend class statement; + database_type& db_; sqlite3* handle_; + // Linked list of active and uncached statements currently associated + // with this connection. + // + statement* statements_; + std::auto_ptr statement_cache_; }; } diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 5f5caef..9bff64c 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -164,10 +164,14 @@ namespace odb insert_one_statement () { if (insert_one_ == 0) + { insert_one_.reset ( new (details::shared) insert_statement_type ( conn_, traits::insert_one_statement, data_image_binding_)); + insert_one_->cached (true); + } + return *insert_one_; } @@ -175,6 +179,7 @@ namespace odb select_all_statement () { if (select_all_ == 0) + { select_all_.reset ( new (details::shared) select_statement_type ( conn_, @@ -182,6 +187,9 @@ namespace odb cond_image_binding_, data_image_binding_)); + select_all_->cached (true); + } + return *select_all_; } @@ -189,10 +197,14 @@ namespace odb delete_all_statement () { if (delete_all_ == 0) + { delete_all_.reset ( new (details::shared) delete_statement_type ( conn_, traits::delete_all_statement, cond_image_binding_)); + delete_all_->cached (true); + } + return *delete_all_; } diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 68fd04e..3ab627d 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -246,10 +246,14 @@ namespace odb persist_statement () { if (persist_ == 0) + { persist_.reset ( new (details::shared) persist_statement_type ( conn_, object_traits::persist_statement, in_image_binding_)); + persist_->cached (true); + } + return *persist_; } @@ -257,6 +261,7 @@ namespace odb find_statement () { if (find_ == 0) + { find_.reset ( new (details::shared) find_statement_type ( conn_, @@ -264,6 +269,9 @@ namespace odb id_image_binding_, out_image_binding_)); + find_->cached (true); + } + return *find_; } @@ -271,6 +279,7 @@ namespace odb update_statement () { if (update_ == 0) + { update_.reset ( new (details::shared) update_statement_type ( conn_, @@ -278,6 +287,9 @@ namespace odb id_image_binding_, in_image_binding_)); + update_->cached (true); + } + return *update_; } @@ -285,12 +297,16 @@ namespace odb erase_statement () { if (erase_ == 0) + { erase_.reset ( new (details::shared) erase_statement_type ( conn_, object_traits::erase_statement, id_image_binding_)); + erase_->cached (true); + } + return *erase_; } diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 66ef266..383a78e 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -21,6 +21,9 @@ namespace odb commit_ (new (shared) simple_statement (conn, "COMMIT", 7)), rollback_ (new (shared) simple_statement (conn, "ROLLBACK", 9)) { + rollback_->cached (true); + commit_->cached (true); + begin_->cached (true); } } } diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index fc9e780..aa87939 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -24,27 +24,11 @@ namespace odb statement:: ~statement () { - sqlite3_finalize (stmt_); + finilize (); } - statement:: - statement (connection& conn, const string& s) - : conn_ (conn) - { - if (int e = sqlite3_prepare_v2 ( - conn_.handle (), - s.c_str (), - static_cast (s.size () + 1), - &stmt_, - 0)) - { - translate_error (e, conn_); - } - } - - statement:: - statement (connection& conn, const char* s, std::size_t n) - : conn_ (conn) + void statement:: + init (const char* s, std::size_t n) { if (int e = sqlite3_prepare_v2 ( conn_.handle (), @@ -55,6 +39,14 @@ namespace odb { translate_error (e, conn_); } + + active_ = false; + cached_ = false; + + prev_ = 0; + next_ = this; + + list_add (); // Add to the list because we are uncached. } void statement:: @@ -233,14 +225,19 @@ namespace odb void select_statement:: execute () { + if (active ()) + reset (); + done_ = false; bind_param (cond_.bind, cond_.count); + active (true); } void select_statement:: free_result () { - sqlite3_reset (stmt_); + reset (); + done_ = true; } bool select_statement:: @@ -250,23 +247,13 @@ namespace odb { int e (sqlite3_step (stmt_)); - switch (e) + if (e != SQLITE_ROW) { - case SQLITE_DONE: - { - done_ = true; - sqlite3_reset (stmt_); - break; - } - case SQLITE_ROW: - { - break; - } - default: - { - sqlite3_reset (stmt_); + reset (); + done_ = true; + + if (e != SQLITE_DONE) translate_error (e, conn_); - } } } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index fe541e5..2a629fe 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -12,12 +12,14 @@ #include #include // std::size_t +#include #include #include #include #include +#include #include namespace odb @@ -32,10 +34,49 @@ namespace odb virtual ~statement () = 0; + sqlite3_stmt* + handle () + { + return stmt_; + } + + // Cached state (public part). + // + public: + bool + cached () const + { + return cached_; + } + + void + cached (bool cached) + { + assert (cached); + + if (!cached_) + { + if (!active_) + list_remove (); + + cached_ = true; + } + } + protected: - statement (connection&, const std::string& statement); - statement (connection&, const char* statement, std::size_t n); + statement (connection& conn, const std::string& statement) + : conn_ (conn) + { + init (statement.c_str (), statement.size () + 1); + } + + statement (connection& conn, const char* statement, std::size_t n) + : conn_ (conn) + { + init (statement, n); + } + protected: void bind_param (const bind*, std::size_t count, std::size_t start_param = 0); @@ -47,9 +88,104 @@ namespace odb bool bind_result (const bind*, std::size_t count, bool truncated = false); + // Active state. + // + protected: + bool + active () const + { + return active_; + } + + void + active (bool active) + { + assert (active); + + if (!active_) + { + list_add (); + active_ = true; + } + } + + void + reset () + { + if (active_) + { + if (stmt_ != 0) + sqlite3_reset (stmt_); + + if (cached_) + list_remove (); + + active_ = false; + } + } + + // Cached state (protected part). + // + protected: + void + finilize () + { + list_remove (); + + if (stmt_ != 0) + { + sqlite3_finalize (stmt_); + stmt_ = 0; + } + } + protected: + friend class connection; + connection& conn_; sqlite3_stmt* stmt_; + + bool active_; + bool cached_; + + private: + void + init (const char* statement, std::size_t n); + + // Doubly-linked list of active/uncached statements. + // + private: + void list_add () + { + if (next_ == this) + { + next_ = conn_.statements_; + conn_.statements_ = this; + } + } + + void list_remove () + { + if (next_ != this) + { + if (prev_ == 0) + conn_.statements_ = next_; + else + { + prev_->next_ = next_; + prev_ = 0; + } + + next_ = this; + } + } + + // prev_ == 0 means we are the first element. + // next_ == 0 means we are the last element. + // next_ == this means we are not on the list (prev_ should be 0). + // + statement* prev_; + statement* next_; }; class LIBODB_SQLITE_EXPORT simple_statement: public statement diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 3730100..36d6c2b 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -28,6 +28,13 @@ namespace odb void transaction_impl:: commit () { + // Reset active and finilize uncached statements. Active statements + // will prevent COMMIT from completing (write statements) or releasing + // the locks (read statements). Finilization of uncached statements is + // needed to release the connection. + // + connection_->clear (); + connection_->statement_cache ().commit_statement ().execute (); // Release the connection. @@ -38,6 +45,12 @@ namespace odb void transaction_impl:: rollback () { + // Reset active and finilize uncached statements. Active statements + // will prevent ROLLBACK from completing. Finilization of uncached + // statements is needed to release the connection. + // + connection_->clear (); + connection_->statement_cache ().rollback_statement ().execute (); // Release the connection. -- cgit v1.1 From 5d084dcd0f24237486e18f024fbbb14c13b8bffe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 13:04:05 +0200 Subject: Check if is_null pointer is not NULL before dereferencing it --- odb/sqlite/statement.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index aa87939..0975545 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -60,7 +60,7 @@ namespace odb const bind& b (p[i]); int j (static_cast (i + start_param)); - if (*b.is_null) + if (b.is_null != 0 && *b.is_null) { e = sqlite3_bind_null (stmt_, j); continue; -- cgit v1.1 From b5d76bf8ab11e73b260cbc4343c1f947c0da2699 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 13:04:55 +0200 Subject: Query support --- odb/sqlite/makefile | 2 + odb/sqlite/query.cxx | 162 +++++++ odb/sqlite/query.hxx | 1228 +++++++++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/query.ixx | 40 ++ odb/sqlite/query.txx | 111 +++++ odb/sqlite/result.cxx | 18 + odb/sqlite/result.hxx | 89 ++++ odb/sqlite/result.txx | 120 +++++ 8 files changed, 1770 insertions(+) create mode 100644 odb/sqlite/query.cxx create mode 100644 odb/sqlite/query.hxx create mode 100644 odb/sqlite/query.ixx create mode 100644 odb/sqlite/query.txx create mode 100644 odb/sqlite/result.cxx create mode 100644 odb/sqlite/result.hxx create mode 100644 odb/sqlite/result.txx diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 3cc9d3c..2d51d7d 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -12,6 +12,8 @@ database.cxx \ error.cxx \ exceptions.cxx \ object-statements.cxx \ +query.cxx \ +result.cxx \ statement-cache.cxx \ statement.cxx \ traits.cxx \ diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx new file mode 100644 index 0000000..a1c5b00 --- /dev/null +++ b/odb/sqlite/query.cxx @@ -0,0 +1,162 @@ +// file : odb/sqlite/query.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + // query_param + // + + query_param:: + ~query_param () + { + } + + // query_params + // + + query_params:: + query_params (const query_params& x) + : details::shared_base (x), + params_ (x.params_), bind_ (x.bind_), binding_ (0, 0) + { + } + + query_params& query_params:: + operator= (const query_params& x) + { + if (this != &x) + { + params_ = x.params_; + bind_ = x.bind_; + } + + return *this; + } + + query_params::binding_type& query_params:: + binding () + { + size_t n (params_.size ()); + binding_type& r (binding_); + + if (n == 0) + return r; // r.bind and r.count should be 0. + + sqlite::bind* b (&bind_[0]); + + bool inc_ver (false); + + if (r.bind != b || r.count != n) + { + r.bind = b; + r.count = n; + inc_ver = true; + } + + for (size_t i (0); i < n; ++i) + { + query_param& p (*params_[i]); + + if (p.reference ()) + { + if (p.init ()) + { + p.bind (b + i); + inc_ver = true; + } + } + } + + if (inc_ver) + r.version++; + + return r; + } + + // query + // + + query:: + query (const query& q) + : clause_ (q.clause_), + parameters_ (new (details::shared) query_params (*q.parameters_)) + { + } + + query& query:: + operator= (const query& q) + { + if (this != &q) + { + clause_ = q.clause_; + *parameters_ = *q.parameters_; + } + + return *this; + } + + query& query:: + operator+= (const query& q) + { + size_t n (clause_.size ()); + + if (n != 0 && clause_[n - 1] != ' ' && + !q.clause_.empty () && q.clause_[0] != ' ') + clause_ += ' '; + + clause_ += q.clause_; + + query_params& p (*parameters_); + query_params& qp (*q.parameters_); + + p.params_.insert ( + p.params_.end (), qp.params_.begin (), qp.params_.end ()); + + p.bind_.insert (p.bind_.end (), qp.bind_.begin (), qp.bind_.end ()); + + return *this; + } + + void query:: + add (details::shared_ptr p) + { + size_t n (clause_.size ()); + + if (n != 0 && clause_[n - 1] != ' ') + clause_ += ' '; + + clause_ += '?'; + + parameters_->params_.push_back (p); + parameters_->bind_.push_back (sqlite::bind ()); + sqlite::bind* b (¶meters_->bind_.back ()); + memset (b, 0, sizeof (sqlite::bind)); + + p->bind (b); + } + + std::string query:: + clause () const + { + if (clause_.empty () || + clause_.compare (0, 6, "WHERE ") == 0 || + clause_.compare (0, 9, "ORDER BY ") == 0 || + clause_.compare (0, 9, "GROUP BY ") == 0 || + clause_.compare (0, 7, "HAVING ") == 0) + return clause_; + else + return "WHERE " + clause_; + } + } +} diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx new file mode 100644 index 0000000..517fd2f --- /dev/null +++ b/odb/sqlite/query.hxx @@ -0,0 +1,1228 @@ +// file : odb/sqlite/query.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_QUERY_HXX +#define ODB_SQLITE_QUERY_HXX + +#include + +#include +#include +#include // std::size_t + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class val_bind + { + public: + explicit + val_bind (const T& v): val (v) {} + + const T& val; + }; + + template + class ref_bind + { + public: + explicit + ref_bind (const T& r): ref (r) {} + + const T& ref; + }; + + struct LIBODB_SQLITE_EXPORT query_param: details::shared_base + { + virtual + ~query_param (); + + bool + reference () const + { + return value_ != 0; + } + + virtual bool + init () = 0; + + virtual void + bind (sqlite::bind*) = 0; + + protected: + query_param (const void* value) + : value_ (value) + { + } + + protected: + const void* value_; + }; + + class query; + + struct LIBODB_SQLITE_EXPORT query_params: details::shared_base + { + typedef sqlite::binding binding_type; + + binding_type& + binding (); + + private: + friend class query; + + query_params (): binding_ (0, 0) {} + query_params (const query_params&); + + query_params& + operator= (const query_params&); + + private: + typedef std::vector > params; + + params params_; + std::vector bind_; + binding_type binding_; + }; + + // + // + template + struct query_column; + + class LIBODB_SQLITE_EXPORT query + { + public: + query () + : parameters_ (new (details::shared) query_params) + { + } + + explicit + query (const std::string& q) + : clause_ (q), parameters_ (new (details::shared) query_params) + { + } + + template + explicit + query (val_bind v) + : parameters_ (new (details::shared) query_params) + { + append::db_type_id> (v); + } + + template + explicit + query (ref_bind r) + : parameters_ (new (details::shared) query_params) + { + append::db_type_id> (r); + } + + template + query (const query_column&); + + query (const query&); + + query& + operator= (const query&); + + public: + std::string + clause () const; + + binding& + parameters_binding () const; + + details::shared_ptr + parameters () const; + + public: + template + static val_bind + _val (const T& x) + { + return val_bind (x); + } + + template + static ref_bind + _ref (const T& x) + { + return ref_bind (x); + } + + public: + query& + operator+= (const query&); + + query& + operator+= (const std::string& q) + { + size_t n (clause_.size ()); + + if (n != 0 && clause_[n - 1] != ' ' && !q.empty () && q[0] != ' ') + clause_ += ' '; + + clause_ += q; + return *this; + } + + template + query& + operator+= (val_bind v) + { + append::db_type_id> (v); + return *this; + } + + template + query& + operator+= (ref_bind r) + { + append::db_type_id> (r); + return *this; + } + + public: + template + void + append (val_bind); + + template + void + append (ref_bind); + + private: + void + add (details::shared_ptr); + + private: + std::string clause_; + details::shared_ptr parameters_; + }; + + inline query + operator+ (const query& x, const query& y) + { + query r (x); + r += y; + return r; + } + + template + inline query + operator+ (const query& q, val_bind b) + { + query r (q); + r += b; + return r; + } + + template + inline query + operator+ (const query& q, ref_bind b) + { + query r (q); + r += b; + return r; + } + + template + inline query + operator+ (val_bind b, const query& q) + { + query r; + r += b; + r += q; + return r; + } + + template + inline query + operator+ (ref_bind b, const query& q) + { + query r; + r += b; + r += q; + return r; + } + + inline query + operator+ (const query& q, const std::string& s) + { + query r (q); + r += s; + return r; + } + + inline query + operator+ (const std::string& s, const query& q) + { + query r (s); + r += q; + return r; + } + + template + inline query + operator+ (const std::string& s, val_bind b) + { + query r (s); + r += b; + return r; + } + + template + inline query + operator+ (const std::string& s, ref_bind b) + { + query r (s); + r += b; + return r; + } + + template + inline query + operator+ (val_bind b, const std::string& s) + { + query r; + r += b; + r += s; + return r; + } + + template + inline query + operator+ (ref_bind b, const std::string& s) + { + query r; + r += b; + r += s; + return r; + } + + inline query + operator&& (const query& x, const query& y) + { + query r ("("); + r += x; + r += ") AND ("; + r += y; + r += ")"; + return r; + } + + inline query + operator|| (const query& x, const query& y) + { + query r ("("); + r += x; + r += ") OR ("; + r += y; + r += ")"; + return r; + } + + inline query + operator! (const query& x) + { + query r ("NOT ("); + r += x; + r += ")"; + return r; + } + + // query_column + // + + template + class copy_bind: public val_bind + { + public: + explicit + copy_bind (const T2& v): val_bind (val), val (v) {} + + const T val; + }; + + template + const T& + type_instance (); + + template + struct query_column + { + explicit + query_column (const char* name) + : name_ (name) + { + } + + const char* + name () const + { + return name_; + } + + // is_null, is_not_null + // + public: + query + is_null () const + { + query q (name_); + q += "IS NULL"; + return q; + } + + query + is_not_null () const + { + query q (name_); + q += "IS NOT NULL"; + return q; + } + + // in + // + public: + query + in (const T&, const T&) const; + + query + in (const T&, const T&, const T&) const; + + query + in (const T&, const T&, const T&, const T&) const; + + query + in (const T&, const T&, const T&, const T&, const T&) const; + + template + query + in_range (I begin, I end) const; + + // = + // + public: + query + equal (const T& v) const + { + return equal (val_bind (v)); + } + + query + equal (val_bind v) const + { + query q (name_); + q += "="; + q.append (v); + return q; + } + + template + query + equal (val_bind v) const + { + copy_bind c (v.val); + return equal (c); + } + + query + equal (ref_bind r) const + { + query q (name_); + q += "="; + q.append (r); + return q; + } + + friend query + operator== (const query_column& c, const T& v) + { + return c.equal (v); + } + + friend query + operator== (const T& v, const query_column& c) + { + return c.equal (v); + } + + friend query + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + friend query + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + template + friend query + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + template + friend query + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + friend query + operator== (const query_column& c, ref_bind r) + { + return c.equal (r); + } + + friend query + operator== (ref_bind r, const query_column& c) + { + return c.equal (r); + } + + // != + // + public: + query + unequal (const T& v) const + { + return unequal (val_bind (v)); + } + + query + unequal (val_bind v) const + { + query q (name_); + q += "!="; + q.append (v); + return q; + } + + template + query + unequal (val_bind v) const + { + copy_bind c (v.val); + return unequal (c); + } + + query + unequal (ref_bind r) const + { + query q (name_); + q += "!="; + q.append (r); + return q; + } + + friend query + operator!= (const query_column& c, const T& v) + { + return c.unequal (v); + } + + friend query + operator!= (const T& v, const query_column& c) + { + return c.unequal (v); + } + + friend query + operator!= (const query_column& c, val_bind v) + { + return c.unequal (v); + } + + friend query + operator!= (val_bind v, const query_column& c) + { + return c.unequal (v); + } + + template + friend query + operator!= (const query_column& c, val_bind v) + { + return c.unequal (v); + } + + template + friend query + operator!= (val_bind v, const query_column& c) + { + return c.unequal (v); + } + + friend query + operator!= (const query_column& c, ref_bind r) + { + return c.unequal (r); + } + + friend query + operator!= (ref_bind r, const query_column& c) + { + return c.unequal (r); + } + + // < + // + public: + query + less (const T& v) const + { + return less (val_bind (v)); + } + + query + less (val_bind v) const + { + query q (name_); + q += "<"; + q.append (v); + return q; + } + + template + query + less (val_bind v) const + { + copy_bind c (v.val); + return less (c); + } + + query + less (ref_bind r) const + { + query q (name_); + q += "<"; + q.append (r); + return q; + } + + friend query + operator< (const query_column& c, const T& v) + { + return c.less (v); + } + + friend query + operator< (const T& v, const query_column& c) + { + return c.greater (v); + } + + friend query + operator< (const query_column& c, val_bind v) + { + return c.less (v); + } + + friend query + operator< (val_bind v, const query_column& c) + { + return c.greater (v); + } + + template + friend query + operator< (const query_column& c, val_bind v) + { + return c.less (v); + } + + template + friend query + operator< (val_bind v, const query_column& c) + { + return c.greater (v); + } + + friend query + operator< (const query_column& c, ref_bind r) + { + return c.less (r); + } + + friend query + operator< (ref_bind r, const query_column& c) + { + return c.greater (r); + } + + // > + // + public: + query + greater (const T& v) const + { + return greater (val_bind (v)); + } + + query + greater (val_bind v) const + { + query q (name_); + q += ">"; + q.append (v); + return q; + } + + template + query + greater (val_bind v) const + { + copy_bind c (v.val); + return greater (c); + } + + query + greater (ref_bind r) const + { + query q (name_); + q += ">"; + q.append (r); + return q; + } + + friend query + operator> (const query_column& c, const T& v) + { + return c.greater (v); + } + + friend query + operator> (const T& v, const query_column& c) + { + return c.less (v); + } + + friend query + operator> (const query_column& c, val_bind v) + { + return c.greater (v); + } + + friend query + operator> (val_bind v, const query_column& c) + { + return c.less (v); + } + + template + friend query + operator> (const query_column& c, val_bind v) + { + return c.greater (v); + } + + template + friend query + operator> (val_bind v, const query_column& c) + { + return c.less (v); + } + + friend query + operator> (const query_column& c, ref_bind r) + { + return c.greater (r); + } + + friend query + operator> (ref_bind r, const query_column& c) + { + return c.less (r); + } + + // <= + // + public: + query + less_equal (const T& v) const + { + return less_equal (val_bind (v)); + } + + query + less_equal (val_bind v) const + { + query q (name_); + q += "<="; + q.append (v); + return q; + } + + template + query + less_equal (val_bind v) const + { + copy_bind c (v.val); + return less_equal (c); + } + + query + less_equal (ref_bind r) const + { + query q (name_); + q += "<="; + q.append (r); + return q; + } + + friend query + operator<= (const query_column& c, const T& v) + { + return c.less_equal (v); + } + + friend query + operator<= (const T& v, const query_column& c) + { + return c.greater_equal (v); + } + + friend query + operator<= (const query_column& c, val_bind v) + { + return c.less_equal (v); + } + + friend query + operator<= (val_bind v, const query_column& c) + { + return c.greater_equal (v); + } + + template + friend query + operator<= (const query_column& c, val_bind v) + { + return c.less_equal (v); + } + + template + friend query + operator<= (val_bind v, const query_column& c) + { + return c.greater_equal (v); + } + + friend query + operator<= (const query_column& c, ref_bind r) + { + return c.less_equal (r); + } + + friend query + operator<= (ref_bind r, const query_column& c) + { + return c.greater_equal (r); + } + + // >= + // + public: + query + greater_equal (const T& v) const + { + return greater_equal (val_bind (v)); + } + + query + greater_equal (val_bind v) const + { + query q (name_); + q += ">="; + q.append (v); + return q; + } + + template + query + greater_equal (val_bind v) const + { + copy_bind c (v.val); + return greater_equal (c); + } + + query + greater_equal (ref_bind r) const + { + query q (name_); + q += ">="; + q.append (r); + return q; + } + + friend query + operator>= (const query_column& c, const T& v) + { + return c.greater_equal (v); + } + + friend query + operator>= (const T& v, const query_column& c) + { + return c.less_equal (v); + } + + friend query + operator>= (const query_column& c, val_bind v) + { + return c.greater_equal (v); + } + + friend query + operator>= (val_bind v, const query_column& c) + { + return c.less_equal (v); + } + + template + friend query + operator>= (const query_column& c, val_bind v) + { + return c.greater_equal (v); + } + + template + friend query + operator>= (val_bind v, const query_column& c) + { + return c.less_equal (v); + } + + friend query + operator>= (const query_column& c, ref_bind r) + { + return c.greater_equal (r); + } + + friend query + operator>= (ref_bind r, const query_column& c) + { + return c.less_equal (r); + } + + // Column comparison. + // + public: + template + query + operator== (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () == type_instance ())); + + query q (name_); + q += "="; + q += c.name (); + return q; + } + + template + query + operator!= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () != type_instance ())); + + query q (name_); + q += "!="; + q += c.name (); + return q; + } + + template + query + operator< (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () < type_instance ())); + + query q (name_); + q += "<"; + q += c.name (); + return q; + } + + template + query + operator> (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () > type_instance ())); + + query q (name_); + q += ">"; + q += c.name (); + return q; + } + + template + query + operator<= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () <= type_instance ())); + + query q (name_); + q += "<="; + q += c.name (); + return q; + } + + template + query + operator>= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (type_instance () >= type_instance ())); + + query q (name_); + q += ">="; + q += c.name (); + return q; + } + + private: + const char* name_; + }; + + // + // + template + struct query_param_impl; + + // INTEGER + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::integer; + b->buffer = &image_; + } + + private: + void + init (const T& v) + { + bool dummy; + value_traits::set_image (image_, dummy, v); + } + + private: + long long image_; + }; + + // REAL + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::real; + b->buffer = &image_; + } + + private: + void + init (const T& v) + { + bool dummy; + value_traits::set_image (image_, dummy, v); + } + + private: + double image_; + }; + + // TEXT + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + return init (*static_cast (value_)); + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::text; + b->buffer = buffer_.data (); + b->size = &size_; + } + + private: + bool + init (const T& v) + { + bool dummy; + std::size_t cap (buffer_.capacity ()); + value_traits::set_image ( + buffer_, size_, dummy, v); + return cap != buffer_.capacity (); + } + + private: + details::buffer buffer_; + std::size_t size_; + }; + + // BLOB + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + return init (*static_cast (value_)); + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::blob; + b->buffer = buffer_.data (); + b->size = &size_; + } + + private: + bool + init (const T& v) + { + bool dummy; + std::size_t cap (buffer_.capacity ()); + value_traits::set_image ( + buffer_, size_, dummy, v); + return cap != buffer_.capacity (); + } + + private: + details::buffer buffer_; + std::size_t size_; + }; + } +} + +// odb::query specialization for SQLite. +// +namespace odb +{ + template + class query: public object_traits::query_type + { + public: + // We don't define any typedefs here since they may clash with + // column names defined by our base type. + // + + query () + { + } + + explicit + query (const std::string& q) + : object_traits::query_type (q) + { + } + + template + explicit + query (sqlite::val_bind v) + : object_traits::query_type (sqlite::query (v)) + { + } + + template + explicit + query (sqlite::ref_bind r) + : object_traits::query_type (sqlite::query (r)) + { + } + + query (const sqlite::query& q) + : object_traits::query_type (q) + { + } + + template + query (const sqlite::query_column& qc) + : object_traits::query_type (qc) + { + } + }; +} + +#include +#include + +#include + +#endif // ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx new file mode 100644 index 0000000..f51da5a --- /dev/null +++ b/odb/sqlite/query.ixx @@ -0,0 +1,40 @@ +// file : odb/sqlite/query.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + inline binding& query:: + parameters_binding () const + { + return parameters_->binding (); + } + + inline details::shared_ptr query:: + parameters () const + { + return parameters_; + } + + template + inline void query:: + append (val_bind v) + { + add ( + details::shared_ptr ( + new (details::shared) query_param_impl (v))); + } + + template + inline void query:: + append (ref_bind r) + { + add ( + details::shared_ptr ( + new (details::shared) query_param_impl (r))); + } + } +} diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx new file mode 100644 index 0000000..3144348 --- /dev/null +++ b/odb/sqlite/query.txx @@ -0,0 +1,111 @@ +// file : odb/sqlite/query.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // query + // + + template + query:: + query (const query_column& c) + : clause_ (c.name ()), + parameters_ (new (details::shared) query_params) + { + // Cannot use IS TRUE here since database type can be a non- + // integral type. + // + clause_ += " = "; + append (val_bind (true)); + } + + // query_column + // + template + query query_column:: + in (const T& v1, const T& v2) const + { + query q (name_); + q += "IN ("; + q.append (val_bind (v1)); + q += ","; + q.append (val_bind (v2)); + q += ")"; + return q; + } + + template + query query_column:: + in (const T& v1, const T& v2, const T& v3) const + { + query q (name_); + q += "IN ("; + q.append (val_bind (v1)); + q += ","; + q.append (val_bind (v2)); + q += ","; + q.append (val_bind (v3)); + q += ")"; + return q; + } + + template + query query_column:: + in (const T& v1, const T& v2, const T& v3, const T& v4) const + { + query q (name_); + q += "IN ("; + q.append (val_bind (v1)); + q += ","; + q.append (val_bind (v2)); + q += ","; + q.append (val_bind (v3)); + q += ","; + q.append (val_bind (v4)); + q += ")"; + return q; + } + + template + query query_column:: + in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const + { + query q (name_); + q += "IN ("; + q.append (val_bind (v1)); + q += ","; + q.append (val_bind (v2)); + q += ","; + q.append (val_bind (v3)); + q += ","; + q.append (val_bind (v4)); + q += ","; + q.append (val_bind (v5)); + q += ")"; + return q; + } + + template + template + query query_column:: + in_range (I begin, I end) const + { + query q (name_); + q += "IN ("; + + for (I i (begin); i != end; ++i) + { + if (i != begin) + q += ","; + + q.append (val_bind (*i)); + } + q += ")"; + return q; + } + } +} diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx new file mode 100644 index 0000000..7e4116f --- /dev/null +++ b/odb/sqlite/result.cxx @@ -0,0 +1,18 @@ +// file : odb/sqlite/result.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + result_impl_base:: + result_impl_base (const query& q, details::shared_ptr s) + : params_ (q.parameters ()), statement_ (s) + { + } + } +} diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx new file mode 100644 index 0000000..187589e --- /dev/null +++ b/odb/sqlite/result.hxx @@ -0,0 +1,89 @@ +// file : odb/sqlite/result.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_RESULT_HXX +#define ODB_SQLITE_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class result_impl_base + { + public: + result_impl_base (const query&, details::shared_ptr); + + protected: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; + }; + + template + class result_impl: public odb::result_impl, public result_impl_base + { + public: + typedef typename odb::result_impl::pointer_type pointer_type; + typedef typename odb::result_impl::pointer_traits pointer_traits; + + typedef typename odb::result_impl::object_type object_type; + typedef typename odb::result_impl::id_type id_type; + typedef typename odb::result_impl::object_traits object_traits; + + + virtual + ~result_impl (); + + result_impl (const query&, + details::shared_ptr, + object_statements&); + + virtual void + load (object_type&); + + virtual id_type + load_id (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using odb::result_impl::current; + + private: + void + load_image (); + + private: + object_statements& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_RESULT_HXX diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx new file mode 100644 index 0000000..a7f00e0 --- /dev/null +++ b/odb/sqlite/result.txx @@ -0,0 +1,120 @@ +// file : odb/sqlite/result.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + template + result_impl:: + ~result_impl () + { + } + + template + result_impl:: + result_impl (const query& q, + details::shared_ptr st, + object_statements& sts) + : odb::result_impl (sts.connection ().database ()), + result_impl_base (q, st), + statements_ (sts) + { + } + + template + void result_impl:: + load (object_type& obj) + { + load_image (); + + // This is a top-level call so the statements cannot be locked. + // + assert (!statements_.locked ()); + typename object_statements::auto_lock l (statements_); + + typename object_traits::image_type& im (statements_.image ()); + object_traits::init (obj, im, this->database ()); + + // Initialize the id image and load the rest of the object + // (containers, etc). + // + object_traits::init (statements_.id_image (), object_traits::id (im)); + object_traits::load_ (statements_, obj); + + statements_.load_delayed (); + l.unlock (); + } + + template + typename result_impl::id_type result_impl:: + load_id () + { + load_image (); + return object_traits::id (statements_.image ()); + } + + template + void result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + this->end_ = true; + } + + template + void result_impl:: + load_image () + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.out_image_version ()) + { + binding& b (statements_.out_image_binding ()); + object_traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + object_traits::grow (im, statements_.out_image_truncated ()); + + if (im.version != statements_.out_image_version ()) + { + binding& b (statements_.out_image_binding ()); + object_traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); + b.version++; + statement_->reload (); + } + } + } + + template + void result_impl:: + cache () + { + } + + template + std::size_t result_impl:: + size () + { + // @@ Should we rather throw unsupported_operation or some such? + // + throw result_not_cached (); + } + } +} -- cgit v1.1 From acee0bb337fe1895a4d06166effccfbade095a1c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 14:15:11 +0200 Subject: Make queries without by-reference parameters immutable This makes it possible to share such queries between multiple threads without the need for synchronization. --- odb/sqlite/query.cxx | 78 +++++++++++++++++++++++++++++++++++----------------- odb/sqlite/query.hxx | 6 ++++ 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index a1c5b00..a97dff2 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -30,6 +30,18 @@ namespace odb : details::shared_base (x), params_ (x.params_), bind_ (x.bind_), binding_ (0, 0) { + // Here and below we want to maintain up to date binding info so + // that the call to binding() below is an immutable operation, + // provided the query does not have any by-reference parameters. + // This way a by-value-only query can be shared between multiple + // threads without the need for synchronization. + // + if (size_t n = bind_.size ()) + { + binding_.bind = &bind_[0]; + binding_.count = n; + binding_.version++; + } } query_params& query_params:: @@ -39,11 +51,48 @@ namespace odb { params_ = x.params_; bind_ = x.bind_; + + size_t n (bind_.size ()); + binding_.bind = n != 0 ? &bind_[0] : 0; + binding_.count = n; + binding_.version++; } return *this; } + query_params& query_params:: + operator+= (const query_params& x) + { + size_t n (bind_.size ()); + + params_.insert (params_.end (), x.params_.begin (), x.params_.end ()); + bind_.insert (bind_.end (), x.bind_.begin (), x.bind_.end ()); + + if (n != bind_.size ()) + { + binding_.bind = &bind_[0]; + binding_.count = bind_.size (); + binding_.version++; + } + + return *this; + } + + void query_params:: + add (details::shared_ptr p) + { + params_.push_back (p); + bind_.push_back (sqlite::bind ()); + binding_.bind = &bind_[0]; + binding_.count = bind_.size (); + binding_.version++; + + sqlite::bind* b (&bind_.back ()); + memset (b, 0, sizeof (sqlite::bind)); + p->bind (b); + } + query_params::binding_type& query_params:: binding () { @@ -51,18 +100,10 @@ namespace odb binding_type& r (binding_); if (n == 0) - return r; // r.bind and r.count should be 0. - - sqlite::bind* b (&bind_[0]); + return r; bool inc_ver (false); - - if (r.bind != b || r.count != n) - { - r.bind = b; - r.count = n; - inc_ver = true; - } + sqlite::bind* b (&bind_[0]); for (size_t i (0); i < n; ++i) { @@ -116,14 +157,7 @@ namespace odb clause_ += ' '; clause_ += q.clause_; - - query_params& p (*parameters_); - query_params& qp (*q.parameters_); - - p.params_.insert ( - p.params_.end (), qp.params_.begin (), qp.params_.end ()); - - p.bind_.insert (p.bind_.end (), qp.bind_.begin (), qp.bind_.end ()); + *parameters_ += *q.parameters_; return *this; } @@ -137,13 +171,7 @@ namespace odb clause_ += ' '; clause_ += '?'; - - parameters_->params_.push_back (p); - parameters_->bind_.push_back (sqlite::bind ()); - sqlite::bind* b (¶meters_->bind_.back ()); - memset (b, 0, sizeof (sqlite::bind)); - - p->bind (b); + parameters_->add (p); } std::string query:: diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 517fd2f..f694b2e 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -92,6 +92,12 @@ namespace odb query_params& operator= (const query_params&); + query_params& + operator+= (const query_params&); + + void + add (details::shared_ptr); + private: typedef std::vector > params; -- cgit v1.1 From 92349548ad2c2381d66ea2fc501b5466fed9789c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 16:52:35 +0200 Subject: Use forward-declared query class in result interface --- odb/sqlite/forward.hxx | 15 +++++++++++++-- odb/sqlite/query.hxx | 3 ++- odb/sqlite/result.cxx | 1 + odb/sqlite/result.hxx | 3 +-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index d141534..7688b9c 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -8,12 +8,12 @@ #include +#include + namespace odb { namespace sqlite { - // @@ Any garbage here? - // class database; class connection; class connection_factory; @@ -29,6 +29,17 @@ namespace odb template class container_statements; + + class query_params; + } + + namespace details + { + template <> + struct counter_type + { + typedef shared_base counter; + }; } } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index f694b2e..edf9222 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -76,8 +76,9 @@ namespace odb class query; - struct LIBODB_SQLITE_EXPORT query_params: details::shared_base + class LIBODB_SQLITE_EXPORT query_params: public details::shared_base { + public: typedef sqlite::binding binding_type; binding_type& diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx index 7e4116f..29afb3b 100644 --- a/odb/sqlite/result.cxx +++ b/odb/sqlite/result.cxx @@ -4,6 +4,7 @@ // license : GNU GPL v2; see accompanying LICENSE file #include +#include namespace odb { diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index 187589e..c49ddf1 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -13,8 +13,7 @@ #include #include -#include -#include +#include // query, query_params #include #include -- cgit v1.1 From 2fe2c22fa340e4854a69a1c17d94f8e58ba68ad4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 28 Mar 2011 09:53:10 +0200 Subject: Fix bugs in active/uncached list maintenance --- odb/sqlite/statement.hxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 2a629fe..5ddb56b 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -161,6 +161,9 @@ namespace odb { next_ = conn_.statements_; conn_.statements_ = this; + + if (next_ != 0) + next_->prev_ = this; } } @@ -173,9 +176,12 @@ namespace odb else { prev_->next_ = next_; - prev_ = 0; } + if (next_ != 0) + next_->prev_ = prev_; + + prev_ = 0; next_ = this; } } -- cgit v1.1 From 83aede3c9e27a8370c71dbde3549905c60524702 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Mar 2011 14:43:47 +0200 Subject: Add support for starting immediate and exclusive transactions --- odb/sqlite/database.cxx | 20 +++++++++++++++++++- odb/sqlite/database.hxx | 8 ++++++++ odb/sqlite/statement-cache.cxx | 22 +++++++++++++++++++--- odb/sqlite/statement-cache.hxx | 27 +++++++++++++++++++++++++++ odb/sqlite/transaction-impl.cxx | 23 +++++++++++++++++++++-- odb/sqlite/transaction-impl.hxx | 9 ++++++++- 6 files changed, 102 insertions(+), 7 deletions(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 176c392..912ec97 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -97,7 +97,25 @@ namespace odb if (transaction::has_current ()) throw already_in_transaction (); - return new transaction_impl (*this); + return new transaction_impl (*this, transaction_impl::deferred); + } + + transaction_impl* database:: + begin_immediate () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl (*this, transaction_impl::immediate); + } + + transaction_impl* database:: + begin_exclusive () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl (*this, transaction_impl::exclusive); } } } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 121f85c..cfff30f 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -78,6 +78,8 @@ namespace odb } public: + using odb::database::execute; + virtual unsigned long long execute (const char* statement, std::size_t length); @@ -85,6 +87,12 @@ namespace odb virtual transaction_impl* begin (); + transaction_impl* + begin_immediate (); + + transaction_impl* + begin_exclusive (); + public: details::shared_ptr connection (); diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 383a78e..ba7b56c 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -17,13 +17,29 @@ namespace odb // String lengths below include '\0', as per SQLite manual // suggestions. // - begin_ (new (shared) simple_statement (conn, "BEGIN", 6)), - commit_ (new (shared) simple_statement (conn, "COMMIT", 7)), - rollback_ (new (shared) simple_statement (conn, "ROLLBACK", 9)) + begin_ (new (shared) simple_statement (conn_, "BEGIN", 6)), + commit_ (new (shared) simple_statement (conn_, "COMMIT", 7)), + rollback_ (new (shared) simple_statement (conn_, "ROLLBACK", 9)) { rollback_->cached (true); commit_->cached (true); begin_->cached (true); } + + void statement_cache:: + begin_immediate_statement_ () const + { + begin_immediate_.reset ( + new (shared) simple_statement (conn_, "BEGIN IMMEDIATE", 16)); + begin_immediate_->cached (true); + } + + void statement_cache:: + begin_exclusive_statement_ () const + { + begin_exclusive_.reset ( + new (shared) simple_statement (conn_, "BEGIN EXCLUSIVE", 16)); + begin_exclusive_->cached (true); + } } } diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 1b3d4b2..ca4ab2e 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -38,6 +38,24 @@ namespace odb } simple_statement& + begin_immediate_statement () const + { + if (!begin_immediate_) + begin_immediate_statement_ (); + + return *begin_immediate_; + } + + simple_statement& + begin_exclusive_statement () const + { + if (!begin_exclusive_) + begin_exclusive_statement_ (); + + return *begin_exclusive_; + } + + simple_statement& commit_statement () const { return *commit_; @@ -66,6 +84,13 @@ namespace odb } private: + void + begin_immediate_statement_ () const; + + void + begin_exclusive_statement_ () const; + + private: typedef std::map, details::type_info_comparator> map; @@ -73,6 +98,8 @@ namespace odb connection& conn_; details::shared_ptr begin_; + mutable details::shared_ptr begin_immediate_; + mutable details::shared_ptr begin_exclusive_; details::shared_ptr commit_; details::shared_ptr rollback_; diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 36d6c2b..41254a1 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -14,10 +14,29 @@ namespace odb namespace sqlite { transaction_impl:: - transaction_impl (database_type& db) + transaction_impl (database_type& db, lock l) : odb::transaction_impl (db), connection_ (db.connection ()) { - connection_->statement_cache ().begin_statement ().execute (); + statement_cache& c (connection_->statement_cache ()); + + switch (l) + { + case deferred: + { + c.begin_statement ().execute (); + break; + } + case immediate: + { + c.begin_immediate_statement ().execute (); + break; + } + case exclusive: + { + c.begin_exclusive_statement ().execute (); + break; + } + } } transaction_impl:: diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index cc38039..3b09bcf 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -28,7 +28,14 @@ namespace odb typedef sqlite::database database_type; typedef sqlite::connection connection_type; - transaction_impl (database_type&); + enum lock + { + deferred, + immediate, + exclusive + }; + + transaction_impl (database_type&, lock); virtual ~transaction_impl (); -- cgit v1.1 From 2cdc08a9bcf807b4b908434c7bbe5439b0da3191 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Mar 2011 14:44:38 +0200 Subject: Update import stub with bug fix --- build/import/libsqlite/rules.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 4bc279b..e482f05 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -13,7 +13,7 @@ else $(dcf_root)/import/libsqlite/sqlite.l: $(libsqlite_root)/.libs/libsqlite3.so @echo $< >$@ - @echo rpath:$(root) >>$@ + @echo rpath:$(root)/.libs >>$@ endif $(dcf_root)/import/libsqlite/sqlite.l.cpp-options: -- cgit v1.1 From 7aadac132d8512e7ee63970561f40ade80772726 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Mar 2011 16:31:59 +0200 Subject: Support for shared cache and unlock notification --- odb/sqlite/connection-factory.cxx | 24 ++++++++++--- odb/sqlite/connection-factory.hxx | 12 ++++--- odb/sqlite/connection.cxx | 55 ++++++++++++++++++++++++++-- odb/sqlite/connection.hxx | 24 +++++++++++-- odb/sqlite/error.cxx | 11 +++++- odb/sqlite/makefile | 1 + odb/sqlite/statement.cxx | 75 ++++++++++++++++++++++++++++++++------- 7 files changed, 173 insertions(+), 29 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 4cae67f..11184bc 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -5,6 +5,7 @@ #include +#include #include using namespace std; @@ -31,13 +32,19 @@ namespace odb shared_ptr new_connection_factory:: connect () { - return shared_ptr (new (shared) connection (*db_)); + return shared_ptr ( + new (shared) connection (*db_, extra_flags_)); } void new_connection_factory:: database (database_type& db) { db_ = &db; + + // Unless explicitly disabled, enable shared cache. + // + if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) + extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; } // @@ -82,7 +89,7 @@ namespace odb if(max_ == 0 || in_use_ < max_) { shared_ptr c ( - new (shared) pooled_connection (*db_, this)); + new (shared) pooled_connection (*db_, extra_flags_, this)); in_use_++; return c; } @@ -100,6 +107,11 @@ namespace odb { db_ = &db; + // Unless explicitly disabled, enable shared cache. + // + if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) + extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; + if (min_ > 0) { connections_.reserve (min_); @@ -108,7 +120,7 @@ namespace odb { connections_.push_back ( shared_ptr ( - new (shared) pooled_connection (*db_, 0))); + new (shared) pooled_connection (*db_, extra_flags_, 0))); } } } @@ -143,8 +155,10 @@ namespace odb // connection_pool_factory::pooled_connection:: - pooled_connection (database_type& db, connection_pool_factory* pool) - : connection (db), pool_ (pool) + pooled_connection (database_type& db, + int extra_flags, + connection_pool_factory* pool) + : connection (db, extra_flags), pool_ (pool) { callback_.arg = this; callback_.zero_counter = &zero_counter; diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 6a42c8f..76bdc11 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -44,10 +44,7 @@ namespace odb public connection_factory { public: - new_connection_factory () - : db_ (0) - { - } + new_connection_factory (): db_ (0), extra_flags_ (0) {} virtual details::shared_ptr connect (); @@ -61,6 +58,7 @@ namespace odb private: database_type* db_; + int extra_flags_; }; class LIBODB_SQLITE_EXPORT connection_pool_factory: @@ -87,6 +85,7 @@ namespace odb std::size_t min_connections = 0) : max_ (max_connections), min_ (min_connections), + extra_flags_ (0), in_use_ (0), waiters_ (0), db_ (0), @@ -114,7 +113,9 @@ namespace odb public: // NULL pool value indicates that the connection is not in use. // - pooled_connection (database_type&, connection_pool_factory*); + pooled_connection (database_type&, + int extra_flags, + connection_pool_factory*); private: static bool @@ -139,6 +140,7 @@ namespace odb private: const std::size_t max_; const std::size_t min_; + int extra_flags_; std::size_t in_use_; // Number of connections currently in use. std::size_t waiters_; // Number of threads waiting for a connection. diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 9af5a3b..91b430a 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -7,14 +7,22 @@ #include #include +#include + #include #include #include #include #include +#include // deadlock + +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY using namespace std; +extern "C" void +odb_sqlite_connection_unlock_callback (void**, int); + namespace odb { namespace sqlite @@ -29,10 +37,10 @@ namespace odb } connection:: - connection (database_type& db) - : db_ (db), statements_ (0) + connection (database_type& db, int extra_flags) + : db_ (db), unlock_cond_ (unlock_mutex_), statements_ (0) { - int f (db.flags ()); + int f (db.flags () | extra_flags); const string& n (db.name ()); // If we are opening a temporary database, then add the create flag. @@ -57,6 +65,41 @@ namespace odb statement_cache_.reset (new statement_cache_type (*this)); } + inline void + connection_unlock_callback (void** args, int n) + { + for (int i (0); i < n; ++i) + { + connection* c (static_cast (args[i])); + details::lock l (c->unlock_mutex_); + c->unlocked_ = true; + c->unlock_cond_.signal (); + } + } + + void connection:: + wait () + { +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + unlocked_ = false; + + // unlock_notify() returns SQLITE_OK or SQLITE_LOCKED (deadlock). + // + int e (sqlite3_unlock_notify (handle_, + &odb_sqlite_connection_unlock_callback, + this)); + if (e == SQLITE_LOCKED) + throw deadlock (); + + details::lock l (unlock_mutex_); + + while (!unlocked_) + unlock_cond_.wait (); +#else + translate_error (SQLITE_LOCKED, *this); +#endif + } + void connection:: clear () { @@ -75,3 +118,9 @@ namespace odb } } } + +extern "C" void +odb_sqlite_connection_unlock_callback (void** args, int n) +{ + odb::sqlite::connection_unlock_callback (args, n); +} diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 5390609..3ae82e3 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -13,6 +13,8 @@ #include // std::auto_ptr #include +#include +#include #include #include @@ -35,7 +37,7 @@ namespace odb virtual ~connection (); - connection (database_type&); + connection (database_type&, int extra_flags = 0); database_type& database () @@ -56,6 +58,12 @@ namespace odb return *statement_cache_; } + // Wait for the locks to be released via unlock notification. Can + // be called after getting SQLITE_LOCKED_SHAREDCACHE. + // + void + wait (); + public: // Reset active and finalize uncached statements. // @@ -67,14 +75,24 @@ namespace odb connection& operator= (const connection&); private: - friend class statement; - database_type& db_; sqlite3* handle_; + // Unlock notification machinery. + // + private: + bool unlocked_; + details::mutex unlock_mutex_; + details::condition unlock_cond_; + + friend void + connection_unlock_callback (void**, int); + // Linked list of active and uncached statements currently associated // with this connection. // + private: + friend class statement; statement* statements_; std::auto_ptr statement_cache_; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index d223b4e..f84a6c0 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -39,8 +39,17 @@ namespace odb m = "SQLite API misuse"; break; } - case SQLITE_BUSY: case SQLITE_LOCKED: + { + if (ee != SQLITE_LOCKED_SHAREDCACHE) + throw deadlock (); // The DROP TABLE special case. + + // Getting SQLITE_LOCKED_SHAREDCACHE here means we don't have + // the unlock notify support. Translate this to timeout. + // + throw timeout (); + } + case SQLITE_BUSY: case SQLITE_IOERR: { if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 2d51d7d..feb62eb 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -73,6 +73,7 @@ $(out_base)/details/config.h: @echo '#ifndef ODB_SQLITE_DETAILS_CONFIG_H' >>$@ @echo '#define ODB_SQLITE_DETAILS_CONFIG_H' >>$@ @echo '' >>$@ + @echo '#define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1' >>$@ @echo '' >>$@ @echo '#endif /* ODB_SQLITE_DETAILS_CONFIG_H */' >>$@ diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 0975545..f503144 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -30,16 +30,19 @@ namespace odb void statement:: init (const char* s, std::size_t n) { - if (int e = sqlite3_prepare_v2 ( - conn_.handle (), - s, - static_cast (n), - &stmt_, - 0)) + int e; + while ((e = sqlite3_prepare_v2 (conn_.handle (), + s, + static_cast (n), + &stmt_, + 0)) == SQLITE_LOCKED) { - translate_error (e, conn_); + conn_.wait (); } + if (e != SQLITE_OK) + translate_error (e, conn_); + active_ = false; cached_ = false; @@ -194,8 +197,20 @@ namespace odb unsigned long long r (0); + // Only the first call to sqlite3_step() can return SQLITE_LOCKED. + // int e; - for (e = sqlite3_step (stmt_); e == SQLITE_ROW; e = sqlite3_step (stmt_)) + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } + + for (; e == SQLITE_ROW; e = sqlite3_step (stmt_)) r++; sqlite3_reset (stmt_); @@ -245,7 +260,16 @@ namespace odb { if (!done_) { - int e (sqlite3_step (stmt_)); + int e; + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } if (e != SQLITE_ROW) { @@ -292,7 +316,16 @@ namespace odb { bind_param (data_.bind, data_.count); - int e (sqlite3_step (stmt_)); + int e; + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } sqlite3_reset (stmt_); @@ -337,7 +370,16 @@ namespace odb bind_param (data_.bind, data_.count); bind_param (cond_.bind, cond_.count, data_.count); - int e (sqlite3_step (stmt_)); + int e; + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } sqlite3_reset (stmt_); @@ -362,7 +404,16 @@ namespace odb { bind_param (cond_.bind, cond_.count); - int e (sqlite3_step (stmt_)); + int e; + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } sqlite3_reset (stmt_); -- cgit v1.1 From 0db95154f2f063f6747d29c5c048bae933dcb7a1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Mar 2011 17:52:25 +0200 Subject: Release connection immediately after commit or rollback --- odb/sqlite/transaction-impl.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 41254a1..609a9c5 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -58,7 +58,7 @@ namespace odb // Release the connection. // - //connection_.reset (); + connection_.reset (); } void transaction_impl:: @@ -74,7 +74,7 @@ namespace odb // Release the connection. // - //connection_.reset (); + connection_.reset (); } } } -- cgit v1.1 From 163bb9d59de08b02074395fbb2a9fde5f8cc14d9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Mar 2011 17:53:00 +0200 Subject: Add single_connection_factory --- odb/sqlite/connection-factory.cxx | 61 +++++++++++++++++++++++++++++++++++++++ odb/sqlite/connection-factory.hxx | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 11184bc..fc9fefc 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -26,6 +26,67 @@ namespace odb } // + // single_connection_factory + // + + single_connection_factory:: + ~single_connection_factory () + { + // If the connection is currently in use, wait for it to return to + // the factory. + // + lock l (mutex_); + } + + shared_ptr single_connection_factory:: + connect () + { + mutex_.lock (); + connection_->factory_ = this; + shared_ptr r (connection_); + connection_.reset (); + return r; + } + + void single_connection_factory:: + database (database_type& db) + { + db_ = &db; + connection_.reset (new (shared) single_connection (*db_, 0, 0)); + } + + bool single_connection_factory:: + release (single_connection* c) + { + c->factory_ = 0; + connection_.reset (inc_ref (c)); + mutex_.unlock (); + return false; + } + + // + // single_connection_factory::single_connection + // + + single_connection_factory::single_connection:: + single_connection (database_type& db, + int extra_flags, + single_connection_factory* factory) + : connection (db, extra_flags), factory_ (factory) + { + callback_.arg = this; + callback_.zero_counter = &zero_counter; + shared_base::callback_ = &callback_; + } + + bool single_connection_factory::single_connection:: + zero_counter (void* arg) + { + single_connection* c (static_cast (arg)); + return c->factory_ ? c->factory_->release (c) : true; + } + + // // new_connection_factory // diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 76bdc11..e687e27 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -40,6 +40,64 @@ namespace odb ~connection_factory (); }; + // Share a single connection. + // + class LIBODB_SQLITE_EXPORT single_connection_factory: + public connection_factory + { + public: + single_connection_factory (): db_ (0) {} + + virtual details::shared_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~single_connection_factory (); + + private: + single_connection_factory (const single_connection_factory&); + single_connection_factory& operator= (const single_connection_factory&); + + private: + class single_connection: public connection + { + public: + // NULL factory value indicates that the connection is not in use. + // + single_connection (database_type&, + int extra_flags, + single_connection_factory*); + + private: + static bool + zero_counter (void*); + + private: + friend class single_connection_factory; + + shared_base::refcount_callback callback_; + single_connection_factory* factory_; + }; + + friend class single_connection; + + private: + // Return true if the connection should be deleted, false otherwise. + // + bool + release (single_connection*); + + private: + database_type* db_; + details::mutex mutex_; + details::shared_ptr connection_; + }; + + // Create a new connection every time one is requested. + // class LIBODB_SQLITE_EXPORT new_connection_factory: public connection_factory { @@ -61,6 +119,8 @@ namespace odb int extra_flags_; }; + // Pool a number of connections. + // class LIBODB_SQLITE_EXPORT connection_pool_factory: public connection_factory { -- cgit v1.1 From adc42a1c2661f0900345dd8a7c84879f76395651 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2011 13:08:19 +0200 Subject: Update to 1.2.0 in line with version.hxx --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 9084fa2..26aaba0 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1.0 +1.2.0 -- cgit v1.1 From 647492377897cf3b7d112d99e9a961a0f786a6b8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2011 13:08:56 +0200 Subject: Add autotools test for SQLite unlock notify feature --- configure.ac | 6 ++++++ m4/libsqlite.m4 | 22 ++++++++++++++++++++++ odb/sqlite/details/config.h.in | 1 + 3 files changed, 29 insertions(+) diff --git a/configure.ac b/configure.ac index c99dab6..269564d 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,12 @@ LIBSQLITE( [], [AC_MSG_ERROR([libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to specify its location])]) +AS_IF([test x$libsqlite_unlock_notify = xyes], +AC_DEFINE([LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY], [1], [Have sqlite3_unlock_notify.])) + +AS_IF([test x$threads != xnone -a x$libsqlite_unlock_notify = xno], +AC_MSG_WARN([libsqlite3 is built without sqlite3_unlock_notify support; multi-threaded support will be limited])) + # Check for libodb. # LIBODB([],[AC_MSG_ERROR([libodb is not found; consider using --with-libodb=DIR])]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 2ad9eb1..acb4fe3 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -5,9 +5,12 @@ dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) dnl +dnl Also sets libsqlite_unlock_notify to yes if sqlite3_unlock_notify() +dnl functionality is available. dnl AC_DEFUN([LIBSQLITE], [ libsqlite_found=no +libsqlite_unlock_notify=no AC_MSG_CHECKING([for libsqlite3]) @@ -37,6 +40,25 @@ if test x"$libsqlite_found" = xno; then LIBS="$save_LIBS" fi +# Check for unlock_notify. +# +if test x"$libsqlite_found" = xyes; then +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#include + +int +main () +{ + sqlite3* handle (0); + sqlite3_unlock_notify (handle, 0, 0); +} +]]), +[ +libsqlite_unlock_notify=yes +]) +fi + if test x"$libsqlite_found" = xyes; then AC_MSG_RESULT([yes]) $1 diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index ff8c029..7e3eb4a 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -10,5 +10,6 @@ #define ODB_SQLITE_DETAILS_CONFIG_H #undef LIBODB_SQLITE_STATIC_LIB +#undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY #endif /* ODB_SQLITE_DETAILS_CONFIG_H */ -- cgit v1.1 From 45131d371c965daf1debcf8d17c2a3b74b2a8633 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2011 16:10:01 +0200 Subject: Export result_impl_base --- odb/sqlite/result.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index c49ddf1..4f1cc2c 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -11,18 +11,18 @@ #include // std::size_t #include +#include #include #include // query, query_params #include - -#include +#include namespace odb { namespace sqlite { - class result_impl_base + class LIBODB_SQLITE_EXPORT result_impl_base { public: result_impl_base (const query&, details::shared_ptr); -- cgit v1.1 From 96f4d040e3b7008f2c8ae6aa30dca3e2f4cc2307 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2011 16:10:33 +0200 Subject: SQLite library name is sqlite3.lib, not sqlite.lib --- odb/sqlite/libodb-sqlite-vc10.vcxproj | 16 ++++++++-------- odb/sqlite/libodb-sqlite-vc9.vcproj | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj b/odb/sqlite/libodb-sqlite-vc10.vcxproj index db13085..974aa48 100644 --- a/odb/sqlite/libodb-sqlite-vc10.vcxproj +++ b/odb/sqlite/libodb-sqlite-vc10.vcxproj @@ -88,12 +88,12 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - odb-d.lib;sqlite.lib;%(AdditionalDependencies) + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) Windows true $(TargetPath) @@ -106,12 +106,12 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - odb-d.lib;sqlite.lib;%(AdditionalDependencies) + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) Windows true $(TargetPath) @@ -126,12 +126,12 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - odb.lib;sqlite.lib;%(AdditionalDependencies) + odb.lib;sqlite3.lib;%(AdditionalDependencies) Windows true true @@ -148,12 +148,12 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - odb.lib;sqlite.lib;%(AdditionalDependencies) + odb.lib;sqlite3.lib;%(AdditionalDependencies) Windows true true diff --git a/odb/sqlite/libodb-sqlite-vc9.vcproj b/odb/sqlite/libodb-sqlite-vc9.vcproj index dba87d8..1bcec78 100644 --- a/odb/sqlite/libodb-sqlite-vc9.vcproj +++ b/odb/sqlite/libodb-sqlite-vc9.vcproj @@ -46,7 +46,7 @@ AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -66,7 +66,7 @@ /> Date: Wed, 30 Mar 2011 16:17:04 +0200 Subject: Cosmetic change --- odb/sqlite/binding.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index 426195b..23a21df 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -31,7 +31,7 @@ namespace odb bind_type* bind; std::size_t count; - std::size_t version; // @@ Don't really need it (gen code). + std::size_t version; private: binding (const binding&); -- cgit v1.1 From ac50467b8a6d043d758dd49954fc6cf8d88ce134 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2011 14:22:18 +0200 Subject: Add error code to string returned by what() --- odb/sqlite/exceptions.cxx | 12 +++++++++++- odb/sqlite/exceptions.hxx | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 6801665..6bd8bb8 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + #include using namespace std; @@ -24,12 +26,20 @@ namespace odb database_exception (int e, int ee, const string& m) : error_ (e), extended_error_ (ee), message_ (m) { + ostringstream ostr; + ostr << error_; + + if (error_ != extended_error_) + ostr << " (" << extended_error_ << ")"; + + ostr << ": " << message_; + what_ = ostr.str (); } const char* database_exception:: what () const throw () { - return message_.c_str (); + return what_.c_str (); } // diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 5e783a5..cb08e8a 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -52,6 +52,7 @@ namespace odb int error_; int extended_error_; std::string message_; + std::string what_; }; struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception -- cgit v1.1 From 208cdb526b699c2059063a4f87baf1c94e15937b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2011 16:07:31 +0200 Subject: Add VC++ project/solution files for SQLite --- etc/sqlite/README | 30 +++ etc/sqlite/sqlite3-vc10.sln | 26 +++ etc/sqlite/sqlite3-vc10.vcxproj | 170 +++++++++++++++ etc/sqlite/sqlite3-vc10.vcxproj.filters | 23 ++ etc/sqlite/sqlite3-vc9.sln | 26 +++ etc/sqlite/sqlite3-vc9.vcproj | 367 ++++++++++++++++++++++++++++++++ makefile | 3 +- 7 files changed, 644 insertions(+), 1 deletion(-) create mode 100644 etc/sqlite/README create mode 100644 etc/sqlite/sqlite3-vc10.sln create mode 100644 etc/sqlite/sqlite3-vc10.vcxproj create mode 100644 etc/sqlite/sqlite3-vc10.vcxproj.filters create mode 100644 etc/sqlite/sqlite3-vc9.sln create mode 100644 etc/sqlite/sqlite3-vc9.vcproj diff --git a/etc/sqlite/README b/etc/sqlite/README new file mode 100644 index 0000000..c16c832 --- /dev/null +++ b/etc/sqlite/README @@ -0,0 +1,30 @@ +This directory contains project/solution files for building SQLite libraries +with Microsoft Visual Studio versions 9 and 10. + +To build SQLite, you will need to download two SQLite packages: sqlite- +amalgamation and sqlite-dll. Copy the sqlite3.c and sqlite3.h files from the +first package and the sqlite3.def file from the second package into the +directory with the project/solution files. Then open the solution and build +the desired configurations (Debug/Release) and platforms (Win32/x64). + +The resulting 32-bit DLLs and import libraries are placed into the bin\ and +lib\ sub-directories, respectively. Similarly, the 64-bit DLLs and import +libraries are placed into bin64\ and lib64\. The Release versions of the +import libraries are named sqlite3.lib and the Debug versions are named +sqlite3-d.lib. + +To configure Visual Studio to automatically locate the SQLite header, DLLs, +and import libraries, add the following paths to your VC++ Directories (below +sqlite refers to the build directory): + +Win32: + + Include: ...\sqlite + Library: ...\sqlite\lib + Executable: ...\sqlite\bin + +x64: + + Include: ...\sqlite + Library: ...\sqlite\lib64 + Executable: ...\sqlite\bin64 diff --git a/etc/sqlite/sqlite3-vc10.sln b/etc/sqlite/sqlite3-vc10.sln new file mode 100644 index 0000000..c9c0922 --- /dev/null +++ b/etc/sqlite/sqlite3-vc10.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc10.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/etc/sqlite/sqlite3-vc10.vcxproj b/etc/sqlite/sqlite3-vc10.vcxproj new file mode 100644 index 0000000..8d2ba96 --- /dev/null +++ b/etc/sqlite/sqlite3-vc10.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3409C5BB-974C-44FC-A9DB-2176837E9035} + Win32Proj + sqlite3 + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + bin\ + sqlite3-d + + + true + bin64\ + sqlite3-d + + + false + bin\ + sqlite3 + + + false + bin64\ + sqlite3 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + $(TargetPath) + lib\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + $(TargetPath) + lib64\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + true + true + $(TargetPath) + lib\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + true + true + $(TargetPath) + lib64\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + + + + + + diff --git a/etc/sqlite/sqlite3-vc10.vcxproj.filters b/etc/sqlite/sqlite3-vc10.vcxproj.filters new file mode 100644 index 0000000..13685a4 --- /dev/null +++ b/etc/sqlite/sqlite3-vc10.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/etc/sqlite/sqlite3-vc9.sln b/etc/sqlite/sqlite3-vc9.sln new file mode 100644 index 0000000..4206336 --- /dev/null +++ b/etc/sqlite/sqlite3-vc9.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc9.vcproj", "{6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.ActiveCfg = Debug|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.Build.0 = Debug|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.ActiveCfg = Debug|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.Build.0 = Debug|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.ActiveCfg = Release|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.Build.0 = Release|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.ActiveCfg = Release|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/etc/sqlite/sqlite3-vc9.vcproj b/etc/sqlite/sqlite3-vc9.vcproj new file mode 100644 index 0000000..9a698b7 --- /dev/null +++ b/etc/sqlite/sqlite3-vc9.vcproj @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/makefile b/makefile index 6112879..3904ece 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,8 @@ $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) $(dist): export docs := GPLv2 LICENSE README NEWS version -$(dist): data_dist := INSTALL libodb-sqlite-vc9.sln libodb-sqlite-vc10.sln +$(dist): data_dist := INSTALL libodb-sqlite-vc9.sln libodb-sqlite-vc10.sln \ +$(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) $(dist): export version = $(shell cat $(src_root)/version) -- cgit v1.1 From 98939a40b154e306649c2e5d053389571f3cbba4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2011 16:08:02 +0200 Subject: Update installation instructions --- INSTALL | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/INSTALL b/INSTALL index e69de29..fd17aff 100644 --- a/INSTALL +++ b/INSTALL @@ -0,0 +1,116 @@ +Prerequisites +============= + + - libodb http://www.codesynthesis.com/products/odb/ + - libsqlite3 http://www.sqlite.org + +If you plan to access an SQLite database from multiple threads, then +you will need SQLite version 3.5.0 or later built with the unlock +notify feature (SQLITE_ENABLE_UNLOCK_NOTIFY) enabled. + + +Building on UNIX +================ + +The following build instructions are for the Linux/UNIX/Mac OS X +operating systems as well as for Cygwin and MinGW on Windows. + +The standard autotools-based build system is used on these platforms. +After unpacking the source code archive, change to the libodb-sqlite +package directory (referred to as libodb-sqlite/ from now on) and run +the configure script: + +./configure + +To see the available configuration options run configure with --help: + +./configure --help + +The configure script expects the libodb and libsqlite3 headers and +libraries to be installed in a directory where the C++ compiler +and linker will search for them by default (normally /usr and +/usr/local). If these libraries are installed in other directories, +you can use the CPPFLAGS and LDFLAGS configure variables to specify +their locations, for example: + +./configure CPPFLAGS=-I/opt/libodb/include LDFLAGS=-L/opt/libodb/lib + +If libodb is not installed and you would like to use its build +directory instead, you can use the --with-libodb configure option +to specify its location, for example: + +./configure --with-libodb=/tmp/libodb + +As another example, the following configure command only builds shared +libraries, uses the specified C++ compiler, and compiles with optimization +and without debug information: + +./configure --disable-static CXX=g++-4.5 CXXFLAGS=-O3 + +Once configuration is complete, run make to build libodb-sqlite: + +make + +Once the build is completed successfully, you can install the libodb-sqlite +headers and libraries using the install target (you may need to do this +step as root depending on the installation directory): + +make install + + +Building on Windows +=================== + +The following build instructions are for Windows using Microsoft Visual +Studio. If you would like to build libodb-sqlite with GCC either using +Cygwin or MinGW, refer to the "Building on UNIX" section above. + +The standard Visual Studio project and solution files are used on this +platform. The provided project files expect the libodb and sqlite +header and import library directories to be in the VC++ Directories +Include and Library search lists. For libodb, see the INSTALL file in +the package directory for more information on how to setup the VC++ +Directories. + +The SQLite binary distribution for Windows contains only a 32-bit DLL +and it is built without unlock notify support. The provided libodb- +sqlite project files assume the unlock notify feature is available (you +can change this by manually removing the LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY +macro from the project's "Preprocessor Definitions" settings). The SQLite +source distribution for Windows lacks Visual Studio project/solution files. + +To rectify this situation, the libodb-sqlite distribution includes, in +the etc\sqlite\ directory, Visual Studio 9 and 10 project/solution files +for building 32 and 64-bit SQLite libraries with unlock notify support. +Refer to the accompanying README file for information on how to build the +libraries and configure VC++ Directories to automatically locate them. + +To build libodb-sqlite, unpack the source code archive and open the +libodb-sqlite-vc.sln file located in the libodb-sqlite package +directory (referred to as libodb-sqlite\ from now on). Here is the +version of Visual Studio that you are using. Once the solution is open, +select the desired build configuration (Debug or Release) and platform +(Win32 or x64) and build the solution. + +The resulting 32-bit DLLs and import libraries are placed into the +libodb-sqlite\bin\ and libodb-sqlite\lib\ directories, respectively. +Similarly, the 64-bit DLLs and import libraries are placed into +libodb-sqlite\bin64\ and libodb-sqlite\lib64\. The Release versions of +the import libraries are named odb-sqlite.lib and the Debug versions +are named odb-sqlite-d.lib. + +To configure Visual Studio to automatically locate the libodb-sqlite +headers, DLLs, and import libraries, add the following paths to your +VC++ Directories: + +Win32: + + Include: ...\libodb-sqlite + Library: ...\libodb-sqlite\lib + Executable: ...\libodb-sqlite\bin + +x64: + + Include: ...\libodb-sqlite + Library: ...\libodb-sqlite\lib64 + Executable: ...\libodb-sqlite\bin64 -- cgit v1.1 From 101bdca85c49e69c59b8e34d727a362a6f7f4625 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2011 16:12:50 +0200 Subject: Bump version to 1.3.0.b1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index c308e82..1b75ff6 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10200 +#if ODB_VERSION != 10251 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1020000 -#define LIBODB_SQLITE_VERSION_STR "1.2.0" +#define LIBODB_SQLITE_VERSION 1029951 +#define LIBODB_SQLITE_VERSION_STR "1.3.0.b1" #include diff --git a/version b/version index 26aaba0..c92d778 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.2.0 +1.3.0.b1 -- cgit v1.1 From 2afd1aa722a8c66079ae3941b192a0cd9bb01155 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Apr 2011 09:01:44 +0200 Subject: Cosmetic change --- odb/sqlite/result.txx | 2 -- 1 file changed, 2 deletions(-) diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx index a7f00e0..f104f6f 100644 --- a/odb/sqlite/result.txx +++ b/odb/sqlite/result.txx @@ -112,8 +112,6 @@ namespace odb std::size_t result_impl:: size () { - // @@ Should we rather throw unsupported_operation or some such? - // throw result_not_cached (); } } -- cgit v1.1 From 12da812979d06cc739d247f891abba4137cf9285 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Apr 2011 09:18:20 +0200 Subject: Bump version to 1.3.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 1b75ff6..483bddc 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10251 +#if ODB_VERSION != 10300 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1029951 -#define LIBODB_SQLITE_VERSION_STR "1.3.0.b1" +#define LIBODB_SQLITE_VERSION 1030000 +#define LIBODB_SQLITE_VERSION_STR "1.3.0" #include diff --git a/version b/version index c92d778..f0bb29e 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.3.0.b1 +1.3.0 -- cgit v1.1 From e04d780ade5f663de1b2314a73cf758db95af439 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Apr 2011 18:30:06 +0200 Subject: Get rid of image type argument in value_traits --- odb/sqlite/query.hxx | 10 ++++------ odb/sqlite/traits.cxx | 4 ++-- odb/sqlite/traits.hxx | 41 +++++++++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index edf9222..98189ab 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1059,7 +1059,7 @@ namespace odb init (const T& v) { bool dummy; - value_traits::set_image (image_, dummy, v); + value_traits::set_image (image_, dummy, v); } private: @@ -1093,7 +1093,7 @@ namespace odb init (const T& v) { bool dummy; - value_traits::set_image (image_, dummy, v); + value_traits::set_image (image_, dummy, v); } private: @@ -1128,8 +1128,7 @@ namespace odb { bool dummy; std::size_t cap (buffer_.capacity ()); - value_traits::set_image ( - buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, dummy, v); return cap != buffer_.capacity (); } @@ -1166,8 +1165,7 @@ namespace odb { bool dummy; std::size_t cap (buffer_.capacity ()); - value_traits::set_image ( - buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, dummy, v); return cap != buffer_.capacity (); } diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index de6c792..e73462a 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -17,7 +17,7 @@ namespace odb // default_value_traits // - void default_value_traits:: + void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, @@ -35,7 +35,7 @@ namespace odb // default_value_traits // - void default_value_traits:: + void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index e5ef318..2fdac04 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -30,26 +30,45 @@ namespace odb }; // + // image_traits + // + + template + struct image_traits; + + template <> + struct image_traits {typedef long long image_type;}; + + template <> + struct image_traits {typedef double image_type;}; + + template <> + struct image_traits {typedef details::buffer image_type;}; + + template <> + struct image_traits {typedef details::buffer image_type;}; + + // // value_traits // - template + template struct default_value_traits; - template - class value_traits: public default_value_traits + template + class value_traits: public default_value_traits { }; - template + template struct default_value_traits { typedef T value_type; typedef T query_type; - typedef I image_type; + typedef typename image_traits::image_type image_type; static void - set_value (T& v, I i, bool is_null) + set_value (T& v, const image_type& i, bool is_null) { if (!is_null) v = T (i); @@ -58,18 +77,17 @@ namespace odb } static void - set_image (I& i, bool& is_null, T v) + set_image (image_type& i, bool& is_null, T v) { is_null = false; - i = I (v); + i = image_type (v); } }; // std::string specialization. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits< - std::string, details::buffer, id_text> + struct LIBODB_SQLITE_EXPORT default_value_traits { typedef std::string value_type; typedef std::string query_type; @@ -101,8 +119,7 @@ namespace odb // we can pass such values to the queries. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits< - const char*, details::buffer, id_text> + struct LIBODB_SQLITE_EXPORT default_value_traits { typedef const char* value_type; typedef const char* query_type; -- cgit v1.1 From 523c0184c0360f6ba77819f90c90afd7a71d1370 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Apr 2011 14:07:32 +0200 Subject: Initial support for non-polymorphic inheritance Every class gets a separate table. New test: common/inheritance. --- odb/sqlite/result.txx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx index f104f6f..83dd4b0 100644 --- a/odb/sqlite/result.txx +++ b/odb/sqlite/result.txx @@ -89,7 +89,8 @@ namespace odb if (r == select_statement::truncated) { - object_traits::grow (im, statements_.out_image_truncated ()); + if (object_traits::grow (im, statements_.out_image_truncated ())) + im.version++; if (im.version != statements_.out_image_version ()) { -- cgit v1.1 From 177658c41d9949f7f327a714210835967a2e9d3e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Apr 2011 09:45:09 +0200 Subject: Check if truncation flag pointer is NULL before setting it --- odb/sqlite/statement.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index f503144..32e8d2a 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -121,7 +121,8 @@ namespace odb if (truncated && !*b.truncated) continue; - *b.truncated = false; + if (b.truncated) + *b.truncated = false; // Check for NULL unless we are reloading a truncated result. // @@ -154,7 +155,9 @@ namespace odb if (*b.size > b.capacity) { - *b.truncated = true; + if (b.truncated) + *b.truncated = true; + r = false; continue; } -- cgit v1.1 From c4d059b6346398e936dbc8c84d35c90aa4ec4253 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Apr 2011 09:46:59 +0200 Subject: Pass id binding instead of id image in container traits This will allow us to reuse things more. --- odb/sqlite/container-statements.hxx | 37 ++++++++++++++++++------------------- odb/sqlite/container-statements.txx | 6 +++--- odb/sqlite/forward.hxx | 1 + odb/sqlite/result.txx | 18 ++++++++++++++---- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 9bff64c..e0df250 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -32,7 +32,6 @@ namespace odb public: typedef T traits; - typedef typename traits::id_image_type id_image_type; typedef typename traits::data_image_type data_image_type; typedef typename traits::cond_image_type cond_image_type; @@ -60,18 +59,18 @@ namespace odb return functions_; } - // Id image (external). + // Id image binding (external). // - id_image_type& - id_image () + const binding& + id_binding () { - return *id_image_; + return *id_binding_; } void - id_image (id_image_type& i) + id_binding (const binding& b) { - id_image_ = &i; + id_binding_ = &b; } // Condition image. @@ -82,7 +81,7 @@ namespace odb return cond_image_; } - std::size_t + std::size_t cond_image_version () const { return cond_image_version_; @@ -95,15 +94,15 @@ namespace odb } std::size_t - cond_id_image_version () const + cond_id_binding_version () const { - return cond_id_image_version_; + return cond_id_binding_version_; } void - cond_id_image_version (std::size_t v) + cond_id_binding_version (std::size_t v) { - cond_id_image_version_ = v; + cond_id_binding_version_ = v; } binding& @@ -133,15 +132,15 @@ namespace odb } std::size_t - data_id_image_version () const + data_id_binding_version () const { - return data_id_image_version_; + return data_id_binding_version_; } void - data_id_image_version (std::size_t v) + data_id_binding_version (std::size_t v) { - data_id_image_version_ = v; + data_id_binding_version_ = v; } binding& @@ -216,17 +215,17 @@ namespace odb connection_type& conn_; functions_type functions_; - id_image_type* id_image_; + const binding* id_binding_; cond_image_type cond_image_; std::size_t cond_image_version_; - std::size_t cond_id_image_version_; + std::size_t cond_id_binding_version_; binding cond_image_binding_; bind cond_image_bind_[traits::cond_column_count]; data_image_type data_image_; std::size_t data_image_version_; - std::size_t data_id_image_version_; + std::size_t data_id_binding_version_; binding data_image_binding_; bind data_image_bind_[traits::data_column_count]; bool data_image_truncated_[traits::data_column_count]; diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index bfef187..15bd4a7 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -21,17 +21,17 @@ namespace odb &traits::insert_one, &traits::load_all, &traits::delete_all), - id_image_ (0), + id_binding_ (0), cond_image_binding_ (cond_image_bind_, traits::cond_column_count), data_image_binding_ (data_image_bind_, traits::data_column_count) { cond_image_.version = 0; cond_image_version_ = 0; - cond_id_image_version_ = 0; + cond_id_binding_version_ = 0; data_image_.version = 0; data_image_version_ = 0; - data_id_image_version_ = 0; + data_id_binding_version_ = 0; std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 7688b9c..63c3be4 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -22,6 +22,7 @@ namespace odb // Implementation details. // + class binding; class select_statement; template diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx index 83dd4b0..daf4d39 100644 --- a/odb/sqlite/result.txx +++ b/odb/sqlite/result.txx @@ -37,13 +37,23 @@ namespace odb assert (!statements_.locked ()); typename object_statements::auto_lock l (statements_); - typename object_traits::image_type& im (statements_.image ()); - object_traits::init (obj, im, this->database ()); + typename object_traits::image_type& i (statements_.image ()); + object_traits::init (obj, i, this->database ()); - // Initialize the id image and load the rest of the object + // Initialize the id image and binding and load the rest of the object // (containers, etc). // - object_traits::init (statements_.id_image (), object_traits::id (im)); + typename object_traits::id_image_type& idi (statements_.id_image ()); + object_traits::init (idi, object_traits::id (i)); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + object_traits::load_ (statements_, obj); statements_.load_delayed (); -- cgit v1.1 From 7a77db69c516415bfd8370c8b4d1e6bb1a4c5f60 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Apr 2011 11:29:06 +0200 Subject: Reuse container traits from base objects --- odb/sqlite/container-statements.hxx | 42 ++++++++++++++++++++++++++++++------- odb/sqlite/container-statements.txx | 34 ++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index e0df250..d67388d 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -24,7 +24,8 @@ namespace odb { class connection; - // Template argument is the generated container traits type. + // Template argument is the generated abstract container traits type. + // That is, it doesn't need to provide column counts and statements. // template class container_statements @@ -166,7 +167,7 @@ namespace odb { insert_one_.reset ( new (details::shared) insert_statement_type ( - conn_, traits::insert_one_statement, data_image_binding_)); + conn_, insert_one_text_, data_image_binding_)); insert_one_->cached (true); } @@ -182,7 +183,7 @@ namespace odb select_all_.reset ( new (details::shared) select_statement_type ( conn_, - traits::select_all_statement, + select_all_text_, cond_image_binding_, data_image_binding_)); @@ -199,7 +200,7 @@ namespace odb { delete_all_.reset ( new (details::shared) delete_statement_type ( - conn_, traits::delete_all_statement, cond_image_binding_)); + conn_, delete_all_text_, cond_image_binding_)); delete_all_->cached (true); } @@ -211,7 +212,7 @@ namespace odb container_statements (const container_statements&); container_statements& operator= (const container_statements&); - private: + protected: connection_type& conn_; functions_type functions_; @@ -221,19 +222,44 @@ namespace odb std::size_t cond_image_version_; std::size_t cond_id_binding_version_; binding cond_image_binding_; - bind cond_image_bind_[traits::cond_column_count]; + bind* cond_image_bind_; data_image_type data_image_; std::size_t data_image_version_; std::size_t data_id_binding_version_; binding data_image_binding_; - bind data_image_bind_[traits::data_column_count]; - bool data_image_truncated_[traits::data_column_count]; + bind* data_image_bind_; + bool* data_image_truncated_; + + const char* insert_one_text_; + const char* select_all_text_; + const char* delete_all_text_; details::shared_ptr insert_one_; details::shared_ptr select_all_; details::shared_ptr delete_all_; }; + + // Template argument is the generated concrete container traits type. + // + template + class container_statements_impl: public T::statements_type + { + public: + typedef T traits; + typedef typename T::statements_type base; + + container_statements_impl (connection&); + + private: + container_statements_impl (const container_statements_impl&); + container_statements_impl& operator= (const container_statements_impl&); + + private: + bind cond_image_bind_array_[traits::cond_column_count]; + bind data_image_bind_array_[traits::data_column_count]; + bool data_image_truncated_array_[traits::data_column_count]; + }; } } diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 15bd4a7..bad380c 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -22,8 +22,8 @@ namespace odb &traits::load_all, &traits::delete_all), id_binding_ (0), - cond_image_binding_ (cond_image_bind_, traits::cond_column_count), - data_image_binding_ (data_image_bind_, traits::data_column_count) + cond_image_binding_ (0, 0), // Initialized by impl. + data_image_binding_ (0, 0) // Initialized by impl. { cond_image_.version = 0; cond_image_version_ = 0; @@ -32,13 +32,35 @@ namespace odb data_image_.version = 0; data_image_version_ = 0; data_id_binding_version_ = 0; + } + + template + container_statements_impl:: + container_statements_impl (connection& conn) + : base (conn) + { + this->cond_image_bind_ = cond_image_bind_array_; + this->data_image_bind_ = data_image_bind_array_; + this->data_image_truncated_ = data_image_truncated_array_; - std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); - std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); - std::memset (data_image_truncated_, 0, sizeof (data_image_truncated_)); + this->cond_image_binding_.bind = this->cond_image_bind_; + this->cond_image_binding_.count = traits::cond_column_count; + + this->data_image_binding_.bind = this->data_image_bind_; + this->data_image_binding_.count = traits::data_column_count; + + std::memset (cond_image_bind_array_, 0, sizeof (cond_image_bind_array_)); + std::memset (data_image_bind_array_, 0, sizeof (data_image_bind_array_)); + std::memset (data_image_truncated_array_, + 0, + sizeof (data_image_truncated_array_)); for (std::size_t i (0); i < traits::data_column_count; ++i) - data_image_bind_[i].truncated = data_image_truncated_ + i; + data_image_bind_array_[i].truncated = data_image_truncated_array_ + i; + + this->insert_one_text_ = traits::insert_one_statement; + this->select_all_text_ = traits::select_all_statement; + this->delete_all_text_ = traits::delete_all_statement; } } } -- cgit v1.1 From be0768dbe6c46fe36b0edd0c7524be89eea00c95 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 26 Apr 2011 16:12:28 +0200 Subject: Bump version to 1.4.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 483bddc..92b02d2 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10300 +#if ODB_VERSION != 10400 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1030000 -#define LIBODB_SQLITE_VERSION_STR "1.3.0" +#define LIBODB_SQLITE_VERSION 1040000 +#define LIBODB_SQLITE_VERSION_STR "1.4.0" #include diff --git a/version b/version index f0bb29e..88c5fb8 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.3.0 +1.4.0 -- cgit v1.1 From db586a28c54a39ddfd2dcefab405320eca374869 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 Apr 2011 10:15:43 +0200 Subject: Work around VC++ bugs --- odb/sqlite/container-statements.hxx | 3 ++- odb/sqlite/container-statements.txx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index d67388d..db59ead 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -248,8 +248,9 @@ namespace odb public: typedef T traits; typedef typename T::statements_type base; + typedef sqlite::connection connection_type; - container_statements_impl (connection&); + container_statements_impl (connection_type&); private: container_statements_impl (const container_statements_impl&); diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index bad380c..5cf3463 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -36,7 +36,7 @@ namespace odb template container_statements_impl:: - container_statements_impl (connection& conn) + container_statements_impl (connection_type& conn) : base (conn) { this->cond_image_bind_ = cond_image_bind_array_; -- cgit v1.1 From 83c2af51a362a7b90c7a581aaf3763dc18695a37 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 30 Jun 2011 11:43:26 +0200 Subject: Check if truncated pointer is not NULL before dereferencing it --- odb/sqlite/statement.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 32e8d2a..0fe52f3 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -118,10 +118,10 @@ namespace odb const bind& b (p[i]); int j (static_cast (i)); - if (truncated && !*b.truncated) + if (truncated && (b.truncated == 0 || !*b.truncated)) continue; - if (b.truncated) + if (b.truncated != 0) *b.truncated = false; // Check for NULL unless we are reloading a truncated result. @@ -155,7 +155,7 @@ namespace odb if (*b.size > b.capacity) { - if (b.truncated) + if (b.truncated != 0) *b.truncated = true; r = false; -- cgit v1.1 From 4eceea6c547240df49697f9d22ccaf4e9101b915 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Jul 2011 17:53:47 +0200 Subject: Implement support for database operations callbacks New object pragma: callback. New test: common/callback. New manual section: 10.1.4, "callback". --- odb/sqlite/object-statements.hxx | 22 ++++++++++++++++++++++ odb/sqlite/object-statements.txx | 25 +++++++++++++++++++------ odb/sqlite/result.txx | 9 +++++++-- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 3ab627d..c181b17 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -377,6 +377,28 @@ namespace odb typedef std::vector delayed_loads; delayed_loads delayed_; + + // Delayed vectors swap guard. See the load_delayed_() function for + // details. + // + struct swap_guard + { + swap_guard (object_statements& os, delayed_loads& dl) + : os_ (os), dl_ (dl) + { + dl_.swap (os_.delayed_); + } + + ~swap_guard () + { + os_.clear_delayed (); + dl_.swap (os_.delayed_); + } + + private: + object_statements& os_; + delayed_loads& dl_; + }; }; } } diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 53a157f..0ae9886 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -7,6 +7,7 @@ #include // std::memset #include +#include #include #include @@ -43,22 +44,34 @@ namespace odb void object_statements:: load_delayed_ () { - // We should be careful here: the delayed vector can change - // from under us as a result of a recursive load. - // database& db (connection ().database ()); - while (!delayed_.empty ()) + delayed_loads dls; + swap_guard sg (*this, dls); + + while (!dls.empty ()) { - delayed_load l (delayed_.back ()); + delayed_load l (dls.back ()); typename object_cache_traits::insert_guard g (l.pos); - delayed_.pop_back (); + dls.pop_back (); if (!object_traits::find_ (*this, l.id)) throw object_not_persistent (); + object_traits::callback (db, *l.obj, callback_event::pre_load); + + // Our calls to init/load below can result in additional delayed + // loads being added to the delayed_ vector. We need to process + // those before we call the post callback. + // object_traits::init (*l.obj, image (), db); object_traits::load_ (*this, *l.obj); // Load containers, etc. + + if (!delayed_.empty ()) + load_delayed_ (); + + object_traits::callback (db, *l.obj, callback_event::post_load); + g.release (); } } diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx index daf4d39..728411d 100644 --- a/odb/sqlite/result.txx +++ b/odb/sqlite/result.txx @@ -3,6 +3,7 @@ // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include #include namespace odb @@ -37,8 +38,11 @@ namespace odb assert (!statements_.locked ()); typename object_statements::auto_lock l (statements_); + odb::database& db (this->database ()); + object_traits::callback (db, obj, callback_event::pre_load); + typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, this->database ()); + object_traits::init (obj, i, db); // Initialize the id image and binding and load the rest of the object // (containers, etc). @@ -55,8 +59,9 @@ namespace odb } object_traits::load_ (statements_, obj); - statements_.load_delayed (); + object_traits::callback (db, obj, callback_event::post_load); + l.unlock (); } -- cgit v1.1 From fd54e365ae793cff2ec746cedc57a642c20120f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Jul 2011 09:25:47 +0200 Subject: Bump version to 1.5.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 92b02d2..d3c3acb 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10400 +#if ODB_VERSION != 10500 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1040000 -#define LIBODB_SQLITE_VERSION_STR "1.4.0" +#define LIBODB_SQLITE_VERSION 1050000 +#define LIBODB_SQLITE_VERSION_STR "1.5.0" #include diff --git a/version b/version index 88c5fb8..bc80560 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.4.0 +1.5.0 -- cgit v1.1 From d32bbee7fdbad3eed60b8264d7950d10e4e36210 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 Jul 2011 17:00:11 +0200 Subject: Bump version to 1.6.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d3c3acb..158bb1a 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10500 +#if ODB_VERSION != 10600 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1050000 -#define LIBODB_SQLITE_VERSION_STR "1.5.0" +#define LIBODB_SQLITE_VERSION 1060000 +#define LIBODB_SQLITE_VERSION_STR "1.6.0" #include diff --git a/version b/version index bc80560..dc1e644 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.0 +1.6.0 -- cgit v1.1 From 37f5dcb1d34205aa4a395c1e21e853e363fd7f12 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jul 2011 09:45:36 +0200 Subject: Add value_traits specializations for std::vector This allows using it as a buffer for BLOB mapping. --- odb/sqlite/traits.cxx | 26 ++++++++++++++++++++++++++ odb/sqlite/traits.hxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index e73462a..96e201d 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -15,8 +15,10 @@ namespace odb { using details::buffer; + // // default_value_traits // + void default_value_traits:: set_image (buffer& b, size_t& n, @@ -33,8 +35,10 @@ namespace odb memcpy (b.data (), v.c_str (), n); } + // // default_value_traits // + void default_value_traits:: set_image (buffer& b, size_t& n, @@ -50,5 +54,27 @@ namespace odb if (n != 0) memcpy (b.data (), v, n); } + + // + // default_value_traits, id_blob> + // + + void default_value_traits, id_blob>:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b.data (), &v[0], n); + } } } diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 2fdac04..8863fb1 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -9,6 +9,7 @@ #include #include +#include #include // std::size_t #include @@ -132,6 +133,35 @@ namespace odb const char*); }; + // std::vector (buffer) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits, id_blob> + { + public: + typedef std::vector value_type; + typedef std::vector query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (b.data (), b.data () + n); + else + v.clear (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const value_type&); + }; + // // type_traits // -- cgit v1.1 From b6a0a7091ab7db75b84f101f96d8b38d5f781990 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 31 Jul 2011 16:48:36 +0200 Subject: Minor optimization --- odb/sqlite/traits.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 96e201d..62093e9 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -74,7 +74,7 @@ namespace odb // std::vector::data() may not be available in older compilers. // if (n != 0) - memcpy (b.data (), &v[0], n); + memcpy (b.data (), &v.front (), n); } } } -- cgit v1.1 From 7082f3a11bcbba197b8fbc3c825b58b8b3875345 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Aug 2011 13:29:42 +0200 Subject: Add support for value wrappers Wrapper is a class that wraps another type. Examples of wrappers are various smart pointers, holders, etc. A wrapper can be transparent or it can handle the NULL semantics. The new odb::nullable class template is a NULL wrapper that helps to add the NULL semantics to a value type. New test: common/wrapper. --- odb/sqlite/traits.hxx | 119 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 8863fb1..e2a4a4d 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -13,7 +13,10 @@ #include // std::size_t #include +#include + #include +#include #include #include @@ -53,12 +56,126 @@ namespace odb // value_traits // + template + struct wrapped_value_traits; + template struct default_value_traits; + template ::r> + struct select_traits; + + template + struct select_traits + { + typedef default_value_traits type; + }; + + template + struct select_traits + { + typedef + wrapped_value_traits::null_handler> + type; + }; + template - class value_traits: public default_value_traits + class value_traits: public select_traits::type + { + }; + + // The wrapped_value_traits specializations should be able to handle + // any value type which means we have to have every possible signature + // of the set_value() and set_image() functions. + // + template + struct wrapped_value_traits { + typedef wrapper_traits wtraits; + typedef typename wtraits::wrapped_type wrapped_type; + + typedef W value_type; + typedef wrapped_type query_type; + typedef typename image_traits::image_type image_type; + + typedef value_traits vtraits; + + static void + set_value (W& v, const image_type& i, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (image_type& i, bool& is_null, const W& v) + { + vtraits::set_image (i, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB. + // + static void + set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) + { + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } + }; + + template + struct wrapped_value_traits + { + typedef wrapper_traits wtraits; + typedef typename wtraits::wrapped_type wrapped_type; + + typedef W value_type; + typedef wrapped_type query_type; + typedef typename image_traits::image_type image_type; + + typedef value_traits vtraits; + + static void + set_value (W& v, const image_type& i, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (image_type& i, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (i, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB. + // + static void + set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } }; template -- cgit v1.1 From 35c3d273bbf1bd8c9c41ac1c3d91f150df0eb280 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Aug 2011 11:38:40 +0200 Subject: Fix custom recursive loading in post_load callback Before we called the callback while holding the statements locked. As a result, if the callback tried to load another object of this type, it failed. Now we unlock the statements (since we have completely loaded the object from ODB's point of view) and then call the callback. The callback test has been updated to test this situation. --- odb/sqlite/object-statements.hxx | 16 ++++++++++++++++ odb/sqlite/object-statements.ixx | 16 ++++++++++++++++ odb/sqlite/object-statements.txx | 13 ++++++++++++- odb/sqlite/result.txx | 3 +-- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index c181b17..c9c101d 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -72,6 +72,22 @@ namespace odb { } + struct auto_unlock + { + // Unlocks the statement on construction and re-locks it on + // destruction. + // + auto_unlock (object_statements_base&); + ~auto_unlock (); + + private: + auto_unlock (const auto_unlock&); + auto_unlock& operator= (const auto_unlock&); + + private: + object_statements_base& s_; + }; + protected: connection_type& conn_; bool locked_; diff --git a/odb/sqlite/object-statements.ixx b/odb/sqlite/object-statements.ixx index e1ae3ef..f629ea7 100644 --- a/odb/sqlite/object-statements.ixx +++ b/odb/sqlite/object-statements.ixx @@ -8,6 +8,22 @@ namespace odb namespace sqlite { // + // auto_unlock + // + inline object_statements_base::auto_unlock:: + auto_unlock (object_statements_base& s) + : s_ (s) + { + s_.unlock (); + } + + inline object_statements_base::auto_unlock:: + ~auto_unlock () + { + s_.lock (); + } + + // // auto_lock // template diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 0ae9886..9cd8344 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -70,7 +70,18 @@ namespace odb if (!delayed_.empty ()) load_delayed_ (); - object_traits::callback (db, *l.obj, callback_event::post_load); + // Temporarily unlock the statement for the post_load call so that + // it can load objects of this type recursively. This is safe to do + // because we have completely loaded the current object. Also the + // delayed_ list is clear before the unlock and should be clear on + // re-lock (since a callback can only call public API functions + // which will make sure all the delayed loads are processed before + // returning). + // + { + auto_unlock u (*this); + object_traits::callback (db, *l.obj, callback_event::post_load); + } g.release (); } diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx index 728411d..9bcfe5f 100644 --- a/odb/sqlite/result.txx +++ b/odb/sqlite/result.txx @@ -60,9 +60,8 @@ namespace odb object_traits::load_ (statements_, obj); statements_.load_delayed (); - object_traits::callback (db, obj, callback_event::post_load); - l.unlock (); + object_traits::callback (db, obj, callback_event::post_load); } template -- cgit v1.1 From 1bf4678c29b6e51396c18582b270254d1bd2cddc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Aug 2011 14:08:16 +0200 Subject: Rework query machinery not to use '_' as primary table alias Now we always qualify with the actual table name and use the '_' alias for situations where an object is referencing itself. --- odb/sqlite/query.cxx | 103 ++++++++++++++++++++++++++++++++++++++++----------- odb/sqlite/query.hxx | 97 ++++++++++++++++++++++++++++++------------------ odb/sqlite/query.txx | 17 +++++---- 3 files changed, 151 insertions(+), 66 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index a97dff2..4a2082b 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -150,41 +150,100 @@ namespace odb query& query:: operator+= (const query& q) { - size_t n (clause_.size ()); - - if (n != 0 && clause_[n - 1] != ' ' && - !q.clause_.empty () && q.clause_[0] != ' ') - clause_ += ' '; - - clause_ += q.clause_; + clause_.insert (clause_.end (), q.clause_.begin (), q.clause_.end ()); *parameters_ += *q.parameters_; - return *this; } void query:: - add (details::shared_ptr p) + append (const string& q, clause_part::kind_type k) { - size_t n (clause_.size ()); + if (k == clause_part::native && + !clause_.empty () && + clause_.back ().kind == clause_part::native) + { + string& s (clause_.back ().part); + + char first (!q.empty () ? q[0] : ' '); + char last (!s.empty () ? s[s.size () - 1] : ' '); - if (n != 0 && clause_[n - 1] != ' ') - clause_ += ' '; + // We don't want extra spaces after '(' as well as before ',' + // and ')'. + // + if (last != ' ' && last != '(' && + first != ' ' && first != ',' && first != ')') + s += ' '; - clause_ += '?'; + s += q; + } + else + clause_.push_back (clause_part (k, q)); + } + + void query:: + add (details::shared_ptr p) + { + clause_.push_back (clause_part (clause_part::param)); parameters_->add (p); } - std::string query:: - clause () const + string query:: + clause (string const& table) const { - if (clause_.empty () || - clause_.compare (0, 6, "WHERE ") == 0 || - clause_.compare (0, 9, "ORDER BY ") == 0 || - clause_.compare (0, 9, "GROUP BY ") == 0 || - clause_.compare (0, 7, "HAVING ") == 0) - return clause_; + string r; + + for (clause_type::const_iterator i (clause_.begin ()), + end (clause_.end ()); i != end; ++i) + { + char last (!r.empty () ? r[r.size () - 1] : ' '); + + switch (i->kind) + { + case clause_part::column: + { + if (last != ' ' && last != '(') + r += ' '; + + if (i->part[0] == '.') + r += table; + + r += i->part; + break; + } + case clause_part::param: + { + if (last != ' ' && last != '(') + r += ' '; + + r += '?'; + break; + } + case clause_part::native: + { + // We don't want extra spaces after '(' as well as before ',' + // and ')'. + // + const string& p (i->part); + char first (!p.empty () ? p[0] : ' '); + + if (last != ' ' && last != '(' && + first != ' ' && first != ',' && first != ')') + r += ' '; + + r += p; + break; + } + } + } + + if (r.empty () || + r.compare (0, 6, "WHERE ") == 0 || + r.compare (0, 9, "ORDER BY ") == 0 || + r.compare (0, 9, "GROUP BY ") == 0 || + r.compare (0, 7, "HAVING ") == 0) + return r; else - return "WHERE " + clause_; + return "WHERE " + r; } } } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 98189ab..3179bda 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -115,15 +115,33 @@ namespace odb class LIBODB_SQLITE_EXPORT query { public: + struct clause_part + { + enum kind_type + { + column, + param, + native + }; + + clause_part (kind_type k): kind (k) {} + clause_part (kind_type k, const std::string& p): kind (k), part (p) {} + + kind_type kind; + std::string part; + }; + query () : parameters_ (new (details::shared) query_params) { } explicit - query (const std::string& q) - : clause_ (q), parameters_ (new (details::shared) query_params) + query (const std::string& q, + clause_part::kind_type k = clause_part::native) + : parameters_ (new (details::shared) query_params) { + clause_.push_back (clause_part (k, q)); } template @@ -152,7 +170,7 @@ namespace odb public: std::string - clause () const; + clause (std::string const& default_table) const; binding& parameters_binding () const; @@ -182,12 +200,7 @@ namespace odb query& operator+= (const std::string& q) { - size_t n (clause_.size ()); - - if (n != 0 && clause_[n - 1] != ' ' && !q.empty () && q[0] != ' ') - clause_ += ' '; - - clause_ += q; + append (q, clause_part::native); return *this; } @@ -216,12 +229,17 @@ namespace odb void append (ref_bind); + void + append (const std::string&, clause_part::kind_type); + private: void add (details::shared_ptr); private: - std::string clause_; + typedef std::vector clause_type; + + clause_type clause_; details::shared_ptr parameters_; }; @@ -394,7 +412,7 @@ namespace odb query is_null () const { - query q (name_); + query q (name_, query::clause_part::column); q += "IS NULL"; return q; } @@ -402,7 +420,7 @@ namespace odb query is_not_null () const { - query q (name_); + query q (name_, query::clause_part::column); q += "IS NOT NULL"; return q; } @@ -438,7 +456,7 @@ namespace odb query equal (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += "="; q.append (v); return q; @@ -455,7 +473,7 @@ namespace odb query equal (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += "="; q.append (r); return q; @@ -523,7 +541,7 @@ namespace odb query unequal (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += "!="; q.append (v); return q; @@ -540,7 +558,7 @@ namespace odb query unequal (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += "!="; q.append (r); return q; @@ -608,7 +626,7 @@ namespace odb query less (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += "<"; q.append (v); return q; @@ -625,7 +643,7 @@ namespace odb query less (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += "<"; q.append (r); return q; @@ -693,7 +711,7 @@ namespace odb query greater (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += ">"; q.append (v); return q; @@ -710,7 +728,7 @@ namespace odb query greater (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += ">"; q.append (r); return q; @@ -778,7 +796,7 @@ namespace odb query less_equal (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += "<="; q.append (v); return q; @@ -795,7 +813,7 @@ namespace odb query less_equal (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += "<="; q.append (r); return q; @@ -863,7 +881,7 @@ namespace odb query greater_equal (val_bind v) const { - query q (name_); + query q (name_, query::clause_part::column); q += ">="; q.append (v); return q; @@ -880,7 +898,7 @@ namespace odb query greater_equal (ref_bind r) const { - query q (name_); + query q (name_, query::clause_part::column); q += ">="; q.append (r); return q; @@ -947,9 +965,9 @@ namespace odb // (void) (sizeof (type_instance () == type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += "="; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -961,9 +979,9 @@ namespace odb // (void) (sizeof (type_instance () != type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += "!="; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -975,9 +993,9 @@ namespace odb // (void) (sizeof (type_instance () < type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += "<"; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -989,9 +1007,9 @@ namespace odb // (void) (sizeof (type_instance () > type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += ">"; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -1003,9 +1021,9 @@ namespace odb // (void) (sizeof (type_instance () <= type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += "<="; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -1017,9 +1035,9 @@ namespace odb // (void) (sizeof (type_instance () >= type_instance ())); - query q (name_); + query q (name_, query::clause_part::column); q += ">="; - q += c.name (); + q.append (c.name (), query::clause_part::column); return q; } @@ -1222,6 +1240,13 @@ namespace odb : object_traits::query_type (qc) { } + + std::string + clause () const + { + return object_traits::query_type::clause ( + object_traits::table_name); + } }; } diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 3144348..6af80e7 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -13,13 +13,14 @@ namespace odb template query:: query (const query_column& c) - : clause_ (c.name ()), - parameters_ (new (details::shared) query_params) + : parameters_ (new (details::shared) query_params) { + clause_.push_back (clause_part (clause_part::column, c.name ())); + // Cannot use IS TRUE here since database type can be a non- // integral type. // - clause_ += " = "; + clause_.push_back (clause_part (clause_part::native, "=")); append (val_bind (true)); } @@ -29,7 +30,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -42,7 +43,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -57,7 +58,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -74,7 +75,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -94,7 +95,7 @@ namespace odb query query_column:: in_range (I begin, I end) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; for (I i (begin); i != end; ++i) -- cgit v1.1 From 5694c0a4529334756f2b914ad67408df199551dc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 21 Aug 2011 16:27:34 +0200 Subject: Add odb::connection class This abstract class represents a connection to the database. One can use it to start a transaction or to execute a native statement out of a transaction. Before we had concrete connection classes in the database runtime libraries (e.g., odb::mysql::connection). Now these classes derive from odb::connection. --- odb/sqlite/connection-factory.cxx | 10 ++++----- odb/sqlite/connection-factory.hxx | 8 ++++---- odb/sqlite/connection.cxx | 43 ++++++++++++++++++++++++++++++++++++++- odb/sqlite/connection.hxx | 23 ++++++++++++++++++++- odb/sqlite/database.cxx | 41 ++++--------------------------------- odb/sqlite/database.hxx | 21 +++++++++---------- odb/sqlite/database.ixx | 26 +++++++++++++++++++++-- odb/sqlite/forward.hxx | 7 +++++++ odb/sqlite/transaction-impl.cxx | 12 +++++------ odb/sqlite/transaction-impl.hxx | 6 +++--- 10 files changed, 127 insertions(+), 70 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index fc9fefc..71f8b3e 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -38,12 +38,12 @@ namespace odb lock l (mutex_); } - shared_ptr single_connection_factory:: + connection_ptr single_connection_factory:: connect () { mutex_.lock (); connection_->factory_ = this; - shared_ptr r (connection_); + connection_ptr r (connection_); connection_.reset (); return r; } @@ -90,10 +90,10 @@ namespace odb // new_connection_factory // - shared_ptr new_connection_factory:: + connection_ptr new_connection_factory:: connect () { - return shared_ptr ( + return connection_ptr ( new (shared) connection (*db_, extra_flags_)); } @@ -126,7 +126,7 @@ namespace odb } } - shared_ptr connection_pool_factory:: + connection_ptr connection_pool_factory:: connect () { lock l (mutex_); diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index e687e27..8166fc4 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -27,7 +27,7 @@ namespace odb class LIBODB_SQLITE_EXPORT connection_factory { public: - virtual details::shared_ptr + virtual connection_ptr connect () = 0; public: @@ -48,7 +48,7 @@ namespace odb public: single_connection_factory (): db_ (0) {} - virtual details::shared_ptr + virtual connection_ptr connect (); virtual void @@ -104,7 +104,7 @@ namespace odb public: new_connection_factory (): db_ (0), extra_flags_ (0) {} - virtual details::shared_ptr + virtual connection_ptr connect (); virtual void @@ -154,7 +154,7 @@ namespace odb // @@ check min_ <= max_ } - virtual details::shared_ptr + virtual connection_ptr connect (); virtual void diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 91b430a..d90c301 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,10 @@ namespace odb connection:: connection (database_type& db, int extra_flags) - : db_ (db), unlock_cond_ (unlock_mutex_), statements_ (0) + : odb::connection (db), + db_ (db), + unlock_cond_ (unlock_mutex_), + statements_ (0) { int f (db.flags () | extra_flags); const string& n (db.name ()); @@ -65,6 +69,43 @@ namespace odb statement_cache_.reset (new statement_cache_type (*this)); } + transaction_impl* connection:: + begin () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::deferred); + } + + transaction_impl* connection:: + begin_immediate () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::immediate); + } + + transaction_impl* connection:: + begin_exclusive () + { + if (transaction::has_current ()) + throw already_in_transaction (); + + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::exclusive); + } + + unsigned long long connection:: + execute (const char* s, std::size_t n) + { + simple_statement st (*this, s, n); + return st.execute (); + } + inline void connection_unlock_callback (void** args, int n) { diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 3ae82e3..e069ce9 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -13,12 +13,14 @@ #include // std::auto_ptr #include +#include #include #include #include #include #include +#include #include namespace odb @@ -28,7 +30,10 @@ namespace odb class statement; class statement_cache; - class LIBODB_SQLITE_EXPORT connection: public details::shared_base + class connection; + typedef details::shared_ptr connection_ptr; + + class LIBODB_SQLITE_EXPORT connection: public odb::connection { public: typedef sqlite::statement_cache statement_cache_type; @@ -46,6 +51,22 @@ namespace odb } public: + virtual transaction_impl* + begin (); + + transaction_impl* + begin_immediate (); + + transaction_impl* + begin_exclusive (); + + public: + using odb::connection::execute; + + virtual unsigned long long + execute (const char* statement, std::size_t length); + + public: sqlite3* handle () { diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 912ec97..e756608 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -6,10 +6,8 @@ #include #include -#include #include #include -#include #include #include @@ -80,42 +78,11 @@ namespace odb details::options::print_usage (os); } - unsigned long long database:: - execute (const char* s, std::size_t n) + odb::connection* database:: + connection_ () { - if (!transaction::has_current ()) - throw not_in_transaction (); - - connection_type& c (transaction::current ().connection ()); - simple_statement st (c, s, n); - return st.execute (); - } - - transaction_impl* database:: - begin () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::deferred); - } - - transaction_impl* database:: - begin_immediate () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::immediate); - } - - transaction_impl* database:: - begin_exclusive () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::exclusive); + connection_ptr c (factory_->connect ()); + return c.release (); } } } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index cfff30f..0eadbbf 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -28,12 +28,11 @@ namespace odb { namespace sqlite { + class transaction_impl; + class LIBODB_SQLITE_EXPORT database: public odb::database { public: - typedef sqlite::connection connection_type; - - public: database (const std::string& name, int flags = SQLITE_OPEN_READWRITE, std::auto_ptr = @@ -77,14 +76,10 @@ namespace odb return flags_; } + // Transactions. + // public: - using odb::database::execute; - - virtual unsigned long long - execute (const char* statement, std::size_t length); - - public: - virtual transaction_impl* + transaction_impl* begin (); transaction_impl* @@ -94,13 +89,17 @@ namespace odb begin_exclusive (); public: - details::shared_ptr + connection_ptr connection (); public: virtual ~database (); + protected: + virtual odb::connection* + connection_ (); + private: std::string name_; int flags_; diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 7e34e01..f78d659 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -7,10 +7,32 @@ namespace odb { namespace sqlite { - inline details::shared_ptr database:: + inline connection_ptr database:: connection () { - return factory_->connect (); + // Go through the virtual connection_() function instead of + // directly to allow overriding. + // + return connection_ptr ( + static_cast (connection_ ())); + } + + inline transaction_impl* database:: + begin () + { + return connection ()->begin (); + } + + inline transaction_impl* database:: + begin_immediate () + { + return connection ()->begin_immediate (); + } + + inline transaction_impl* database:: + begin_exclusive () + { + return connection ()->begin_exclusive (); } } } diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 63c3be4..a4e3376 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -16,6 +16,7 @@ namespace odb { class database; class connection; + typedef details::shared_ptr connection_ptr; class connection_factory; class transaction; class query; @@ -37,6 +38,12 @@ namespace odb namespace details { template <> + struct counter_type + { + typedef shared_base counter; + }; + + template <> struct counter_type { typedef shared_base counter; diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 609a9c5..772b274 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -14,26 +14,26 @@ namespace odb namespace sqlite { transaction_impl:: - transaction_impl (database_type& db, lock l) - : odb::transaction_impl (db), connection_ (db.connection ()) + transaction_impl (connection_ptr c, lock l) + : odb::transaction_impl (c->database (), *c), connection_ (c) { - statement_cache& c (connection_->statement_cache ()); + statement_cache& sc (connection_->statement_cache ()); switch (l) { case deferred: { - c.begin_statement ().execute (); + sc.begin_statement ().execute (); break; } case immediate: { - c.begin_immediate_statement ().execute (); + sc.begin_immediate_statement ().execute (); break; } case exclusive: { - c.begin_exclusive_statement ().execute (); + sc.begin_exclusive_statement ().execute (); break; } } diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 3b09bcf..8b5687b 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -22,7 +22,7 @@ namespace odb class LIBODB_SQLITE_EXPORT transaction_impl: public odb::transaction_impl { protected: - friend class database; + friend class connection; friend class transaction; typedef sqlite::database database_type; @@ -35,7 +35,7 @@ namespace odb exclusive }; - transaction_impl (database_type&, lock); + transaction_impl (connection_ptr, lock); virtual ~transaction_impl (); @@ -50,7 +50,7 @@ namespace odb connection (); private: - details::shared_ptr connection_; + connection_ptr connection_; }; } } -- cgit v1.1 From 5a69eecefb4f5d29d7ab76f81e69ab27d85586cf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2011 10:47:30 +0200 Subject: Enable foreign key constraints checking in SQLite Due to bugs in SQLite DDL foreign key support, we have to temporarily disable foreign keys when re-creating the schema. New manual section: 12.5.3, "Foreign Key Constraints". --- odb/sqlite/connection.cxx | 10 ++++++++++ odb/sqlite/database.cxx | 9 +++++++-- odb/sqlite/database.hxx | 9 +++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index d90c301..ffb70a7 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -66,6 +66,16 @@ namespace odb translate_error (e, *this); } + // Enable/disable foreign key constraints. + // + simple_statement st ( + *this, + db.foreign_keys () + ? "PRAGMA foreign_keys=ON" + : "PRAGMA foreign_keys=OFF", + db.foreign_keys () ? 22 : 23); + st.execute (); + statement_cache_.reset (new statement_cache_type (*this)); } diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index e756608..6ce4621 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -27,8 +27,12 @@ namespace odb database:: database (const string& name, int flags, + bool foreign_keys, auto_ptr factory) - : name_ (name), flags_ (flags), factory_ (factory) + : name_ (name), + flags_ (flags), + foreign_keys_ (foreign_keys), + factory_ (factory) { if (factory_.get () == 0) factory_.reset (new connection_pool_factory ()); @@ -41,8 +45,9 @@ namespace odb char* argv[], bool erase, int flags, + bool foreign_keys, std::auto_ptr factory) - : flags_ (flags), factory_ (factory) + : flags_ (flags), foreign_keys_ (foreign_keys), factory_ (factory) { using namespace details; diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 0eadbbf..13c44e6 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -35,6 +35,7 @@ namespace odb public: database (const std::string& name, int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, std::auto_ptr = std::auto_ptr (0)); @@ -56,6 +57,7 @@ namespace odb char* argv[], bool erase = false, int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, std::auto_ptr = std::auto_ptr (0)); @@ -76,6 +78,12 @@ namespace odb return flags_; } + bool + foreign_keys () const + { + return foreign_keys_; + } + // Transactions. // public: @@ -103,6 +111,7 @@ namespace odb private: std::string name_; int flags_; + bool foreign_keys_; std::auto_ptr factory_; }; } -- cgit v1.1 From 80c9352bdb197cea6a1fddc9f9e623c06e5d71ce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2011 14:59:10 +0200 Subject: Bump version to 1.6.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 158bb1a..2b69750 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10600 +#if ODB_VERSION != 10501 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1060000 -#define LIBODB_SQLITE_VERSION_STR "1.6.0" +#define LIBODB_SQLITE_VERSION 1059901 +#define LIBODB_SQLITE_VERSION_STR "1.6.0.a1" #include diff --git a/version b/version index dc1e644..f715635 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.6.0 +1.6.0.a1 -- cgit v1.1 From 7392db256c1587ff8fe87d95c5ae5c10f854f79e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Aug 2011 13:42:04 +0200 Subject: Add support for transaction multiplexing Also delay getting a connection until after we do all the sanity checks (e.g., that there is no active transaction). Otherwise we are running risk of getting blocked rather than throwing an exception. --- odb/sqlite/connection.cxx | 9 --------- odb/sqlite/database.cxx | 18 ++++++++++++++++++ odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 18 ------------------ odb/sqlite/transaction-impl.cxx | 35 ++++++++++++++++++++++++++++------- odb/sqlite/transaction-impl.hxx | 10 ++++++---- odb/sqlite/transaction.hxx | 5 +++++ odb/sqlite/transaction.ixx | 6 ++++++ 8 files changed, 64 insertions(+), 39 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index ffb70a7..1e9ff6f 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -82,9 +82,6 @@ namespace odb transaction_impl* connection:: begin () { - if (transaction::has_current ()) - throw already_in_transaction (); - return new transaction_impl ( connection_ptr (inc_ref (this)), transaction_impl::deferred); } @@ -92,9 +89,6 @@ namespace odb transaction_impl* connection:: begin_immediate () { - if (transaction::has_current ()) - throw already_in_transaction (); - return new transaction_impl ( connection_ptr (inc_ref (this)), transaction_impl::immediate); } @@ -102,9 +96,6 @@ namespace odb transaction_impl* connection:: begin_exclusive () { - if (transaction::has_current ()) - throw already_in_transaction (); - return new transaction_impl ( connection_ptr (inc_ref (this)), transaction_impl::exclusive); } diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 6ce4621..04f788b 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -83,6 +83,24 @@ namespace odb details::options::print_usage (os); } + transaction_impl* database:: + begin () + { + return new transaction_impl (*this, transaction_impl::deferred); + } + + transaction_impl* database:: + begin_immediate () + { + return new transaction_impl (*this, transaction_impl::immediate); + } + + transaction_impl* database:: + begin_exclusive () + { + return new transaction_impl (*this, transaction_impl::exclusive); + } + odb::connection* database:: connection_ () { diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 13c44e6..348f236 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -87,7 +87,7 @@ namespace odb // Transactions. // public: - transaction_impl* + virtual transaction_impl* begin (); transaction_impl* diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index f78d659..e7ae208 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -16,23 +16,5 @@ namespace odb return connection_ptr ( static_cast (connection_ ())); } - - inline transaction_impl* database:: - begin () - { - return connection ()->begin (); - } - - inline transaction_impl* database:: - begin_immediate () - { - return connection ()->begin_immediate (); - } - - inline transaction_impl* database:: - begin_exclusive () - { - return connection ()->begin_exclusive (); - } } } diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 772b274..b425ed8 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -14,12 +14,38 @@ namespace odb namespace sqlite { transaction_impl:: + transaction_impl (database_type& db, lock l) + : odb::transaction_impl (db), lock_ (l) + { + } + + transaction_impl:: transaction_impl (connection_ptr c, lock l) - : odb::transaction_impl (c->database (), *c), connection_ (c) + : odb::transaction_impl (c->database (), *c), + connection_ (c), + lock_ (l) + { + } + + transaction_impl:: + ~transaction_impl () + { + } + + void transaction_impl:: + start () { + // Grab a connection if we don't already have one. + // + if (connection_ == 0) + { + connection_ = static_cast (database_).connection (); + odb::transaction_impl::connection_ = connection_.get (); + } + statement_cache& sc (connection_->statement_cache ()); - switch (l) + switch (lock_) { case deferred: { @@ -39,11 +65,6 @@ namespace odb } } - transaction_impl:: - ~transaction_impl () - { - } - void transaction_impl:: commit () { diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 8b5687b..f0df824 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -21,10 +21,7 @@ namespace odb { class LIBODB_SQLITE_EXPORT transaction_impl: public odb::transaction_impl { - protected: - friend class connection; - friend class transaction; - + public: typedef sqlite::database database_type; typedef sqlite::connection connection_type; @@ -35,12 +32,16 @@ namespace odb exclusive }; + transaction_impl (database_type&, lock); transaction_impl (connection_ptr, lock); virtual ~transaction_impl (); virtual void + start (); + + virtual void commit (); virtual void @@ -51,6 +52,7 @@ namespace odb private: connection_ptr connection_; + lock lock_; }; } } diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index aecf8aa..b30a818 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -45,6 +45,11 @@ namespace odb static transaction& current (); + // Set the current thread's transaction. + // + static void + current (transaction&); + public: transaction_impl& implementation (); diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index f2c9cc8..e8a6594 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -37,5 +37,11 @@ namespace odb { return implementation ().connection (); } + + inline void transaction:: + current (transaction& t) + { + odb::transaction::current (t); + } } } -- cgit v1.1 From b9764c3eb6626fb96deb0901b9ee63c2246ff52e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2011 16:07:38 +0200 Subject: Add support for creating connection from existing handle This will allow for custom connection establishment and configuration. --- odb/sqlite/connection.cxx | 23 +++++++++++++++++++++-- odb/sqlite/connection.hxx | 5 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 1e9ff6f..68b57f9 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -66,16 +66,35 @@ namespace odb translate_error (e, *this); } + init (); + } + + connection:: + connection (database_type& db, sqlite3* handle) + : odb::connection (db), + db_ (db), + handle_ (handle), + unlock_cond_ (unlock_mutex_), + statements_ (0) + { + init (); + } + + void connection:: + init () + { // Enable/disable foreign key constraints. // simple_statement st ( *this, - db.foreign_keys () + db_.foreign_keys () ? "PRAGMA foreign_keys=ON" : "PRAGMA foreign_keys=OFF", - db.foreign_keys () ? 22 : 23); + db_.foreign_keys () ? 22 : 23); st.execute (); + // Create statement cache. + // statement_cache_.reset (new statement_cache_type (*this)); } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index e069ce9..e487e6b 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -43,6 +43,7 @@ namespace odb ~connection (); connection (database_type&, int extra_flags = 0); + connection (database_type&, sqlite3* handle); database_type& database () @@ -96,6 +97,10 @@ namespace odb connection& operator= (const connection&); private: + void + init (); + + private: database_type& db_; sqlite3* handle_; -- cgit v1.1 From 282cdfe67cc9f9763868abf9aeb0d97e52c06d63 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2011 16:53:54 +0200 Subject: Add create() hook to connection factories This will allow the user to either establish the connection themselves (using the handle c-tor) and/or configure the connection post-creation. --- odb/sqlite/connection-factory.cxx | 59 +++++++++++++++++++++++++++------------ odb/sqlite/connection-factory.hxx | 52 ++++++++++++++++++++++------------ 2 files changed, 75 insertions(+), 36 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 71f8b3e..358fa0c 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -38,6 +38,13 @@ namespace odb lock l (mutex_); } + single_connection_factory::single_connection_ptr + single_connection_factory:: + create () + { + return single_connection_ptr (new (shared) single_connection (*db_, 0)); + } + connection_ptr single_connection_factory:: connect () { @@ -52,7 +59,7 @@ namespace odb database (database_type& db) { db_ = &db; - connection_.reset (new (shared) single_connection (*db_, 0, 0)); + connection_ = create (); } bool single_connection_factory:: @@ -69,10 +76,17 @@ namespace odb // single_connection_factory::single_connection:: - single_connection (database_type& db, - int extra_flags, - single_connection_factory* factory) - : connection (db, extra_flags), factory_ (factory) + single_connection (database_type& db, int extra_flags) + : connection (db, extra_flags), factory_ (0) + { + callback_.arg = this; + callback_.zero_counter = &zero_counter; + shared_base::callback_ = &callback_; + } + + single_connection_factory::single_connection:: + single_connection (database_type& db, sqlite3* handle) + : connection (db, handle), factory_ (0) { callback_.arg = this; callback_.zero_counter = &zero_counter; @@ -112,6 +126,13 @@ namespace odb // connection_pool_factory // + connection_pool_factory::pooled_connection_ptr connection_pool_factory:: + create () + { + return pooled_connection_ptr ( + new (shared) pooled_connection (*db_, extra_flags_)); + } + connection_pool_factory:: ~connection_pool_factory () { @@ -149,8 +170,8 @@ namespace odb // if(max_ == 0 || in_use_ < max_) { - shared_ptr c ( - new (shared) pooled_connection (*db_, extra_flags_, this)); + shared_ptr c (create ()); + c->pool_ = this; in_use_++; return c; } @@ -178,11 +199,7 @@ namespace odb connections_.reserve (min_); for(size_t i (0); i < min_; ++i) - { - connections_.push_back ( - shared_ptr ( - new (shared) pooled_connection (*db_, extra_flags_, 0))); - } + connections_.push_back (create ()); } } @@ -202,8 +219,7 @@ namespace odb in_use_--; if (keep) - connections_.push_back ( - shared_ptr (inc_ref (c))); + connections_.push_back (pooled_connection_ptr (inc_ref (c))); if (waiters_ != 0) cond_.signal (); @@ -216,10 +232,17 @@ namespace odb // connection_pool_factory::pooled_connection:: - pooled_connection (database_type& db, - int extra_flags, - connection_pool_factory* pool) - : connection (db, extra_flags), pool_ (pool) + pooled_connection (database_type& db, int extra_flags) + : connection (db, extra_flags), pool_ (0) + { + callback_.arg = this; + callback_.zero_counter = &zero_counter; + shared_base::callback_ = &callback_; + } + + connection_pool_factory::pooled_connection:: + pooled_connection (database_type& db, sqlite3* handle) + : connection (db, handle), pool_ (0) { callback_.arg = this; callback_.zero_counter = &zero_counter; diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 8166fc4..04f91bf 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -61,15 +61,12 @@ namespace odb single_connection_factory (const single_connection_factory&); single_connection_factory& operator= (const single_connection_factory&); - private: + protected: class single_connection: public connection { public: - // NULL factory value indicates that the connection is not in use. - // - single_connection (database_type&, - int extra_flags, - single_connection_factory*); + single_connection (database_type&, int extra_flags); + single_connection (database_type&, sqlite3*); private: static bool @@ -79,21 +76,32 @@ namespace odb friend class single_connection_factory; shared_base::refcount_callback callback_; + + // NULL factory value indicates that the connection is not in use. + // single_connection_factory* factory_; }; friend class single_connection; - private: + typedef details::shared_ptr single_connection_ptr; + + // This function is called when the factory needs to create the + // connection. + // + virtual single_connection_ptr + create (); + + protected: // Return true if the connection should be deleted, false otherwise. // bool release (single_connection*); - private: + protected: database_type* db_; details::mutex mutex_; - details::shared_ptr connection_; + single_connection_ptr connection_; }; // Create a new connection every time one is requested. @@ -167,15 +175,12 @@ namespace odb connection_pool_factory (const connection_pool_factory&); connection_pool_factory& operator= (const connection_pool_factory&); - private: + protected: class pooled_connection: public connection { public: - // NULL pool value indicates that the connection is not in use. - // - pooled_connection (database_type&, - int extra_flags, - connection_pool_factory*); + pooled_connection (database_type&, int extra_flags); + pooled_connection (database_type&, sqlite3*); private: static bool @@ -185,19 +190,30 @@ namespace odb friend class connection_pool_factory; shared_base::refcount_callback callback_; + + // NULL pool value indicates that the connection is not in use. + // connection_pool_factory* pool_; }; friend class pooled_connection; - typedef std::vector > connections; - private: + typedef details::shared_ptr pooled_connection_ptr; + typedef std::vector connections; + + // This function is called whenever the pool needs to create a new + // connection. + // + virtual pooled_connection_ptr + create (); + + protected: // Return true if the connection should be deleted, false otherwise. // bool release (pooled_connection*); - private: + protected: const std::size_t max_; const std::size_t min_; int extra_flags_; -- cgit v1.1 From 8568cd25d943636e33ec00a935ad8a67d4876e14 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Aug 2011 09:14:11 +0200 Subject: Add default value for extra_flags argument --- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 358fa0c..f200a17 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -42,7 +42,7 @@ namespace odb single_connection_factory:: create () { - return single_connection_ptr (new (shared) single_connection (*db_, 0)); + return single_connection_ptr (new (shared) single_connection (*db_)); } connection_ptr single_connection_factory:: diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 04f91bf..94cd227 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -65,7 +65,7 @@ namespace odb class single_connection: public connection { public: - single_connection (database_type&, int extra_flags); + single_connection (database_type&, int extra_flags = 0); single_connection (database_type&, sqlite3*); private: @@ -179,7 +179,7 @@ namespace odb class pooled_connection: public connection { public: - pooled_connection (database_type&, int extra_flags); + pooled_connection (database_type&, int extra_flags = 0); pooled_connection (database_type&, sqlite3*); private: -- cgit v1.1 From 1c1544f5297f88bbbcbbad2d21c4ec7b62bb9a28 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Aug 2011 16:10:02 +0200 Subject: Implement uniform handle management across all databases Also use the auto_handle template instead of the raw handle in connection, statement, and result classes. This removes a lot of brittle "exception safety guarantee" code that we had in those classes. --- odb/sqlite/auto-handle.hxx | 103 +++++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/connection.cxx | 20 ++++----- odb/sqlite/connection.hxx | 11 +++-- odb/sqlite/statement.cxx | 5 ++- odb/sqlite/statement.hxx | 11 ++--- 5 files changed, 129 insertions(+), 21 deletions(-) create mode 100644 odb/sqlite/auto-handle.hxx diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx new file mode 100644 index 0000000..60b1ea9 --- /dev/null +++ b/odb/sqlite/auto-handle.hxx @@ -0,0 +1,103 @@ +// file : odb/sqlite/auto-handle.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_AUTO_HANDLE_HXX +#define ODB_SQLITE_AUTO_HANDLE_HXX + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + struct handle_traits; + + template <> + struct handle_traits + { + static void + release (sqlite3* h) + { + if (sqlite3_close (h) == SQLITE_BUSY) + { + // Connection has outstanding prepared statements. + // + assert (false); + } + } + }; + + template <> + struct handle_traits + { + static void + release (sqlite3_stmt* h) + { + sqlite3_finalize (h); + } + }; + + template + class auto_handle + { + public: + auto_handle (H* h = 0) + : h_ (h) + { + } + + ~auto_handle () + { + if (h_ != 0) + handle_traits::release (h_); + } + + H* + get () const + { + return h_; + } + + void + reset (H* h = 0) + { + if (h_ != 0) + handle_traits::release (h_); + + h_ = h; + } + + H* + release () + { + H* h (h_); + h_ = 0; + return h; + } + + operator H* () + { + return h_; + } + + private: + auto_handle (const auto_handle&); + auto_handle& operator= (const auto_handle&); + + private: + H* h_; + }; + } +} + +#include + +#endif // ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 68b57f9..7b16547 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -29,15 +29,6 @@ namespace odb namespace sqlite { connection:: - ~connection () - { - statement_cache_.reset (); // Free prepared statements. - - if (sqlite3_close (handle_) == SQLITE_BUSY) - assert (false); // Connection has outstanding prepared statements. - } - - connection:: connection (database_type& db, int extra_flags) : odb::connection (db), db_ (db), @@ -58,7 +49,11 @@ namespace odb if ((f & SQLITE_OPEN_FULLMUTEX) == 0) f |= SQLITE_OPEN_NOMUTEX; - if (int e = sqlite3_open_v2 (n.c_str (), &handle_, f, 0)) + sqlite3* h (0); + int e (sqlite3_open_v2 (n.c_str (), &h, f, 0)); + handle_.reset (h); + + if (e != SQLITE_OK) { if (handle_ == 0) throw bad_alloc (); @@ -98,6 +93,11 @@ namespace odb statement_cache_.reset (new statement_cache_type (*this)); } + connection:: + ~connection () + { + } + transaction_impl* connection:: begin () { diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index e487e6b..c1133eb 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -21,6 +21,8 @@ #include #include #include +#include + #include namespace odb @@ -102,7 +104,12 @@ namespace odb private: database_type& db_; - sqlite3* handle_; + auto_handle handle_; + + // Keep statement_cache_ after handle_ so that it is destroyed before + // the connection is closed. + // + std::auto_ptr statement_cache_; // Unlock notification machinery. // @@ -120,8 +127,6 @@ namespace odb private: friend class statement; statement* statements_; - - std::auto_ptr statement_cache_; }; } } diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 0fe52f3..d0020d5 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -31,10 +31,11 @@ namespace odb init (const char* s, std::size_t n) { int e; + sqlite3_stmt* stmt (0); while ((e = sqlite3_prepare_v2 (conn_.handle (), s, static_cast (n), - &stmt_, + &stmt, 0)) == SQLITE_LOCKED) { conn_.wait (); @@ -43,6 +44,8 @@ namespace odb if (e != SQLITE_OK) translate_error (e, conn_); + stmt_.reset (stmt); + active_ = false; cached_ = false; diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 5ddb56b..1d48cd4 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -20,6 +20,8 @@ #include #include #include +#include + #include namespace odb @@ -131,19 +133,14 @@ namespace odb finilize () { list_remove (); - - if (stmt_ != 0) - { - sqlite3_finalize (stmt_); - stmt_ = 0; - } + stmt_.reset (); } protected: friend class connection; connection& conn_; - sqlite3_stmt* stmt_; + auto_handle stmt_; bool active_; bool cached_; -- cgit v1.1 From 4ee004a6de190316d5ff2fb8bfe0f28b33d74e7f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Aug 2011 16:19:42 +0200 Subject: Add comment with some explanations --- odb/sqlite/connection.hxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index c1133eb..4ad4f42 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -103,7 +103,11 @@ namespace odb init (); private: + // Needed to break the circular connection-database dependency + // (odb::connection has the odb::database member). + // database_type& db_; + auto_handle handle_; // Keep statement_cache_ after handle_ so that it is destroyed before -- cgit v1.1 From 7d3f2b0badf4298bca53936d22a0a22c74538713 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Sep 2011 14:57:40 +0200 Subject: Allow select statement without parameters --- odb/sqlite/statement.cxx | 15 +++++++++++++-- odb/sqlite/statement.hxx | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index d0020d5..6417b3a 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -239,7 +239,15 @@ namespace odb const string& s, binding& cond, binding& data) - : statement (conn, s), cond_ (cond), data_ (data) + : statement (conn, s), cond_ (&cond), data_ (data) + { + } + + select_statement:: + select_statement (connection& conn, + const string& s, + binding& data) + : statement (conn, s), cond_ (0), data_ (data) { } @@ -250,7 +258,10 @@ namespace odb reset (); done_ = false; - bind_param (cond_.bind, cond_.count); + + if (cond_ != 0) + bind_param (cond_->bind, cond_->count); + active (true); } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 1d48cd4..69f5a95 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -216,6 +216,10 @@ namespace odb binding& cond, binding& data); + select_statement (connection& conn, + const std::string& statement, + binding& data); + // Common select interface expected by the generated code. // public: @@ -273,7 +277,7 @@ namespace odb private: bool done_; - binding& cond_; + binding* cond_; binding& data_; }; -- cgit v1.1 From 1b1cb92a27592da6ab9300b2c5c8384f7588e2af Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Sep 2011 16:54:06 +0200 Subject: Support for views; native part --- odb/sqlite/forward.hxx | 3 + odb/sqlite/makefile | 1 + odb/sqlite/object-result.hxx | 77 ++++++++++++++++++++++ odb/sqlite/object-result.txx | 136 +++++++++++++++++++++++++++++++++++++++ odb/sqlite/object-statements.hxx | 26 +++----- odb/sqlite/object-statements.txx | 6 ++ odb/sqlite/query.hxx | 16 ++--- odb/sqlite/result.hxx | 59 ++++------------- odb/sqlite/result.txx | 133 -------------------------------------- odb/sqlite/statement-cache.hxx | 24 ++++++- odb/sqlite/statements-base.cxx | 17 +++++ odb/sqlite/statements-base.hxx | 51 +++++++++++++++ odb/sqlite/view-result.hxx | 69 ++++++++++++++++++++ odb/sqlite/view-result.txx | 96 +++++++++++++++++++++++++++ odb/sqlite/view-statements.hxx | 113 ++++++++++++++++++++++++++++++++ odb/sqlite/view-statements.txx | 35 ++++++++++ 16 files changed, 656 insertions(+), 206 deletions(-) create mode 100644 odb/sqlite/object-result.hxx create mode 100644 odb/sqlite/object-result.txx delete mode 100644 odb/sqlite/result.txx create mode 100644 odb/sqlite/statements-base.cxx create mode 100644 odb/sqlite/statements-base.hxx create mode 100644 odb/sqlite/view-result.hxx create mode 100644 odb/sqlite/view-result.txx create mode 100644 odb/sqlite/view-statements.hxx create mode 100644 odb/sqlite/view-statements.txx diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index a4e3376..5203434 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -30,6 +30,9 @@ namespace odb class object_statements; template + class view_statements; + + template class container_statements; class query_params; diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index feb62eb..e9115a7 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -16,6 +16,7 @@ query.cxx \ result.cxx \ statement-cache.cxx \ statement.cxx \ +statements-base.cxx \ traits.cxx \ transaction.cxx \ transaction-impl.cxx diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx new file mode 100644 index 0000000..b3dbf2b --- /dev/null +++ b/odb/sqlite/object-result.hxx @@ -0,0 +1,77 @@ +// file : odb/sqlite/object-result.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_OBJECT_RESULT_HXX +#define ODB_SQLITE_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include +#include // query, object_statements +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class result_impl: + public odb::result_impl, + public result_impl_base + { + public: + typedef odb::result_impl base_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename base_type::object_type object_type; + typedef typename base_type::id_type id_type; + typedef typename base_type::object_traits object_traits; + + virtual + ~result_impl (); + + result_impl (const query&, + details::shared_ptr, + object_statements&); + + virtual void + load (object_type&); + + virtual id_type + load_id (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + void + load_image (); + + private: + object_statements& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx new file mode 100644 index 0000000..7675262 --- /dev/null +++ b/odb/sqlite/object-result.txx @@ -0,0 +1,136 @@ +// file : odb/sqlite/object-result.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + result_impl:: + ~result_impl () + { + } + + template + result_impl:: + result_impl (const query& q, + details::shared_ptr statement, + object_statements& statements) + : base_type (statements.connection ().database ()), + result_impl_base (q, statement), + statements_ (statements) + { + } + + template + void result_impl:: + load (object_type& obj) + { + load_image (); + + // This is a top-level call so the statements cannot be locked. + // + assert (!statements_.locked ()); + typename object_statements::auto_lock l (statements_); + + odb::database& db (this->database ()); + object_traits::callback (db, obj, callback_event::pre_load); + + typename object_traits::image_type& i (statements_.image ()); + object_traits::init (obj, i, db); + + // Initialize the id image and binding and load the rest of the object + // (containers, etc). + // + typename object_traits::id_image_type& idi (statements_.id_image ()); + object_traits::init (idi, object_traits::id (i)); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + + object_traits::load_ (statements_, obj); + statements_.load_delayed (); + l.unlock (); + object_traits::callback (db, obj, callback_event::post_load); + } + + template + typename result_impl::id_type + result_impl:: + load_id () + { + load_image (); + return object_traits::id (statements_.image ()); + } + + template + void result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + this->end_ = true; + } + + template + void result_impl:: + load_image () + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.out_image_version ()) + { + binding& b (statements_.out_image_binding ()); + object_traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (object_traits::grow (im, statements_.out_image_truncated ())) + im.version++; + + if (im.version != statements_.out_image_version ()) + { + binding& b (statements_.out_image_binding ()); + object_traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); + b.version++; + statement_->reload (); + } + } + } + + template + void result_impl:: + cache () + { + } + + template + std::size_t result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index c9c101d..4816d66 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -15,31 +15,23 @@ #include #include #include + #include #include #include #include +#include + #include namespace odb { namespace sqlite { - class connection; - - class LIBODB_SQLITE_EXPORT object_statements_base: - public details::shared_base + class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base { public: - typedef sqlite::connection connection_type; - - connection_type& - connection () - { - return conn_; - } - // Locking. // void @@ -68,7 +60,7 @@ namespace odb protected: object_statements_base (connection_type& conn) - : conn_ (conn), locked_ (false) + : statements_base (conn), locked_ (false) { } @@ -89,7 +81,6 @@ namespace odb }; protected: - connection_type& conn_; bool locked_; }; @@ -150,10 +141,13 @@ namespace odb bool locked_; }; - // - // + + public: object_statements (connection_type&); + virtual + ~object_statements (); + // Delayed loading. // void diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 9cd8344..04d57c8 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -18,6 +18,12 @@ namespace odb { template object_statements:: + ~object_statements () + { + } + + template + object_statements:: object_statements (connection_type& conn) : object_statements_base (conn), container_statement_cache_ (conn), diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 3179bda..f413756 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1199,7 +1199,7 @@ namespace odb namespace odb { template - class query: public object_traits::query_type + class query: public query_selector::type { public: // We don't define any typedefs here since they may clash with @@ -1212,40 +1212,40 @@ namespace odb explicit query (const std::string& q) - : object_traits::query_type (q) + : query_selector::type (q) { } template explicit query (sqlite::val_bind v) - : object_traits::query_type (sqlite::query (v)) + : query_selector::type (sqlite::query (v)) { } template explicit query (sqlite::ref_bind r) - : object_traits::query_type (sqlite::query (r)) + : query_selector::type (sqlite::query (r)) { } query (const sqlite::query& q) - : object_traits::query_type (q) + : query_selector::type (q) { } template query (const sqlite::query_column& qc) - : object_traits::query_type (qc) + : query_selector::type (qc) { } std::string clause () const { - return object_traits::query_type::clause ( - object_traits::table_name); + return query_selector::type::clause ( + query_selector::table_name ()); } }; } diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index 4f1cc2c..1417a6c 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -8,14 +8,15 @@ #include -#include // std::size_t - +#include #include + #include #include #include // query, query_params #include + #include namespace odb @@ -35,54 +36,18 @@ namespace odb details::shared_ptr statement_; }; - template - class result_impl: public odb::result_impl, public result_impl_base - { - public: - typedef typename odb::result_impl::pointer_type pointer_type; - typedef typename odb::result_impl::pointer_traits pointer_traits; - - typedef typename odb::result_impl::object_type object_type; - typedef typename odb::result_impl::id_type id_type; - typedef typename odb::result_impl::object_traits object_traits; - - - virtual - ~result_impl (); - - result_impl (const query&, - details::shared_ptr, - object_statements&); - - virtual void - load (object_type&); - - virtual id_type - load_id (); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - using odb::result_impl::current; - - private: - void - load_image (); - - private: - object_statements& statements_; - }; + template + class result_impl; } } -#include - #include #endif // ODB_SQLITE_RESULT_HXX + +// Include result specializations so that the user code only needs +// to include this header. +// + +#include +#include diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx deleted file mode 100644 index 9bcfe5f..0000000 --- a/odb/sqlite/result.txx +++ /dev/null @@ -1,133 +0,0 @@ -// file : odb/sqlite/result.txx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include - -namespace odb -{ - namespace sqlite - { - template - result_impl:: - ~result_impl () - { - } - - template - result_impl:: - result_impl (const query& q, - details::shared_ptr st, - object_statements& sts) - : odb::result_impl (sts.connection ().database ()), - result_impl_base (q, st), - statements_ (sts) - { - } - - template - void result_impl:: - load (object_type& obj) - { - load_image (); - - // This is a top-level call so the statements cannot be locked. - // - assert (!statements_.locked ()); - typename object_statements::auto_lock l (statements_); - - odb::database& db (this->database ()); - object_traits::callback (db, obj, callback_event::pre_load); - - typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, db); - - // Initialize the id image and binding and load the rest of the object - // (containers, etc). - // - typename object_traits::id_image_type& idi (statements_.id_image ()); - object_traits::init (idi, object_traits::id (i)); - - binding& idb (statements_.id_image_binding ()); - if (idi.version != statements_.id_image_version () || idb.version == 0) - { - object_traits::bind (idb.bind, idi); - statements_.id_image_version (idi.version); - idb.version++; - } - - object_traits::load_ (statements_, obj); - statements_.load_delayed (); - l.unlock (); - object_traits::callback (db, obj, callback_event::post_load); - } - - template - typename result_impl::id_type result_impl:: - load_id () - { - load_image (); - return object_traits::id (statements_.image ()); - } - - template - void result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - this->end_ = true; - } - - template - void result_impl:: - load_image () - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename object_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.out_image_version ()) - { - binding& b (statements_.out_image_binding ()); - object_traits::bind (b.bind, im, true); - statements_.out_image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (object_traits::grow (im, statements_.out_image_truncated ())) - im.version++; - - if (im.version != statements_.out_image_version ()) - { - binding& b (statements_.out_image_binding ()); - object_traits::bind (b.bind, im, true); - statements_.out_image_version (im.version); - b.version++; - statement_->reload (); - } - } - } - - template - void result_impl:: - cache () - { - } - - template - std::size_t result_impl:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index ca4ab2e..16e0c15 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -12,12 +12,16 @@ #include #include + #include #include #include #include +#include #include +#include + #include namespace odb @@ -69,7 +73,7 @@ namespace odb template object_statements& - find () + find_object () { map::iterator i (map_.find (&typeid (T))); @@ -83,6 +87,22 @@ namespace odb return *p; } + template + view_statements& + find_view () + { + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast&> (*i->second); + + details::shared_ptr > p ( + new (details::shared) view_statements (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + private: void begin_immediate_statement_ () const; @@ -92,7 +112,7 @@ namespace odb private: typedef std::map, + details::shared_ptr, details::type_info_comparator> map; connection& conn_; diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx new file mode 100644 index 0000000..9379047 --- /dev/null +++ b/odb/sqlite/statements-base.cxx @@ -0,0 +1,17 @@ +// file : odb/sqlite/statements-base.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + statements_base:: + ~statements_base () + { + } + } +} diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx new file mode 100644 index 0000000..a2d5a81 --- /dev/null +++ b/odb/sqlite/statements-base.hxx @@ -0,0 +1,51 @@ +// file : odb/sqlite/statements-base.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENTS_BASE_HXX +#define ODB_SQLITE_STATEMENTS_BASE_HXX + +#include + +#include + +#include +#include // connection + +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT statements_base: public details::shared_base + { + public: + typedef sqlite::connection connection_type; + + connection_type& + connection () + { + return conn_; + } + + public: + virtual + ~statements_base (); + + protected: + statements_base (connection_type& conn) + : conn_ (conn) + { + } + + protected: + connection_type& conn_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx new file mode 100644 index 0000000..7f65c4b --- /dev/null +++ b/odb/sqlite/view-result.hxx @@ -0,0 +1,69 @@ +// file : odb/sqlite/view-result.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_VIEW_RESULT_HXX +#define ODB_SQLITE_VIEW_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include +#include // query, view_statements +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class result_impl: + public odb::result_impl, + public result_impl_base + { + public: + typedef odb::result_impl base_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename base_type::view_type view_type; + typedef typename base_type::view_traits view_traits; + + virtual + ~result_impl (); + + result_impl (const query&, + details::shared_ptr, + view_statements&); + + virtual void + load (view_type&); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + view_statements& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx new file mode 100644 index 0000000..eec8b0a --- /dev/null +++ b/odb/sqlite/view-result.txx @@ -0,0 +1,96 @@ +// file : odb/sqlite/view-result.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + result_impl:: + ~result_impl () + { + } + + template + result_impl:: + result_impl (const query& q, + details::shared_ptr statement, + view_statements& statements) + : base_type (statements.connection ().database ()), + result_impl_base (q, statement), + statements_ (statements) + { + } + + template + void result_impl:: + load (view_type& view) + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename view_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.image_version ()) + { + binding& b (statements_.image_binding ()); + view_traits::bind (b.bind, im); + statements_.image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (view_traits::grow (im, statements_.image_truncated ())) + im.version++; + + if (im.version != statements_.image_version ()) + { + binding& b (statements_.image_binding ()); + view_traits::bind (b.bind, im); + statements_.image_version (im.version); + b.version++; + statement_->reload (); + } + } + + odb::database& db (this->database ()); + + view_traits::callback (db, view, callback_event::pre_load); + view_traits::init (view, im); + view_traits::callback (db, view, callback_event::post_load); + } + + template + void result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + this->end_ = true; + } + + template + void result_impl:: + cache () + { + } + + template + std::size_t result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx new file mode 100644 index 0000000..e940495 --- /dev/null +++ b/odb/sqlite/view-statements.hxx @@ -0,0 +1,113 @@ +// file : odb/sqlite/view-statements.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX +#define ODB_SQLITE_VIEW_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class view_statements: public statements_base + { + public: + typedef T view_type; + typedef odb::view_traits view_traits; + typedef typename view_traits::pointer_type pointer_type; + typedef typename view_traits::image_type image_type; + + typedef sqlite::select_statement query_statement_type; + + public: + view_statements (connection_type&); + + virtual + ~view_statements (); + + // View image. + // + image_type& + image () + { + return image_; + } + + std::size_t + image_version () const + { + return image_version_; + } + + void + image_version (std::size_t v) + { + image_version_ = v; + } + + binding& + image_binding () + { + return image_binding_; + } + + bool* + image_truncated () + { + return image_truncated_; + } + + query_statement_type& + query_statement () + { + if (query_ == 0) + { + query_.reset ( + new (details::shared) query_statement_type ( + conn_, + view_traits::query_statement, + image_binding_)); + + query_->cached (true); + } + + return *query_; + } + + private: + view_statements (const view_statements&); + view_statements& operator= (const view_statements&); + + private: + image_type image_; + std::size_t image_version_; + binding image_binding_; + bind image_bind_[view_traits::column_count]; + bool image_truncated_[view_traits::column_count]; + + details::shared_ptr query_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx new file mode 100644 index 0000000..790a537 --- /dev/null +++ b/odb/sqlite/view-statements.txx @@ -0,0 +1,35 @@ +// file : odb/sqlite/view-statements.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + view_statements:: + ~view_statements () + { + } + + template + view_statements:: + view_statements (connection_type& conn) + : statements_base (conn), + image_binding_ (image_bind_, view_traits::column_count) + { + image_.version = 0; + image_version_ = 0; + + std::memset (image_bind_, 0, sizeof (image_bind_)); + std::memset (image_truncated_, 0, sizeof (image_truncated_)); + + for (std::size_t i (0); i < view_traits::column_count; ++i) + image_bind_[i].truncated = image_truncated_ + i; + } + } +} -- cgit v1.1 From a8b1a89c291ab5bd170568eab3d7666631adf035 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 9 Sep 2011 12:18:39 +0200 Subject: New templated query_columns architecture We also now use the correct separate "role"-base join approach instead of having a single merged join for each table. --- odb/sqlite/query.cxx | 25 ++++++++----- odb/sqlite/query.hxx | 99 ++++++++++++++++++++++++++++------------------------ odb/sqlite/query.txx | 15 ++++---- 3 files changed, 77 insertions(+), 62 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 4a2082b..ab158bb 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -156,11 +156,9 @@ namespace odb } void query:: - append (const string& q, clause_part::kind_type k) + append (const string& q) { - if (k == clause_part::native && - !clause_.empty () && - clause_.back ().kind == clause_part::native) + if (!clause_.empty () && clause_.back ().kind == clause_part::native) { string& s (clause_.back ().part); @@ -177,7 +175,19 @@ namespace odb s += q; } else - clause_.push_back (clause_part (k, q)); + clause_.push_back (clause_part (clause_part::native, q)); + } + + void query:: + append (const char* table, const char* column) + { + string s ("\""); + s += table; + s += "\".\""; + s += column; + s += '"'; + + clause_.push_back (clause_part (clause_part::column, s)); } void query:: @@ -188,7 +198,7 @@ namespace odb } string query:: - clause (string const& table) const + clause () const { string r; @@ -204,9 +214,6 @@ namespace odb if (last != ' ' && last != '(') r += ' '; - if (i->part[0] == '.') - r += table; - r += i->part; break; } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index f413756..9731d10 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -137,11 +137,16 @@ namespace odb } explicit - query (const std::string& q, - clause_part::kind_type k = clause_part::native) + query (const std::string& native) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (k, q)); + clause_.push_back (clause_part (clause_part::native, native)); + } + + query (const char* table, const char* column) + : parameters_ (new (details::shared) query_params) + { + append (table, column); } template @@ -170,7 +175,7 @@ namespace odb public: std::string - clause (std::string const& default_table) const; + clause () const; binding& parameters_binding () const; @@ -200,7 +205,7 @@ namespace odb query& operator+= (const std::string& q) { - append (q, clause_part::native); + append (q); return *this; } @@ -230,7 +235,10 @@ namespace odb append (ref_bind); void - append (const std::string&, clause_part::kind_type); + append (const std::string& native); + + void + append (const char* table, const char* column); private: void @@ -394,16 +402,23 @@ namespace odb template struct query_column { - explicit - query_column (const char* name) - : name_ (name) + // Note that we keep shalow copies of the table and column names. + // + query_column (const char* table, const char* column) + : table_ (table), column_ (column) { } const char* - name () const + table () const { - return name_; + return table_; + } + + const char* + column () const + { + return column_; } // is_null, is_not_null @@ -412,7 +427,7 @@ namespace odb query is_null () const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IS NULL"; return q; } @@ -420,7 +435,7 @@ namespace odb query is_not_null () const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IS NOT NULL"; return q; } @@ -456,7 +471,7 @@ namespace odb query equal (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "="; q.append (v); return q; @@ -473,7 +488,7 @@ namespace odb query equal (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "="; q.append (r); return q; @@ -541,7 +556,7 @@ namespace odb query unequal (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "!="; q.append (v); return q; @@ -558,7 +573,7 @@ namespace odb query unequal (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "!="; q.append (r); return q; @@ -626,7 +641,7 @@ namespace odb query less (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<"; q.append (v); return q; @@ -643,7 +658,7 @@ namespace odb query less (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<"; q.append (r); return q; @@ -711,7 +726,7 @@ namespace odb query greater (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">"; q.append (v); return q; @@ -728,7 +743,7 @@ namespace odb query greater (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">"; q.append (r); return q; @@ -796,7 +811,7 @@ namespace odb query less_equal (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<="; q.append (v); return q; @@ -813,7 +828,7 @@ namespace odb query less_equal (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<="; q.append (r); return q; @@ -881,7 +896,7 @@ namespace odb query greater_equal (val_bind v) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">="; q.append (v); return q; @@ -898,7 +913,7 @@ namespace odb query greater_equal (ref_bind r) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">="; q.append (r); return q; @@ -965,9 +980,9 @@ namespace odb // (void) (sizeof (type_instance () == type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += "="; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } @@ -979,9 +994,9 @@ namespace odb // (void) (sizeof (type_instance () != type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += "!="; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } @@ -993,9 +1008,9 @@ namespace odb // (void) (sizeof (type_instance () < type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<"; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } @@ -1007,9 +1022,9 @@ namespace odb // (void) (sizeof (type_instance () > type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">"; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } @@ -1021,9 +1036,9 @@ namespace odb // (void) (sizeof (type_instance () <= type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += "<="; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } @@ -1035,14 +1050,15 @@ namespace odb // (void) (sizeof (type_instance () >= type_instance ())); - query q (name_, query::clause_part::column); + query q (table_, column_); q += ">="; - q.append (c.name (), query::clause_part::column); + q.append (c.table (), c.column ()); return q; } private: - const char* name_; + const char* table_; + const char* column_; }; // @@ -1240,13 +1256,6 @@ namespace odb : query_selector::type (qc) { } - - std::string - clause () const - { - return query_selector::type::clause ( - query_selector::table_name ()); - } }; } diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 6af80e7..590d4bd 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -15,12 +15,11 @@ namespace odb query (const query_column& c) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (clause_part::column, c.name ())); - // Cannot use IS TRUE here since database type can be a non- // integral type. // - clause_.push_back (clause_part (clause_part::native, "=")); + append (c.table (), c.column ()); + append ("="); append (val_bind (true)); } @@ -30,7 +29,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -43,7 +42,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -58,7 +57,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -75,7 +74,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -95,7 +94,7 @@ namespace odb query query_column:: in_range (I begin, I end) const { - query q (name_, query::clause_part::column); + query q (table_, column_); q += "IN ("; for (I i (begin); i != end; ++i) -- cgit v1.1 From 02aed5f059797cd5e53a9fe6dde13714f86332d4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Sep 2011 16:03:25 +0200 Subject: Support for views; integrated part --- odb/sqlite/query.cxx | 50 +++++++++++++++++++++++++----- odb/sqlite/query.hxx | 70 ++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/traits.cxx | 14 +++------ odb/sqlite/traits.hxx | 20 ++++++++++-- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 21 ------------- 6 files changed, 135 insertions(+), 42 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index ab158bb..16d8cc2 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -197,6 +197,47 @@ namespace odb parameters_->add (p); } + const char* query:: + clause_prefix () const + { + if (!clause_.empty ()) + { + const clause_part& p (clause_.front ()); + + if (p.kind == clause_part::native) + { + const string& s (p.part); + string::size_type n; + + // It is easier to compare to upper and lower-case versions + // rather than getting involved with the portable case- + // insensitive string comparison mess. + // + if (s.compare (0, (n = 5), "WHERE") == 0 || + s.compare (0, (n = 5), "where") == 0 || + s.compare (0, (n = 6), "SELECT") == 0 || + s.compare (0, (n = 6), "select") == 0 || + s.compare (0, (n = 8), "ORDER BY") == 0 || + s.compare (0, (n = 8), "order by") == 0 || + s.compare (0, (n = 8), "GROUP BY") == 0 || + s.compare (0, (n = 8), "group by") == 0 || + s.compare (0, (n = 6), "HAVING") == 0 || + s.compare (0, (n = 6), "having") == 0) + { + // It either has to be an exact match, or there should be + // a whitespace following the keyword. + // + if (s.size () == n || s[n] == ' ' || s[n] =='\t') + return ""; + } + } + + return "WHERE "; + } + + return ""; + } + string query:: clause () const { @@ -243,14 +284,7 @@ namespace odb } } - if (r.empty () || - r.compare (0, 6, "WHERE ") == 0 || - r.compare (0, 9, "ORDER BY ") == 0 || - r.compare (0, 9, "GROUP BY ") == 0 || - r.compare (0, 7, "HAVING ") == 0) - return r; - else - return "WHERE " + r; + return clause_prefix () + r; } } } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 9731d10..c712b58 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -136,6 +136,22 @@ namespace odb { } + // True or false literal. + // + explicit + query (bool v) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::native, v ? "1" : "0")); + } + + explicit + query (const char* native) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::native, native)); + } + explicit query (const std::string& native) : parameters_ (new (details::shared) query_params) @@ -177,6 +193,9 @@ namespace odb std::string clause () const; + const char* + clause_prefix () const; + binding& parameters_binding () const; @@ -1061,6 +1080,45 @@ namespace odb const char* column_; }; + // Provide operator+() for using columns to construct native + // query fragments (e.g., ORDER BY). + // + template + inline query + operator+ (const query_column& c, const std::string& s) + { + query q (c.table (), c.column ()); + q += s; + return q; + } + + template + inline query + operator+ (const std::string& s, const query_column& c) + { + query q (s); + q.append (c.table (), c.column ()); + return q; + } + + template + inline query + operator+ (const query_column& c, const query& q) + { + query r (c.table (), c.column ()); + r += q; + return r; + } + + template + inline query + operator+ (const query& q, const query_column& c) + { + query r (q); + r.append (c.table (), c.column ()); + return r; + } + // // template @@ -1227,6 +1285,18 @@ namespace odb } explicit + query (bool v) + : query_selector::type (v) + { + } + + explicit + query (const char* q) + : query_selector::type (q) + { + } + + explicit query (const std::string& q) : query_selector::type (q) { diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 62093e9..8a9f310 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -20,10 +20,7 @@ namespace odb // void default_value_traits:: - set_image (buffer& b, - size_t& n, - bool& is_null, - const string& v) + set_image (buffer& b, size_t& n, bool& is_null, const string& v) { is_null = false; n = v.size (); @@ -36,14 +33,11 @@ namespace odb } // - // default_value_traits + // c_string_value_traits // - void default_value_traits:: - set_image (buffer& b, - size_t& n, - bool& is_null, - const char* v) + void c_string_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const char* v) { is_null = false; n = strlen (v); diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index e2a4a4d..e712aa7 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -236,8 +236,7 @@ namespace odb // of an image from the value but not the other way around. This way // we can pass such values to the queries. // - template <> - struct LIBODB_SQLITE_EXPORT default_value_traits + struct LIBODB_SQLITE_EXPORT c_string_value_traits { typedef const char* value_type; typedef const char* query_type; @@ -250,6 +249,17 @@ namespace odb const char*); }; + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + c_string_value_traits + { + }; + + template + struct default_value_traits: c_string_value_traits + { + }; + // std::vector (buffer) specialization. // template <> @@ -386,6 +396,12 @@ namespace odb { static const database_type_id db_type_id = id_text; }; + + template + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; } } diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index eec8b0a..2facc24 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -66,7 +66,7 @@ namespace odb odb::database& db (this->database ()); view_traits::callback (db, view, callback_event::pre_load); - view_traits::init (view, im); + view_traits::init (view, im, db); view_traits::callback (db, view, callback_event::post_load); } diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index e940495..6126f08 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -33,8 +33,6 @@ namespace odb typedef typename view_traits::pointer_type pointer_type; typedef typename view_traits::image_type image_type; - typedef sqlite::select_statement query_statement_type; - public: view_statements (connection_type&); @@ -73,23 +71,6 @@ namespace odb return image_truncated_; } - query_statement_type& - query_statement () - { - if (query_ == 0) - { - query_.reset ( - new (details::shared) query_statement_type ( - conn_, - view_traits::query_statement, - image_binding_)); - - query_->cached (true); - } - - return *query_; - } - private: view_statements (const view_statements&); view_statements& operator= (const view_statements&); @@ -100,8 +81,6 @@ namespace odb binding image_binding_; bind image_bind_[view_traits::column_count]; bool image_truncated_[view_traits::column_count]; - - details::shared_ptr query_; }; } } -- cgit v1.1 From f2d85ec8bb5ab5ba11f43de8c4334b6b8412a045 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Sep 2011 11:11:35 +0200 Subject: Add assertion for mismatch of result set column count in MySQL and SQLite This is useful for detecting native views that happened to have stray data members. Also update comment in PostgreSQL. --- odb/sqlite/statement.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 6417b3a..9071f68 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -114,6 +114,13 @@ namespace odb bool statement:: bind_result (const bind* p, size_t n, bool truncated) { + // Make sure that the number of columns in the result returned by + // the database matches the number that we expect. A common cause + // of this assertion is a native view with a number of data members + // not matching the number of columns in the SELECT-list. + // + assert (static_cast (sqlite3_data_count (stmt_)) == n); + bool r (true); for (size_t i (0); i < n; ++i) -- cgit v1.1 From d202c0af423f0e1e783ed0ce639076346a19a1df Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Sep 2011 16:43:13 +0200 Subject: Bump version to 1.6.0.a2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 2b69750..f20b602 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10501 +#if ODB_VERSION != 10502 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1059901 -#define LIBODB_SQLITE_VERSION_STR "1.6.0.a1" +#define LIBODB_SQLITE_VERSION 1059902 +#define LIBODB_SQLITE_VERSION_STR "1.6.0.a2" #include diff --git a/version b/version index f715635..be9a4ff 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.6.0.a1 +1.6.0.a2 -- cgit v1.1 From a21f161ebbec15125fd6bc8a006a7beeea77d032 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Sep 2011 13:00:33 +0200 Subject: Rework const object handling Now objects are always loaded as non-const and the object cache in session treats all objects as non-const. --- odb/sqlite/object-result.hxx | 8 ++++---- odb/sqlite/view-result.hxx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx index b3dbf2b..401c83a 100644 --- a/odb/sqlite/object-result.hxx +++ b/odb/sqlite/object-result.hxx @@ -29,12 +29,12 @@ namespace odb public: typedef odb::result_impl base_type; - typedef typename base_type::pointer_type pointer_type; - typedef typename base_type::pointer_traits pointer_traits; - + typedef typename base_type::object_traits object_traits; typedef typename base_type::object_type object_type; typedef typename base_type::id_type id_type; - typedef typename base_type::object_traits object_traits; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; virtual ~result_impl (); diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 7f65c4b..fe4fca5 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -29,12 +29,12 @@ namespace odb public: typedef odb::result_impl base_type; - typedef typename base_type::pointer_type pointer_type; - typedef typename base_type::pointer_traits pointer_traits; - typedef typename base_type::view_type view_type; typedef typename base_type::view_traits view_traits; + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + virtual ~result_impl (); -- cgit v1.1 From 7c8575dc312511623889119acbd105bbf4deb35b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Sep 2011 11:03:40 +0200 Subject: Add const char[n] value_traits specialization in addition to char[n] --- odb/sqlite/traits.hxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index e712aa7..c93c2c6 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -260,6 +260,11 @@ namespace odb { }; + template + struct default_value_traits: c_string_value_traits + { + }; + // std::vector (buffer) specialization. // template <> @@ -402,6 +407,12 @@ namespace odb { static const database_type_id db_type_id = id_text; }; + + template + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; } } -- cgit v1.1 From 894c72c73dc07ce417e5411bd3ac50f4c0461a60 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 2 Oct 2011 17:07:20 +0200 Subject: If query substituting placeholder is empty, pass true expression instead This allows uniform usage of views both with and without any extra conditions. Also optimize some common cases so that we don't have useless WHERE TRUE clauses or (...) AND (TRUE) expressions. --- odb/sqlite/query.cxx | 139 ++++++++++++++++++++++++++++++++++++++++----------- odb/sqlite/query.hxx | 61 +++++++++++----------- 2 files changed, 142 insertions(+), 58 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 16d8cc2..c3fd31e 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -128,6 +128,10 @@ namespace odb // query // + // query + // + const query query::true_expr (true); + query:: query (const query& q) : clause_ (q.clause_), @@ -197,6 +201,56 @@ namespace odb parameters_->add (p); } + static bool + check_prefix (const string& s) + { + string::size_type n; + + // It is easier to compare to upper and lower-case versions + // rather than getting involved with the portable case- + // insensitive string comparison mess. + // + if (s.compare (0, (n = 5), "WHERE") == 0 || + s.compare (0, (n = 5), "where") == 0 || + s.compare (0, (n = 6), "SELECT") == 0 || + s.compare (0, (n = 6), "select") == 0 || + s.compare (0, (n = 8), "ORDER BY") == 0 || + s.compare (0, (n = 8), "order by") == 0 || + s.compare (0, (n = 8), "GROUP BY") == 0 || + s.compare (0, (n = 8), "group by") == 0 || + s.compare (0, (n = 6), "HAVING") == 0 || + s.compare (0, (n = 6), "having") == 0) + { + // It either has to be an exact match, or there should be + // a whitespace following the keyword. + // + if (s.size () == n || s[n] == ' ' || s[n] =='\t') + return true; + } + + return false; + } + + void query:: + optimize () + { + // Remove a single TRUE literal or one that is followe by one of + // the other clauses. This avoids usless WHERE clauses like + // + // WHERE TRUE GROUP BY foo + // + clause_type::iterator i (clause_.begin ()), e (clause_.end ()); + + if (i != e && i->kind == clause_part::boolean && i->bool_part) + { + clause_type::iterator j (i + 1); + + if (j == e || + (j->kind == clause_part::native && check_prefix (j->part))) + clause_.erase (i); + } + } + const char* query:: clause_prefix () const { @@ -204,33 +258,8 @@ namespace odb { const clause_part& p (clause_.front ()); - if (p.kind == clause_part::native) - { - const string& s (p.part); - string::size_type n; - - // It is easier to compare to upper and lower-case versions - // rather than getting involved with the portable case- - // insensitive string comparison mess. - // - if (s.compare (0, (n = 5), "WHERE") == 0 || - s.compare (0, (n = 5), "where") == 0 || - s.compare (0, (n = 6), "SELECT") == 0 || - s.compare (0, (n = 6), "select") == 0 || - s.compare (0, (n = 8), "ORDER BY") == 0 || - s.compare (0, (n = 8), "order by") == 0 || - s.compare (0, (n = 8), "GROUP BY") == 0 || - s.compare (0, (n = 8), "group by") == 0 || - s.compare (0, (n = 6), "HAVING") == 0 || - s.compare (0, (n = 6), "having") == 0) - { - // It either has to be an exact match, or there should be - // a whitespace following the keyword. - // - if (s.size () == n || s[n] == ' ' || s[n] =='\t') - return ""; - } - } + if (p.kind == clause_part::native && check_prefix (p.part)) + return ""; return "WHERE "; } @@ -244,7 +273,9 @@ namespace odb string r; for (clause_type::const_iterator i (clause_.begin ()), - end (clause_.end ()); i != end; ++i) + end (clause_.end ()); + i != end; + ++i) { char last (!r.empty () ? r[r.size () - 1] : ' '); @@ -281,10 +312,62 @@ namespace odb r += p; break; } + case clause_part::boolean: + { + if (last != ' ' && last != '(') + r += ' '; + + r += i->bool_part ? "1" : "0"; + break; + } } } return clause_prefix () + r; } + + query + operator&& (const query& x, const query& y) + { + // Optimize cases where one or both sides are constant truth. + // + bool xt (x.const_true ()), yt (y.const_true ()); + + if (xt && yt) + return x; + + if (xt) + return y; + + if (yt) + return x; + + query r ("("); + r += x; + r += ") AND ("; + r += y; + r += ")"; + return r; + } + + query + operator|| (const query& x, const query& y) + { + query r ("("); + r += x; + r += ") OR ("; + r += y; + r += ")"; + return r; + } + + query + operator! (const query& x) + { + query r ("NOT ("); + r += x; + r += ")"; + return r; + } } } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index c712b58..a3c63ba 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -121,14 +121,17 @@ namespace odb { column, param, - native + native, + boolean }; clause_part (kind_type k): kind (k) {} clause_part (kind_type k, const std::string& p): kind (k), part (p) {} + clause_part (bool p): kind (boolean), bool_part (p) {} kind_type kind; std::string part; + bool bool_part; }; query () @@ -142,7 +145,7 @@ namespace odb query (bool v) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (clause_part::native, v ? "1" : "0")); + clause_.push_back (clause_part (v)); } explicit @@ -203,6 +206,26 @@ namespace odb parameters () const; public: + bool + empty () const + { + return clause_.empty (); + } + + static const query true_expr; + + bool + const_true () const + { + return clause_.size () == 1 && + clause_.front ().kind == clause_part::boolean && + clause_.front ().bool_part; + } + + void + optimize (); + + public: template static val_bind _val (const T& x) @@ -370,36 +393,14 @@ namespace odb return r; } - inline query - operator&& (const query& x, const query& y) - { - query r ("("); - r += x; - r += ") AND ("; - r += y; - r += ")"; - return r; - } + query + operator&& (const query&, const query&); - inline query - operator|| (const query& x, const query& y) - { - query r ("("); - r += x; - r += ") OR ("; - r += y; - r += ")"; - return r; - } + query + operator|| (const query&, const query&); - inline query - operator! (const query& x) - { - query r ("NOT ("); - r += x; - r += ")"; - return r; - } + query + operator! (const query&); // query_column // -- cgit v1.1 From a2f5ba2865cedf29d7497766b6600c0df887afc4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Oct 2011 09:59:54 +0200 Subject: Bump version to 1.6.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index f20b602..158bb1a 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10502 +#if ODB_VERSION != 10600 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1059902 -#define LIBODB_SQLITE_VERSION_STR "1.6.0.a2" +#define LIBODB_SQLITE_VERSION 1060000 +#define LIBODB_SQLITE_VERSION_STR "1.6.0" #include diff --git a/version b/version index be9a4ff..dc1e644 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.6.0.a2 +1.6.0 -- cgit v1.1 From 16aa8be08a69482d6208bdc9257facc13347a6cd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Oct 2011 13:57:23 +0200 Subject: Export query operators that were made non-inline --- odb/sqlite/query.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index a3c63ba..957e7b7 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -393,13 +393,13 @@ namespace odb return r; } - query + LIBODB_SQLITE_EXPORT query operator&& (const query&, const query&); - query + LIBODB_SQLITE_EXPORT query operator|| (const query&, const query&); - query + LIBODB_SQLITE_EXPORT query operator! (const query&); // query_column -- cgit v1.1 From 5c69154cf32d8b2c7c760222adccdce6e66acfd9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Oct 2011 15:19:22 +0200 Subject: Work around bug in Sun CC --- odb/sqlite/makefile | 1 + odb/sqlite/query-const-expr.cxx | 16 ++++++++++++++++ odb/sqlite/query.cxx | 4 ---- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 odb/sqlite/query-const-expr.cxx diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index e9115a7..ae355a8 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -13,6 +13,7 @@ error.cxx \ exceptions.cxx \ object-statements.cxx \ query.cxx \ +query-const-expr.cxx \ result.cxx \ statement-cache.cxx \ statement.cxx \ diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx new file mode 100644 index 0000000..49c5a6c --- /dev/null +++ b/odb/sqlite/query-const-expr.cxx @@ -0,0 +1,16 @@ +// file : odb/sqlite/query-const-expr.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + // Sun CC cannot handle this in query.cxx. + // + const query query::true_expr (true); + } +} diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index c3fd31e..222805b 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -128,10 +128,6 @@ namespace odb // query // - // query - // - const query query::true_expr (true); - query:: query (const query& q) : clause_ (q.clause_), -- cgit v1.1 From 0cd9d3b8bbe0e243c37336b3b8ffb3d40e968034 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2011 14:20:19 +0200 Subject: Mention autotools as prerequisite in INSTALL-GIT --- INSTALL-GIT | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/INSTALL-GIT b/INSTALL-GIT index fc6d7fe..f917af5 100644 --- a/INSTALL-GIT +++ b/INSTALL-GIT @@ -22,7 +22,6 @@ following additional packages: - GNU bash >= 2.0.0 http://www.gnu.org/software/bash/ - GNU make >= 3.81 http://www.gnu.org/software/make/ - build >= latest http://www.codesynthesis.com/projects/build/ - - cli >= latest http://www.codesynthesis.com/projects/cli/ If you are planning to create the source code distributions, then you will also need the following packages: @@ -31,6 +30,12 @@ also need the following packages: - GNU sed >= 4.0.0 http://www.gnu.org/software/sed/ - tofrodos >= 1.7.0 http://www.thefreecountry.com/tofrodos/ +As we as the GNU autotools: + + - GNU libtool >= 2.2.6b http://www.gnu.org/software/libtool/ + - GNU autoconf >= 2.67 http://www.gnu.org/software/autoconf/ + - GNU automake >= 1.11.1 http://www.gnu.org/software/automake/ + Any reasonably up to date GNU/Linux installation would normally have all of the above packages already present, except for build and maybe tofrodos. -- cgit v1.1 From e514a43339bbce7c8d15fb1350674ecfc5649e14 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Oct 2011 16:52:45 +0200 Subject: Split 'in' binding into insert/update pair; rename 'out' to select Also add the initial infrastructure for the readonly members support. Right now the split insert/update bindings allows us to avoid sending object id in UPDATE statements. It will also allows us to support readonly members. --- odb/sqlite/forward.hxx | 7 ++ odb/sqlite/object-result.txx | 18 ++--- odb/sqlite/object-statements.hxx | 158 ++++++++++++++++++++------------------- odb/sqlite/object-statements.txx | 25 ++++--- 4 files changed, 113 insertions(+), 95 deletions(-) diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 5203434..23d995e 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -23,6 +23,13 @@ namespace odb // Implementation details. // + enum statement_kind + { + statement_select, + statement_insert, + statement_update + }; + class binding; class select_statement; diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index 7675262..6e3a0c9 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -94,11 +94,11 @@ namespace odb // typename object_traits::image_type& im (statements_.image ()); - if (im.version != statements_.out_image_version ()) + if (im.version != statements_.select_image_version ()) { - binding& b (statements_.out_image_binding ()); - object_traits::bind (b.bind, im, true); - statements_.out_image_version (im.version); + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); b.version++; } @@ -106,14 +106,14 @@ namespace odb if (r == select_statement::truncated) { - if (object_traits::grow (im, statements_.out_image_truncated ())) + if (object_traits::grow (im, statements_.select_image_truncated ())) im.version++; - if (im.version != statements_.out_image_version ()) + if (im.version != statements_.select_image_version ()) { - binding& b (statements_.out_image_binding ()); - object_traits::bind (b.bind, im, true); - statements_.out_image_version (im.version); + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); b.version++; statement_->reload (); } diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 4816d66..a651507 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -101,10 +101,10 @@ namespace odb typename object_traits::container_statement_cache_type container_statement_cache_type; - typedef sqlite::insert_statement persist_statement_type; - typedef sqlite::select_statement find_statement_type; + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; typedef sqlite::update_statement update_statement_type; - typedef sqlite::delete_statement erase_statement_type; + typedef sqlite::delete_statement delete_statement_type; // Automatic lock. // @@ -177,89 +177,70 @@ namespace odb // Object image. // image_type& - image () - { - return image_; - } - - std::size_t - in_image_version () const - { - return in_image_version_; - } + image () {return image_;} + // Insert binding. + // std::size_t - out_image_version () const - { - return out_image_version_; - } + insert_image_version () const { return insert_image_version_;} void - in_image_version (std::size_t v) - { - in_image_version_ = v; - } + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} void - out_image_version (std::size_t v) - { - out_image_version_ = v; - } + update_image_version (std::size_t v) {update_image_version_ = v;} binding& - in_image_binding () - { - return in_image_binding_; - } + update_image_binding () {return update_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} binding& - out_image_binding () - { - return out_image_binding_; - } + select_image_binding () {return select_image_binding_;} bool* - out_image_truncated () - { - return out_image_truncated_; - } + select_image_truncated () {return select_image_truncated_;} - // Object id image. + // Object id image and binding. // id_image_type& - id_image () - { - return id_image_; - } + id_image () {return id_image_;} std::size_t - id_image_version () const - { - return id_image_version_; - } + id_image_version () const {return id_image_version_;} void - id_image_version (std::size_t v) - { - id_image_version_ = v; - } + id_image_version (std::size_t v) {id_image_version_ = v;} binding& - id_image_binding () - { - return id_image_binding_; - } + id_image_binding () {return id_image_binding_;} // Statements. // - persist_statement_type& + insert_statement_type& persist_statement () { if (persist_ == 0) { persist_.reset ( - new (details::shared) persist_statement_type ( - conn_, object_traits::persist_statement, in_image_binding_)); + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + insert_image_binding_)); persist_->cached (true); } @@ -267,17 +248,17 @@ namespace odb return *persist_; } - find_statement_type& + select_statement_type& find_statement () { if (find_ == 0) { find_.reset ( - new (details::shared) find_statement_type ( + new (details::shared) select_statement_type ( conn_, object_traits::find_statement, id_image_binding_, - out_image_binding_)); + select_image_binding_)); find_->cached (true); } @@ -295,7 +276,7 @@ namespace odb conn_, object_traits::update_statement, id_image_binding_, - in_image_binding_)); + update_image_binding_)); update_->cached (true); } @@ -303,13 +284,13 @@ namespace odb return *update_; } - erase_statement_type& + delete_statement_type& erase_statement () { if (erase_ == 0) { erase_.reset ( - new (details::shared) erase_statement_type ( + new (details::shared) delete_statement_type ( conn_, object_traits::erase_statement, id_image_binding_)); @@ -340,33 +321,58 @@ namespace odb clear_delayed_ (); private: + // select = total + // insert = total - inverse + // update = total - inverse - id - readonly + // + static const std::size_t select_column_count = + object_traits::column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - object_traits::inverse_column_count; + + static const std::size_t update_column_count = insert_column_count - + object_traits::id_column_count - object_traits::readonly_column_count; + + static const std::size_t id_column_count = + object_traits::id_column_count; + + private: container_statement_cache_type container_statement_cache_; image_type image_; - // In (send) binding. The last element is the id parameter. + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. // - std::size_t in_image_version_; - binding in_image_binding_; - bind in_image_bind_[object_traits::in_column_count + 1]; + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; - // Out (receive) binding. + // Update binding. The suffix of the bind array is object id. We + // do it this way for consistency with other database runtimes. // - std::size_t out_image_version_; - binding out_image_binding_; - bind out_image_bind_[object_traits::out_column_count]; - bool out_image_truncated_[object_traits::out_column_count]; + std::size_t update_image_version_; + binding update_image_binding_; + bind update_image_bind_[update_column_count + id_column_count]; - // Id image binding (only in). + // Id image binding (only used as a parameter). Uses the suffix in + // the update bind. // id_image_type id_image_; std::size_t id_image_version_; binding id_image_binding_; - details::shared_ptr persist_; - details::shared_ptr find_; + details::shared_ptr persist_; + details::shared_ptr find_; details::shared_ptr update_; - details::shared_ptr erase_; + details::shared_ptr erase_; // Delayed loading. // diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 04d57c8..fd596e7 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -27,23 +27,28 @@ namespace odb object_statements (connection_type& conn) : object_statements_base (conn), container_statement_cache_ (conn), - in_image_binding_ (in_image_bind_, object_traits::in_column_count), - out_image_binding_ (out_image_bind_, object_traits::out_column_count), - id_image_binding_ (in_image_bind_ + object_traits::in_column_count, 1) + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count), + update_image_binding_ (update_image_bind_, update_column_count), + id_image_binding_ (update_image_bind_ + update_column_count, + id_column_count) { image_.version = 0; - in_image_version_ = 0; - out_image_version_ = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + update_image_version_ = 0; id_image_.version = 0; id_image_version_ = 0; - std::memset (in_image_bind_, 0, sizeof (in_image_bind_)); - std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); - std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); - for (std::size_t i (0); i < object_traits::out_column_count; ++i) - out_image_bind_[i].truncated = out_image_truncated_ + i; + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; } template -- cgit v1.1 From 2e8daa4a5880f47e547de7db4e7ff5074d365723 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2011 10:47:40 +0200 Subject: Add support for const data members Const data members are automatically treated as readonly. New test: const-member. --- odb/sqlite/traits.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index c93c2c6..5d88365 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -92,7 +92,7 @@ namespace odb struct wrapped_value_traits { typedef wrapper_traits wtraits; - typedef typename wtraits::wrapped_type wrapped_type; + typedef typename wtraits::unrestricted_wrapped_type wrapped_type; typedef W value_type; typedef wrapped_type query_type; @@ -131,7 +131,7 @@ namespace odb struct wrapped_value_traits { typedef wrapper_traits wtraits; - typedef typename wtraits::wrapped_type wrapped_type; + typedef typename wtraits::unrestricted_wrapped_type wrapped_type; typedef W value_type; typedef wrapped_type query_type; -- cgit v1.1 From d83a7296e228cf0af74992020f51c566a03108c9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2011 15:16:49 +0200 Subject: Add support for persistent classes without object ids New pragma id (object). New test: common/no-id. --- odb/sqlite/forward.hxx | 3 + odb/sqlite/object-result.hxx | 53 ++++++++++++++--- odb/sqlite/object-result.txx | 115 +++++++++++++++++++++++++++++++---- odb/sqlite/object-statements.hxx | 125 +++++++++++++++++++++++++++++++++++++++ odb/sqlite/object-statements.txx | 34 +++++++++++ odb/sqlite/result.hxx | 3 - odb/sqlite/statement-cache.hxx | 10 ++-- odb/sqlite/view-result.hxx | 15 +++-- odb/sqlite/view-result.txx | 16 ++--- 9 files changed, 330 insertions(+), 44 deletions(-) diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 23d995e..cc1fbfc 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -37,6 +37,9 @@ namespace odb class object_statements; template + class object_statements_no_id; + + template class view_statements; template diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx index 401c83a..fb7865c 100644 --- a/odb/sqlite/object-result.hxx +++ b/odb/sqlite/object-result.hxx @@ -22,12 +22,11 @@ namespace odb namespace sqlite { template - class result_impl: - public odb::result_impl, - public result_impl_base + class object_result_impl: public odb::object_result_impl, + public result_impl_base { public: - typedef odb::result_impl base_type; + typedef odb::object_result_impl base_type; typedef typename base_type::object_traits object_traits; typedef typename base_type::object_type object_type; @@ -37,11 +36,11 @@ namespace odb typedef typename base_type::pointer_traits pointer_traits; virtual - ~result_impl (); + ~object_result_impl (); - result_impl (const query&, - details::shared_ptr, - object_statements&); + object_result_impl (const query&, + details::shared_ptr, + object_statements&); virtual void load (object_type&); @@ -67,6 +66,44 @@ namespace odb private: object_statements& statements_; }; + + template + class object_result_impl_no_id: public odb::object_result_impl_no_id, + public result_impl_base + { + public: + typedef odb::object_result_impl_no_id base_type; + + typedef typename base_type::object_traits object_traits; + typedef typename base_type::object_type object_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + virtual + ~object_result_impl_no_id (); + + object_result_impl_no_id (const query&, + details::shared_ptr, + object_statements_no_id&); + + virtual void + load (object_type&); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + object_statements_no_id& statements_; + }; } } diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index 6e3a0c9..dc258cc 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -12,17 +12,21 @@ namespace odb { namespace sqlite { + // + // object_result_impl + // + template - result_impl:: - ~result_impl () + object_result_impl:: + ~object_result_impl () { } template - result_impl:: - result_impl (const query& q, - details::shared_ptr statement, - object_statements& statements) + object_result_impl:: + object_result_impl (const query& q, + details::shared_ptr statement, + object_statements& statements) : base_type (statements.connection ().database ()), result_impl_base (q, statement), statements_ (statements) @@ -30,7 +34,7 @@ namespace odb } template - void result_impl:: + void object_result_impl:: load (object_type& obj) { load_image (); @@ -67,8 +71,8 @@ namespace odb } template - typename result_impl::id_type - result_impl:: + typename object_result_impl::id_type + object_result_impl:: load_id () { load_image (); @@ -76,7 +80,7 @@ namespace odb } template - void result_impl:: + void object_result_impl:: next () { this->current (pointer_type ()); @@ -86,7 +90,7 @@ namespace odb } template - void result_impl:: + void object_result_impl:: load_image () { // The image can grow between calls to load() as a result of other @@ -121,13 +125,98 @@ namespace odb } template - void result_impl:: + void object_result_impl:: + cache () + { + } + + template + std::size_t object_result_impl:: + size () + { + throw result_not_cached (); + } + + // + // object_result_impl_no_id + // + + template + object_result_impl_no_id:: + ~object_result_impl_no_id () + { + } + + template + object_result_impl_no_id:: + object_result_impl_no_id (const query& q, + details::shared_ptr statement, + object_statements_no_id& statements) + : base_type (statements.connection ().database ()), + result_impl_base (q, statement), + statements_ (statements) + { + } + + template + void object_result_impl_no_id:: + load (object_type& obj) + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (object_traits::grow (im, statements_.select_image_truncated ())) + im.version++; + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + statement_->reload (); + } + } + + odb::database& db (this->database ()); + + object_traits::callback (db, obj, callback_event::pre_load); + object_traits::init (obj, im, db); + object_traits::callback (db, obj, callback_event::post_load); + } + + template + void object_result_impl_no_id:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + this->end_ = true; + } + + template + void object_result_impl_no_id:: cache () { } template - std::size_t result_impl:: + std::size_t object_result_impl_no_id:: size () { throw result_not_cached (); diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index a651507..15c848d 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -29,6 +29,28 @@ namespace odb { namespace sqlite { + template + class object_statements; + + template + class object_statements_no_id; + + template ::id_type> + struct object_statements_selector + { + typedef object_statements type; + }; + + template + struct object_statements_selector + { + typedef object_statements_no_id type; + }; + + // + // Implementation for objects with object id. + // + class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base { public: @@ -416,6 +438,109 @@ namespace odb delayed_loads& dl_; }; }; + + // + // Implementation for objects without object id. + // + + template + class object_statements_no_id: public statements_base + { + public: + typedef T object_type; + typedef odb::object_traits object_traits; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + + typedef sqlite::insert_statement insert_statement_type; + + public: + object_statements_no_id (connection_type&); + + virtual + ~object_statements_no_id (); + + // Object image. + // + image_type& + image () {return image_;} + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + insert_image_binding_)); + + persist_->cached (true); + } + + return *persist_; + } + + private: + object_statements_no_id (const object_statements_no_id&); + object_statements_no_id& operator= (const object_statements_no_id&); + + private: + // select = total + // insert = total - inverse; inverse == 0 for object without id + // + static const std::size_t insert_column_count = + object_traits::column_count; + + static const std::size_t select_column_count = + object_traits::column_count; + + private: + image_type image_; + + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. + // + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + details::shared_ptr persist_; + }; } } diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index fd596e7..d2bd06f 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -16,6 +16,10 @@ namespace odb { namespace sqlite { + // + // object_statements + // + template object_statements:: ~object_statements () @@ -115,5 +119,35 @@ namespace odb delayed_.clear (); } + + // + // object_statements_no_id + // + + template + object_statements_no_id:: + ~object_statements_no_id () + { + } + + template + object_statements_no_id:: + object_statements_no_id (connection_type& conn) + : statements_base (conn), + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count) + { + image_.version = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } } } diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index 1417a6c..b8b759e 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -35,9 +35,6 @@ namespace odb details::shared_ptr params_; details::shared_ptr statement_; }; - - template - class result_impl; } } diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 16e0c15..1bdefb6 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -72,16 +72,18 @@ namespace odb } template - object_statements& + typename object_statements_selector::type& find_object () { + typedef typename object_statements_selector::type object_statements; + map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) - return static_cast&> (*i->second); + return static_cast (*i->second); - details::shared_ptr > p ( - new (details::shared) object_statements (conn_)); + details::shared_ptr p ( + new (details::shared) object_statements (conn_)); map_.insert (map::value_type (&typeid (T), p)); return *p; diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index fe4fca5..32507fd 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -22,12 +22,11 @@ namespace odb namespace sqlite { template - class result_impl: - public odb::result_impl, - public result_impl_base + class view_result_impl: public odb::view_result_impl, + public result_impl_base { public: - typedef odb::result_impl base_type; + typedef odb::view_result_impl base_type; typedef typename base_type::view_type view_type; typedef typename base_type::view_traits view_traits; @@ -36,11 +35,11 @@ namespace odb typedef typename base_type::pointer_traits pointer_traits; virtual - ~result_impl (); + ~view_result_impl (); - result_impl (const query&, - details::shared_ptr, - view_statements&); + view_result_impl (const query&, + details::shared_ptr, + view_statements&); virtual void load (view_type&); diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 2facc24..f4449eb 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -13,14 +13,14 @@ namespace odb namespace sqlite { template - result_impl:: - ~result_impl () + view_result_impl:: + ~view_result_impl () { } template - result_impl:: - result_impl (const query& q, + view_result_impl:: + view_result_impl (const query& q, details::shared_ptr statement, view_statements& statements) : base_type (statements.connection ().database ()), @@ -30,7 +30,7 @@ namespace odb } template - void result_impl:: + void view_result_impl:: load (view_type& view) { // The image can grow between calls to load() as a result of other @@ -71,7 +71,7 @@ namespace odb } template - void result_impl:: + void view_result_impl:: next () { this->current (pointer_type ()); @@ -81,13 +81,13 @@ namespace odb } template - void result_impl:: + void view_result_impl:: cache () { } template - std::size_t result_impl:: + std::size_t view_result_impl:: size () { throw result_not_cached (); -- cgit v1.1 From 192af55136c79910046de751bd85bf6d1f426e9e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2011 17:55:03 +0200 Subject: Make sure output directory exist before generating config.h --- odb/sqlite/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index ae355a8..50ef959 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -67,7 +67,7 @@ $(gen): cli_options += \ --cli-namespace odb::sqlite::details::cli \ --guard-prefix LIBODB_SQLITE_DETAILS -$(out_base)/details/config.h: +$(out_base)/details/config.h: | $(out_base)/details/. @echo '/* file : odb/sqlite/details/config.h' >$@ @echo ' * author : automatically generated' >>$@ @echo ' */' >>$@ -- cgit v1.1 From 59cab2f5fd95ed8ae833397044f2b704c3e7a8c4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 30 Oct 2011 17:52:31 +0200 Subject: Rework statement interfaces wrt param/result passing --- odb/sqlite/object-statements.hxx | 14 ++++++++--- odb/sqlite/object-statements.txx | 4 +++- odb/sqlite/statement.cxx | 50 ++++++++++++++++++++-------------------- odb/sqlite/statement.hxx | 26 ++++++++++----------- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 15c848d..53445b8 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -220,6 +220,12 @@ namespace odb void update_image_version (std::size_t v) {update_image_version_ = v;} + std::size_t + update_id_image_version () const { return update_id_image_version_;} + + void + update_id_image_version (std::size_t v) {update_id_image_version_ = v;} + binding& update_image_binding () {return update_image_binding_;} @@ -297,7 +303,6 @@ namespace odb new (details::shared) update_statement_type ( conn_, object_traits::update_statement, - id_image_binding_, update_image_binding_)); update_->cached (true); @@ -377,10 +382,13 @@ namespace odb binding insert_image_binding_; bind insert_image_bind_[insert_column_count]; - // Update binding. The suffix of the bind array is object id. We - // do it this way for consistency with other database runtimes. + // Update binding. Note that the id suffix is bound to id_image_ + // below instead of image_ which makes this binding effectively + // bound to two images. As a result, we have to track versions + // for both of them. // std::size_t update_image_version_; + std::size_t update_id_image_version_; binding update_image_binding_; bind update_image_bind_[update_column_count + id_column_count]; diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index d2bd06f..7c5c178 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -33,7 +33,8 @@ namespace odb container_statement_cache_ (conn), select_image_binding_ (select_image_bind_, select_column_count), insert_image_binding_ (insert_image_bind_, insert_column_count), - update_image_binding_ (update_image_bind_, update_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count), id_image_binding_ (update_image_bind_ + update_column_count, id_column_count) { @@ -41,6 +42,7 @@ namespace odb select_image_version_ = 0; insert_image_version_ = 0; update_image_version_ = 0; + update_id_image_version_ = 0; id_image_.version = 0; id_image_version_ = 0; diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 9071f68..a7ace7a 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -56,15 +56,17 @@ namespace odb } void statement:: - bind_param (const bind* p, size_t n, size_t start_param) + bind_param (const bind* p, size_t n) { int e (SQLITE_OK); - start_param++; // SQLite parameters are counted from 1. - for (size_t i (0); e == SQLITE_OK && i < n; ++i) + // SQLite parameters are counted from 1. + // + n++; + for (size_t i (1); e == SQLITE_OK && i < n; ++i, ++p) { - const bind& b (p[i]); - int j (static_cast (i + start_param)); + const bind& b (*p); + int j (static_cast (i)); if (b.is_null != 0 && *b.is_null) { @@ -244,17 +246,17 @@ namespace odb select_statement:: select_statement (connection& conn, const string& s, - binding& cond, - binding& data) - : statement (conn, s), cond_ (&cond), data_ (data) + binding& param, + binding& result) + : statement (conn, s), param_ (¶m), result_ (result) { } select_statement:: select_statement (connection& conn, const string& s, - binding& data) - : statement (conn, s), cond_ (0), data_ (data) + binding& result) + : statement (conn, s), param_ (0), result_ (result) { } @@ -266,8 +268,8 @@ namespace odb done_ = false; - if (cond_ != 0) - bind_param (cond_->bind, cond_->count); + if (param_ != 0) + bind_param (param_->bind, param_->count); active (true); } @@ -314,7 +316,7 @@ namespace odb if (done_) return no_data; - return bind_result (data_.bind, data_.count) ? success : truncated; + return bind_result (result_.bind, result_.count) ? success : truncated; } void select_statement:: @@ -322,7 +324,7 @@ namespace odb { assert (!done_); - if (!bind_result (data_.bind, data_.count, true)) + if (!bind_result (result_.bind, result_.count, true)) assert (false); } @@ -330,15 +332,15 @@ namespace odb // insert_statement:: - insert_statement (connection& conn, const string& s, binding& data) - : statement (conn, s), data_ (data) + insert_statement (connection& conn, const string& s, binding& param) + : statement (conn, s), param_ (param) { } bool insert_statement:: execute () { - bind_param (data_.bind, data_.count); + bind_param (param_.bind, param_.count); int e; sqlite3* h (conn_.handle ()); @@ -382,17 +384,15 @@ namespace odb update_statement:: update_statement (connection& conn, const string& s, - binding& cond, - binding& data) - : statement (conn, s), cond_ (cond), data_ (data) + binding& param) + : statement (conn, s), param_ (param) { } void update_statement:: execute () { - bind_param (data_.bind, data_.count); - bind_param (cond_.bind, cond_.count, data_.count); + bind_param (param_.bind, param_.count); int e; sqlite3* h (conn_.handle ()); @@ -418,15 +418,15 @@ namespace odb // delete_statement:: - delete_statement (connection& conn, const string& s, binding& cond) - : statement (conn, s), cond_ (cond) + delete_statement (connection& conn, const string& s, binding& param) + : statement (conn, s), param_ (param) { } unsigned long long delete_statement:: execute () { - bind_param (cond_.bind, cond_.count); + bind_param (param_.bind, param_.count); int e; sqlite3* h (conn_.handle ()); diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 69f5a95..2bf770c 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -80,7 +80,7 @@ namespace odb protected: void - bind_param (const bind*, std::size_t count, std::size_t start_param = 0); + bind_param (const bind*, std::size_t count); // Extract row columns into the bound buffers. If the truncated // argument is true, then only truncated columns are extracted. @@ -213,12 +213,12 @@ namespace odb public: select_statement (connection& conn, const std::string& statement, - binding& cond, - binding& data); + binding& param, + binding& result); select_statement (connection& conn, const std::string& statement, - binding& data); + binding& result); // Common select interface expected by the generated code. // @@ -277,8 +277,8 @@ namespace odb private: bool done_; - binding* cond_; - binding& data_; + binding* param_; + binding& result_; }; class LIBODB_SQLITE_EXPORT insert_statement: public statement @@ -286,7 +286,7 @@ namespace odb public: insert_statement (connection& conn, const std::string& statement, - binding& data); + binding& param); // Return true if successful and false if the row is a duplicate. // All other errors are reported by throwing exceptions. @@ -302,7 +302,7 @@ namespace odb insert_statement& operator= (const insert_statement&); private: - binding& data_; + binding& param_; }; class LIBODB_SQLITE_EXPORT update_statement: public statement @@ -310,8 +310,7 @@ namespace odb public: update_statement (connection& conn, const std::string& statement, - binding& cond, - binding& data); + binding& param); void execute (); @@ -320,8 +319,7 @@ namespace odb update_statement& operator= (const update_statement&); private: - binding& cond_; - binding& data_; + binding& param_; }; class LIBODB_SQLITE_EXPORT delete_statement: public statement @@ -329,7 +327,7 @@ namespace odb public: delete_statement (connection& conn, const std::string& statement, - binding& cond); + binding& param); unsigned long long execute (); @@ -339,7 +337,7 @@ namespace odb delete_statement& operator= (const delete_statement&); private: - binding& cond_; + binding& param_; }; } } -- cgit v1.1 From 8bff3a2fc0ccce05abef7972beefadcd2534bdcd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Nov 2011 12:41:02 +0200 Subject: Implement support for optimistic concurrency New pragmas: optimistic, version. New test: optimistic. New database function: reload(). --- odb/sqlite/object-statements.hxx | 75 +++++++++++++++++++++++++++++++++++++--- odb/sqlite/object-statements.txx | 21 +++++++++-- odb/sqlite/statement.cxx | 6 ++-- odb/sqlite/statement.hxx | 3 +- 4 files changed, 94 insertions(+), 11 deletions(-) diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 53445b8..34a6a5e 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -106,6 +106,31 @@ namespace odb bool locked_; }; + template + struct optimistic_data; + + template + struct optimistic_data + { + typedef T object_type; + typedef odb::object_traits object_traits; + + optimistic_data (bind*); + + // The id + optimistic column binding. + // + std::size_t id_image_version_; + binding id_image_binding_; + + details::shared_ptr erase_; + }; + + template + struct optimistic_data + { + optimistic_data (bind*) {} + }; + template class object_statements: public object_statements_base { @@ -257,6 +282,17 @@ namespace odb binding& id_image_binding () {return id_image_binding_;} + // Optimistic id + managed column image binding. + // + std::size_t + optimistic_id_image_version () const {return od_.id_image_version_;} + + void + optimistic_id_image_version (std::size_t v) {od_.id_image_version_ = v;} + + binding& + optimistic_id_image_binding () {return od_.id_image_binding_;} + // Statements. // insert_statement_type& @@ -328,6 +364,23 @@ namespace odb return *erase_; } + delete_statement_type& + optimistic_erase_statement () + { + if (od_.erase_ == 0) + { + od_.erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::optimistic_erase_statement, + od_.id_image_binding_)); + + od_.erase_->cached (true); + } + + return *od_.erase_; + } + // Container statement cache. // container_statement_cache_type& @@ -349,14 +402,15 @@ namespace odb private: // select = total - // insert = total - inverse - // update = total - inverse - id - readonly + // insert = total - inverse - managed_optimistic + // update = total - inverse - managed_optimistic - id - readonly // static const std::size_t select_column_count = object_traits::column_count; static const std::size_t insert_column_count = - object_traits::column_count - object_traits::inverse_column_count; + object_traits::column_count - object_traits::inverse_column_count - + object_traits::managed_optimistic_column_count; static const std::size_t update_column_count = insert_column_count - object_traits::id_column_count - object_traits::readonly_column_count; @@ -364,6 +418,9 @@ namespace odb static const std::size_t id_column_count = object_traits::id_column_count; + static const std::size_t managed_optimistic_column_count = + object_traits::managed_optimistic_column_count; + private: container_statement_cache_type container_statement_cache_; @@ -385,12 +442,16 @@ namespace odb // Update binding. Note that the id suffix is bound to id_image_ // below instead of image_ which makes this binding effectively // bound to two images. As a result, we have to track versions - // for both of them. + // for both of them. If this object uses optimistic concurrency, + // then the binding for the managed column (version, timestamp, + // etc) comes after the id and the image for such a column is + // stored as part of the id image. // std::size_t update_image_version_; std::size_t update_id_image_version_; binding update_image_binding_; - bind update_image_bind_[update_column_count + id_column_count]; + bind update_image_bind_[update_column_count + id_column_count + + managed_optimistic_column_count]; // Id image binding (only used as a parameter). Uses the suffix in // the update bind. @@ -399,6 +460,10 @@ namespace odb std::size_t id_image_version_; binding id_image_binding_; + // Extra data for objects with optimistic concurrency support. + // + optimistic_data od_; + details::shared_ptr persist_; details::shared_ptr find_; details::shared_ptr update_; diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 7c5c178..7132296 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -17,6 +17,21 @@ namespace odb namespace sqlite { // + // optimistic_data + // + + template + optimistic_data:: + optimistic_data (bind* b) + : id_image_binding_ ( + b, + object_traits::id_column_count + + object_traits::managed_optimistic_column_count) + { + id_image_version_ = 0; + } + + // // object_statements // @@ -34,9 +49,11 @@ namespace odb select_image_binding_ (select_image_bind_, select_column_count), insert_image_binding_ (insert_image_bind_, insert_column_count), update_image_binding_ (update_image_bind_, - update_column_count + id_column_count), + update_column_count + id_column_count + + managed_optimistic_column_count), id_image_binding_ (update_image_bind_ + update_column_count, - id_column_count) + id_column_count), + od_ (update_image_bind_ + update_column_count) { image_.version = 0; select_image_version_ = 0; diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index a7ace7a..a33ebcb 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -389,7 +389,7 @@ namespace odb { } - void update_statement:: + unsigned long long update_statement:: execute () { bind_param (param_.bind, param_.count); @@ -410,8 +410,8 @@ namespace odb if (e != SQLITE_DONE) translate_error (e, conn_); - if (sqlite3_changes (conn_.handle ()) == 0) - throw object_not_persistent (); + return static_cast ( + sqlite3_changes (conn_.handle ())); } // delete_statement diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 2bf770c..4fad1a3 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -311,7 +311,8 @@ namespace odb update_statement (connection& conn, const std::string& statement, binding& param); - void + + unsigned long long execute (); private: -- cgit v1.1 From fb12544461cf4ea5fb331d726c96152c9389f995 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Nov 2011 09:35:02 +0200 Subject: Optimize load_id(), load() sequence for SQLite and PostgreSQL In these databases both of these functions load the data into the object image. If there is no chance of image overwrite between these calls, then we don't need to load the image the second time. --- odb/sqlite/object-result.hxx | 2 +- odb/sqlite/object-result.txx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx index fb7865c..6953787 100644 --- a/odb/sqlite/object-result.hxx +++ b/odb/sqlite/object-result.hxx @@ -43,7 +43,7 @@ namespace odb object_statements&); virtual void - load (object_type&); + load (object_type&, bool fetch); virtual id_type load_id (); diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index dc258cc..f400fe4 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -35,9 +35,10 @@ namespace odb template void object_result_impl:: - load (object_type& obj) + load (object_type& obj, bool fetch) { - load_image (); + if (fetch) + load_image (); // This is a top-level call so the statements cannot be locked. // -- cgit v1.1 From a82b67271a23ca42575bda276dc6a0c03b2156ed Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Nov 2011 15:08:25 +0200 Subject: Bump version to 1.7.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 158bb1a..b4ebe64 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10600 +#if ODB_VERSION != 10601 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1060000 -#define LIBODB_SQLITE_VERSION_STR "1.6.0" +#define LIBODB_SQLITE_VERSION 1069901 +#define LIBODB_SQLITE_VERSION_STR "1.7.0.a1" #include diff --git a/version b/version index dc1e644..38a3807 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.6.0 +1.7.0.a1 -- cgit v1.1 From 85654d7ca5f8b92466465c1ec48975ca343fd331 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Nov 2011 08:16:50 +0200 Subject: Add support for mapping std::vector to BLOB types --- odb/sqlite/traits.cxx | 22 ++++++++++++++++++++++ odb/sqlite/traits.hxx | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 8a9f310..d6b6572 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -70,5 +70,27 @@ namespace odb if (n != 0) memcpy (b.data (), &v.front (), n); } + + // + // default_value_traits, id_blob> + // + + void default_value_traits, id_blob>:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b.data (), &v.front (), n); + } } } diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 5d88365..b53d3ab 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -268,7 +268,8 @@ namespace odb // std::vector (buffer) specialization. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits, id_blob> + struct LIBODB_SQLITE_EXPORT default_value_traits< + std::vector, id_blob> { public: typedef std::vector value_type; @@ -294,6 +295,40 @@ namespace odb const value_type&); }; + // std::vector (buffer) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits< + std::vector, id_blob> + { + public: + typedef std::vector value_type; + typedef std::vector query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + { + const unsigned char* d ( + reinterpret_cast (b.data ())); + v.assign (d, d + n); + } + else + v.clear (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const value_type&); + }; + // // type_traits // -- cgit v1.1 From 3c150763bc946bebe2eb5a2e487a28cf25f2e449 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Nov 2011 10:11:24 +0200 Subject: Add support for mapping char[N] and unsigned char[N] types to BLOB New test: common/blob. --- odb/sqlite/traits.cxx | 2 -- odb/sqlite/traits.hxx | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index d6b6572..3884f36 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -3,8 +3,6 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file -#include // std::memcpy, std::strlen - #include using namespace std; diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index b53d3ab..fe16835 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -11,6 +11,7 @@ #include #include #include // std::size_t +#include // std::memcpy, std::memset, std::strlen #include #include @@ -329,6 +330,82 @@ namespace odb const value_type&); }; + // char[n] (buffer) specialization. + // + template + struct default_value_traits + { + public: + typedef char* value_type; + typedef const char* query_type; + typedef details::buffer image_type; + + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v, b.data (), (n < N ? n : N)); + else + std::memset (v, 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v, n); + } + }; + + // unsigned char[n] (buffer) specialization. + // + template + struct default_value_traits + { + public: + typedef unsigned char* value_type; + typedef const unsigned char* query_type; + typedef details::buffer image_type; + + static void + set_value (unsigned char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v, b.data (), (n < N ? n : N)); + else + std::memset (v, 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const unsigned char* v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v, n); + } + }; + // // type_traits // -- cgit v1.1 From 0a71eaad620be004e7e28e7d3265a373dcd92395 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Nov 2011 15:00:06 +0200 Subject: Add support for SQL statement tracing --- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/connection.cxx | 4 +- odb/sqlite/connection.hxx | 20 ++++++++++ odb/sqlite/database.hxx | 20 ++++++++++ odb/sqlite/forward.hxx | 2 + odb/sqlite/makefile | 1 + odb/sqlite/statement-cache.cxx | 10 ++--- odb/sqlite/statement-cache.hxx | 20 +++++----- odb/sqlite/statement.cxx | 86 ++++++++++++++++++++++++++++++++++++++---- odb/sqlite/statement.hxx | 25 ++++++------ odb/sqlite/tracer.cxx | 62 ++++++++++++++++++++++++++++++ odb/sqlite/tracer.hxx | 62 ++++++++++++++++++++++++++++++ odb/sqlite/transaction.hxx | 20 ++++++++++ 13 files changed, 296 insertions(+), 38 deletions(-) create mode 100644 odb/sqlite/tracer.cxx create mode 100644 odb/sqlite/tracer.hxx diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 60b1ea9..f0f0806 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -83,7 +83,7 @@ namespace odb return h; } - operator H* () + operator H* () const { return h_; } diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 7b16547..f9753be 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -80,7 +80,7 @@ namespace odb { // Enable/disable foreign key constraints. // - simple_statement st ( + generic_statement st ( *this, db_.foreign_keys () ? "PRAGMA foreign_keys=ON" @@ -122,7 +122,7 @@ namespace odb unsigned long long connection:: execute (const char* s, std::size_t n) { - simple_statement st (*this, s, n); + generic_statement st (*this, s, n); return st.execute (); } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 4ad4f42..0986866 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -69,6 +70,25 @@ namespace odb virtual unsigned long long execute (const char* statement, std::size_t length); + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::connection::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::connection::tracer (t); + } + + using odb::connection::tracer; + public: sqlite3* handle () diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 348f236..aeaca22 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -100,6 +101,25 @@ namespace odb connection_ptr connection (); + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::database::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::database::tracer (t); + } + + using odb::database::tracer; + public: virtual ~database (); diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index cc1fbfc..5ad3a0f 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -18,7 +18,9 @@ namespace odb class connection; typedef details::shared_ptr connection_ptr; class connection_factory; + class statement; class transaction; + class tracer; class query; // Implementation details. diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 50ef959..69ae8de 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -18,6 +18,7 @@ result.cxx \ statement-cache.cxx \ statement.cxx \ statements-base.cxx \ +tracer.cxx \ traits.cxx \ transaction.cxx \ transaction-impl.cxx diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index ba7b56c..48a4220 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -17,9 +17,9 @@ namespace odb // String lengths below include '\0', as per SQLite manual // suggestions. // - begin_ (new (shared) simple_statement (conn_, "BEGIN", 6)), - commit_ (new (shared) simple_statement (conn_, "COMMIT", 7)), - rollback_ (new (shared) simple_statement (conn_, "ROLLBACK", 9)) + begin_ (new (shared) generic_statement (conn_, "BEGIN", 6)), + commit_ (new (shared) generic_statement (conn_, "COMMIT", 7)), + rollback_ (new (shared) generic_statement (conn_, "ROLLBACK", 9)) { rollback_->cached (true); commit_->cached (true); @@ -30,7 +30,7 @@ namespace odb begin_immediate_statement_ () const { begin_immediate_.reset ( - new (shared) simple_statement (conn_, "BEGIN IMMEDIATE", 16)); + new (shared) generic_statement (conn_, "BEGIN IMMEDIATE", 16)); begin_immediate_->cached (true); } @@ -38,7 +38,7 @@ namespace odb begin_exclusive_statement_ () const { begin_exclusive_.reset ( - new (shared) simple_statement (conn_, "BEGIN EXCLUSIVE", 16)); + new (shared) generic_statement (conn_, "BEGIN EXCLUSIVE", 16)); begin_exclusive_->cached (true); } } diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 1bdefb6..4f717e7 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -35,13 +35,13 @@ namespace odb public: statement_cache (connection&); - simple_statement& + generic_statement& begin_statement () const { return *begin_; } - simple_statement& + generic_statement& begin_immediate_statement () const { if (!begin_immediate_) @@ -50,7 +50,7 @@ namespace odb return *begin_immediate_; } - simple_statement& + generic_statement& begin_exclusive_statement () const { if (!begin_exclusive_) @@ -59,13 +59,13 @@ namespace odb return *begin_exclusive_; } - simple_statement& + generic_statement& commit_statement () const { return *commit_; } - simple_statement& + generic_statement& rollback_statement () const { return *rollback_; @@ -119,11 +119,11 @@ namespace odb connection& conn_; - details::shared_ptr begin_; - mutable details::shared_ptr begin_immediate_; - mutable details::shared_ptr begin_exclusive_; - details::shared_ptr commit_; - details::shared_ptr rollback_; + details::shared_ptr begin_; + mutable details::shared_ptr begin_immediate_; + mutable details::shared_ptr begin_exclusive_; + details::shared_ptr commit_; + details::shared_ptr rollback_; map map_; }; diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index a33ebcb..e1f4fb6 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -6,8 +6,10 @@ #include // std::memcpy #include +#include #include // object_not_persistent +#include #include #include #include @@ -24,7 +26,8 @@ namespace odb statement:: ~statement () { - finilize (); + if (stmt_ != 0) + finilize (); } void statement:: @@ -53,6 +56,35 @@ namespace odb next_ = this; list_add (); // Add to the list because we are uncached. + + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->prepare (conn_, *this); + } + } + + void statement:: + finilize () + { + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->deallocate (conn_, *this); + } + + list_remove (); + stmt_.reset (); + } + + const char* statement:: + text () const + { + return sqlite3_sql (stmt_); } void statement:: @@ -187,29 +219,37 @@ namespace odb return r; } - // simple_statement + // generic_statement // - simple_statement:: - simple_statement (connection& conn, const string& s) + generic_statement:: + generic_statement (connection& conn, const string& s) : statement (conn, s), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } - simple_statement:: - simple_statement (connection& conn, const char* s, std::size_t n) + generic_statement:: + generic_statement (connection& conn, const char* s, std::size_t n) : statement (conn, s, n), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } - unsigned long long simple_statement:: + unsigned long long generic_statement:: execute () { if (stmt_ == 0) // Empty statement or comment. return 0; + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + unsigned long long r (0); // Only the first call to sqlite3_step() can return SQLITE_LOCKED. @@ -266,6 +306,14 @@ namespace odb if (active ()) reset (); + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + done_ = false; if (param_ != 0) @@ -340,6 +388,14 @@ namespace odb bool insert_statement:: execute () { + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + bind_param (param_.bind, param_.count); int e; @@ -392,6 +448,14 @@ namespace odb unsigned long long update_statement:: execute () { + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + bind_param (param_.bind, param_.count); int e; @@ -426,6 +490,14 @@ namespace odb unsigned long long delete_statement:: execute () { + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + bind_param (param_.bind, param_.count); int e; diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 4fad1a3..4f1e3fd 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -30,18 +30,21 @@ namespace odb { class connection; - class LIBODB_SQLITE_EXPORT statement: public details::shared_base + class LIBODB_SQLITE_EXPORT statement: public odb::statement { public: virtual ~statement () = 0; sqlite3_stmt* - handle () + handle () const { return stmt_; } + virtual const char* + text () const; + // Cached state (public part). // public: @@ -130,11 +133,7 @@ namespace odb // protected: void - finilize () - { - list_remove (); - stmt_.reset (); - } + finilize (); protected: friend class connection; @@ -191,18 +190,18 @@ namespace odb statement* next_; }; - class LIBODB_SQLITE_EXPORT simple_statement: public statement + class LIBODB_SQLITE_EXPORT generic_statement: public statement { public: - simple_statement (connection&, const std::string& statement); - simple_statement (connection&, const char* statement, std::size_t n); + generic_statement (connection&, const std::string& statement); + generic_statement (connection&, const char* statement, std::size_t n); unsigned long long execute (); private: - simple_statement (const simple_statement&); - simple_statement& operator= (const simple_statement&); + generic_statement (const generic_statement&); + generic_statement& operator= (const generic_statement&); private: bool result_set_; diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx new file mode 100644 index 0000000..45f1a3d --- /dev/null +++ b/odb/sqlite/tracer.cxx @@ -0,0 +1,62 @@ +// file : odb/sqlite/tracer.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + tracer:: + ~tracer () + { + } + + void tracer:: + prepare (connection&, const statement&) + { + } + + void tracer:: + execute (connection& c, const statement& s) + { + execute (c, s.text ()); + } + + void tracer:: + deallocate (connection&, const statement&) + { + } + + void tracer:: + prepare (odb::connection& c, const odb::statement& s) + { + prepare (static_cast (c), + static_cast (s)); + } + + void tracer:: + execute (odb::connection& c, const odb::statement& s) + { + execute (static_cast (c), + static_cast (s)); + } + + void tracer:: + execute (odb::connection& c, const char* s) + { + execute (static_cast (c), s); + } + + void tracer:: + deallocate (odb::connection& c, const odb::statement& s) + { + deallocate (static_cast (c), + static_cast (s)); + } + } +} diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx new file mode 100644 index 0000000..f5466dc --- /dev/null +++ b/odb/sqlite/tracer.hxx @@ -0,0 +1,62 @@ +// file : odb/sqlite/tracer.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRACER_HXX +#define ODB_SQLITE_TRACER_HXX + +#include + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_EXPORT tracer: private odb::tracer + { + public: + virtual + ~tracer (); + + virtual void + prepare (connection&, const statement&); + + virtual void + execute (connection&, const statement&); + + virtual void + execute (connection&, const char* statement) = 0; + + virtual void + deallocate (connection&, const statement&); + + private: + // Allow these classes to convert sqlite::tracer to odb::tracer. + // + friend class database; + friend class connection; + friend class transaction; + + virtual void + prepare (odb::connection&, const odb::statement&); + + virtual void + execute (odb::connection&, const odb::statement&); + + virtual void + execute (odb::connection&, const char* statement); + + virtual void + deallocate (odb::connection&, const odb::statement&); + }; + } +} + +#include + +#endif // ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index b30a818..dbf73ab 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -12,6 +12,7 @@ #include #include +#include #include namespace odb @@ -50,6 +51,25 @@ namespace odb static void current (transaction&); + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::transaction::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::transaction::tracer (t); + } + + using odb::transaction::tracer; + public: transaction_impl& implementation (); -- cgit v1.1 From 2097d19dc2e7351b2fa027fa33379e36d1eafd6f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Nov 2011 14:09:52 +0200 Subject: Avoid copying statement text if it is statically allocated --- odb/sqlite/statement.cxx | 79 ++++++++++++++++++++++++++++++++++-------------- odb/sqlite/statement.hxx | 47 ++++++++++++++++++++-------- 2 files changed, 91 insertions(+), 35 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index e1f4fb6..8d5c94b 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -3,9 +3,6 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file -#include // std::memcpy -#include - #include #include // object_not_persistent @@ -31,13 +28,13 @@ namespace odb } void statement:: - init (const char* s, std::size_t n) + init (const char* text, std::size_t text_size) { int e; sqlite3_stmt* stmt (0); while ((e = sqlite3_prepare_v2 (conn_.handle (), - s, - static_cast (n), + text, + static_cast (text_size), &stmt, 0)) == SQLITE_LOCKED) { @@ -223,15 +220,24 @@ namespace odb // generic_statement:: - generic_statement (connection& conn, const string& s) - : statement (conn, s), + generic_statement (connection& conn, const string& text) + : statement (conn, text), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } generic_statement:: - generic_statement (connection& conn, const char* s, std::size_t n) - : statement (conn, s, n), + generic_statement (connection& conn, const char* text) + : statement (conn, text), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + generic_statement:: + generic_statement (connection& conn, + const char* text, + std::size_t text_size) + : statement (conn, text, text_size), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } @@ -285,18 +291,31 @@ namespace odb select_statement:: select_statement (connection& conn, - const string& s, + const string& text, binding& param, binding& result) - : statement (conn, s), param_ (¶m), result_ (result) + : statement (conn, text), param_ (¶m), result_ (result) { } select_statement:: select_statement (connection& conn, - const string& s, + const char* text, + binding& param, binding& result) - : statement (conn, s), param_ (0), result_ (result) + : statement (conn, text), param_ (¶m), result_ (result) + { + } + + select_statement:: + select_statement (connection& conn, const string& text, binding& result) + : statement (conn, text), param_ (0), result_ (result) + { + } + + select_statement:: + select_statement (connection& conn, const char* text, binding& result) + : statement (conn, text), param_ (0), result_ (result) { } @@ -380,8 +399,14 @@ namespace odb // insert_statement:: - insert_statement (connection& conn, const string& s, binding& param) - : statement (conn, s), param_ (param) + insert_statement (connection& conn, const string& text, binding& param) + : statement (conn, text), param_ (param) + { + } + + insert_statement:: + insert_statement (connection& conn, const char* text, binding& param) + : statement (conn, text), param_ (param) { } @@ -438,10 +463,14 @@ namespace odb // update_statement:: - update_statement (connection& conn, - const string& s, - binding& param) - : statement (conn, s), param_ (param) + update_statement (connection& conn, const string& text, binding& param) + : statement (conn, text), param_ (param) + { + } + + update_statement:: + update_statement (connection& conn, const char* text, binding& param) + : statement (conn, text), param_ (param) { } @@ -482,8 +511,14 @@ namespace odb // delete_statement:: - delete_statement (connection& conn, const string& s, binding& param) - : statement (conn, s), param_ (param) + delete_statement (connection& conn, const string& text, binding& param) + : statement (conn, text), param_ (param) + { + } + + delete_statement:: + delete_statement (connection& conn, const char* text, binding& param) + : statement (conn, text), param_ (param) { } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 4f1e3fd..a9b11a0 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -11,7 +11,8 @@ #include #include -#include // std::size_t +#include // std::size_t +#include // std::strlen, std::memcpy #include #include @@ -69,16 +70,22 @@ namespace odb } protected: - statement (connection& conn, const std::string& statement) + statement (connection& conn, const std::string& text) : conn_ (conn) { - init (statement.c_str (), statement.size () + 1); + init (text.c_str (), text.size ()); } - statement (connection& conn, const char* statement, std::size_t n) + statement (connection& conn, const char* text) : conn_ (conn) { - init (statement, n); + init (text, std::strlen (text)); + } + + statement (connection& conn, const char* text, std::size_t text_size) + : conn_ (conn) + { + init (text, text_size); } protected: @@ -146,7 +153,7 @@ namespace odb private: void - init (const char* statement, std::size_t n); + init (const char* text, std::size_t text_size); // Doubly-linked list of active/uncached statements. // @@ -193,8 +200,9 @@ namespace odb class LIBODB_SQLITE_EXPORT generic_statement: public statement { public: - generic_statement (connection&, const std::string& statement); - generic_statement (connection&, const char* statement, std::size_t n); + generic_statement (connection&, const std::string& text); + generic_statement (connection&, const char* text); + generic_statement (connection&, const char* text, std::size_t text_size); unsigned long long execute (); @@ -211,14 +219,21 @@ namespace odb { public: select_statement (connection& conn, - const std::string& statement, + const std::string& text, + binding& param, + binding& result); + + select_statement (connection& conn, + const char* text, binding& param, binding& result); select_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& result); + select_statement (connection& conn, const char* text, binding& result); + // Common select interface expected by the generated code. // public: @@ -284,9 +299,11 @@ namespace odb { public: insert_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + insert_statement (connection& conn, const char* text, binding& param); + // Return true if successful and false if the row is a duplicate. // All other errors are reported by throwing exceptions. // @@ -308,9 +325,11 @@ namespace odb { public: update_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + update_statement (connection& conn, const char* text, binding& param); + unsigned long long execute (); @@ -326,9 +345,11 @@ namespace odb { public: delete_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + delete_statement (connection& conn, const char* text, binding& param); + unsigned long long execute (); -- cgit v1.1 From 3167ac0713a756e948a367274eeb8fbf84ae9853 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Nov 2011 12:17:52 +0200 Subject: Fix misspelled file name --- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index f84a6c0..52554bf 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,4 +1,4 @@ -// file : odb/sqlite/errors.cxx +// file : odb/sqlite/error.cxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index c897988..48f0e6a 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,10 +1,10 @@ -// file : odb/sqlite/errors.hxx +// file : odb/sqlite/error.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file -#ifndef ODB_SQLITE_ERRORS_HXX -#define ODB_SQLITE_ERRORS_HXX +#ifndef ODB_SQLITE_ERROR_HXX +#define ODB_SQLITE_ERROR_HXX #include @@ -26,4 +26,4 @@ namespace odb #include -#endif // ODB_SQLITE_ERRORS_HXX +#endif // ODB_SQLITE_ERROR_HXX -- cgit v1.1 From 0621ffcc107e4cf106d7b48a8bbc1dba086cfb89 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Nov 2011 11:51:15 +0200 Subject: Remove unnecessary includes --- odb/sqlite/database.hxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/view-statements.hxx | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index aeaca22..49e34d7 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -15,7 +15,6 @@ #include // std::ostream #include -#include #include #include @@ -23,6 +22,7 @@ #include #include #include + #include namespace odb diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index f0df824..c353156 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -9,10 +9,10 @@ #include #include -#include #include #include + #include namespace odb diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 6126f08..92bbca3 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include -- cgit v1.1 From 4476c35c66b3fc795f71ccaf38c886f5e725d173 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Nov 2011 11:54:02 +0200 Subject: Remove unnecessary forward declaration --- odb/sqlite/connection.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 0986866..94f08d0 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -30,7 +30,6 @@ namespace odb { namespace sqlite { - class statement; class statement_cache; class connection; -- cgit v1.1 From f82fdb8d55ec0c675169ba300ff451481bc4e43c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 28 Nov 2011 15:57:43 +0200 Subject: Add missing version.hxx include; correct export macro --- odb/sqlite/tracer.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index f5466dc..1cca414 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -10,6 +10,7 @@ #include +#include #include #include @@ -17,7 +18,7 @@ namespace odb { namespace sqlite { - class LIBODB_EXPORT tracer: private odb::tracer + class LIBODB_SQLITE_EXPORT tracer: private odb::tracer { public: virtual -- cgit v1.1 From 609a0171aea00a78bfd4c0da01756f55639262e9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Dec 2011 09:30:31 +0200 Subject: Add link to licensing overview page --- LICENSE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LICENSE b/LICENSE index ed9c55c..612c66c 100644 --- a/LICENSE +++ b/LICENSE @@ -2,6 +2,12 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. +For more information on ODB licensing as well as for answers to +some of the common licensing questions, visit the ODB License +page: + +http://www.codesynthesis.com/products/odb/license.xhtml + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- cgit v1.1 From 3edeea46dc85e37a3205f2f38f2ebb645df69c4f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Dec 2011 12:02:19 +0200 Subject: Bump version to 1.7.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b4ebe64..7aefe64 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -29,15 +29,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10601 +#if ODB_VERSION != 10700 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1069901 -#define LIBODB_SQLITE_VERSION_STR "1.7.0.a1" +#define LIBODB_SQLITE_VERSION 1070000 +#define LIBODB_SQLITE_VERSION_STR "1.7.0" #include diff --git a/version b/version index 38a3807..bd8bf88 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.7.0.a1 +1.7.0 -- cgit v1.1 From 2ce2258f8a014186639b7fed4b80020a82508cd1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Dec 2011 15:35:51 +0200 Subject: Do not select object id in container SELECT statement --- odb/sqlite/container-statements.hxx | 26 +++++++++++++++++++++----- odb/sqlite/container-statements.txx | 24 +++++++++++++++--------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index db59ead..c839872 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -156,6 +156,18 @@ namespace odb return data_image_truncated_; } + binding& + select_image_binding () + { + return select_image_binding_; + } + + bool* + select_image_truncated () + { + return select_image_truncated_; + } + // // Statements. // @@ -185,7 +197,7 @@ namespace odb conn_, select_all_text_, cond_image_binding_, - data_image_binding_)); + select_image_binding_)); select_all_->cached (true); } @@ -222,15 +234,19 @@ namespace odb std::size_t cond_image_version_; std::size_t cond_id_binding_version_; binding cond_image_binding_; - bind* cond_image_bind_; data_image_type data_image_; std::size_t data_image_version_; std::size_t data_id_binding_version_; + binding data_image_binding_; - bind* data_image_bind_; bool* data_image_truncated_; + // Skips the id from data_image_binding. + // + binding select_image_binding_; + bool* select_image_truncated_; + const char* insert_one_text_; const char* select_all_text_; const char* delete_all_text_; @@ -257,8 +273,8 @@ namespace odb container_statements_impl& operator= (const container_statements_impl&); private: - bind cond_image_bind_array_[traits::cond_column_count]; - bind data_image_bind_array_[traits::data_column_count]; + bind cond_image_bind_[traits::cond_column_count]; + bind data_image_bind_[traits::data_column_count]; bool data_image_truncated_array_[traits::data_column_count]; }; } diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 5cf3463..43afb39 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -22,8 +22,9 @@ namespace odb &traits::load_all, &traits::delete_all), id_binding_ (0), - cond_image_binding_ (0, 0), // Initialized by impl. - data_image_binding_ (0, 0) // Initialized by impl. + cond_image_binding_ (0, 0), // Initialized by impl. + data_image_binding_ (0, 0), // Initialized by impl. + select_image_binding_ (0, 0) // Initialized by impl. { cond_image_.version = 0; cond_image_version_ = 0; @@ -39,24 +40,29 @@ namespace odb container_statements_impl (connection_type& conn) : base (conn) { - this->cond_image_bind_ = cond_image_bind_array_; - this->data_image_bind_ = data_image_bind_array_; this->data_image_truncated_ = data_image_truncated_array_; + this->select_image_truncated_ = data_image_truncated_array_ + + traits::id_column_count; - this->cond_image_binding_.bind = this->cond_image_bind_; + this->cond_image_binding_.bind = cond_image_bind_; this->cond_image_binding_.count = traits::cond_column_count; - this->data_image_binding_.bind = this->data_image_bind_; + this->data_image_binding_.bind = data_image_bind_; this->data_image_binding_.count = traits::data_column_count; - std::memset (cond_image_bind_array_, 0, sizeof (cond_image_bind_array_)); - std::memset (data_image_bind_array_, 0, sizeof (data_image_bind_array_)); + this->select_image_binding_.bind = data_image_bind_ + + traits::id_column_count; + this->select_image_binding_.count = traits::data_column_count - + traits::id_column_count; + + std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); + std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); std::memset (data_image_truncated_array_, 0, sizeof (data_image_truncated_array_)); for (std::size_t i (0); i < traits::data_column_count; ++i) - data_image_bind_array_[i].truncated = data_image_truncated_array_ + i; + data_image_bind_[i].truncated = data_image_truncated_array_ + i; this->insert_one_text_ = traits::insert_one_statement; this->select_all_text_ = traits::select_all_statement; -- cgit v1.1 From f85e4bbdcfa4a111b6a6f9104b9bf666046ab061 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Jan 2012 08:47:57 +0200 Subject: Add missing #include --- odb/sqlite/object-result.txx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index f400fe4..4690181 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + #include #include -- cgit v1.1 From 6d217bf037d27eb5a82eb1ebecbc06c9f7da76eb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Jan 2012 08:48:03 +0200 Subject: Cosmetic changes --- odb/sqlite/query.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 222805b..1667a92 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -231,7 +231,7 @@ namespace odb optimize () { // Remove a single TRUE literal or one that is followe by one of - // the other clauses. This avoids usless WHERE clauses like + // the other clauses. This avoids useless WHERE clauses like // // WHERE TRUE GROUP BY foo // -- cgit v1.1 From 672e2e42125975d98195e9f4e9b7ccb654a9c7cc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Jan 2012 12:43:15 +0200 Subject: Implement support for database schema New pragma qualifier: namespace. New pragma specifier: schema. The table specifier was extended to accept a schema prefix. New option: --default- schema. The common/schema test was extended to cover the new functionality. --- odb/sqlite/query.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 1667a92..d2a34ac 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -181,11 +181,9 @@ namespace odb void query:: append (const char* table, const char* column) { - string s ("\""); - s += table; - s += "\".\""; + string s (table); + s += '.'; s += column; - s += '"'; clause_.push_back (clause_part (clause_part::column, s)); } -- cgit v1.1 From d5868b392885b35240fb0982ba66d6b6df12857f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Jan 2012 14:25:55 +0200 Subject: Remove author field from file header Too much effort to maintain. --- Makefile.am | 1 - bootstrap | 1 - build/bootstrap.make | 1 - build/export/libodb-sqlite/stub.make | 1 - build/import/cli/cli-cxx.make | 1 - build/import/cli/configuration-rules.make | 1 - build/import/cli/configure | 1 - build/import/cli/stub.make | 1 - build/import/libodb-sqlite/configuration-rules.make | 1 - build/import/libodb-sqlite/configure | 1 - build/import/libodb-sqlite/stub.make | 1 - build/import/libodb/configuration-rules.make | 1 - build/import/libodb/configure | 1 - build/import/libodb/stub.make | 1 - build/import/libsqlite/configuration-rules.make | 1 - build/import/libsqlite/configure | 1 - build/import/libsqlite/rules.make | 1 - build/import/libsqlite/stub.make | 1 - configure.ac | 1 - libodb-sqlite.pc.in | 1 - m4/disable-rpath.m4 | 1 - m4/libodb.m4 | 1 - m4/libsqlite.m4 | 1 - m4/libtool-link.m4 | 1 - m4/pkgconfig.m4 | 1 - m4/static-lib.m4 | 1 - m4/threads.m4 | 1 - makefile | 1 - odb/sqlite/Makefile.am | 1 - odb/sqlite/auto-handle.hxx | 1 - odb/sqlite/binding.hxx | 1 - odb/sqlite/connection-factory.cxx | 1 - odb/sqlite/connection-factory.hxx | 1 - odb/sqlite/connection.cxx | 1 - odb/sqlite/connection.hxx | 1 - odb/sqlite/container-statements.hxx | 1 - odb/sqlite/container-statements.txx | 1 - odb/sqlite/database.cxx | 1 - odb/sqlite/database.hxx | 1 - odb/sqlite/database.ixx | 1 - odb/sqlite/details/config.h.in | 1 - odb/sqlite/details/config.hxx | 1 - odb/sqlite/details/export.hxx | 1 - odb/sqlite/details/options.cli | 1 - odb/sqlite/error.cxx | 1 - odb/sqlite/error.hxx | 1 - odb/sqlite/exceptions.cxx | 1 - odb/sqlite/exceptions.hxx | 1 - odb/sqlite/forward.hxx | 1 - odb/sqlite/makefile | 3 +-- odb/sqlite/object-result.hxx | 1 - odb/sqlite/object-result.txx | 1 - odb/sqlite/object-statements.cxx | 1 - odb/sqlite/object-statements.hxx | 1 - odb/sqlite/object-statements.ixx | 1 - odb/sqlite/object-statements.txx | 1 - odb/sqlite/query-const-expr.cxx | 1 - odb/sqlite/query.cxx | 1 - odb/sqlite/query.hxx | 1 - odb/sqlite/query.ixx | 1 - odb/sqlite/query.txx | 1 - odb/sqlite/result.cxx | 1 - odb/sqlite/result.hxx | 1 - odb/sqlite/sqlite-types.hxx | 1 - odb/sqlite/statement-cache.cxx | 1 - odb/sqlite/statement-cache.hxx | 1 - odb/sqlite/statement.cxx | 1 - odb/sqlite/statement.hxx | 1 - odb/sqlite/statements-base.cxx | 1 - odb/sqlite/statements-base.hxx | 1 - odb/sqlite/tracer.cxx | 1 - odb/sqlite/tracer.hxx | 1 - odb/sqlite/traits.cxx | 1 - odb/sqlite/traits.hxx | 1 - odb/sqlite/transaction-impl.cxx | 1 - odb/sqlite/transaction-impl.hxx | 1 - odb/sqlite/transaction-impl.ixx | 1 - odb/sqlite/transaction.cxx | 1 - odb/sqlite/transaction.hxx | 1 - odb/sqlite/transaction.ixx | 1 - odb/sqlite/version.hxx | 1 - odb/sqlite/view-result.hxx | 1 - odb/sqlite/view-result.txx | 1 - odb/sqlite/view-statements.hxx | 1 - odb/sqlite/view-statements.txx | 1 - 85 files changed, 1 insertion(+), 86 deletions(-) diff --git a/Makefile.am b/Makefile.am index 031bf8b..5f2eb1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,4 @@ # file : Makefile.am -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/bootstrap b/bootstrap index 777bd86..7f49d40 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,6 @@ #! /bin/sh # file : bootstrap -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/bootstrap.make b/build/bootstrap.make index b5f87a7..fe99225 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,4 @@ # file : build/bootstrap.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index 6beb3be..f1ab0ef 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,4 @@ # file : build/export/libodb-sqlite/stub.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index 5d4293e..8e7da18 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,4 @@ # file : build/import/cli/cli-cxx.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index e5a77f2..a4b6d50 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/cli/configuration-rules.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/configure b/build/import/cli/configure index 612301c..33b91a5 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 20cf45a..36e743f 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,4 @@ # file : build/import/cli/stub.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 420f1ef..7fce21e 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index ee067ca..b891125 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 43f0e11..6ea894f 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,4 @@ # file : build/import/libodb-sqlite/stub.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 9263bb0..15b4ffd 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libodb/configuration-rules.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/configure b/build/import/libodb/configure index 90e21d4..959e613 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index 97bb5ff..29a4ae6 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,4 @@ # file : build/import/libodb/stub.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 6752b77..b6e30eb 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/configuration-rules.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index 3bbf936..c1b2744 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index e482f05..f893a32 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/rules.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index a6ae87d..7890040 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/stub.make -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file diff --git a/configure.ac b/configure.ac index 269564d..242b6e3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,4 @@ # file : configure.ac -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 0871c16..5f1457e 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,4 @@ # file : libodb-sqlite.pc.in -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index 376599e..a3f1fcc 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,4 @@ dnl file : m4/disable-rpath.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/libodb.m4 b/m4/libodb.m4 index fb11859..ffee03d 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,4 @@ dnl file : m4/libodb.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index acb4fe3..6cfe4e1 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,4 @@ dnl file : m4/libsqlite.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index d8395d5..221b9f2 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,4 @@ dnl file : m4/libtool-link.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 11ccb00..443afb1 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,4 @@ dnl file : m4/pkgconfig.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index f550b7b..14a1041 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,4 @@ dnl file : m4/static-lib.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/m4/threads.m4 b/m4/threads.m4 index d4ed7cd..e351480 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,4 @@ dnl file : m4/threads.m4 -dnl author : Boris Kolpackov dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl diff --git a/makefile b/makefile index 3904ece..ab1088a 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,4 @@ # file : makefile -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index 238583d..f0f6185 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,4 @@ # file : odb/sqlite/Makefile.am -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index f0f0806..3b714a2 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/auto-handle.hxx -// author : Constantin Michael // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index 23a21df..cb4cfe1 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/binding.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index f200a17..f14e036 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection-factory.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 94cd227..9135274 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection-factory.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index f9753be..ce6c82c 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 94f08d0..044eb66 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index c839872..47cd278 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/container-statements.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 43afb39..5f2c442 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/container-statements.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 04f788b..aa6dabd 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 49e34d7..2c4d84f 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index e7ae208..ff63a84 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.ixx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 7e3eb4a..2938f73 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/config.h.in - * author : Boris Kolpackov * copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 26aeaf3..bcb523c 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/details/config.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index dd17e33..9bdb648 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/details/export.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 4105557..b709e80 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,4 @@ // file : odb/sqlite/details/options.cli -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 52554bf..abc5c34 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/error.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 48f0e6a..13c5231 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/error.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 6bd8bb8..1e8547e 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/exceptions.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index cb08e8a..ce004ea 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/exceptions.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 5ad3a0f..bcfffea 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/forward.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 69ae8de..1ec3417 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,4 @@ # file : odb/sqlite/makefile -# author : Boris Kolpackov # copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file @@ -70,7 +69,7 @@ $(gen): cli_options += \ $(out_base)/details/config.h: | $(out_base)/details/. @echo '/* file : odb/sqlite/details/config.h' >$@ - @echo ' * author : automatically generated' >>$@ + @echo ' * note : automatically generated' >>$@ @echo ' */' >>$@ @echo '' >>$@ @echo '#ifndef ODB_SQLITE_DETAILS_CONFIG_H' >>$@ diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx index 6953787..dad67bd 100644 --- a/odb/sqlite/object-result.hxx +++ b/odb/sqlite/object-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-result.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index 4690181..28cbb9e 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-result.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/object-statements.cxx b/odb/sqlite/object-statements.cxx index fd3df50..45bb013 100644 --- a/odb/sqlite/object-statements.cxx +++ b/odb/sqlite/object-statements.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-statements.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 34a6a5e..1c81fd5 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-statements.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/object-statements.ixx b/odb/sqlite/object-statements.ixx index f629ea7..833dcc3 100644 --- a/odb/sqlite/object-statements.ixx +++ b/odb/sqlite/object-statements.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-statements.ixx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 7132296..e30e644 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/object-statements.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 49c5a6c..3c5d1af 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-const-expr.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index d2a34ac..f9eae20 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 957e7b7..cd1bb96 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index f51da5a..6d9d1af 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.ixx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 590d4bd..d4cb9f0 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx index 29afb3b..ccee062 100644 --- a/odb/sqlite/result.cxx +++ b/odb/sqlite/result.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/result.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index b8b759e..bf46e96 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/result.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index b0bcde4..1b5a935 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/sqlite-types.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 48a4220..25421ae 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement-cache.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 4f717e7..fbd2bf4 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement-cache.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 8d5c94b..0f5734c 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index a9b11a0..740be95 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index 9379047..452f3a2 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statements-base.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index a2d5a81..40d9c8b 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statements-base.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 45f1a3d..06de483 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/tracer.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 1cca414..159513f 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/tracer.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 3884f36..37d0406 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/traits.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index fe16835..234d362 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/traits.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index b425ed8..93f2b12 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index c353156..a88586e 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index f31f0ab..5572b40 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.ixx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 6690d92..53e619a 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.cxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index dbf73ab..16c79cf 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index e8a6594..c69c857 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.ixx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 7aefe64..ef1020f 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/version.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 32507fd..3a1849a 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-result.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index f4449eb..8253b84 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-result.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 92bbca3..cebc25e 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-statements.hxx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index 790a537..3ac82ef 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-statements.txx -// author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file -- cgit v1.1 From 49385d22e24d53e9c742e537b34b2555174a68f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Jan 2012 14:52:02 +0200 Subject: Update copyright year --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.make | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/object-result.hxx | 2 +- odb/sqlite/object-result.txx | 2 +- odb/sqlite/object-statements.cxx | 2 +- odb/sqlite/object-statements.hxx | 2 +- odb/sqlite/object-statements.ixx | 2 +- odb/sqlite/object-statements.txx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/result.cxx | 2 +- odb/sqlite/result.hxx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- 86 files changed, 86 insertions(+), 86 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5f2eb1b..d9543d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index 7f49d40..39910bb 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.make b/build/bootstrap.make index fe99225..89a21af 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index f1ab0ef..b161b5d 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index 3fe3ab2..57ee246 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2011 Code Synthesis Tools CC. +Copyright (c) 2009-2012 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index 8e7da18..cd009d9 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index a4b6d50..5fb2485 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index 33b91a5..ae1e512 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 36e743f..3704723 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 7fce21e..f5787e8 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index b891125..cf14ccd 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 6ea894f..872aa63 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 15b4ffd..1fe7152 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index 959e613..1217fee 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index 29a4ae6..65ac80b 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index b6e30eb..9816bfc 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index c1b2744..27932ec 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index f893a32..52ef9bc 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 7890040..691f679 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2011 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Boris Kolpackov # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/configure.ac b/configure.ac index 242b6e3..b357aa2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 5f1457e..e81c54c 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index a3f1fcc..e0ef81d 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index ffee03d..6e282a6 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 6cfe4e1..5a353b9 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index 221b9f2..adecac1 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 443afb1..0e57142 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 14a1041..6e0f45b 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index e351480..fce3f39 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index ab1088a..79a5007 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index f0f6185..e03eedb 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 3b714a2..368df00 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index cb4cfe1..cb5e24c 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index f14e036..75f1240 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 9135274..4f59791 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index ce6c82c..38f622d 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 044eb66..3ddd68d 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 47cd278..bd4ea24 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 5f2c442..b6fc52e 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index aa6dabd..6bd3636 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 2c4d84f..ba0e2c2 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index ff63a84..ab0f09b 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 2938f73..bcd9553 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index bcb523c..ea83884 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 9bdb648..bd29d6e 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index b709e80..ee7529b 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index abc5c34..b7d56c1 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 13c5231..c1471f6 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 1e8547e..6a1a7d9 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index ce004ea..52a976f 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index bcfffea..2084ffb 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 1ec3417..7c74807 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx index dad67bd..9dcdca0 100644 --- a/odb/sqlite/object-result.hxx +++ b/odb/sqlite/object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-result.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index 28cbb9e..c2d06ce 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-result.txx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/object-statements.cxx b/odb/sqlite/object-statements.cxx index 45bb013..6ae631e 100644 --- a/odb/sqlite/object-statements.cxx +++ b/odb/sqlite/object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-statements.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index 1c81fd5..0628222 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-statements.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/object-statements.ixx b/odb/sqlite/object-statements.ixx index 833dcc3..399185a 100644 --- a/odb/sqlite/object-statements.ixx +++ b/odb/sqlite/object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-statements.ixx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index e30e644..9ef6043 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/object-statements.txx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 3c5d1af..c4eba2e 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index f9eae20..0adf8d9 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index cd1bb96..54e0b2b 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 6d9d1af..dcd1ebe 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index d4cb9f0..b095d52 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx index ccee062..2c950d0 100644 --- a/odb/sqlite/result.cxx +++ b/odb/sqlite/result.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/result.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index bf46e96..2d6574f 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/result.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_RESULT_HXX diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 1b5a935..316c032 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 25421ae..6262b25 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index fbd2bf4..8281b22 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 0f5734c..e917ac8 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 740be95..cf94c71 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index 452f3a2..53957af 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 40d9c8b..bd70c37 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 06de483..63eaed1 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 159513f..ac183ca 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 37d0406..0e875a2 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 234d362..ecd982f 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 93f2b12..9497c0a 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index a88586e..dcc7cc2 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index 5572b40..72189cc 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 53e619a..2b874b8 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index 16c79cf..dfcd264 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index c69c857..870f150 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index ef1020f..682a456 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VERSION_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 3a1849a..fb26e39 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 8253b84..b7ec7ae 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index cebc25e..9a4f566 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index 3ac82ef..c5f497b 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t -- cgit v1.1 From 66104116540a703761420ff8cd3e18e8847932ef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Jan 2012 15:12:37 +0200 Subject: Fix incorrect copyright holder --- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 9816bfc..6e3dafd 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2012 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index 27932ec..f13948e 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2012 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 52ef9bc..0e2b5e4 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2012 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 691f679..06f52e5 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2012 Boris Kolpackov +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) -- cgit v1.1 From 896de9d3d468f5f59c28153f5d8559eae7f27901 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Jan 2012 16:37:05 +0200 Subject: Bump version to 1.8.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 682a456..9592f48 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10700 +#if ODB_VERSION != 10800 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1070000 -#define LIBODB_SQLITE_VERSION_STR "1.7.0" +#define LIBODB_SQLITE_VERSION 1080000 +#define LIBODB_SQLITE_VERSION_STR "1.8.0" #include diff --git a/version b/version index bd8bf88..27f9cd3 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.7.0 +1.8.0 -- cgit v1.1 From de7d733d27c13c482f06b23a5770f0d7657cb04b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Feb 2012 15:27:01 +0200 Subject: Don't allocate unnecessary entries in container truncation array --- odb/sqlite/container-statements.hxx | 10 ++-------- odb/sqlite/container-statements.txx | 11 +++++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index bd4ea24..80011d9 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -149,12 +149,6 @@ namespace odb return data_image_binding_; } - bool* - data_image_truncated () - { - return data_image_truncated_; - } - binding& select_image_binding () { @@ -239,7 +233,6 @@ namespace odb std::size_t data_id_binding_version_; binding data_image_binding_; - bool* data_image_truncated_; // Skips the id from data_image_binding. // @@ -274,7 +267,8 @@ namespace odb private: bind cond_image_bind_[traits::cond_column_count]; bind data_image_bind_[traits::data_column_count]; - bool data_image_truncated_array_[traits::data_column_count]; + bool select_image_truncated_array_[traits::data_column_count- + traits::id_column_count]; }; } } diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index b6fc52e..a4dd6f4 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -39,9 +39,7 @@ namespace odb container_statements_impl (connection_type& conn) : base (conn) { - this->data_image_truncated_ = data_image_truncated_array_; - this->select_image_truncated_ = data_image_truncated_array_ + - traits::id_column_count; + this->select_image_truncated_ = select_image_truncated_array_; this->cond_image_binding_.bind = cond_image_bind_; this->cond_image_binding_.count = traits::cond_column_count; @@ -56,12 +54,13 @@ namespace odb std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); - std::memset (data_image_truncated_array_, + std::memset (select_image_truncated_array_, 0, - sizeof (data_image_truncated_array_)); + sizeof (select_image_truncated_array_)); for (std::size_t i (0); i < traits::data_column_count; ++i) - data_image_bind_[i].truncated = data_image_truncated_array_ + i; + data_image_bind_[i + traits::id_column_count].truncated = + select_image_truncated_array_ + i; this->insert_one_text_ = traits::insert_one_statement; this->select_all_text_ = traits::select_all_statement; -- cgit v1.1 From 88d2a5bf72dc8dabce16428ab8c6d37df5dd6cce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 Feb 2012 12:28:05 +0200 Subject: Add support for composite object ids New pragma id_type (member). New test: common/composite-id. The composite example has also been updated. --- odb/sqlite/object-result.txx | 4 ++-- odb/sqlite/object-statements.txx | 2 +- odb/sqlite/view-result.txx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index c2d06ce..a6b4e50 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -50,7 +50,7 @@ namespace odb object_traits::callback (db, obj, callback_event::pre_load); typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, db); + object_traits::init (obj, i, &db); // Initialize the id image and binding and load the rest of the object // (containers, etc). @@ -197,7 +197,7 @@ namespace odb odb::database& db (this->database ()); object_traits::callback (db, obj, callback_event::pre_load); - object_traits::init (obj, im, db); + object_traits::init (obj, im, &db); object_traits::callback (db, obj, callback_event::post_load); } diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx index 9ef6043..a880ceb 100644 --- a/odb/sqlite/object-statements.txx +++ b/odb/sqlite/object-statements.txx @@ -97,7 +97,7 @@ namespace odb // loads being added to the delayed_ vector. We need to process // those before we call the post callback. // - object_traits::init (*l.obj, image (), db); + object_traits::init (*l.obj, image (), &db); object_traits::load_ (*this, *l.obj); // Load containers, etc. if (!delayed_.empty ()) diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index b7ec7ae..c240add 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -65,7 +65,7 @@ namespace odb odb::database& db (this->database ()); view_traits::callback (db, view, callback_event::pre_load); - view_traits::init (view, im, db); + view_traits::init (view, im, &db); view_traits::callback (db, view, callback_event::post_load); } -- cgit v1.1 From 89ceaaf470d19d475d665b87a1fbe66009d0912b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Mar 2012 12:34:41 +0200 Subject: Add support for using C++11 std::unique_ptr to pass connection factory --- odb/sqlite/database.cxx | 12 ++++++++---- odb/sqlite/database.hxx | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 6bd3636..cd62a1c 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -18,6 +18,8 @@ namespace odb { namespace sqlite { + using odb::details::transfer_ptr; + database:: ~database () { @@ -27,11 +29,11 @@ namespace odb database (const string& name, int flags, bool foreign_keys, - auto_ptr factory) + transfer_ptr factory) : name_ (name), flags_ (flags), foreign_keys_ (foreign_keys), - factory_ (factory) + factory_ (factory.transfer ()) { if (factory_.get () == 0) factory_.reset (new connection_pool_factory ()); @@ -45,8 +47,10 @@ namespace odb bool erase, int flags, bool foreign_keys, - std::auto_ptr factory) - : flags_ (flags), foreign_keys_ (foreign_keys), factory_ (factory) + transfer_ptr factory) + : flags_ (flags), + foreign_keys_ (foreign_keys), + factory_ (factory.transfer ()) { using namespace details; diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index ba0e2c2..d2bf61f 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -10,10 +10,12 @@ #include #include -#include // std::auto_ptr +#include // std::auto_ptr, std::unique_ptr #include // std::ostream #include +#include // ODB_CXX11 +#include #include #include @@ -36,8 +38,8 @@ namespace odb database (const std::string& name, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, - std::auto_ptr = - std::auto_ptr (0)); + details::transfer_ptr = + details::transfer_ptr ()); // Extract the database parameters from the command line. The // following options are recognized: @@ -58,8 +60,8 @@ namespace odb bool erase = false, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, - std::auto_ptr = - std::auto_ptr (0)); + details::transfer_ptr = + details::transfer_ptr ()); static void print_usage (std::ostream&); @@ -131,7 +133,12 @@ namespace odb std::string name_; int flags_; bool foreign_keys_; + +#ifdef ODB_CXX11 + std::unique_ptr factory_; +#else std::auto_ptr factory_; +#endif }; } } -- cgit v1.1 From 97866a78e12fd4398ef9cb023feba794dbf7ff32 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Mar 2012 12:28:33 +0200 Subject: Fix array subscript overflow --- odb/sqlite/container-statements.txx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index a4dd6f4..19ecfdc 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -58,7 +58,9 @@ namespace odb 0, sizeof (select_image_truncated_array_)); - for (std::size_t i (0); i < traits::data_column_count; ++i) + for (std::size_t i (0); + i < traits::data_column_count - traits::id_column_count; + ++i) data_image_bind_[i + traits::id_column_count].truncated = select_image_truncated_array_ + i; -- cgit v1.1 From 907801bacc542813759d6191cfd01bc26dff6648 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Mar 2012 14:11:03 +0200 Subject: Reimplement C++11 support to be header-only This way, the same build of the runtime libraries can be used in both C++98 and C++11 modes. This is important for when runtimes are installed or packaged. --- odb/sqlite/database.cxx | 4 ++-- odb/sqlite/database.hxx | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index cd62a1c..74c32d1 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -35,7 +35,7 @@ namespace odb foreign_keys_ (foreign_keys), factory_ (factory.transfer ()) { - if (factory_.get () == 0) + if (!factory_) factory_.reset (new connection_pool_factory ()); factory_->database (*this); @@ -74,7 +74,7 @@ namespace odb throw cli_exception (ostr.str ()); } - if (factory_.get () == 0) + if (!factory_) factory_.reset (new connection_pool_factory ()); factory_->database (*this); diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index d2bf61f..021a5df 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -14,7 +14,7 @@ #include // std::ostream #include -#include // ODB_CXX11 +#include #include #include @@ -133,12 +133,7 @@ namespace odb std::string name_; int flags_; bool foreign_keys_; - -#ifdef ODB_CXX11 - std::unique_ptr factory_; -#else - std::auto_ptr factory_; -#endif + details::unique_ptr factory_; }; } } -- cgit v1.1 From 2de569a55b9fc25142844f88d35f7b6d2d3fb53c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Mar 2012 18:08:04 +0200 Subject: Bump version to 1.9.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 9592f48..04c0b12 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10800 +#if ODB_VERSION != 10801 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1080000 -#define LIBODB_SQLITE_VERSION_STR "1.8.0" +#define LIBODB_SQLITE_VERSION 1089901 +#define LIBODB_SQLITE_VERSION_STR "1.9.0.a1" #include diff --git a/version b/version index 27f9cd3..8a776ac 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.8.0 +1.9.0.a1 -- cgit v1.1 From 7d52205f2b2fc9403b9ea46483e8a17746c6be35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 7 Mar 2012 10:21:08 +0200 Subject: Use RAII to free select statement results --- odb/sqlite/object-result.txx | 10 ++++++++++ odb/sqlite/statement.hxx | 13 +++++++++++++ odb/sqlite/view-result.txx | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index a6b4e50..39dcdd7 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -21,6 +21,8 @@ namespace odb object_result_impl:: ~object_result_impl () { + if (!this->end_) + statement_->free_result (); } template @@ -88,7 +90,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template @@ -147,6 +152,8 @@ namespace odb object_result_impl_no_id:: ~object_result_impl_no_id () { + if (!this->end_) + statement_->free_result (); } template @@ -208,7 +215,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index cf94c71..0ed8aa8 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -294,6 +294,19 @@ namespace odb binding& result_; }; + struct LIBODB_SQLITE_EXPORT auto_result + { + explicit auto_result (select_statement& s): s_ (s) {} + ~auto_result () {s_.free_result ();} + + private: + auto_result (const auto_result&); + auto_result& operator= (const auto_result&); + + private: + select_statement& s_; + }; + class LIBODB_SQLITE_EXPORT insert_statement: public statement { public: diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index c240add..49d0e68 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -15,6 +15,8 @@ namespace odb view_result_impl:: ~view_result_impl () { + if (!this->end_) + statement_->free_result (); } template @@ -76,7 +78,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template -- cgit v1.1 From 851cbe3927b987ec992bbbb69bd62224bf4a0dc3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2012 16:48:01 +0200 Subject: Polymorphic inheritance support --- odb/sqlite/binding.hxx | 2 + odb/sqlite/forward.hxx | 8 +- odb/sqlite/makefile | 32 +- odb/sqlite/no-id-object-result.hxx | 71 +++ odb/sqlite/no-id-object-result.txx | 100 +++++ odb/sqlite/no-id-object-statements.hxx | 137 ++++++ odb/sqlite/no-id-object-statements.txx | 37 ++ odb/sqlite/object-result.hxx | 113 ----- odb/sqlite/object-result.txx | 237 ---------- odb/sqlite/object-statements.cxx | 16 - odb/sqlite/object-statements.hxx | 624 --------------------------- odb/sqlite/object-statements.ixx | 69 --- odb/sqlite/object-statements.txx | 171 -------- odb/sqlite/polymorphic-object-result.hxx | 87 ++++ odb/sqlite/polymorphic-object-result.txx | 266 ++++++++++++ odb/sqlite/polymorphic-object-statements.hxx | 452 +++++++++++++++++++ odb/sqlite/polymorphic-object-statements.txx | 141 ++++++ odb/sqlite/result.hxx | 10 - odb/sqlite/simple-object-result.hxx | 79 ++++ odb/sqlite/simple-object-result.txx | 143 ++++++ odb/sqlite/simple-object-statements.cxx | 16 + odb/sqlite/simple-object-statements.hxx | 515 ++++++++++++++++++++++ odb/sqlite/simple-object-statements.ixx | 69 +++ odb/sqlite/simple-object-statements.txx | 145 +++++++ odb/sqlite/statement-cache.hxx | 40 +- odb/sqlite/statement-cache.txx | 43 ++ odb/sqlite/view-result.hxx | 9 +- odb/sqlite/view-result.txx | 2 +- 28 files changed, 2340 insertions(+), 1294 deletions(-) create mode 100644 odb/sqlite/no-id-object-result.hxx create mode 100644 odb/sqlite/no-id-object-result.txx create mode 100644 odb/sqlite/no-id-object-statements.hxx create mode 100644 odb/sqlite/no-id-object-statements.txx delete mode 100644 odb/sqlite/object-result.hxx delete mode 100644 odb/sqlite/object-result.txx delete mode 100644 odb/sqlite/object-statements.cxx delete mode 100644 odb/sqlite/object-statements.hxx delete mode 100644 odb/sqlite/object-statements.ixx delete mode 100644 odb/sqlite/object-statements.txx create mode 100644 odb/sqlite/polymorphic-object-result.hxx create mode 100644 odb/sqlite/polymorphic-object-result.txx create mode 100644 odb/sqlite/polymorphic-object-statements.hxx create mode 100644 odb/sqlite/polymorphic-object-statements.txx create mode 100644 odb/sqlite/simple-object-result.hxx create mode 100644 odb/sqlite/simple-object-result.txx create mode 100644 odb/sqlite/simple-object-statements.cxx create mode 100644 odb/sqlite/simple-object-statements.hxx create mode 100644 odb/sqlite/simple-object-statements.ixx create mode 100644 odb/sqlite/simple-object-statements.txx create mode 100644 odb/sqlite/statement-cache.txx diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index cb5e24c..f55d48a 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -23,6 +23,8 @@ namespace odb public: typedef sqlite::bind bind_type; + binding (): bind (0), count (0), version (0) {} + binding (bind_type* b, std::size_t n) : bind (b), count (n), version (0) { diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 2084ffb..9be506f 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -38,7 +38,13 @@ namespace odb class object_statements; template - class object_statements_no_id; + class polymorphic_root_object_statements; + + template + class polymorphic_derived_object_statements; + + template + class no_id_object_statements; template class view_statements; diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 7c74807..8674e4a 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -4,22 +4,22 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make -cxx := \ -connection.cxx \ -connection-factory.cxx \ -database.cxx \ -error.cxx \ -exceptions.cxx \ -object-statements.cxx \ -query.cxx \ -query-const-expr.cxx \ -result.cxx \ -statement-cache.cxx \ -statement.cxx \ -statements-base.cxx \ -tracer.cxx \ -traits.cxx \ -transaction.cxx \ +cxx := \ +connection.cxx \ +connection-factory.cxx \ +database.cxx \ +error.cxx \ +exceptions.cxx \ +query.cxx \ +query-const-expr.cxx \ +result.cxx \ +simple-object-statements.cxx \ +statement.cxx \ +statements-base.cxx \ +statement-cache.cxx \ +tracer.cxx \ +traits.cxx \ +transaction.cxx \ transaction-impl.cxx cli_tun := details/options.cli diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx new file mode 100644 index 0000000..84a7265 --- /dev/null +++ b/odb/sqlite/no-id-object-result.hxx @@ -0,0 +1,71 @@ +// file : odb/sqlite/no-id-object-result.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX +#define ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include + +#include +#include // query +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class no_id_object_result_impl: public odb::no_id_object_result_impl, + public result_impl_base + { + public: + typedef odb::no_id_object_result_impl base_type; + + typedef typename base_type::object_traits object_traits; + typedef typename base_type::object_type object_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~no_id_object_result_impl (); + + no_id_object_result_impl (const query&, + details::shared_ptr, + statements_type&); + + virtual void + load (object_type&); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + statements_type& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx new file mode 100644 index 0000000..8519c47 --- /dev/null +++ b/odb/sqlite/no-id-object-result.txx @@ -0,0 +1,100 @@ +// file : odb/sqlite/no-id-object-result.txx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + no_id_object_result_impl:: + ~no_id_object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + no_id_object_result_impl:: + no_id_object_result_impl (const query& q, + details::shared_ptr statement, + statements_type& statements) + : base_type (statements.connection ().database ()), + result_impl_base (q, statement), + statements_ (statements) + { + } + + template + void no_id_object_result_impl:: + load (object_type& obj) + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (object_traits::grow (im, statements_.select_image_truncated ())) + im.version++; + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + statement_->reload (); + } + } + + odb::database& db (this->database ()); + + object_traits::callback (db, obj, callback_event::pre_load); + object_traits::init (obj, im, &db); + object_traits::callback (db, obj, callback_event::post_load); + } + + template + void no_id_object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + void no_id_object_result_impl:: + cache () + { + } + + template + std::size_t no_id_object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx new file mode 100644 index 0000000..04d46ce --- /dev/null +++ b/odb/sqlite/no-id-object-statements.hxx @@ -0,0 +1,137 @@ +// file : odb/sqlite/no-id-object-statements.hxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // Implementation for objects without object id. + // + + template + class no_id_object_statements: public statements_base + { + public: + typedef T object_type; + typedef odb::object_traits object_traits; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + + typedef sqlite::insert_statement insert_statement_type; + + public: + no_id_object_statements (connection_type&); + + virtual + ~no_id_object_statements (); + + // Object image. + // + image_type& + image () {return image_;} + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + insert_image_binding_)); + + persist_->cached (true); + } + + return *persist_; + } + + public: + // select = total + // insert = total - inverse; inverse == 0 for object without id + // + static const std::size_t insert_column_count = + object_traits::column_count; + + static const std::size_t select_column_count = + object_traits::column_count; + + private: + no_id_object_statements (const no_id_object_statements&); + no_id_object_statements& operator= (const no_id_object_statements&); + + private: + image_type image_; + + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. + // + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + details::shared_ptr persist_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx new file mode 100644 index 0000000..9b531f6 --- /dev/null +++ b/odb/sqlite/no-id-object-statements.txx @@ -0,0 +1,37 @@ +// file : odb/sqlite/no-id-object-statements.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + no_id_object_statements:: + ~no_id_object_statements () + { + } + + template + no_id_object_statements:: + no_id_object_statements (connection_type& conn) + : statements_base (conn), + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count) + { + image_.version = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + } +} diff --git a/odb/sqlite/object-result.hxx b/odb/sqlite/object-result.hxx deleted file mode 100644 index 9dcdca0..0000000 --- a/odb/sqlite/object-result.hxx +++ /dev/null @@ -1,113 +0,0 @@ -// file : odb/sqlite/object-result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_OBJECT_RESULT_HXX -#define ODB_SQLITE_OBJECT_RESULT_HXX - -#include - -#include // std::size_t - -#include - -#include -#include // query, object_statements -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class object_result_impl: public odb::object_result_impl, - public result_impl_base - { - public: - typedef odb::object_result_impl base_type; - - typedef typename base_type::object_traits object_traits; - typedef typename base_type::object_type object_type; - typedef typename base_type::id_type id_type; - - typedef typename base_type::pointer_type pointer_type; - typedef typename base_type::pointer_traits pointer_traits; - - virtual - ~object_result_impl (); - - object_result_impl (const query&, - details::shared_ptr, - object_statements&); - - virtual void - load (object_type&, bool fetch); - - virtual id_type - load_id (); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - using base_type::current; - - private: - void - load_image (); - - private: - object_statements& statements_; - }; - - template - class object_result_impl_no_id: public odb::object_result_impl_no_id, - public result_impl_base - { - public: - typedef odb::object_result_impl_no_id base_type; - - typedef typename base_type::object_traits object_traits; - typedef typename base_type::object_type object_type; - - typedef typename base_type::pointer_type pointer_type; - typedef typename base_type::pointer_traits pointer_traits; - - virtual - ~object_result_impl_no_id (); - - object_result_impl_no_id (const query&, - details::shared_ptr, - object_statements_no_id&); - - virtual void - load (object_type&); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - using base_type::current; - - private: - object_statements_no_id& statements_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx deleted file mode 100644 index 39dcdd7..0000000 --- a/odb/sqlite/object-result.txx +++ /dev/null @@ -1,237 +0,0 @@ -// file : odb/sqlite/object-result.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - // - // object_result_impl - // - - template - object_result_impl:: - ~object_result_impl () - { - if (!this->end_) - statement_->free_result (); - } - - template - object_result_impl:: - object_result_impl (const query& q, - details::shared_ptr statement, - object_statements& statements) - : base_type (statements.connection ().database ()), - result_impl_base (q, statement), - statements_ (statements) - { - } - - template - void object_result_impl:: - load (object_type& obj, bool fetch) - { - if (fetch) - load_image (); - - // This is a top-level call so the statements cannot be locked. - // - assert (!statements_.locked ()); - typename object_statements::auto_lock l (statements_); - - odb::database& db (this->database ()); - object_traits::callback (db, obj, callback_event::pre_load); - - typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, &db); - - // Initialize the id image and binding and load the rest of the object - // (containers, etc). - // - typename object_traits::id_image_type& idi (statements_.id_image ()); - object_traits::init (idi, object_traits::id (i)); - - binding& idb (statements_.id_image_binding ()); - if (idi.version != statements_.id_image_version () || idb.version == 0) - { - object_traits::bind (idb.bind, idi); - statements_.id_image_version (idi.version); - idb.version++; - } - - object_traits::load_ (statements_, obj); - statements_.load_delayed (); - l.unlock (); - object_traits::callback (db, obj, callback_event::post_load); - } - - template - typename object_result_impl::id_type - object_result_impl:: - load_id () - { - load_image (); - return object_traits::id (statements_.image ()); - } - - template - void object_result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - void object_result_impl:: - load_image () - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename object_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (object_traits::grow (im, statements_.select_image_truncated ())) - im.version++; - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - statement_->reload (); - } - } - } - - template - void object_result_impl:: - cache () - { - } - - template - std::size_t object_result_impl:: - size () - { - throw result_not_cached (); - } - - // - // object_result_impl_no_id - // - - template - object_result_impl_no_id:: - ~object_result_impl_no_id () - { - if (!this->end_) - statement_->free_result (); - } - - template - object_result_impl_no_id:: - object_result_impl_no_id (const query& q, - details::shared_ptr statement, - object_statements_no_id& statements) - : base_type (statements.connection ().database ()), - result_impl_base (q, statement), - statements_ (statements) - { - } - - template - void object_result_impl_no_id:: - load (object_type& obj) - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename object_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (object_traits::grow (im, statements_.select_image_truncated ())) - im.version++; - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - statement_->reload (); - } - } - - odb::database& db (this->database ()); - - object_traits::callback (db, obj, callback_event::pre_load); - object_traits::init (obj, im, &db); - object_traits::callback (db, obj, callback_event::post_load); - } - - template - void object_result_impl_no_id:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - void object_result_impl_no_id:: - cache () - { - } - - template - std::size_t object_result_impl_no_id:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/object-statements.cxx b/odb/sqlite/object-statements.cxx deleted file mode 100644 index 6ae631e..0000000 --- a/odb/sqlite/object-statements.cxx +++ /dev/null @@ -1,16 +0,0 @@ -// file : odb/sqlite/object-statements.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - namespace sqlite - { - object_statements_base:: - ~object_statements_base () - { - } - } -} diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx deleted file mode 100644 index 0628222..0000000 --- a/odb/sqlite/object-statements.hxx +++ /dev/null @@ -1,624 +0,0 @@ -// file : odb/sqlite/object-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_OBJECT_STATEMENTS_HXX -#define ODB_SQLITE_OBJECT_STATEMENTS_HXX - -#include - -#include -#include -#include // std::size_t - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - template - class object_statements; - - template - class object_statements_no_id; - - template ::id_type> - struct object_statements_selector - { - typedef object_statements type; - }; - - template - struct object_statements_selector - { - typedef object_statements_no_id type; - }; - - // - // Implementation for objects with object id. - // - - class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base - { - public: - // Locking. - // - void - lock () - { - assert (!locked_); - locked_ = true; - } - - void - unlock () - { - assert (locked_); - locked_ = false; - } - - bool - locked () const - { - return locked_; - } - - public: - virtual - ~object_statements_base (); - - protected: - object_statements_base (connection_type& conn) - : statements_base (conn), locked_ (false) - { - } - - struct auto_unlock - { - // Unlocks the statement on construction and re-locks it on - // destruction. - // - auto_unlock (object_statements_base&); - ~auto_unlock (); - - private: - auto_unlock (const auto_unlock&); - auto_unlock& operator= (const auto_unlock&); - - private: - object_statements_base& s_; - }; - - protected: - bool locked_; - }; - - template - struct optimistic_data; - - template - struct optimistic_data - { - typedef T object_type; - typedef odb::object_traits object_traits; - - optimistic_data (bind*); - - // The id + optimistic column binding. - // - std::size_t id_image_version_; - binding id_image_binding_; - - details::shared_ptr erase_; - }; - - template - struct optimistic_data - { - optimistic_data (bind*) {} - }; - - template - class object_statements: public object_statements_base - { - public: - typedef T object_type; - typedef odb::object_traits object_traits; - typedef typename object_traits::id_type id_type; - typedef typename object_traits::pointer_type pointer_type; - typedef typename object_traits::image_type image_type; - typedef typename object_traits::id_image_type id_image_type; - - typedef pointer_cache_traits object_cache_traits; - - typedef - typename object_traits::container_statement_cache_type - container_statement_cache_type; - - typedef sqlite::insert_statement insert_statement_type; - typedef sqlite::select_statement select_statement_type; - typedef sqlite::update_statement update_statement_type; - typedef sqlite::delete_statement delete_statement_type; - - // Automatic lock. - // - struct auto_lock - { - // Lock the statements unless they are already locked in which - // case subsequent calls to locked() will return false. - // - auto_lock (object_statements&); - - // Unlock the statemens if we are holding the lock and clear - // the delayed loads. This should only happen in case an - // exception is thrown. In normal circumstances, the user - // should call unlock() explicitly. - // - ~auto_lock (); - - // Return true if this auto_lock instance holds the lock. - // - bool - locked () const; - - // Unlock the statemens. - // - void - unlock (); - - private: - auto_lock (const auto_lock&); - auto_lock& operator= (const auto_lock&); - - private: - object_statements& s_; - bool locked_; - }; - - - public: - object_statements (connection_type&); - - virtual - ~object_statements (); - - // Delayed loading. - // - void - delay_load (const id_type& id, - object_type& obj, - const typename object_cache_traits::position_type& p) - { - delayed_.push_back (delayed_load (id, obj, p)); - } - - void - load_delayed () - { - assert (locked ()); - - if (!delayed_.empty ()) - load_delayed_ (); - } - - void - clear_delayed () - { - if (!delayed_.empty ()) - clear_delayed_ (); - } - - // Object image. - // - image_type& - image () {return image_;} - - // Insert binding. - // - std::size_t - insert_image_version () const { return insert_image_version_;} - - void - insert_image_version (std::size_t v) {insert_image_version_ = v;} - - binding& - insert_image_binding () {return insert_image_binding_;} - - // Update binding. - // - std::size_t - update_image_version () const { return update_image_version_;} - - void - update_image_version (std::size_t v) {update_image_version_ = v;} - - std::size_t - update_id_image_version () const { return update_id_image_version_;} - - void - update_id_image_version (std::size_t v) {update_id_image_version_ = v;} - - binding& - update_image_binding () {return update_image_binding_;} - - // Select binding. - // - std::size_t - select_image_version () const { return select_image_version_;} - - void - select_image_version (std::size_t v) {select_image_version_ = v;} - - binding& - select_image_binding () {return select_image_binding_;} - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Object id image and binding. - // - id_image_type& - id_image () {return id_image_;} - - std::size_t - id_image_version () const {return id_image_version_;} - - void - id_image_version (std::size_t v) {id_image_version_ = v;} - - binding& - id_image_binding () {return id_image_binding_;} - - // Optimistic id + managed column image binding. - // - std::size_t - optimistic_id_image_version () const {return od_.id_image_version_;} - - void - optimistic_id_image_version (std::size_t v) {od_.id_image_version_ = v;} - - binding& - optimistic_id_image_binding () {return od_.id_image_binding_;} - - // Statements. - // - insert_statement_type& - persist_statement () - { - if (persist_ == 0) - { - persist_.reset ( - new (details::shared) insert_statement_type ( - conn_, - object_traits::persist_statement, - insert_image_binding_)); - - persist_->cached (true); - } - - return *persist_; - } - - select_statement_type& - find_statement () - { - if (find_ == 0) - { - find_.reset ( - new (details::shared) select_statement_type ( - conn_, - object_traits::find_statement, - id_image_binding_, - select_image_binding_)); - - find_->cached (true); - } - - return *find_; - } - - update_statement_type& - update_statement () - { - if (update_ == 0) - { - update_.reset ( - new (details::shared) update_statement_type ( - conn_, - object_traits::update_statement, - update_image_binding_)); - - update_->cached (true); - } - - return *update_; - } - - delete_statement_type& - erase_statement () - { - if (erase_ == 0) - { - erase_.reset ( - new (details::shared) delete_statement_type ( - conn_, - object_traits::erase_statement, - id_image_binding_)); - - erase_->cached (true); - } - - return *erase_; - } - - delete_statement_type& - optimistic_erase_statement () - { - if (od_.erase_ == 0) - { - od_.erase_.reset ( - new (details::shared) delete_statement_type ( - conn_, - object_traits::optimistic_erase_statement, - od_.id_image_binding_)); - - od_.erase_->cached (true); - } - - return *od_.erase_; - } - - // Container statement cache. - // - container_statement_cache_type& - container_statment_cache () - { - return container_statement_cache_; - } - - private: - object_statements (const object_statements&); - object_statements& operator= (const object_statements&); - - private: - void - load_delayed_ (); - - void - clear_delayed_ (); - - private: - // select = total - // insert = total - inverse - managed_optimistic - // update = total - inverse - managed_optimistic - id - readonly - // - static const std::size_t select_column_count = - object_traits::column_count; - - static const std::size_t insert_column_count = - object_traits::column_count - object_traits::inverse_column_count - - object_traits::managed_optimistic_column_count; - - static const std::size_t update_column_count = insert_column_count - - object_traits::id_column_count - object_traits::readonly_column_count; - - static const std::size_t id_column_count = - object_traits::id_column_count; - - static const std::size_t managed_optimistic_column_count = - object_traits::managed_optimistic_column_count; - - private: - container_statement_cache_type container_statement_cache_; - - image_type image_; - - // Select binding. - // - std::size_t select_image_version_; - binding select_image_binding_; - bind select_image_bind_[select_column_count]; - bool select_image_truncated_[select_column_count]; - - // Insert binding. - // - std::size_t insert_image_version_; - binding insert_image_binding_; - bind insert_image_bind_[insert_column_count]; - - // Update binding. Note that the id suffix is bound to id_image_ - // below instead of image_ which makes this binding effectively - // bound to two images. As a result, we have to track versions - // for both of them. If this object uses optimistic concurrency, - // then the binding for the managed column (version, timestamp, - // etc) comes after the id and the image for such a column is - // stored as part of the id image. - // - std::size_t update_image_version_; - std::size_t update_id_image_version_; - binding update_image_binding_; - bind update_image_bind_[update_column_count + id_column_count + - managed_optimistic_column_count]; - - // Id image binding (only used as a parameter). Uses the suffix in - // the update bind. - // - id_image_type id_image_; - std::size_t id_image_version_; - binding id_image_binding_; - - // Extra data for objects with optimistic concurrency support. - // - optimistic_data od_; - - details::shared_ptr persist_; - details::shared_ptr find_; - details::shared_ptr update_; - details::shared_ptr erase_; - - // Delayed loading. - // - struct delayed_load - { - typedef typename object_cache_traits::position_type position_type; - - delayed_load () {} - delayed_load (const id_type& i, object_type& o, const position_type& p) - : id (i), obj (&o), pos (p) - { - } - - id_type id; - object_type* obj; - position_type pos; - }; - - typedef std::vector delayed_loads; - delayed_loads delayed_; - - // Delayed vectors swap guard. See the load_delayed_() function for - // details. - // - struct swap_guard - { - swap_guard (object_statements& os, delayed_loads& dl) - : os_ (os), dl_ (dl) - { - dl_.swap (os_.delayed_); - } - - ~swap_guard () - { - os_.clear_delayed (); - dl_.swap (os_.delayed_); - } - - private: - object_statements& os_; - delayed_loads& dl_; - }; - }; - - // - // Implementation for objects without object id. - // - - template - class object_statements_no_id: public statements_base - { - public: - typedef T object_type; - typedef odb::object_traits object_traits; - typedef typename object_traits::pointer_type pointer_type; - typedef typename object_traits::image_type image_type; - - typedef sqlite::insert_statement insert_statement_type; - - public: - object_statements_no_id (connection_type&); - - virtual - ~object_statements_no_id (); - - // Object image. - // - image_type& - image () {return image_;} - - // Insert binding. - // - std::size_t - insert_image_version () const { return insert_image_version_;} - - void - insert_image_version (std::size_t v) {insert_image_version_ = v;} - - binding& - insert_image_binding () {return insert_image_binding_;} - - // Select binding. - // - std::size_t - select_image_version () const { return select_image_version_;} - - void - select_image_version (std::size_t v) {select_image_version_ = v;} - - binding& - select_image_binding () {return select_image_binding_;} - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Statements. - // - insert_statement_type& - persist_statement () - { - if (persist_ == 0) - { - persist_.reset ( - new (details::shared) insert_statement_type ( - conn_, - object_traits::persist_statement, - insert_image_binding_)); - - persist_->cached (true); - } - - return *persist_; - } - - private: - object_statements_no_id (const object_statements_no_id&); - object_statements_no_id& operator= (const object_statements_no_id&); - - private: - // select = total - // insert = total - inverse; inverse == 0 for object without id - // - static const std::size_t insert_column_count = - object_traits::column_count; - - static const std::size_t select_column_count = - object_traits::column_count; - - private: - image_type image_; - - // Select binding. - // - std::size_t select_image_version_; - binding select_image_binding_; - bind select_image_bind_[select_column_count]; - bool select_image_truncated_[select_column_count]; - - // Insert binding. - // - std::size_t insert_image_version_; - binding insert_image_binding_; - bind insert_image_bind_[insert_column_count]; - - details::shared_ptr persist_; - }; - } -} - -#include -#include - -#include - -#endif // ODB_SQLITE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/object-statements.ixx b/odb/sqlite/object-statements.ixx deleted file mode 100644 index 399185a..0000000 --- a/odb/sqlite/object-statements.ixx +++ /dev/null @@ -1,69 +0,0 @@ -// file : odb/sqlite/object-statements.ixx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - // - // auto_unlock - // - inline object_statements_base::auto_unlock:: - auto_unlock (object_statements_base& s) - : s_ (s) - { - s_.unlock (); - } - - inline object_statements_base::auto_unlock:: - ~auto_unlock () - { - s_.lock (); - } - - // - // auto_lock - // - template - inline object_statements::auto_lock:: - auto_lock (object_statements& s) - : s_ (s) - { - if (!s_.locked ()) - { - s_.lock (); - locked_ = true; - } - else - locked_ = false; - } - - template - inline object_statements::auto_lock:: - ~auto_lock () - { - if (locked_) - { - s_.unlock (); - s_.clear_delayed (); - } - } - - template - inline bool object_statements::auto_lock:: - locked () const - { - return locked_; - } - - template - inline void object_statements::auto_lock:: - unlock () - { - assert (locked_); - s_.unlock (); - locked_ = false; - } - } -} diff --git a/odb/sqlite/object-statements.txx b/odb/sqlite/object-statements.txx deleted file mode 100644 index a880ceb..0000000 --- a/odb/sqlite/object-statements.txx +++ /dev/null @@ -1,171 +0,0 @@ -// file : odb/sqlite/object-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::size_t -#include // std::memset - -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - // - // optimistic_data - // - - template - optimistic_data:: - optimistic_data (bind* b) - : id_image_binding_ ( - b, - object_traits::id_column_count + - object_traits::managed_optimistic_column_count) - { - id_image_version_ = 0; - } - - // - // object_statements - // - - template - object_statements:: - ~object_statements () - { - } - - template - object_statements:: - object_statements (connection_type& conn) - : object_statements_base (conn), - container_statement_cache_ (conn), - select_image_binding_ (select_image_bind_, select_column_count), - insert_image_binding_ (insert_image_bind_, insert_column_count), - update_image_binding_ (update_image_bind_, - update_column_count + id_column_count + - managed_optimistic_column_count), - id_image_binding_ (update_image_bind_ + update_column_count, - id_column_count), - od_ (update_image_bind_ + update_column_count) - { - image_.version = 0; - select_image_version_ = 0; - insert_image_version_ = 0; - update_image_version_ = 0; - update_id_image_version_ = 0; - - id_image_.version = 0; - id_image_version_ = 0; - - std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); - std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - - for (std::size_t i (0); i < select_column_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - - template - void object_statements:: - load_delayed_ () - { - database& db (connection ().database ()); - - delayed_loads dls; - swap_guard sg (*this, dls); - - while (!dls.empty ()) - { - delayed_load l (dls.back ()); - typename object_cache_traits::insert_guard g (l.pos); - dls.pop_back (); - - if (!object_traits::find_ (*this, l.id)) - throw object_not_persistent (); - - object_traits::callback (db, *l.obj, callback_event::pre_load); - - // Our calls to init/load below can result in additional delayed - // loads being added to the delayed_ vector. We need to process - // those before we call the post callback. - // - object_traits::init (*l.obj, image (), &db); - object_traits::load_ (*this, *l.obj); // Load containers, etc. - - if (!delayed_.empty ()) - load_delayed_ (); - - // Temporarily unlock the statement for the post_load call so that - // it can load objects of this type recursively. This is safe to do - // because we have completely loaded the current object. Also the - // delayed_ list is clear before the unlock and should be clear on - // re-lock (since a callback can only call public API functions - // which will make sure all the delayed loads are processed before - // returning). - // - { - auto_unlock u (*this); - object_traits::callback (db, *l.obj, callback_event::post_load); - } - - g.release (); - } - } - - template - void object_statements:: - clear_delayed_ () - { - // Remove the objects from the session cache. - // - if (session::has_current ()) - { - for (typename delayed_loads::iterator i (delayed_.begin ()), - e (delayed_.end ()); i != e; ++i) - { - object_cache_traits::erase (i->pos); - } - } - - delayed_.clear (); - } - - // - // object_statements_no_id - // - - template - object_statements_no_id:: - ~object_statements_no_id () - { - } - - template - object_statements_no_id:: - object_statements_no_id (connection_type& conn) - : statements_base (conn), - select_image_binding_ (select_image_bind_, select_column_count), - insert_image_binding_ (insert_image_bind_, insert_column_count) - { - image_.version = 0; - select_image_version_ = 0; - insert_image_version_ = 0; - - std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - - for (std::size_t i (0); i < select_column_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - } -} diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx new file mode 100644 index 0000000..54f4092 --- /dev/null +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -0,0 +1,87 @@ +// file : odb/sqlite/polymorphic-object-result.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX +#define ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include + +#include +#include // query +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class polymorphic_object_result_impl: + public odb::polymorphic_object_result_impl, + public result_impl_base + { + public: + typedef odb::polymorphic_object_result_impl base_type; + + typedef typename base_type::object_type object_type; + typedef typename base_type::object_traits object_traits; + typedef typename base_type::id_type id_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename base_type::root_type root_type; + typedef typename base_type::root_traits root_traits; + typedef typename base_type::discriminator_type discriminator_type; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~polymorphic_object_result_impl (); + + polymorphic_object_result_impl (const query&, + details::shared_ptr, + statements_type&); + + virtual void + load (object_type*, bool fetch); + + virtual id_type + load_id (); + + virtual discriminator_type + load_discriminator (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + void + load_image (); + + private: + statements_type& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx new file mode 100644 index 0000000..a8cd1f0 --- /dev/null +++ b/odb/sqlite/polymorphic-object-result.txx @@ -0,0 +1,266 @@ +// file : odb/sqlite/polymorphic-object-result.txx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + polymorphic_object_result_impl:: + ~polymorphic_object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + polymorphic_object_result_impl:: + polymorphic_object_result_impl (const query& q, + details::shared_ptr st, + statements_type& sts) + : base_type (sts.connection ().database ()), + result_impl_base (q, st), + statements_ (sts) + { + } + + template + void polymorphic_object_result_impl:: + load (object_type* pobj, bool fetch) + { + if (fetch) + load_image (); + + typename statements_type::root_statements_type& rsts ( + statements_.root_statements ()); + + // This is a top-level call so the statements cannot be locked. + // + assert (!rsts.locked ()); + typename statements_type::auto_lock l (rsts); + + odb::database& db (this->database ()); + typename object_traits::image_type& i (statements_.image ()); + typename root_traits::image_type& ri (rsts.image ()); + + id_type id (root_traits::id (ri)); + + // Determine this object's dynamic type. + // + typedef typename root_traits::info_type info_type; + discriminator_type d (root_traits::discriminator (ri)); + discriminator_type disc (d); + + // Use the polymorphic_info() helper to get concrete_info if + // object_type is concrete and NULL if it is abstract. + // + const info_type* spi (polymorphic_info (object_traits::info)); + const info_type& pi ( + spi != 0 && spi->discriminator == d + ? *spi + : root_traits::map->find (d)); + + typedef typename root_traits::pointer_type root_pointer_type; + typedef typename root_traits::pointer_traits root_pointer_traits; + + typename object_traits::pointer_cache_traits::insert_guard ig; + + if (pobj == 0) + { + // Need to create a new instance of the dynamic type. + // + root_pointer_type rp (pi.create ()); + pointer_type p ( + root_pointer_traits::template static_pointer_cast (rp)); + + // Insert it as a root pointer (for non-unique pointers, rp should + // still be valid and for unique pointers this is a no-op). + // + ig.reset (object_traits::pointer_cache_traits::insert (db, id, rp)); + + pobj = &pointer_traits::get_ref (p); + current (p); + } + else + { + // We are loading into an existing instance. If the static and + // dynamic types differ, then make sure the instance is at least + // of the dynamic type. + // + if (&pi != &object_traits::info) + { + const info_type& dpi (root_traits::map->find (typeid (*pobj))); + + if (&dpi != &pi && dpi.derived (pi)) + throw object_not_persistent (); // @@ type_mismatch ? + } + } + + callback_event ce (callback_event::pre_load); + pi.dispatch (info_type::call_callback, db, pobj, &ce); + + object_traits::init (*pobj, i, &db); + + // Initialize the id image and binding and load the rest of the object + // (containers, dynamic part, etc). + // + typename object_traits::id_image_type& idi (statements_.id_image ()); + root_traits::init (idi, id); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + + object_traits::load_ (statements_, *pobj); + + // Load the dynamic part of the object unless static and dynamic + // types are the same. + // + if (&pi != &object_traits::info) + { + std::size_t d (object_traits::depth); + pi.dispatch (info_type::call_load, db, pobj, &d); + }; + + rsts.load_delayed (); + l.unlock (); + + ce = callback_event::post_load; + pi.dispatch (info_type::call_callback, db, pobj, &ce); + ig.release (); + } + + template + typename polymorphic_object_result_impl::id_type + polymorphic_object_result_impl:: + load_id () + { + load_image (); + return root_traits::id (statements_.root_statements ().image ()); + } + + template + typename polymorphic_object_result_impl::discriminator_type + polymorphic_object_result_impl:: + load_discriminator () + { + load_image (); + return root_traits::discriminator ( + statements_.root_statements ().image ()); + } + + template + void polymorphic_object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + struct polymorphic_image_rebind + { + // Derived type version. + // + typedef object_traits traits; + + static bool + rebind (typename traits::statements_type& sts) + { + typename traits::image_type& im (sts.image ()); + + if (traits::check_version (sts.select_image_versions (), im)) + { + binding& b (sts.select_image_binding (traits::depth)); + traits::bind (b.bind, 0, 0, im, statement_select); + traits::update_version ( + sts.select_image_versions (), im, sts.select_image_bindings ()); + return true; + } + + return false; + } + }; + + template + struct polymorphic_image_rebind + { + // Root type version. + // + typedef object_traits traits; + + static bool + rebind (typename traits::statements_type& sts) + { + typename traits::image_type& im (sts.image ()); + + if (im.version != sts.select_image_version ()) + { + binding& b (sts.select_image_binding ()); + traits::bind (b.bind, im, statement_select); + sts.select_image_version (im.version); + b.version++; + return true; + } + + return false; + } + }; + + template + void polymorphic_object_result_impl:: + load_image () + { + typedef polymorphic_image_rebind image_rebind; + + // The image can grow between calls to load() as a result of other + // statements execution. + // + image_rebind::rebind (statements_); + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + typename object_traits::image_type& im (statements_.image ()); + + if (object_traits::grow (im, statements_.select_image_truncated ())) + im.version++; + + if (image_rebind::rebind (statements_)) + statement_->reload (); + } + } + + template + void polymorphic_object_result_impl:: + cache () + { + } + + template + std::size_t polymorphic_object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx new file mode 100644 index 0000000..1212176 --- /dev/null +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -0,0 +1,452 @@ +// file : odb/sqlite/polymorphic-object-statements.hxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // Implementation for polymorphic objects. + // + + template + class polymorphic_root_object_statements: public object_statements + { + public: + typedef typename object_statements::connection_type connection_type; + typedef typename object_statements::object_traits object_traits; + typedef typename object_statements::id_image_type id_image_type; + + typedef + typename object_traits::discriminator_image_type + discriminator_image_type; + + typedef + typename object_statements::select_statement_type + select_statement_type; + + public: + // Interface compatibility with derived_object_statements. + // + typedef polymorphic_root_object_statements root_statements_type; + + root_statements_type& + root_statements () + { + return *this; + } + + public: + // Discriminator binding. + // + discriminator_image_type& + discriminator_image () {return discriminator_image_;} + + std::size_t + discriminator_image_version () const + {return discriminator_image_version_;} + + void + discriminator_image_version (std::size_t v) + {discriminator_image_version_ = v;} + + binding& + discriminator_image_binding () {return discriminator_image_binding_;} + + bool* + discriminator_image_truncated () {return discriminator_image_truncated_;} + + // Id binding for discriminator retrieval. + // + id_image_type& + discriminator_id_image () {return discriminator_id_image_;} + + std::size_t + discriminator_id_image_version () const + {return discriminator_id_image_version_;} + + void + discriminator_id_image_version (std::size_t v) + {discriminator_id_image_version_ = v;} + + binding& + discriminator_id_image_binding () + {return discriminator_id_image_binding_;} + + // + // + select_statement_type& + find_discriminator_statement () + { + if (find_discriminator_ == 0) + { + find_discriminator_.reset ( + new (details::shared) select_statement_type ( + this->conn_, + object_traits::find_discriminator_statement, + discriminator_id_image_binding_, + discriminator_image_binding_)); + + find_discriminator_->cached (true); + } + + return *find_discriminator_; + } + + public: + polymorphic_root_object_statements (connection_type&); + + virtual + ~polymorphic_root_object_statements (); + + public: + static const std::size_t id_column_count = + object_statements::id_column_count; + + static const std::size_t discriminator_column_count = + object_traits::discriminator_column_count; + + static const std::size_t managed_optimistic_column_count = + object_traits::managed_optimistic_column_count; + + private: + // Discriminator image. + // + discriminator_image_type discriminator_image_; + std::size_t discriminator_image_version_; + binding discriminator_image_binding_; + bind discriminator_image_bind_[discriminator_column_count + + managed_optimistic_column_count]; + bool discriminator_image_truncated_[discriminator_column_count + + managed_optimistic_column_count]; + + // Id image for discriminator retrieval (only used as a parameter). + // + id_image_type discriminator_id_image_; + std::size_t discriminator_id_image_version_; + binding discriminator_id_image_binding_; + bind discriminator_id_image_bind_[id_column_count]; + + details::shared_ptr find_discriminator_; + }; + + template + class polymorphic_derived_object_statements: public statements_base + { + public: + typedef T object_type; + typedef odb::object_traits object_traits; + typedef typename object_traits::id_type id_type; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::id_image_type id_image_type; + typedef typename object_traits::image_type image_type; + + typedef typename object_traits::root_type root_type; + typedef + polymorphic_root_object_statements + root_statements_type; + + typedef typename object_traits::base_type base_type; + typedef + typename object_traits::base_traits::statements_type + base_statements_type; + + typedef + typename object_traits::container_statement_cache_type + container_statement_cache_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef typename root_statements_type::auto_lock auto_lock; + + public: + polymorphic_derived_object_statements (connection_type&); + + virtual + ~polymorphic_derived_object_statements (); + + public: + // Delayed loading. + // + static void + delayed_loader (odb::database&, const id_type&, root_type&); + + public: + // Root and immediate base statements. + // + root_statements_type& + root_statements () + { + return root_statements_; + } + + base_statements_type& + base_statements () + { + return base_statements_; + } + + public: + // Object image. + // + image_type& + image () + { + return image_; + } + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + std::size_t + insert_id_binding_version () const { return insert_id_binding_version_;} + + void + insert_id_binding_version (std::size_t v) {insert_id_binding_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_binding_version () const { return update_id_binding_version_;} + + void + update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // Select binding. + // + std::size_t* + select_image_versions () { return select_image_versions_;} + + binding* + select_image_bindings () {return select_image_bindings_;} + + binding& + select_image_binding (std::size_t d) + { + return select_image_bindings_[object_traits::depth - d]; + } + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Object id binding (comes from the root statements). + // + id_image_type& + id_image () {return root_statements_.id_image ();} + + std::size_t + id_image_version () const {return root_statements_.id_image_version ();} + + void + id_image_version (std::size_t v) {root_statements_.id_image_version (v);} + + binding& + id_image_binding () {return root_statements_.id_image_binding ();} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + insert_image_binding_)); + + persist_->cached (true); + } + + return *persist_; + } + + select_statement_type& + find_statement (std::size_t d) + { + std::size_t i (object_traits::depth - d); + details::shared_ptr& p (find_[i]); + + if (p == 0) + { + p.reset ( + new (details::shared) select_statement_type ( + conn_, + object_traits::find_statements[i], + root_statements_.id_image_binding (), + select_image_bindings_[i])); + + p->cached (true); + } + + return *p; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + { + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + object_traits::update_statement, + update_image_binding_)); + + update_->cached (true); + } + + return *update_; + } + + delete_statement_type& + erase_statement () + { + if (erase_ == 0) + { + erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::erase_statement, + root_statements_.id_image_binding ())); + + erase_->cached (true); + } + + return *erase_; + } + + // Container statement cache. + // + container_statement_cache_type& + container_statment_cache () + { + return container_statement_cache_; + } + + public: + // select = total - id + base::select + // insert = total - inverse + // update = total - inverse - id - readonly + // + static const std::size_t id_column_count = + object_traits::id_column_count; + + static const std::size_t select_column_count = + object_traits::column_count - id_column_count + + base_statements_type::select_column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - object_traits::inverse_column_count; + + static const std::size_t update_column_count = insert_column_count - + object_traits::id_column_count - object_traits::readonly_column_count; + + private: + polymorphic_derived_object_statements ( + const polymorphic_derived_object_statements&); + + polymorphic_derived_object_statements& + operator= (const polymorphic_derived_object_statements&); + + private: + root_statements_type& root_statements_; + base_statements_type& base_statements_; + + container_statement_cache_type container_statement_cache_; + + image_type image_; + + // Select binding. Here we are have an array of statements/bindings + // one for each depth. In other words, if we have classes root, base, + // and derived, then we have the following array of statements: + // + // [0] d + b + r + // [1] d + b + // [2] d + // + // Also, because we have a chain of images bound to these statements, + // we have an array of versions, one entry for each base plus one for + // our own image. + // + // A poly-abstract class only needs the first statement and in this + // case we have only one entry in the the bindings and statements + // arrays (but not versions; we still have a chain of images). + // + std::size_t select_image_versions_[object_traits::depth]; + binding select_image_bindings_[ + object_traits::abstract ? 1 : object_traits::depth]; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. The id binding is copied from the hierarchy root. + // + std::size_t insert_image_version_; + std::size_t insert_id_binding_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + // Update binding. The id suffix binding is copied from the hierarchy + // root. + // + std::size_t update_image_version_; + std::size_t update_id_binding_version_; + binding update_image_binding_; + bind update_image_bind_[update_column_count + id_column_count]; + + details::shared_ptr persist_; + details::shared_ptr find_[ + object_traits::abstract ? 1 : object_traits::depth]; + details::shared_ptr update_; + details::shared_ptr erase_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx new file mode 100644 index 0000000..5a7efe0 --- /dev/null +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -0,0 +1,141 @@ +// file : odb/sqlite/polymorphic-object-statements.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +#include +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // polymorphic_root_object_statements + // + + template + polymorphic_root_object_statements:: + ~polymorphic_root_object_statements () + { + } + + template + polymorphic_root_object_statements:: + polymorphic_root_object_statements (connection_type& conn) + : object_statements (conn), + discriminator_image_binding_ (discriminator_image_bind_, + discriminator_column_count + + managed_optimistic_column_count), + discriminator_id_image_binding_ (discriminator_id_image_bind_, + id_column_count) + { + discriminator_image_.version = 0; + discriminator_id_image_.version = 0; + + discriminator_image_version_ = 0; + discriminator_id_image_version_ = 0; + + std::memset (discriminator_image_bind_, + 0, + sizeof (discriminator_image_bind_)); + std::memset (discriminator_id_image_bind_, + 0, + sizeof (discriminator_id_image_bind_)); + std::memset (discriminator_image_truncated_, + 0, + sizeof (discriminator_image_truncated_)); + + for (std::size_t i (0); + i < discriminator_column_count + managed_optimistic_column_count; + ++i) + { + discriminator_image_bind_[i].truncated = + discriminator_image_truncated_ + i; + } + } + + // + // polymorphic_derived_object_statements + // + + template + polymorphic_derived_object_statements:: + ~polymorphic_derived_object_statements () + { + } + + template + polymorphic_derived_object_statements:: + polymorphic_derived_object_statements (connection_type& conn) + : statements_base (conn), + root_statements_ (conn.statement_cache ().find_object ()), + base_statements_ (conn.statement_cache ().find_object ()), + container_statement_cache_ (conn), + insert_image_binding_ (insert_image_bind_, insert_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count) + { + image_.base = &base_statements_.image (); + image_.version = 0; + + for (std::size_t i (0); i < object_traits::depth; ++i) + select_image_versions_[i] = 0; + + for (std::size_t i (0); + i < (object_traits::abstract ? 1 : object_traits::depth); + ++i) + { + select_image_bindings_[i].bind = select_image_bind_; + select_image_bindings_[i].count = object_traits::find_column_counts[i]; + } + + insert_image_version_ = 0; + insert_id_binding_version_ = 0; + update_image_version_ = 0; + update_id_binding_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + + template + void polymorphic_derived_object_statements:: + delayed_loader (odb::database& db, const id_type& id, root_type& robj) + { + connection_type& conn (transaction::current ().connection ()); + polymorphic_derived_object_statements& sts ( + conn.statement_cache ().find_object ()); + root_statements_type& rsts (sts.root_statements ()); + + object_type& obj (static_cast (robj)); + + // The same code as in object_statements::load_delayed_(). + // + if (!object_traits::find_ (sts, &id)) + throw object_not_persistent (); + + object_traits::callback (db, obj, callback_event::pre_load); + object_traits::init (obj, sts.image (), &db); + object_traits::load_ (sts, obj); // Load containers, etc. + + rsts.load_delayed (); + + { + typename root_statements_type::auto_unlock u (rsts); + object_traits::callback (db, obj, callback_event::post_load); + } + } + } +} diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index 2d6574f..92c1bb1 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -7,9 +7,6 @@ #include -#include -#include - #include #include @@ -40,10 +37,3 @@ namespace odb #include #endif // ODB_SQLITE_RESULT_HXX - -// Include result specializations so that the user code only needs -// to include this header. -// - -#include -#include diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx new file mode 100644 index 0000000..8c748bc --- /dev/null +++ b/odb/sqlite/simple-object-result.hxx @@ -0,0 +1,79 @@ +// file : odb/sqlite/simple-object-result.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX +#define ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include + +#include + +#include +#include // query +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class object_result_impl: public odb::object_result_impl, + public result_impl_base + { + public: + typedef odb::object_result_impl base_type; + + typedef typename base_type::object_traits object_traits; + typedef typename base_type::object_type object_type; + typedef typename base_type::id_type id_type; + + typedef typename base_type::pointer_type pointer_type; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~object_result_impl (); + + object_result_impl (const query&, + details::shared_ptr, + statements_type&); + + virtual void + load (object_type&, bool fetch); + + virtual id_type + load_id (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + using base_type::current; + + private: + void + load_image (); + + private: + statements_type& statements_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx new file mode 100644 index 0000000..2152a21 --- /dev/null +++ b/odb/sqlite/simple-object-result.txx @@ -0,0 +1,143 @@ +// file : odb/sqlite/simple-object-result.txx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + object_result_impl:: + ~object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + object_result_impl:: + object_result_impl (const query& q, + details::shared_ptr statement, + statements_type& statements) + : base_type (statements.connection ().database ()), + result_impl_base (q, statement), + statements_ (statements) + { + } + + template + void object_result_impl:: + load (object_type& obj, bool fetch) + { + if (fetch) + load_image (); + + // This is a top-level call so the statements cannot be locked. + // + assert (!statements_.locked ()); + typename statements_type::auto_lock l (statements_); + + odb::database& db (this->database ()); + object_traits::callback (db, obj, callback_event::pre_load); + + typename object_traits::image_type& i (statements_.image ()); + object_traits::init (obj, i, &db); + + // Initialize the id image and binding and load the rest of the object + // (containers, etc). + // + typename object_traits::id_image_type& idi (statements_.id_image ()); + object_traits::init (idi, object_traits::id (i)); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + + object_traits::load_ (statements_, obj); + statements_.load_delayed (); + l.unlock (); + object_traits::callback (db, obj, callback_event::post_load); + } + + template + typename object_result_impl::id_type + object_result_impl:: + load_id () + { + load_image (); + return object_traits::id (statements_.image ()); + } + + template + void object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + void object_result_impl:: + load_image () + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (object_traits::grow (im, statements_.select_image_truncated ())) + im.version++; + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + statement_->reload (); + } + } + } + + template + void object_result_impl:: + cache () + { + } + + template + std::size_t object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx new file mode 100644 index 0000000..110795a --- /dev/null +++ b/odb/sqlite/simple-object-statements.cxx @@ -0,0 +1,16 @@ +// file : odb/sqlite/simple-object-statements.cxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + object_statements_base:: + ~object_statements_base () + { + } + } +} diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx new file mode 100644 index 0000000..2cdb16c --- /dev/null +++ b/odb/sqlite/simple-object-statements.hxx @@ -0,0 +1,515 @@ +// file : odb/sqlite/simple-object-statements.hxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX + +#include + +#include +#include +#include // std::size_t + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + // + // Implementation for objects with object id. + // + + class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base + { + public: + // Locking. + // + void + lock () + { + assert (!locked_); + locked_ = true; + } + + void + unlock () + { + assert (locked_); + locked_ = false; + } + + bool + locked () const + { + return locked_; + } + + struct auto_unlock + { + // Unlocks the statement on construction and re-locks it on + // destruction. + // + auto_unlock (object_statements_base&); + ~auto_unlock (); + + private: + auto_unlock (const auto_unlock&); + auto_unlock& operator= (const auto_unlock&); + + private: + object_statements_base& s_; + }; + + public: + virtual + ~object_statements_base (); + + protected: + object_statements_base (connection_type& conn) + : statements_base (conn), locked_ (false) + { + } + + protected: + bool locked_; + }; + + template + struct optimistic_data; + + template + struct optimistic_data + { + typedef T object_type; + typedef odb::object_traits object_traits; + + optimistic_data (bind*); + + // The id + optimistic column binding. + // + std::size_t id_image_version_; + binding id_image_binding_; + + details::shared_ptr erase_; + }; + + template + struct optimistic_data + { + optimistic_data (bind*) {} + }; + + template + class object_statements: public object_statements_base + { + public: + typedef T object_type; + typedef odb::object_traits object_traits; + typedef typename object_traits::id_type id_type; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + typedef typename object_traits::id_image_type id_image_type; + + typedef + typename object_traits::pointer_cache_traits + pointer_cache_traits; + + typedef + typename object_traits::container_statement_cache_type + container_statement_cache_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + // Automatic lock. + // + struct auto_lock + { + // Lock the statements unless they are already locked in which + // case subsequent calls to locked() will return false. + // + auto_lock (object_statements&); + + // Unlock the statemens if we are holding the lock and clear + // the delayed loads. This should only happen in case an + // exception is thrown. In normal circumstances, the user + // should call unlock() explicitly. + // + ~auto_lock (); + + // Return true if this auto_lock instance holds the lock. + // + bool + locked () const; + + // Unlock the statemens. + // + void + unlock (); + + private: + auto_lock (const auto_lock&); + auto_lock& operator= (const auto_lock&); + + private: + object_statements& s_; + bool locked_; + }; + + + public: + object_statements (connection_type&); + + virtual + ~object_statements (); + + // Delayed loading. + // + typedef void (*loader_function) ( + odb::database&, const id_type&, object_type&); + + void + delay_load (const id_type& id, + object_type& obj, + const typename pointer_cache_traits::position_type& p, + loader_function l = 0) + { + delayed_.push_back (delayed_load (id, obj, p, l)); + } + + void + load_delayed () + { + assert (locked ()); + + if (!delayed_.empty ()) + load_delayed_ (); + } + + void + clear_delayed () + { + if (!delayed_.empty ()) + clear_delayed_ (); + } + + // Object image. + // + image_type& + image () {return image_;} + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_image_version () const { return update_id_image_version_;} + + void + update_id_image_version (std::size_t v) {update_id_image_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Object id image and binding. + // + id_image_type& + id_image () {return id_image_;} + + std::size_t + id_image_version () const {return id_image_version_;} + + void + id_image_version (std::size_t v) {id_image_version_ = v;} + + binding& + id_image_binding () {return id_image_binding_;} + + // Optimistic id + managed column image binding. + // + std::size_t + optimistic_id_image_version () const {return od_.id_image_version_;} + + void + optimistic_id_image_version (std::size_t v) {od_.id_image_version_ = v;} + + binding& + optimistic_id_image_binding () {return od_.id_image_binding_;} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + insert_image_binding_)); + + persist_->cached (true); + } + + return *persist_; + } + + select_statement_type& + find_statement () + { + if (find_ == 0) + { + find_.reset ( + new (details::shared) select_statement_type ( + conn_, + object_traits::find_statement, + id_image_binding_, + select_image_binding_)); + + find_->cached (true); + } + + return *find_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + { + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + object_traits::update_statement, + update_image_binding_)); + + update_->cached (true); + } + + return *update_; + } + + delete_statement_type& + erase_statement () + { + if (erase_ == 0) + { + erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::erase_statement, + id_image_binding_)); + + erase_->cached (true); + } + + return *erase_; + } + + delete_statement_type& + optimistic_erase_statement () + { + if (od_.erase_ == 0) + { + od_.erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::optimistic_erase_statement, + od_.id_image_binding_)); + + od_.erase_->cached (true); + } + + return *od_.erase_; + } + + // Container statement cache. + // + container_statement_cache_type& + container_statment_cache () + { + return container_statement_cache_; + } + + public: + // select = total + // insert = total - inverse - managed_optimistic + // update = total - inverse - managed_optimistic - id - readonly + // + static const std::size_t select_column_count = + object_traits::column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - object_traits::inverse_column_count - + object_traits::managed_optimistic_column_count; + + static const std::size_t update_column_count = insert_column_count - + object_traits::id_column_count - object_traits::readonly_column_count; + + static const std::size_t id_column_count = + object_traits::id_column_count; + + static const std::size_t managed_optimistic_column_count = + object_traits::managed_optimistic_column_count; + + private: + object_statements (const object_statements&); + object_statements& operator= (const object_statements&); + + private: + void + load_delayed_ (); + + void + clear_delayed_ (); + + private: + container_statement_cache_type container_statement_cache_; + + image_type image_; + + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. + // + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + // Update binding. Note that the id suffix is bound to id_image_ + // below instead of image_ which makes this binding effectively + // bound to two images. As a result, we have to track versions + // for both of them. If this object uses optimistic concurrency, + // then the binding for the managed column (version, timestamp, + // etc) comes after the id and the image for such a column is + // stored as part of the id image. + // + std::size_t update_image_version_; + std::size_t update_id_image_version_; + binding update_image_binding_; + bind update_image_bind_[update_column_count + id_column_count + + managed_optimistic_column_count]; + + // Id image binding (only used as a parameter). Uses the suffix in + // the update bind. + // + id_image_type id_image_; + std::size_t id_image_version_; + binding id_image_binding_; + + // Extra data for objects with optimistic concurrency support. + // + optimistic_data od_; + + details::shared_ptr persist_; + details::shared_ptr find_; + details::shared_ptr update_; + details::shared_ptr erase_; + + // Delayed loading. + // + struct delayed_load + { + typedef typename pointer_cache_traits::position_type position_type; + + delayed_load () {} + delayed_load (const id_type& i, + object_type& o, + const position_type& p, + loader_function l) + : id (i), obj (&o), pos (p), loader (l) + { + } + + id_type id; + object_type* obj; + position_type pos; + loader_function loader; + }; + + typedef std::vector delayed_loads; + delayed_loads delayed_; + + // Delayed vectors swap guard. See the load_delayed_() function for + // details. + // + struct swap_guard + { + swap_guard (object_statements& os, delayed_loads& dl) + : os_ (os), dl_ (dl) + { + dl_.swap (os_.delayed_); + } + + ~swap_guard () + { + os_.clear_delayed (); + dl_.swap (os_.delayed_); + } + + private: + object_statements& os_; + delayed_loads& dl_; + }; + }; + } +} + +#include +#include + +#include + +#endif // ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx new file mode 100644 index 0000000..11d4fbc --- /dev/null +++ b/odb/sqlite/simple-object-statements.ixx @@ -0,0 +1,69 @@ +// file : odb/sqlite/simple-object-statements.ixx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // auto_unlock + // + inline object_statements_base::auto_unlock:: + auto_unlock (object_statements_base& s) + : s_ (s) + { + s_.unlock (); + } + + inline object_statements_base::auto_unlock:: + ~auto_unlock () + { + s_.lock (); + } + + // + // auto_lock + // + template + inline object_statements::auto_lock:: + auto_lock (object_statements& s) + : s_ (s) + { + if (!s_.locked ()) + { + s_.lock (); + locked_ = true; + } + else + locked_ = false; + } + + template + inline object_statements::auto_lock:: + ~auto_lock () + { + if (locked_) + { + s_.unlock (); + s_.clear_delayed (); + } + } + + template + inline bool object_statements::auto_lock:: + locked () const + { + return locked_; + } + + template + inline void object_statements::auto_lock:: + unlock () + { + assert (locked_); + s_.unlock (); + locked_ = false; + } + } +} diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx new file mode 100644 index 0000000..ea0b89b --- /dev/null +++ b/odb/sqlite/simple-object-statements.txx @@ -0,0 +1,145 @@ +// file : odb/sqlite/simple-object-statements.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + // + // optimistic_data + // + + template + optimistic_data:: + optimistic_data (bind* b) + : id_image_binding_ ( + b, + object_traits::id_column_count + + object_traits::managed_optimistic_column_count) + { + id_image_version_ = 0; + } + + // + // object_statements + // + + template + object_statements:: + ~object_statements () + { + } + + template + object_statements:: + object_statements (connection_type& conn) + : object_statements_base (conn), + container_statement_cache_ (conn), + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count + + managed_optimistic_column_count), + id_image_binding_ (update_image_bind_ + update_column_count, + id_column_count), + od_ (update_image_bind_ + update_column_count) + { + image_.version = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + update_image_version_ = 0; + update_id_image_version_ = 0; + + id_image_.version = 0; + id_image_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + + template + void object_statements:: + load_delayed_ () + { + database& db (connection ().database ()); + + delayed_loads dls; + swap_guard sg (*this, dls); + + while (!dls.empty ()) + { + delayed_load l (dls.back ()); + typename pointer_cache_traits::insert_guard g (l.pos); + dls.pop_back (); + + if (l.loader == 0) + { + if (!object_traits::find_ (*this, &l.id)) + throw object_not_persistent (); + + object_traits::callback (db, *l.obj, callback_event::pre_load); + + // Our calls to init/load below can result in additional delayed + // loads being added to the delayed_ vector. We need to process + // those before we call the post callback. + // + object_traits::init (*l.obj, image (), &db); + object_traits::load_ (*this, *l.obj); // Load containers, etc. + + if (!delayed_.empty ()) + load_delayed_ (); + + // Temporarily unlock the statement for the post_load call so that + // it can load objects of this type recursively. This is safe to do + // because we have completely loaded the current object. Also the + // delayed_ list is clear before the unlock and should be clear on + // re-lock (since a callback can only call public API functions + // which will make sure all the delayed loads are processed before + // returning). + // + { + auto_unlock u (*this); + object_traits::callback (db, *l.obj, callback_event::post_load); + } + } + else + l.loader (db, l.id, *l.obj); + + g.release (); + } + } + + template + void object_statements:: + clear_delayed_ () + { + // Remove the objects from the session cache. + // + if (session::has_current ()) + { + for (typename delayed_loads::iterator i (delayed_.begin ()), + e (delayed_.end ()); i != e; ++i) + { + pointer_cache_traits::erase (i->pos); + } + } + + delayed_.clear (); + } + } +} diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 8281b22..5d94296 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -11,15 +11,15 @@ #include #include +#include #include #include #include +#include #include #include -#include -#include #include @@ -27,8 +27,6 @@ namespace odb { namespace sqlite { - class connection; - class LIBODB_SQLITE_EXPORT statement_cache { public: @@ -71,38 +69,12 @@ namespace odb } template - typename object_statements_selector::type& - find_object () - { - typedef typename object_statements_selector::type object_statements; - - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast (*i->second); - - details::shared_ptr p ( - new (details::shared) object_statements (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } + typename object_traits::statements_type& + find_object (); template view_statements& - find_view () - { - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast&> (*i->second); - - details::shared_ptr > p ( - new (details::shared) view_statements (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } + find_view (); private: void @@ -129,6 +101,8 @@ namespace odb } } +#include + #include #endif // ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx new file mode 100644 index 0000000..b702712 --- /dev/null +++ b/odb/sqlite/statement-cache.txx @@ -0,0 +1,43 @@ +// file : odb/sqlite/statement-cache.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + template + typename object_traits::statements_type& statement_cache:: + find_object () + { + typedef typename object_traits::statements_type statements_type; + + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast (*i->second); + + details::shared_ptr p ( + new (details::shared) statements_type (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + + template + view_statements& statement_cache:: + find_view () + { + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast&> (*i->second); + + details::shared_ptr > p ( + new (details::shared) view_statements (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + } +} diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index fb26e39..82910db 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -9,11 +9,12 @@ #include // std::size_t +#include + #include #include #include // query, view_statements -#include #include namespace odb @@ -33,12 +34,14 @@ namespace odb typedef typename base_type::pointer_type pointer_type; typedef typename base_type::pointer_traits pointer_traits; + typedef view_statements statements_type; + virtual ~view_result_impl (); view_result_impl (const query&, details::shared_ptr, - view_statements&); + statements_type&); virtual void load (view_type&); @@ -55,7 +58,7 @@ namespace odb using base_type::current; private: - view_statements& statements_; + statements_type& statements_; }; } } diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 49d0e68..f2170c9 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -23,7 +23,7 @@ namespace odb view_result_impl:: view_result_impl (const query& q, details::shared_ptr statement, - view_statements& statements) + statements_type& statements) : base_type (statements.connection ().database ()), result_impl_base (q, statement), statements_ (statements) -- cgit v1.1 From ed96c77af3264975403fbb12d3ef3796c763b756 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Apr 2012 11:29:05 +0200 Subject: Make session optional --- odb/sqlite/polymorphic-object-result.txx | 1 - odb/sqlite/simple-object-statements.hxx | 1 - odb/sqlite/simple-object-statements.txx | 16 ++++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index a8cd1f0..dfff9ff 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -5,7 +5,6 @@ #include #include -#include #include // result_not_cached #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 2cdb16c..ee383b5 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -13,7 +13,6 @@ #include #include -#include #include diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index ea0b89b..995aca6 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -4,7 +4,6 @@ #include // std::memset -#include #include #include @@ -128,15 +127,16 @@ namespace odb void object_statements:: clear_delayed_ () { - // Remove the objects from the session cache. + // Remove the objects from the session cache. This is not the most + // efficient way to do this (cache_traits::erase() will check for + // a session on every iteration), but the delay vector won't be + // empty only if something goes wrong (i.e., we are throwing an + // exception). // - if (session::has_current ()) + for (typename delayed_loads::iterator i (delayed_.begin ()), + e (delayed_.end ()); i != e; ++i) { - for (typename delayed_loads::iterator i (delayed_.begin ()), - e (delayed_.end ()); i != e; ++i) - { - pointer_cache_traits::erase (i->pos); - } + pointer_cache_traits::erase (i->pos); } delayed_.clear (); -- cgit v1.1 From 736b520b08c8d12e9536628317da17faa6081e84 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Apr 2012 18:09:51 +0200 Subject: Replace remaining std::auto_ptr uses with odb::details::unique_ptr GCC in C++11 mode issues a deprecation warning for std::auto_ptr. --- odb/sqlite/connection.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 3ddd68d..5eb1995 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -9,13 +9,13 @@ #include -#include // std::auto_ptr - #include #include + #include #include #include +#include #include #include @@ -131,7 +131,7 @@ namespace odb // Keep statement_cache_ after handle_ so that it is destroyed before // the connection is closed. // - std::auto_ptr statement_cache_; + details::unique_ptr statement_cache_; // Unlock notification machinery. // -- cgit v1.1 From 95279da1a57faa4fc4e97bf7ab27dd53b8a7e4d5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Apr 2012 11:50:52 +0200 Subject: Make transaction_impl sanity check optional, use assert --- odb/sqlite/transaction.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 2b874b8..7fd3f08 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + #include namespace odb @@ -18,7 +20,7 @@ namespace odb // no virtual functions. The former is checked in the tests. // odb::transaction& b (odb::transaction::current ()); - dynamic_cast (b.implementation ()); + assert (dynamic_cast (&b.implementation ()) != 0); return reinterpret_cast (b); } } -- cgit v1.1 From 9fee1caf6f8bcfac52ea981d8a9b8fb8d541468d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 29 Apr 2012 16:14:54 +0200 Subject: Bump version to 2.0.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 04c0b12..d206d40 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 10801 +#if ODB_VERSION != 20000 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 1089901 -#define LIBODB_SQLITE_VERSION_STR "1.9.0.a1" +#define LIBODB_SQLITE_VERSION 2000000 +#define LIBODB_SQLITE_VERSION_STR "2.0.0" #include diff --git a/version b/version index 8a776ac..227cea2 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.9.0.a1 +2.0.0 -- cgit v1.1 From a64a2d583b948308d287ab0940ca6c1958f771a4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 May 2012 12:40:24 +0200 Subject: Add -D_REENTRANT when building on Linux to emulate -pthread --- m4/acx-pthread.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m4/acx-pthread.m4 b/m4/acx-pthread.m4 index ffa3dfa..204b32d 100644 --- a/m4/acx-pthread.m4 +++ b/m4/acx-pthread.m4 @@ -220,7 +220,9 @@ dnl fi flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + # CS: Add _REENTRANT in Linux to emulate -pthread. + # + *-linux* | *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then -- cgit v1.1 From 31995832803d21aad266258d5cc1022bc086c2b7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Jun 2012 09:32:09 +0200 Subject: Allocate container traits lazily and only when their definition is seen This fixes a problem with polymorphic hierarchies spread over multiple files in which case the source code for the derived class does not have the definition of the container traits for the base class. See the comment in the source code for further details. --- odb/sqlite/polymorphic-object-statements.hxx | 5 ++- odb/sqlite/polymorphic-object-statements.txx | 1 - odb/sqlite/simple-object-statements.hxx | 57 +++++++++++++++++++++++++++- odb/sqlite/simple-object-statements.txx | 1 - 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 1212176..54319ee 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -363,7 +363,7 @@ namespace odb container_statement_cache_type& container_statment_cache () { - return container_statement_cache_; + return container_statement_cache_.get (conn_); } public: @@ -395,7 +395,8 @@ namespace odb root_statements_type& root_statements_; base_statements_type& base_statements_; - container_statement_cache_type container_statement_cache_; + container_statement_cache_ptr + container_statement_cache_; image_type image_; diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index 5a7efe0..061215e 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -76,7 +76,6 @@ namespace odb : statements_base (conn), root_statements_ (conn.statement_cache ().find_object ()), base_statements_ (conn.statement_cache ().find_object ()), - container_statement_cache_ (conn), insert_image_binding_ (insert_image_bind_, insert_column_count), update_image_binding_ (update_image_bind_, update_column_count + id_column_count) diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index ee383b5..90f2494 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -29,6 +29,58 @@ namespace odb { namespace sqlite { + // The container_statement_cache class is only defined (and used) in + // the generated source file. However, object_statements may be + // referenced from another source file in the case of a polymorphic + // hierarchy (though in this case the container statement cache is + // not used). As a result, we cannot have a by-value member and + // instead will store a pointer and lazily allocate the cache if + // and when needed. We will also need to store a pointer to the + // deleter function which will be initialized during allocation + // (at that point we know that the cache class is defined). + // + template + struct container_statement_cache_ptr + { + typedef sqlite::connection connection_type; + + container_statement_cache_ptr (): p_ (0) {} + ~container_statement_cache_ptr () {if (p_ != 0) (this->*deleter_) (0);} + + T& + get (connection_type& c) + { + if (p_ == 0) + allocate (&c); + + return *p_; + } + + private: + void + allocate (connection_type*); + + private: + T* p_; + void (container_statement_cache_ptr::*deleter_) (connection_type*); + }; + + template + void container_statement_cache_ptr:: + allocate (connection_type* c) + { + // To reduce object code size, this function acts as both allocator + // and deleter. + // + if (p_ == 0) + { + p_ = new T (*c); + deleter_ = &container_statement_cache_ptr::allocate; + } + else + delete p_; + } + // // Implementation for objects with object id. // @@ -374,7 +426,7 @@ namespace odb container_statement_cache_type& container_statment_cache () { - return container_statement_cache_; + return container_statement_cache_.get (conn_); } public: @@ -410,7 +462,8 @@ namespace odb clear_delayed_ (); private: - container_statement_cache_type container_statement_cache_; + container_statement_cache_ptr + container_statement_cache_; image_type image_; diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 995aca6..8c61d5d 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -42,7 +42,6 @@ namespace odb object_statements:: object_statements (connection_type& conn) : object_statements_base (conn), - container_statement_cache_ (conn), select_image_binding_ (select_image_bind_, select_column_count), insert_image_binding_ (insert_image_bind_, insert_column_count), update_image_binding_ (update_image_bind_, -- cgit v1.1 From 47d783b340df91a43abc36470c78f998db0b33fe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Jun 2012 09:34:39 +0200 Subject: Bump version to 2.0.1 --- odb/sqlite/version.hxx | 4 ++-- version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d206d40..9d5bd38 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -35,8 +35,8 @@ // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2000000 -#define LIBODB_SQLITE_VERSION_STR "2.0.0" +#define LIBODB_SQLITE_VERSION 2000100 +#define LIBODB_SQLITE_VERSION_STR "2.0.1" #include diff --git a/version b/version index 227cea2..38f77a6 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.0.0 +2.0.1 -- cgit v1.1 From 1568e64c2135bf245de960ae614bd3533c6d157a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Jul 2012 15:17:14 +0200 Subject: Add support for custom database type mapping New pragma qualifier, map, and specifiers: as, to, from. New tests: /custom. --- odb/sqlite/details/conversion.hxx | 59 +++++++++++++++++++++++++++++++++++++ odb/sqlite/query.cxx | 19 +++++++++++- odb/sqlite/query.hxx | 62 ++++++++++++++++++++++++--------------- odb/sqlite/query.ixx | 10 ++++--- odb/sqlite/query.txx | 32 ++++++++++---------- 5 files changed, 138 insertions(+), 44 deletions(-) create mode 100644 odb/sqlite/details/conversion.hxx diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx new file mode 100644 index 0000000..9daf35c --- /dev/null +++ b/odb/sqlite/details/conversion.hxx @@ -0,0 +1,59 @@ +// file : odb/sqlite/details/conversion.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX +#define ODB_SQLITE_DETAILS_CONVERSION_HXX + +#include + +#include + +namespace odb +{ + // @@ Revise this. + // + namespace details {} + + namespace sqlite + { + namespace details + { + using namespace odb::details; + + // Detect whether conversion is specified in type_traits. + // + template + meta::yes + conversion_p_test (typename type_traits::conversion*); + + template + meta::no + conversion_p_test (...); + + template + struct conversion_p + { + static const bool value = + sizeof (conversion_p_test (0)) == sizeof (meta::yes); + }; + + template ::value> + struct conversion; + + template + struct conversion + { + static const char* to () {return type_traits::conversion::to ();} + }; + + template + struct conversion + { + static const char* to () {return 0;} + }; + } + } +} + +#endif // ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 0adf8d9..2c0706a 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -188,9 +188,13 @@ namespace odb } void query:: - add (details::shared_ptr p) + add (details::shared_ptr p, const char* conv) { clause_.push_back (clause_part (clause_part::param)); + + if (conv != 0) + clause_.back ().part = conv; + parameters_->add (p); } @@ -287,7 +291,20 @@ namespace odb if (last != ' ' && last != '(') r += ' '; + // Add the conversion expression, if any. + // + string::size_type p; + if (!i->part.empty ()) + { + p = i->part.find ("(?)"); + r.append (i->part, 0, p); + } + r += '?'; + + if (!i->part.empty ()) + r.append (i->part, p + 3, string::npos); + break; } case clause_part::native: diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 54e0b2b..ee05feb 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -20,7 +20,9 @@ #include #include #include + #include +#include namespace odb { @@ -129,7 +131,7 @@ namespace odb clause_part (bool p): kind (boolean), bool_part (p) {} kind_type kind; - std::string part; + std::string part; // If kind is param, then part is conversion expr. bool bool_part; }; @@ -172,7 +174,8 @@ namespace odb query (val_bind v) : parameters_ (new (details::shared) query_params) { - append::db_type_id> (v); + append::db_type_id> ( + v, details::conversion::to ()); } template @@ -180,7 +183,8 @@ namespace odb query (ref_bind r) : parameters_ (new (details::shared) query_params) { - append::db_type_id> (r); + append::db_type_id> ( + r, details::conversion::to ()); } template @@ -254,7 +258,8 @@ namespace odb query& operator+= (val_bind v) { - append::db_type_id> (v); + append::db_type_id> ( + v, details::conversion::to ()); return *this; } @@ -262,18 +267,19 @@ namespace odb query& operator+= (ref_bind r) { - append::db_type_id> (r); + append::db_type_id> ( + r, details::conversion::to ()); return *this; } public: template void - append (val_bind); + append (val_bind, const char* conv); template void - append (ref_bind); + append (ref_bind, const char* conv); void append (const std::string& native); @@ -283,7 +289,7 @@ namespace odb private: void - add (details::shared_ptr); + add (details::shared_ptr, const char* conv); private: typedef std::vector clause_type; @@ -421,10 +427,11 @@ namespace odb template struct query_column { - // Note that we keep shalow copies of the table and column names. + // Note that we keep shallow copies of the table, column, and conversion + // expression. The latter can be NULL. // - query_column (const char* table, const char* column) - : table_ (table), column_ (column) + query_column (const char* table, const char* column, const char* conv) + : table_ (table), column_ (column), conversion_ (conv) { } @@ -440,6 +447,14 @@ namespace odb return column_; } + // Can be NULL. + // + const char* + conversion () const + { + return conversion_; + } + // is_null, is_not_null // public: @@ -492,7 +507,7 @@ namespace odb { query q (table_, column_); q += "="; - q.append (v); + q.append (v, conversion_); return q; } @@ -509,7 +524,7 @@ namespace odb { query q (table_, column_); q += "="; - q.append (r); + q.append (r, conversion_); return q; } @@ -577,7 +592,7 @@ namespace odb { query q (table_, column_); q += "!="; - q.append (v); + q.append (v, conversion_); return q; } @@ -594,7 +609,7 @@ namespace odb { query q (table_, column_); q += "!="; - q.append (r); + q.append (r, conversion_); return q; } @@ -662,7 +677,7 @@ namespace odb { query q (table_, column_); q += "<"; - q.append (v); + q.append (v, conversion_); return q; } @@ -679,7 +694,7 @@ namespace odb { query q (table_, column_); q += "<"; - q.append (r); + q.append (r, conversion_); return q; } @@ -747,7 +762,7 @@ namespace odb { query q (table_, column_); q += ">"; - q.append (v); + q.append (v, conversion_); return q; } @@ -764,7 +779,7 @@ namespace odb { query q (table_, column_); q += ">"; - q.append (r); + q.append (r, conversion_); return q; } @@ -832,7 +847,7 @@ namespace odb { query q (table_, column_); q += "<="; - q.append (v); + q.append (v, conversion_); return q; } @@ -849,7 +864,7 @@ namespace odb { query q (table_, column_); q += "<="; - q.append (r); + q.append (r, conversion_); return q; } @@ -917,7 +932,7 @@ namespace odb { query q (table_, column_); q += ">="; - q.append (v); + q.append (v, conversion_); return q; } @@ -934,7 +949,7 @@ namespace odb { query q (table_, column_); q += ">="; - q.append (r); + q.append (r, conversion_); return q; } @@ -1078,6 +1093,7 @@ namespace odb private: const char* table_; const char* column_; + const char* conversion_; }; // Provide operator+() for using columns to construct native diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index dcd1ebe..113b376 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -20,20 +20,22 @@ namespace odb template inline void query:: - append (val_bind v) + append (val_bind v, const char* conv) { add ( details::shared_ptr ( - new (details::shared) query_param_impl (v))); + new (details::shared) query_param_impl (v)), + conv); } template inline void query:: - append (ref_bind r) + append (ref_bind r, const char* conv) { add ( details::shared_ptr ( - new (details::shared) query_param_impl (r))); + new (details::shared) query_param_impl (r)), + conv); } } } diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index b095d52..ba3fac1 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -19,7 +19,7 @@ namespace odb // append (c.table (), c.column ()); append ("="); - append (val_bind (true)); + append (val_bind (true), c.conversion ()); } // query_column @@ -30,9 +30,9 @@ namespace odb { query q (table_, column_); q += "IN ("; - q.append (val_bind (v1)); + q.append (val_bind (v1), conversion_); q += ","; - q.append (val_bind (v2)); + q.append (val_bind (v2), conversion_); q += ")"; return q; } @@ -43,11 +43,11 @@ namespace odb { query q (table_, column_); q += "IN ("; - q.append (val_bind (v1)); + q.append (val_bind (v1), conversion_); q += ","; - q.append (val_bind (v2)); + q.append (val_bind (v2), conversion_); q += ","; - q.append (val_bind (v3)); + q.append (val_bind (v3), conversion_); q += ")"; return q; } @@ -58,13 +58,13 @@ namespace odb { query q (table_, column_); q += "IN ("; - q.append (val_bind (v1)); + q.append (val_bind (v1), conversion_); q += ","; - q.append (val_bind (v2)); + q.append (val_bind (v2), conversion_); q += ","; - q.append (val_bind (v3)); + q.append (val_bind (v3), conversion_); q += ","; - q.append (val_bind (v4)); + q.append (val_bind (v4), conversion_); q += ")"; return q; } @@ -75,15 +75,15 @@ namespace odb { query q (table_, column_); q += "IN ("; - q.append (val_bind (v1)); + q.append (val_bind (v1), conversion_); q += ","; - q.append (val_bind (v2)); + q.append (val_bind (v2), conversion_); q += ","; - q.append (val_bind (v3)); + q.append (val_bind (v3), conversion_); q += ","; - q.append (val_bind (v4)); + q.append (val_bind (v4), conversion_); q += ","; - q.append (val_bind (v5)); + q.append (val_bind (v5), conversion_); q += ")"; return q; } @@ -101,7 +101,7 @@ namespace odb if (i != begin) q += ","; - q.append (val_bind (*i)); + q.append (val_bind (*i), conversion_); } q += ")"; return q; -- cgit v1.1 From e745f91fa1b1cbdd4e1092b2e797c772977d5e18 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Jul 2012 13:45:29 +0200 Subject: Simplify query inheritance hierarchy This should also allow Sun CC handle queries for objects with circular dependencies. --- odb/sqlite/query.hxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index ee05feb..1e8a0a0 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1289,7 +1289,8 @@ namespace odb namespace odb { template - class query: public query_selector::type + class query: public sqlite::query, + public query_selector::columns_type { public: // We don't define any typedefs here since they may clash with @@ -1302,44 +1303,44 @@ namespace odb explicit query (bool v) - : query_selector::type (v) + : sqlite::query (v) { } explicit query (const char* q) - : query_selector::type (q) + : sqlite::query (q) { } explicit query (const std::string& q) - : query_selector::type (q) + : sqlite::query (q) { } template explicit query (sqlite::val_bind v) - : query_selector::type (sqlite::query (v)) + : sqlite::query (sqlite::query (v)) { } template explicit query (sqlite::ref_bind r) - : query_selector::type (sqlite::query (r)) + : sqlite::query (sqlite::query (r)) { } query (const sqlite::query& q) - : query_selector::type (q) + : sqlite::query (q) { } template query (const sqlite::query_column& qc) - : query_selector::type (qc) + : sqlite::query (qc) { } }; -- cgit v1.1 From c3866336c6e6c976b81d32abceda32c49face259 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Jul 2012 10:44:02 +0200 Subject: Bump version to 2.1.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 9d5bd38..9787fb4 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20000 +#if ODB_VERSION != 20001 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2000100 -#define LIBODB_SQLITE_VERSION_STR "2.0.1" +#define LIBODB_SQLITE_VERSION 2009901 +#define LIBODB_SQLITE_VERSION_STR "2.1.0.a1" #include diff --git a/version b/version index 38f77a6..7900f1c 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.0.1 +2.1.0.a1 -- cgit v1.1 From 6c54f21ce97f52d7df7df3f980586bb70a295d97 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Jul 2012 15:17:56 +0200 Subject: Get rid of warning --- odb/sqlite/query.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 2c0706a..d979379 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -293,7 +293,7 @@ namespace odb // Add the conversion expression, if any. // - string::size_type p; + string::size_type p (0); if (!i->part.empty ()) { p = i->part.find ("(?)"); -- cgit v1.1 From 3fabd5107e81d1f75a259ba1d1fa1911c166ebac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 18 Jul 2012 12:07:18 +0200 Subject: Convert NULLs to NaNs in SQLite for float and double This makes it consistent with SQLite behavior which converts NaNs to NULLs. --- odb/sqlite/traits.hxx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index ecd982f..65883b6 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -9,6 +9,7 @@ #include #include +#include // std::numeric_limits #include // std::size_t #include // std::memcpy, std::memset, std::strlen @@ -202,6 +203,45 @@ namespace odb } }; + // Float & double specialization. SQLite converts NaNs to NULLs so + // we convert NULLs to NaNs for consistency. + // + template + struct real_value_traits + { + typedef T value_type; + typedef T query_type; + typedef double image_type; + + static void + set_value (T& v, double i, bool is_null) + { + if (!is_null) + v = T (i); + else + v = std::numeric_limits::quiet_NaN (); + } + + static void + set_image (double& i, bool& is_null, T v) + { + is_null = false; + i = image_type (v); + } + }; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + real_value_traits + { + }; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + real_value_traits + { + }; + // std::string specialization. // template <> -- cgit v1.1 From 158b06969b0c8438afda841b63c5fec7ed186725 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Jul 2012 16:04:28 +0200 Subject: Bump version to 2.1.0.a2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 9787fb4..9df1031 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20001 +#if ODB_VERSION != 20002 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2009901 -#define LIBODB_SQLITE_VERSION_STR "2.1.0.a1" +#define LIBODB_SQLITE_VERSION 2009902 +#define LIBODB_SQLITE_VERSION_STR "2.1.0.a2" #include diff --git a/version b/version index 7900f1c..51b720e 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.1.0.a1 +2.1.0.a2 -- cgit v1.1 From 95143f4028efb896348008dc4cf4ce2d5925f720 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 6 Sep 2012 14:36:20 +0200 Subject: Add ability to specify SQLite vfs module in database constructor --- odb/sqlite/connection.cxx | 6 +++++- odb/sqlite/database.cxx | 4 ++++ odb/sqlite/database.hxx | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 38f622d..22955b4 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -48,8 +48,12 @@ namespace odb if ((f & SQLITE_OPEN_FULLMUTEX) == 0) f |= SQLITE_OPEN_NOMUTEX; + const string& vfs (db.vfs ()); + sqlite3* h (0); - int e (sqlite3_open_v2 (n.c_str (), &h, f, 0)); + int e ( + sqlite3_open_v2 ( + n.c_str (), &h, f, (vfs.empty () ? 0 : vfs.c_str ()))); handle_.reset (h); if (e != SQLITE_OK) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 74c32d1..bf2d8dd 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -29,10 +29,12 @@ namespace odb database (const string& name, int flags, bool foreign_keys, + const string& vfs, transfer_ptr factory) : name_ (name), flags_ (flags), foreign_keys_ (foreign_keys), + vfs_ (vfs), factory_ (factory.transfer ()) { if (!factory_) @@ -47,9 +49,11 @@ namespace odb bool erase, int flags, bool foreign_keys, + const string& vfs, transfer_ptr factory) : flags_ (flags), foreign_keys_ (foreign_keys), + vfs_ (vfs), factory_ (factory.transfer ()) { using namespace details; diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 021a5df..042fb29 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -38,6 +38,7 @@ namespace odb database (const std::string& name, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, + const std::string& vfs = "", details::transfer_ptr = details::transfer_ptr ()); @@ -60,13 +61,13 @@ namespace odb bool erase = false, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, + const std::string& vfs = "", details::transfer_ptr = details::transfer_ptr ()); static void print_usage (std::ostream&); - public: const std::string& name () const @@ -86,6 +87,12 @@ namespace odb return foreign_keys_; } + const std::string& + vfs () const + { + return vfs_; + } + // Transactions. // public: @@ -133,6 +140,7 @@ namespace odb std::string name_; int flags_; bool foreign_keys_; + std::string vfs_; details::unique_ptr factory_; }; } -- cgit v1.1 From a15eb05821b1ae5b40b24bfa3efa0c70a095b3e9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 7 Sep 2012 13:58:47 +0200 Subject: Add support for passing database name as std::wstring on Windows --- odb/sqlite/database.cxx | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/database.hxx | 9 +++++++ 2 files changed, 72 insertions(+) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index bf2d8dd..0f1138f 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -2,6 +2,13 @@ // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#ifdef _WIN32 +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include // WideCharToMultiByte +#endif + #include #include @@ -43,6 +50,62 @@ namespace odb factory_->database (*this); } +#ifdef _WIN32 + database:: + database (const wstring& name, + int flags, + bool foreign_keys, + const string& vfs, + transfer_ptr factory) + : flags_ (flags), + foreign_keys_ (foreign_keys), + vfs_ (vfs), + factory_ (factory.transfer ()) + { + // Convert UTF-16 name to UTF-8 using the WideCharToMultiByte() Win32 + // function. + // + int n ( + WideCharToMultiByte ( + CP_UTF8, + 0, + name.c_str (), + static_cast (name.size ()), + 0, + 0, + 0, + 0)); + + if (n == 0) + throw database_exception ( + SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); + + // This string is not shared so we are going to modify the underlying + // buffer directly. + // + name_.resize (static_cast (n)); + + n = WideCharToMultiByte ( + CP_UTF8, + 0, + name.c_str (), + static_cast (name.size ()), + const_cast (name_.c_str ()), + n, + 0, + 0); + + if (n == 0) + throw database_exception ( + SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); + + if (!factory_) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } +#endif + database:: database (int& argc, char* argv[], diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 042fb29..bbb01f6 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -42,6 +42,15 @@ namespace odb details::transfer_ptr = details::transfer_ptr ()); +#ifdef _WIN32 + database (const std::wstring& name, + int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, + const std::string& vfs = "", + details::transfer_ptr = + details::transfer_ptr ()); +#endif + // Extract the database parameters from the command line. The // following options are recognized: // -- cgit v1.1 From b3af5d13db8c29b42436c54abd94b73b7a7f00bd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Sep 2012 10:21:14 +0200 Subject: Rearrange data/size calls as recommended by SQLite documentation --- odb/sqlite/statement.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index e917ac8..60cf410 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -191,6 +191,14 @@ namespace odb case bind::text: case bind::blob: { + // SQLite documentation recommends that we first call *_text() + // or *_blob() function in order to force the type conversion, + // if any. + // + const void* d (b.type == bind::text + ? sqlite3_column_text (stmt_, j) + : sqlite3_column_blob (stmt_, j)); + *b.size = static_cast (sqlite3_column_bytes (stmt_, j)); if (*b.size > b.capacity) @@ -202,10 +210,6 @@ namespace odb continue; } - const void* d (b.type == bind::text - ? sqlite3_column_text (stmt_, j) - : sqlite3_column_blob (stmt_, j)); - memcpy (b.buffer, d, *b.size); break; } -- cgit v1.1 From 866f0ce4fa567db60d46741a5c865cdf2741c619 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Sep 2012 12:12:06 +0200 Subject: Add support for alternative UTF-16 image for TEXT in SQLite Use it to handle QString and support std::wstring on Windows. --- odb/sqlite/query.hxx | 2 +- odb/sqlite/sqlite-types.hxx | 3 +- odb/sqlite/statement.cxx | 34 ++++++++++--- odb/sqlite/traits.cxx | 36 ++++++++++++++ odb/sqlite/traits.hxx | 118 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 172 insertions(+), 21 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 1e8a0a0..5991c51 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1225,7 +1225,7 @@ namespace odb virtual void bind (sqlite::bind* b) { - b->type = sqlite::bind::text; + b->type = image_traits::bind_value; b->buffer = buffer_.data (); b->size = &size_; } diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 316c032..295cd1f 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -22,7 +22,8 @@ namespace odb { integer, // Buffer is long long; size, capacity, truncated are unused. real, // Buffer is double; size, capacity, truncated are unused. - text, // Buffer is a char array. + text, // Buffer is a UTF-8 char array. + text16, // Buffer is a UTF-16 2-byte char array (sizes in bytes). blob // Buffer is a char array. }; diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 60cf410..36066ff 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -125,6 +125,15 @@ namespace odb SQLITE_STATIC); break; } + case bind::text16: + { + e = sqlite3_bind_text16 (stmt_, + j, + b.buffer, + static_cast (*b.size), + SQLITE_STATIC); + break; + } case bind::blob: { e = sqlite3_bind_blob (stmt_, @@ -189,17 +198,28 @@ namespace odb break; } case bind::text: + case bind::text16: case bind::blob: { - // SQLite documentation recommends that we first call *_text() - // or *_blob() function in order to force the type conversion, - // if any. + // SQLite documentation recommends that we first call *_text(), + // *_text16(), or *_blob() function in order to force the type + // conversion, if any. // - const void* d (b.type == bind::text - ? sqlite3_column_text (stmt_, j) - : sqlite3_column_blob (stmt_, j)); + const void* d; - *b.size = static_cast (sqlite3_column_bytes (stmt_, j)); + if (b.type != bind::text16) + { + d = b.type == bind::text + ? sqlite3_column_text (stmt_, j) + : sqlite3_column_blob (stmt_, j); + *b.size = static_cast (sqlite3_column_bytes (stmt_, j)); + } + else + { + d = sqlite3_column_text16 (stmt_, j); + *b.size = static_cast ( + sqlite3_column_bytes16 (stmt_, j)); + } if (*b.size > b.capacity) { diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 0e875a2..3f9c5cb 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -46,6 +46,42 @@ namespace odb memcpy (b.data (), v, n); } +#ifdef _WIN32 + // + // default_value_traits + // + + void default_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const wstring& v) + { + is_null = false; + n = v.size () * 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v.c_str (), n); + } + + // + // c_wstring_value_traits + // + + void c_wstring_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const wchar_t* v) + { + is_null = false; + n = wcslen (v) * 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } +#endif // _WIN32 + // // default_value_traits, id_blob> // diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 65883b6..0de67f9 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -20,6 +20,7 @@ #include #include +#include #include namespace odb @@ -38,20 +39,27 @@ namespace odb // image_traits // - template + template struct image_traits; - template <> - struct image_traits {typedef long long image_type;}; + template + struct image_traits {typedef long long image_type;}; - template <> - struct image_traits {typedef double image_type;}; + template + struct image_traits {typedef double image_type;}; - template <> - struct image_traits {typedef details::buffer image_type;}; + template + struct image_traits + { + typedef details::buffer image_type; - template <> - struct image_traits {typedef details::buffer image_type;}; + // By default the text is in UTF-8. + // + static const bind::buffer_type bind_value = bind::text; + }; + + template + struct image_traits {typedef details::buffer image_type;}; // // value_traits @@ -97,7 +105,7 @@ namespace odb typedef W value_type; typedef wrapped_type query_type; - typedef typename image_traits::image_type image_type; + typedef typename image_traits::image_type image_type; typedef value_traits vtraits; @@ -136,7 +144,7 @@ namespace odb typedef W value_type; typedef wrapped_type query_type; - typedef typename image_traits::image_type image_type; + typedef typename image_traits::image_type image_type; typedef value_traits vtraits; @@ -184,7 +192,7 @@ namespace odb { typedef T value_type; typedef T query_type; - typedef typename image_traits::image_type image_type; + typedef typename image_traits::image_type image_type; static void set_value (T& v, const image_type& i, bool is_null) @@ -305,6 +313,92 @@ namespace odb { }; +#ifdef _WIN32 + // std::wstring specialization. Using UTF-16 binding. + // + template <> + struct image_traits + { + typedef details::buffer image_type; + static const bind::buffer_type bind_value = bind::text16; + }; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + typedef std::wstring value_type; + typedef std::wstring query_type; + typedef details::buffer image_type; + + static void + set_value (std::wstring& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (reinterpret_cast (b.data ()), n / 2); + else + v.erase (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const std::wstring&); + }; + + // const wchar_t* specialization + // + template <> + struct c_wstring_image_traits + { + typedef details::buffer image_type; + static const bind::buffer_type bind_value = bind::text16; + }; + + struct LIBODB_SQLITE_EXPORT c_wstring_value_traits + { + typedef const wchar_t* value_type; + typedef const wchar_t* query_type; + typedef details::buffer image_type; + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const wchar_t*); + }; + + template <> + struct image_traits: c_wstring_image_traits {}; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + c_wstring_value_traits + { + }; + + template + struct image_traits: c_wstring_image_traits {}; + + template + struct default_value_traits: + c_wstring_value_traits + { + }; + + template + struct image_traits: c_wstring_image_traits {}; + + template + struct default_value_traits: + c_wstring_value_traits + { + }; +#endif // _WIN32 + // std::vector (buffer) specialization. // template <> -- cgit v1.1 From 748e05183a0dd33631a3d4d4c0b943dc6703f4ff Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Sep 2012 13:55:47 +0200 Subject: Add support for mapping std::array to BLOB and char[16] to UUID types --- odb/sqlite/traits.hxx | 150 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 131 insertions(+), 19 deletions(-) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 0de67f9..b812361 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -7,12 +7,18 @@ #include +#include // ODB_CXX11 + #include #include #include // std::numeric_limits #include // std::size_t #include // std::memcpy, std::memset, std::strlen +#ifdef ODB_CXX11 +# include +#endif + #include #include @@ -303,13 +309,13 @@ namespace odb { }; - template - struct default_value_traits: c_string_value_traits + template + struct default_value_traits: c_string_value_traits { }; - template - struct default_value_traits: c_string_value_traits + template + struct default_value_traits: c_string_value_traits { }; @@ -380,20 +386,20 @@ namespace odb { }; - template - struct image_traits: c_wstring_image_traits {}; + template + struct image_traits: c_wstring_image_traits {}; - template - struct default_value_traits: + template + struct default_value_traits: c_wstring_value_traits { }; - template - struct image_traits: c_wstring_image_traits {}; + template + struct image_traits: c_wstring_image_traits {}; - template - struct default_value_traits: + template + struct default_value_traits: c_wstring_value_traits { }; @@ -463,7 +469,7 @@ namespace odb const value_type&); }; - // char[n] (buffer) specialization. + // char[N] (buffer) specialization. // template struct default_value_traits @@ -501,7 +507,7 @@ namespace odb } }; - // unsigned char[n] (buffer) specialization. + // unsigned char[N] (buffer) specialization. // template struct default_value_traits @@ -539,6 +545,84 @@ namespace odb } }; +#ifdef ODB_CXX11 + // std::array (buffer) specialization. + // + template + struct default_value_traits, id_blob> + { + public: + typedef std::array value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v.data (), b.data (), (n < N ? n : N)); + else + std::memset (v.data (), 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v.data (), n); + } + }; + + // std::array (buffer) specialization. + // + template + struct default_value_traits, id_blob> + { + public: + typedef std::array value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v.data (), b.data (), (n < N ? n : N)); + else + std::memset (v.data (), 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v.data (), n); + } + }; +#endif + // // type_traits // @@ -633,7 +717,7 @@ namespace odb static const database_type_id db_type_id = id_real; }; - // String type. + // String types. // template <> struct default_type_traits @@ -647,17 +731,45 @@ namespace odb static const database_type_id db_type_id = id_text; }; - template - struct default_type_traits + template + struct default_type_traits { static const database_type_id db_type_id = id_text; }; - template - struct default_type_traits + template + struct default_type_traits { static const database_type_id db_type_id = id_text; }; + + // Binary types. + // + template <> + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; + + template <> + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; + +#ifdef ODB_CXX11 + template + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; + + template + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; +#endif } } -- cgit v1.1 From 55a70a3a283fe6a55f73ba6935336ff0eb8f6dbd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 14 Sep 2012 08:29:54 +0200 Subject: Bump version to 2.1.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 9df1031..0c20a5a 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20002 +#if ODB_VERSION != 20100 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2009902 -#define LIBODB_SQLITE_VERSION_STR "2.1.0.a2" +#define LIBODB_SQLITE_VERSION 2010000 +#define LIBODB_SQLITE_VERSION_STR "2.1.0" #include diff --git a/version b/version index 51b720e..7ec1d6d 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.1.0.a2 +2.1.0 -- cgit v1.1 From 82744db6e41e138bad813b5a9bcec75d31c98cf7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 14 Sep 2012 08:41:30 +0200 Subject: Indicate value cannot be NULL when initializing query parameter image --- odb/sqlite/query.hxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 5991c51..ffd3559 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1166,8 +1166,8 @@ namespace odb void init (const T& v) { - bool dummy; - value_traits::set_image (image_, dummy, v); + bool is_null (false); // Can't be NULL. + value_traits::set_image (image_, is_null, v); } private: @@ -1200,8 +1200,8 @@ namespace odb void init (const T& v) { - bool dummy; - value_traits::set_image (image_, dummy, v); + bool is_null (false); // Can't be NULL. + value_traits::set_image (image_, is_null, v); } private: @@ -1234,9 +1234,9 @@ namespace odb bool init (const T& v) { - bool dummy; + bool is_null (false); // Can't be NULL. std::size_t cap (buffer_.capacity ()); - value_traits::set_image (buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, is_null, v); return cap != buffer_.capacity (); } @@ -1271,9 +1271,9 @@ namespace odb bool init (const T& v) { - bool dummy; + bool is_null (false); // Can't be NULL. std::size_t cap (buffer_.capacity ()); - value_traits::set_image (buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, is_null, v); return cap != buffer_.capacity (); } -- cgit v1.1 From adda9a060e333987cd02ac50cb6c5d96b2a423a1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 14 Sep 2012 12:48:17 +0200 Subject: Remove stray template specialization --- odb/sqlite/traits.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index b812361..20cd3f3 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -357,7 +357,6 @@ namespace odb // const wchar_t* specialization // - template <> struct c_wstring_image_traits { typedef details::buffer image_type; -- cgit v1.1 From a77615868e8935e84ebbb4c441858917e971942c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 16 Sep 2012 13:21:48 +0200 Subject: Add support for Visual Studio 2012 --- INSTALL | 4 +- etc/sqlite/README | 2 +- etc/sqlite/sqlite3-vc11.sln | 26 ++++ etc/sqlite/sqlite3-vc11.vcxproj | 174 +++++++++++++++++++++++++ etc/sqlite/sqlite3-vc11.vcxproj.filters | 23 ++++ libodb-sqlite-vc11.sln | 26 ++++ makefile | 1 + odb/sqlite/libodb-sqlite-vc11.vcxproj | 178 ++++++++++++++++++++++++++ odb/sqlite/libodb-sqlite-vc11.vcxproj.filters | 19 +++ odb/sqlite/makefile | 5 +- 10 files changed, 454 insertions(+), 4 deletions(-) create mode 100644 etc/sqlite/sqlite3-vc11.sln create mode 100644 etc/sqlite/sqlite3-vc11.vcxproj create mode 100644 etc/sqlite/sqlite3-vc11.vcxproj.filters create mode 100644 libodb-sqlite-vc11.sln create mode 100644 odb/sqlite/libodb-sqlite-vc11.vcxproj create mode 100644 odb/sqlite/libodb-sqlite-vc11.vcxproj.filters diff --git a/INSTALL b/INSTALL index fd17aff..842f545 100644 --- a/INSTALL +++ b/INSTALL @@ -79,8 +79,8 @@ can change this by manually removing the LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY macro from the project's "Preprocessor Definitions" settings). The SQLite source distribution for Windows lacks Visual Studio project/solution files. -To rectify this situation, the libodb-sqlite distribution includes, in -the etc\sqlite\ directory, Visual Studio 9 and 10 project/solution files +To rectify this situation, the libodb-sqlite distribution includes, in the +etc\sqlite\ directory, Visual Studio 9, 10, and 11 project/solution files for building 32 and 64-bit SQLite libraries with unlock notify support. Refer to the accompanying README file for information on how to build the libraries and configure VC++ Directories to automatically locate them. diff --git a/etc/sqlite/README b/etc/sqlite/README index c16c832..b147916 100644 --- a/etc/sqlite/README +++ b/etc/sqlite/README @@ -1,5 +1,5 @@ This directory contains project/solution files for building SQLite libraries -with Microsoft Visual Studio versions 9 and 10. +with Microsoft Visual Studio versions 9, 10, and 11. To build SQLite, you will need to download two SQLite packages: sqlite- amalgamation and sqlite-dll. Copy the sqlite3.c and sqlite3.h files from the diff --git a/etc/sqlite/sqlite3-vc11.sln b/etc/sqlite/sqlite3-vc11.sln new file mode 100644 index 0000000..89ed59f --- /dev/null +++ b/etc/sqlite/sqlite3-vc11.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc11.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/etc/sqlite/sqlite3-vc11.vcxproj b/etc/sqlite/sqlite3-vc11.vcxproj new file mode 100644 index 0000000..9174372 --- /dev/null +++ b/etc/sqlite/sqlite3-vc11.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3409C5BB-974C-44FC-A9DB-2176837E9035} + Win32Proj + sqlite3 + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + bin\ + sqlite3-d + + + true + bin64\ + sqlite3-d + + + false + bin\ + sqlite3 + + + false + bin64\ + sqlite3 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + $(TargetPath) + lib\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + $(TargetPath) + lib64\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + true + true + $(TargetPath) + lib\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + + + Windows + true + true + true + $(TargetPath) + lib64\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + + + + + + diff --git a/etc/sqlite/sqlite3-vc11.vcxproj.filters b/etc/sqlite/sqlite3-vc11.vcxproj.filters new file mode 100644 index 0000000..13685a4 --- /dev/null +++ b/etc/sqlite/sqlite3-vc11.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/libodb-sqlite-vc11.sln b/libodb-sqlite-vc11.sln new file mode 100644 index 0000000..0ca7868 --- /dev/null +++ b/libodb-sqlite-vc11.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc11.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/makefile b/makefile index 79a5007..6611491 100644 --- a/makefile +++ b/makefile @@ -15,6 +15,7 @@ $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) $(dist): export docs := GPLv2 LICENSE README NEWS version $(dist): data_dist := INSTALL libodb-sqlite-vc9.sln libodb-sqlite-vc10.sln \ +libodb-sqlite-vc11.sln \ $(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) diff --git a/odb/sqlite/libodb-sqlite-vc11.vcxproj b/odb/sqlite/libodb-sqlite-vc11.vcxproj new file mode 100644 index 0000000..3ec1701 --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc11.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} + Win32Proj + libodb-sqlite + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + ..\..\bin\ + odb-sqlite-d-__value__(interface_version)-vc11 + + + true + ..\..\bin64\ + odb-sqlite-d-__value__(interface_version)-vc11 + + + false + ..\..\bin\ + odb-sqlite-__value__(interface_version)-vc11 + + + false + ..\..\bin64\ + odb-sqlite-__value__(interface_version)-vc11 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib\odb-sqlite-d.lib + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib64\odb-sqlite-d.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib\odb-sqlite.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + + + odb.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib64\odb-sqlite.lib + + + +__header_entries__(headers) + + +__source_entries__(sources) + + + + + diff --git a/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters new file mode 100644 index 0000000..6a1e44f --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} + cxx + + + {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} + h;hxx;ixx;txx + + + +__header_filter_entries__(headers) + + +__source_filter_entries__(sources) + + diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 8674e4a..a1e8c17 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -96,7 +96,8 @@ $(dist): export headers = $(sort $(headers_dist) $(gen_headers)) $(dist): gen_dist := $(gen) $(dist): data_dist := $(cli_tun) details/config.h.in $(dist): export extra_dist := $(data_dist) libodb-sqlite-vc9.vcproj \ -libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters +libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ +libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters $(dist): export interface_version = $(shell sed -e \ 's/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) @@ -105,6 +106,7 @@ $(dist): $(gen) $(call dist-data,$(gen_dist),$(dist_prefix)/odb/sqlite/details) $(call meta-vc9proj,$(src_base)/libodb-sqlite-vc9.vcproj) $(call meta-vc10proj,$(src_base)/libodb-sqlite-vc10.vcxproj) + $(call meta-vc11proj,$(src_base)/libodb-sqlite-vc11.vcxproj) $(call meta-automake) # Clean. @@ -132,6 +134,7 @@ endif $(call include,$(bld_root)/dist.make) $(call include,$(bld_root)/meta/vc9proj.make) $(call include,$(bld_root)/meta/vc10proj.make) +$(call include,$(bld_root)/meta/vc11proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(cli_rules)) -- cgit v1.1 From fd2e006c32a407e4f097250b1e5e7f04098bae7b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Sep 2012 09:50:53 +0200 Subject: Make sure we support older versions of SQLite (3.5.3 and up) --- odb/sqlite/connection-factory.cxx | 6 ++++++ odb/sqlite/connection.cxx | 2 ++ odb/sqlite/error.cxx | 14 +++++++++++++- odb/sqlite/makefile | 6 +++++- odb/sqlite/statement.cxx | 40 +++++++++++++++++++++++++++++++-------- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 75f1240..63d7507 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -7,6 +7,8 @@ #include #include +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + using namespace std; namespace odb @@ -117,8 +119,10 @@ namespace odb // Unless explicitly disabled, enable shared cache. // +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; +#endif } // @@ -190,8 +194,10 @@ namespace odb // Unless explicitly disabled, enable shared cache. // +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; +#endif if (min_ > 0) { diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 22955b4..a477e28 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -45,8 +45,10 @@ namespace odb // A connection can only be used by a single thread at a time. So // disable locking in SQLite unless explicitly requested. // +#if defined(SQLITE_OPEN_NOMUTEX) if ((f & SQLITE_OPEN_FULLMUTEX) == 0) f |= SQLITE_OPEN_NOMUTEX; +#endif const string& vfs (db.vfs ()); diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index b7d56c1..847e9c1 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -10,6 +10,8 @@ #include #include +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + using namespace std; namespace odb @@ -20,7 +22,14 @@ namespace odb translate_error (int e, connection& c) { sqlite3* h (c.handle ()); + + // Extended error codes are only available in 3.6.5 and later. + // +#if SQLITE_VERSION_NUMBER >= 3006005 int ee (sqlite3_extended_errcode (h)); +#else + int ee (0); +#endif string m; switch (e) @@ -40,9 +49,10 @@ namespace odb } case SQLITE_LOCKED: { +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY if (ee != SQLITE_LOCKED_SHAREDCACHE) throw deadlock (); // The DROP TABLE special case. - +#endif // Getting SQLITE_LOCKED_SHAREDCACHE here means we don't have // the unlock notify support. Translate this to timeout. // @@ -51,8 +61,10 @@ namespace odb case SQLITE_BUSY: case SQLITE_IOERR: { +#if SQLITE_VERSION_NUMBER >= 3006005 if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) throw timeout (); +#endif // Fall throught. } diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index a1e8c17..28cb2fe 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -75,7 +75,11 @@ $(out_base)/details/config.h: | $(out_base)/details/. @echo '#ifndef ODB_SQLITE_DETAILS_CONFIG_H' >>$@ @echo '#define ODB_SQLITE_DETAILS_CONFIG_H' >>$@ @echo '' >>$@ - @echo '#define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1' >>$@ + @echo '#include ' >>$@ + @echo '' >>$@ + @echo '#if SQLITE_VERSION_NUMBER >= 3006012' >>$@ + @echo ' #define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1' >>$@ + @echo '#endif' >>$@ @echo '' >>$@ @echo '#endif /* ODB_SQLITE_DETAILS_CONFIG_H */' >>$@ diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 36066ff..e1731ac 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -10,6 +10,8 @@ #include #include +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + using namespace std; namespace odb @@ -281,10 +283,12 @@ namespace odb unsigned long long r (0); - // Only the first call to sqlite3_step() can return SQLITE_LOCKED. - // int e; sqlite3* h (conn_.handle ()); + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + // Only the first call to sqlite3_step() can return SQLITE_LOCKED. + // while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) @@ -293,6 +297,9 @@ namespace odb sqlite3_reset (stmt_); conn_.wait (); } +#else + e = sqlite3_step (stmt_); +#endif for (; e == SQLITE_ROW; e = sqlite3_step (stmt_)) r++; @@ -303,8 +310,7 @@ namespace odb translate_error (e, conn_); if (!result_set_) - r = static_cast ( - sqlite3_changes (conn_.handle ())); + r = static_cast (sqlite3_changes (h)); return r; } @@ -377,6 +383,8 @@ namespace odb if (!done_) { int e; + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY sqlite3* h (conn_.handle ()); while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { @@ -386,6 +394,9 @@ namespace odb sqlite3_reset (stmt_); conn_.wait (); } +#else + e = sqlite3_step (stmt_); +#endif if (e != SQLITE_ROW) { @@ -447,6 +458,8 @@ namespace odb bind_param (param_.bind, param_.count); int e; + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY sqlite3* h (conn_.handle ()); while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { @@ -456,6 +469,9 @@ namespace odb sqlite3_reset (stmt_); conn_.wait (); } +#else + e = sqlite3_step (stmt_); +#endif sqlite3_reset (stmt_); @@ -512,6 +528,8 @@ namespace odb int e; sqlite3* h (conn_.handle ()); + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) @@ -520,14 +538,16 @@ namespace odb sqlite3_reset (stmt_); conn_.wait (); } +#else + e = sqlite3_step (stmt_); +#endif sqlite3_reset (stmt_); if (e != SQLITE_DONE) translate_error (e, conn_); - return static_cast ( - sqlite3_changes (conn_.handle ())); + return static_cast (sqlite3_changes (h)); } // delete_statement @@ -560,6 +580,8 @@ namespace odb int e; sqlite3* h (conn_.handle ()); + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) @@ -568,14 +590,16 @@ namespace odb sqlite3_reset (stmt_); conn_.wait (); } +#else + e = sqlite3_step (stmt_); +#endif sqlite3_reset (stmt_); if (e != SQLITE_DONE) translate_error (e, conn_); - return static_cast ( - sqlite3_changes (conn_.handle ())); + return static_cast (sqlite3_changes (h)); } } } -- cgit v1.1 From d8fed1d9dbab80e14033b385c604abb41cc84390 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Sep 2012 17:15:13 +0200 Subject: More older SQLite compatibility fixes --- odb/sqlite/connection-factory.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 63d7507..62e43f2 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -119,7 +119,7 @@ namespace odb // Unless explicitly disabled, enable shared cache. // -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY +#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; #endif @@ -194,7 +194,7 @@ namespace odb // Unless explicitly disabled, enable shared cache. // -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY +#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; #endif -- cgit v1.1 From 382035d872a2cbb22fc14d3c87db93b1f39b407b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Oct 2012 16:09:08 +0200 Subject: Ground work for multi-database support All generated code now includes database id. The database-specific database class interface has been updated to include all the database operations. The database-specific tests now use this interface. --- odb/sqlite/database.cxx | 9 +- odb/sqlite/database.hxx | 186 ++++++++++++ odb/sqlite/database.ixx | 378 ++++++++++++++++++++++++ odb/sqlite/forward.hxx | 2 +- odb/sqlite/no-id-object-result.hxx | 8 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 13 +- odb/sqlite/polymorphic-object-result.txx | 6 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query.cxx | 44 +-- odb/sqlite/query.hxx | 424 +++++++++++++++------------ odb/sqlite/query.ixx | 8 +- odb/sqlite/query.txx | 27 +- odb/sqlite/result.cxx | 3 +- odb/sqlite/result.hxx | 5 +- odb/sqlite/simple-object-result.hxx | 10 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.hxx | 4 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 7 +- odb/sqlite/view-result.hxx | 8 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- 25 files changed, 897 insertions(+), 261 deletions(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 0f1138f..00618b5 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -38,7 +38,8 @@ namespace odb bool foreign_keys, const string& vfs, transfer_ptr factory) - : name_ (name), + : odb::database (id_sqlite), + name_ (name), flags_ (flags), foreign_keys_ (foreign_keys), vfs_ (vfs), @@ -57,7 +58,8 @@ namespace odb bool foreign_keys, const string& vfs, transfer_ptr factory) - : flags_ (flags), + : odb::database (id_sqlite), + flags_ (flags), foreign_keys_ (foreign_keys), vfs_ (vfs), factory_ (factory.transfer ()) @@ -114,7 +116,8 @@ namespace odb bool foreign_keys, const string& vfs, transfer_ptr factory) - : flags_ (flags), + : odb::database (id_sqlite), + flags_ (flags), foreign_keys_ (foreign_keys), vfs_ (vfs), factory_ (factory.transfer ()) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index bbb01f6..aa15a9b 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -102,6 +103,191 @@ namespace odb return vfs_; } + // Object persistence API. + // + public: + + // Make the object persistent. + // + template + typename object_traits::id_type + persist (T& object); + + template + typename object_traits::id_type + persist (T* obj_ptr); + + template class P> + typename object_traits::id_type + persist (const P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (const P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (P& obj_ptr); + + template + typename object_traits::id_type + persist (const typename object_traits::pointer_type& obj_ptr); + + // Load an object. Throw object_not_persistent if not found. + // + template + typename object_traits::pointer_type + load (const typename object_traits::id_type& id); + + template + void + load (const typename object_traits::id_type& id, T& object); + + // Reload an object. + // + template + void + reload (T& object); + + template + void + reload (T* obj_ptr); + + template class P> + void + reload (const P& obj_ptr); + + template class P> + void + reload (const P& obj_ptr); + + template class P> + void + reload (P& obj_ptr); + + template class P> + void + reload (P& obj_ptr); + + template + void + reload (const typename object_traits::pointer_type& obj_ptr); + + // Loan an object if found. Return NULL/false if not found. + // + template + typename object_traits::pointer_type + find (const typename object_traits::id_type& id); + + template + bool + find (const typename object_traits::id_type& id, T& object); + + // Update the state of a modified objects. + // + template + void + update (T& object); + + template + void + update (T* obj_ptr); + + template class P> + void + update (const P& obj_ptr); + + template class P> + void + update (const P& obj_ptr); + + template class P> + void + update (P& obj_ptr); + + template class P> + void + update (P& obj_ptr); + + template + void + update (const typename object_traits::pointer_type& obj_ptr); + + // Make the object transient. Throw object_not_persistent if not + // found. + // + template + void + erase (const typename object_traits::id_type& id); + + template + void + erase (T& object); + + template + void + erase (T* obj_ptr); + + template class P> + void + erase (const P& obj_ptr); + + template class P> + void + erase (const P& obj_ptr); + + template class P> + void + erase (P& obj_ptr); + + template class P> + void + erase (P& obj_ptr); + + template + void + erase (const typename object_traits::pointer_type& obj_ptr); + + // Erase multiple objects matching a query predicate. + // + template + unsigned long long + erase_query (); + + template + unsigned long long + erase_query (const char*); + + template + unsigned long long + erase_query (const std::string&); + + template + unsigned long long + erase_query (const sqlite::query&); + + // Query API. + // + template + result + query (); + + template + result + query (const char*); + + template + result + query (const std::string&); + + template + result + query (const sqlite::query&); + // Transactions. // public: diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index ab0f09b..c8b2a30 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -15,5 +15,383 @@ namespace odb return connection_ptr ( static_cast (connection_ ())); } + + template + inline typename object_traits::id_type database:: + persist (T& obj) + { + return persist_ (obj); + } + + template + inline typename object_traits::id_type database:: + persist (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (P& p) + { + const P& cr (p); + return persist (cr); + } + + template class P> + inline typename object_traits::id_type database:: + persist (P& p) + { + const P& cr (p); + return persist (cr); + } + + template + inline typename object_traits::id_type database:: + persist (const typename object_traits::pointer_type& pobj) + { + return persist_ (pobj); + } + + template + inline typename object_traits::pointer_type database:: + load (const typename object_traits::id_type& id) + { + return load_ (id); + } + + template + inline void database:: + load (const typename object_traits::id_type& id, T& obj) + { + return load_ (id, obj); + } + + template + inline typename object_traits::pointer_type database:: + find (const typename object_traits::id_type& id) + { + return find_ (id); + } + + template + inline bool database:: + find (const typename object_traits::id_type& id, T& obj) + { + return find_ (id, obj); + } + + template + inline void database:: + reload (T& obj) + { + reload_ (obj); + } + + template + inline void database:: + reload (T* p) + { + reload (*p); + } + + template class P> + inline void database:: + reload (const P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (const P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template + inline void database:: + reload (const typename object_traits::pointer_type& pobj) + { + typedef typename object_traits::pointer_type pointer_type; + + reload (odb::pointer_traits::get_ref (pobj)); + } + + template + inline void database:: + update (T& obj) + { + update_ (obj); + } + + template + inline void database:: + update (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (P& p) + { + const P& cr (p); + update (cr); + } + + template class P> + inline void database:: + update (P& p) + { + const P& cr (p); + update (cr); + } + + template + inline void database:: + update (const typename object_traits::pointer_type& pobj) + { + update_ (pobj); + } + + template + inline void database:: + erase (const typename object_traits::id_type& id) + { + return erase_ (id); + } + + template + inline void database:: + erase (T& obj) + { + return erase_ (obj); + } + + template + inline void database:: + erase (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (P& p) + { + const P& cr (p); + erase (cr); + } + + template class P> + inline void database:: + erase (P& p) + { + const P& cr (p); + erase (cr); + } + + template + inline void database:: + erase (const typename object_traits::pointer_type& pobj) + { + erase_ (pobj); + } + + template + inline unsigned long long database:: + erase_query () + { + // T is always object_type. + // + return erase_query (sqlite::query ()); + } + + template + inline unsigned long long database:: + erase_query (const char* q) + { + // T is always object_type. + // + return erase_query (sqlite::query (q)); + } + + template + inline unsigned long long database:: + erase_query (const std::string& q) + { + // T is always object_type. + // + return erase_query (sqlite::query (q)); + } + + template + inline unsigned long long database:: + erase_query (const sqlite::query& q) + { + // T is always object_type. + // + return object_traits_impl::erase_query (*this, q); + } + + template + inline result database:: + query () + { + return query (sqlite::query ()); + } + + template + inline result database:: + query (const char* q) + { + return query (sqlite::query (q)); + } + + template + inline result database:: + query (const std::string& q) + { + return query (sqlite::query (q)); + } + + template + inline result database:: + query (const sqlite::query& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_::call (*this, q); + } } } diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 9be506f..e2f4df1 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -20,7 +20,6 @@ namespace odb class statement; class transaction; class tracer; - class query; // Implementation details. // @@ -52,6 +51,7 @@ namespace odb template class container_statements; + class query_base; class query_params; } diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 84a7265..7079678 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -14,7 +14,7 @@ #include #include -#include // query +#include // query_base #include #include @@ -29,10 +29,10 @@ namespace odb public: typedef odb::no_id_object_result_impl base_type; - typedef typename base_type::object_traits object_traits; typedef typename base_type::object_type object_type; - typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; typedef typename base_type::pointer_traits pointer_traits; typedef typename object_traits::statements_type statements_type; @@ -40,7 +40,7 @@ namespace odb virtual ~no_id_object_result_impl (); - no_id_object_result_impl (const query&, + no_id_object_result_impl (const query_base&, details::shared_ptr, statements_type&); diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 8519c47..5dad5b2 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -21,7 +21,7 @@ namespace odb template no_id_object_result_impl:: - no_id_object_result_impl (const query& q, + no_id_object_result_impl (const query_base& q, details::shared_ptr statement, statements_type& statements) : base_type (statements.connection ().database ()), diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 04d46ce..93aedb0 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -34,7 +34,7 @@ namespace odb { public: typedef T object_type; - typedef odb::object_traits object_traits; + typedef object_traits_impl object_traits; typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::image_type image_type; diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 54f4092..6023248 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -14,7 +14,7 @@ #include #include -#include // query +#include // query_base #include #include @@ -30,23 +30,24 @@ namespace odb public: typedef odb::polymorphic_object_result_impl base_type; - typedef typename base_type::object_type object_type; - typedef typename base_type::object_traits object_traits; typedef typename base_type::id_type id_type; - + typedef typename base_type::object_type object_type; typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; typedef typename base_type::pointer_traits pointer_traits; typedef typename base_type::root_type root_type; - typedef typename base_type::root_traits root_traits; typedef typename base_type::discriminator_type discriminator_type; + typedef object_traits_impl root_traits; + typedef typename object_traits::statements_type statements_type; virtual ~polymorphic_object_result_impl (); - polymorphic_object_result_impl (const query&, + polymorphic_object_result_impl (const query_base&, details::shared_ptr, statements_type&); diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index dfff9ff..7e751b3 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -23,7 +23,7 @@ namespace odb template polymorphic_object_result_impl:: - polymorphic_object_result_impl (const query& q, + polymorphic_object_result_impl (const query_base& q, details::shared_ptr st, statements_type& sts) : base_type (sts.connection ().database ()), @@ -179,7 +179,7 @@ namespace odb { // Derived type version. // - typedef object_traits traits; + typedef object_traits_impl traits; static bool rebind (typename traits::statements_type& sts) @@ -204,7 +204,7 @@ namespace odb { // Root type version. // - typedef object_traits traits; + typedef object_traits_impl traits; static bool rebind (typename traits::statements_type& sts) diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 54319ee..286b9e3 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -156,7 +156,7 @@ namespace odb { public: typedef T object_type; - typedef odb::object_traits object_traits; + typedef object_traits_impl object_traits; typedef typename object_traits::id_type id_type; typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::id_image_type id_image_type; diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index c4eba2e..9e48ace 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -10,6 +10,6 @@ namespace odb { // Sun CC cannot handle this in query.cxx. // - const query query::true_expr (true); + const query_base query_base::true_expr (true); } } diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index d979379..15934fb 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -124,18 +124,18 @@ namespace odb return r; } - // query + // query_base // - query:: - query (const query& q) + query_base:: + query_base (const query_base& q) : clause_ (q.clause_), parameters_ (new (details::shared) query_params (*q.parameters_)) { } - query& query:: - operator= (const query& q) + query_base& query_base:: + operator= (const query_base& q) { if (this != &q) { @@ -146,15 +146,15 @@ namespace odb return *this; } - query& query:: - operator+= (const query& q) + query_base& query_base:: + operator+= (const query_base& q) { clause_.insert (clause_.end (), q.clause_.begin (), q.clause_.end ()); *parameters_ += *q.parameters_; return *this; } - void query:: + void query_base:: append (const string& q) { if (!clause_.empty () && clause_.back ().kind == clause_part::native) @@ -177,7 +177,7 @@ namespace odb clause_.push_back (clause_part (clause_part::native, q)); } - void query:: + void query_base:: append (const char* table, const char* column) { string s (table); @@ -187,7 +187,7 @@ namespace odb clause_.push_back (clause_part (clause_part::column, s)); } - void query:: + void query_base:: add (details::shared_ptr p, const char* conv) { clause_.push_back (clause_part (clause_part::param)); @@ -228,7 +228,7 @@ namespace odb return false; } - void query:: + void query_base:: optimize () { // Remove a single TRUE literal or one that is followe by one of @@ -248,7 +248,7 @@ namespace odb } } - const char* query:: + const char* query_base:: clause_prefix () const { if (!clause_.empty ()) @@ -264,7 +264,7 @@ namespace odb return ""; } - string query:: + string query_base:: clause () const { string r; @@ -336,8 +336,8 @@ namespace odb return clause_prefix () + r; } - query - operator&& (const query& x, const query& y) + query_base + operator&& (const query_base& x, const query_base& y) { // Optimize cases where one or both sides are constant truth. // @@ -352,7 +352,7 @@ namespace odb if (yt) return x; - query r ("("); + query_base r ("("); r += x; r += ") AND ("; r += y; @@ -360,10 +360,10 @@ namespace odb return r; } - query - operator|| (const query& x, const query& y) + query_base + operator|| (const query_base& x, const query_base& y) { - query r ("("); + query_base r ("("); r += x; r += ") OR ("; r += y; @@ -371,10 +371,10 @@ namespace odb return r; } - query - operator! (const query& x) + query_base + operator! (const query_base& x) { - query r ("NOT ("); + query_base r ("NOT ("); r += x; r += ")"; return r; diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index ffd3559..fdae3a2 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -75,7 +75,7 @@ namespace odb const void* value_; }; - class query; + class query_base; class LIBODB_SQLITE_EXPORT query_params: public details::shared_base { @@ -86,7 +86,7 @@ namespace odb binding (); private: - friend class query; + friend class query_base; query_params (): binding_ (0, 0) {} query_params (const query_params&); @@ -113,7 +113,7 @@ namespace odb template struct query_column; - class LIBODB_SQLITE_EXPORT query + class LIBODB_SQLITE_EXPORT query_base { public: struct clause_part @@ -135,7 +135,7 @@ namespace odb bool bool_part; }; - query () + query_base () : parameters_ (new (details::shared) query_params) { } @@ -143,27 +143,27 @@ namespace odb // True or false literal. // explicit - query (bool v) + query_base (bool v) : parameters_ (new (details::shared) query_params) { clause_.push_back (clause_part (v)); } explicit - query (const char* native) + query_base (const char* native) : parameters_ (new (details::shared) query_params) { clause_.push_back (clause_part (clause_part::native, native)); } explicit - query (const std::string& native) + query_base (const std::string& native) : parameters_ (new (details::shared) query_params) { clause_.push_back (clause_part (clause_part::native, native)); } - query (const char* table, const char* column) + query_base (const char* table, const char* column) : parameters_ (new (details::shared) query_params) { append (table, column); @@ -171,7 +171,7 @@ namespace odb template explicit - query (val_bind v) + query_base (val_bind v) : parameters_ (new (details::shared) query_params) { append::db_type_id> ( @@ -180,7 +180,7 @@ namespace odb template explicit - query (ref_bind r) + query_base (ref_bind r) : parameters_ (new (details::shared) query_params) { append::db_type_id> ( @@ -188,12 +188,12 @@ namespace odb } template - query (const query_column&); + query_base (const query_column&); - query (const query&); + query_base (const query_base&); - query& - operator= (const query&); + query_base& + operator= (const query_base&); public: std::string @@ -215,7 +215,7 @@ namespace odb return clause_.empty (); } - static const query true_expr; + static const query_base true_expr; bool const_true () const @@ -244,10 +244,10 @@ namespace odb } public: - query& - operator+= (const query&); + query_base& + operator+= (const query_base&); - query& + query_base& operator+= (const std::string& q) { append (q); @@ -255,7 +255,7 @@ namespace odb } template - query& + query_base& operator+= (val_bind v) { append::db_type_id> ( @@ -264,7 +264,7 @@ namespace odb } template - query& + query_base& operator+= (ref_bind r) { append::db_type_id> ( @@ -298,114 +298,114 @@ namespace odb details::shared_ptr parameters_; }; - inline query - operator+ (const query& x, const query& y) + inline query_base + operator+ (const query_base& x, const query_base& y) { - query r (x); + query_base r (x); r += y; return r; } template - inline query - operator+ (const query& q, val_bind b) + inline query_base + operator+ (const query_base& q, val_bind b) { - query r (q); + query_base r (q); r += b; return r; } template - inline query - operator+ (const query& q, ref_bind b) + inline query_base + operator+ (const query_base& q, ref_bind b) { - query r (q); + query_base r (q); r += b; return r; } template - inline query - operator+ (val_bind b, const query& q) + inline query_base + operator+ (val_bind b, const query_base& q) { - query r; + query_base r; r += b; r += q; return r; } template - inline query - operator+ (ref_bind b, const query& q) + inline query_base + operator+ (ref_bind b, const query_base& q) { - query r; + query_base r; r += b; r += q; return r; } - inline query - operator+ (const query& q, const std::string& s) + inline query_base + operator+ (const query_base& q, const std::string& s) { - query r (q); + query_base r (q); r += s; return r; } - inline query - operator+ (const std::string& s, const query& q) + inline query_base + operator+ (const std::string& s, const query_base& q) { - query r (s); + query_base r (s); r += q; return r; } template - inline query + inline query_base operator+ (const std::string& s, val_bind b) { - query r (s); + query_base r (s); r += b; return r; } template - inline query + inline query_base operator+ (const std::string& s, ref_bind b) { - query r (s); + query_base r (s); r += b; return r; } template - inline query + inline query_base operator+ (val_bind b, const std::string& s) { - query r; + query_base r; r += b; r += s; return r; } template - inline query + inline query_base operator+ (ref_bind b, const std::string& s) { - query r; + query_base r; r += b; r += s; return r; } - LIBODB_SQLITE_EXPORT query - operator&& (const query&, const query&); + LIBODB_SQLITE_EXPORT query_base + operator&& (const query_base&, const query_base&); - LIBODB_SQLITE_EXPORT query - operator|| (const query&, const query&); + LIBODB_SQLITE_EXPORT query_base + operator|| (const query_base&, const query_base&); - LIBODB_SQLITE_EXPORT query - operator! (const query&); + LIBODB_SQLITE_EXPORT query_base + operator! (const query_base&); // query_column // @@ -458,18 +458,18 @@ namespace odb // is_null, is_not_null // public: - query + query_base is_null () const { - query q (table_, column_); + query_base q (table_, column_); q += "IS NULL"; return q; } - query + query_base is_not_null () const { - query q (table_, column_); + query_base q (table_, column_); q += "IS NOT NULL"; return q; } @@ -477,102 +477,102 @@ namespace odb // in // public: - query + query_base in (const T&, const T&) const; - query + query_base in (const T&, const T&, const T&) const; - query + query_base in (const T&, const T&, const T&, const T&) const; - query + query_base in (const T&, const T&, const T&, const T&, const T&) const; template - query + query_base in_range (I begin, I end) const; // = // public: - query + query_base equal (const T& v) const { return equal (val_bind (v)); } - query + query_base equal (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += "="; q.append (v, conversion_); return q; } template - query + query_base equal (val_bind v) const { copy_bind c (v.val); return equal (c); } - query + query_base equal (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += "="; q.append (r, conversion_); return q; } - friend query + friend query_base operator== (const query_column& c, const T& v) { return c.equal (v); } - friend query + friend query_base operator== (const T& v, const query_column& c) { return c.equal (v); } - friend query + friend query_base operator== (const query_column& c, val_bind v) { return c.equal (v); } - friend query + friend query_base operator== (val_bind v, const query_column& c) { return c.equal (v); } template - friend query + friend query_base operator== (const query_column& c, val_bind v) { return c.equal (v); } template - friend query + friend query_base operator== (val_bind v, const query_column& c) { return c.equal (v); } - friend query + friend query_base operator== (const query_column& c, ref_bind r) { return c.equal (r); } - friend query + friend query_base operator== (ref_bind r, const query_column& c) { return c.equal (r); @@ -581,83 +581,83 @@ namespace odb // != // public: - query + query_base unequal (const T& v) const { return unequal (val_bind (v)); } - query + query_base unequal (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += "!="; q.append (v, conversion_); return q; } template - query + query_base unequal (val_bind v) const { copy_bind c (v.val); return unequal (c); } - query + query_base unequal (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += "!="; q.append (r, conversion_); return q; } - friend query + friend query_base operator!= (const query_column& c, const T& v) { return c.unequal (v); } - friend query + friend query_base operator!= (const T& v, const query_column& c) { return c.unequal (v); } - friend query + friend query_base operator!= (const query_column& c, val_bind v) { return c.unequal (v); } - friend query + friend query_base operator!= (val_bind v, const query_column& c) { return c.unequal (v); } template - friend query + friend query_base operator!= (const query_column& c, val_bind v) { return c.unequal (v); } template - friend query + friend query_base operator!= (val_bind v, const query_column& c) { return c.unequal (v); } - friend query + friend query_base operator!= (const query_column& c, ref_bind r) { return c.unequal (r); } - friend query + friend query_base operator!= (ref_bind r, const query_column& c) { return c.unequal (r); @@ -666,83 +666,83 @@ namespace odb // < // public: - query + query_base less (const T& v) const { return less (val_bind (v)); } - query + query_base less (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += "<"; q.append (v, conversion_); return q; } template - query + query_base less (val_bind v) const { copy_bind c (v.val); return less (c); } - query + query_base less (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += "<"; q.append (r, conversion_); return q; } - friend query + friend query_base operator< (const query_column& c, const T& v) { return c.less (v); } - friend query + friend query_base operator< (const T& v, const query_column& c) { return c.greater (v); } - friend query + friend query_base operator< (const query_column& c, val_bind v) { return c.less (v); } - friend query + friend query_base operator< (val_bind v, const query_column& c) { return c.greater (v); } template - friend query + friend query_base operator< (const query_column& c, val_bind v) { return c.less (v); } template - friend query + friend query_base operator< (val_bind v, const query_column& c) { return c.greater (v); } - friend query + friend query_base operator< (const query_column& c, ref_bind r) { return c.less (r); } - friend query + friend query_base operator< (ref_bind r, const query_column& c) { return c.greater (r); @@ -751,83 +751,83 @@ namespace odb // > // public: - query + query_base greater (const T& v) const { return greater (val_bind (v)); } - query + query_base greater (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += ">"; q.append (v, conversion_); return q; } template - query + query_base greater (val_bind v) const { copy_bind c (v.val); return greater (c); } - query + query_base greater (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += ">"; q.append (r, conversion_); return q; } - friend query + friend query_base operator> (const query_column& c, const T& v) { return c.greater (v); } - friend query + friend query_base operator> (const T& v, const query_column& c) { return c.less (v); } - friend query + friend query_base operator> (const query_column& c, val_bind v) { return c.greater (v); } - friend query + friend query_base operator> (val_bind v, const query_column& c) { return c.less (v); } template - friend query + friend query_base operator> (const query_column& c, val_bind v) { return c.greater (v); } template - friend query + friend query_base operator> (val_bind v, const query_column& c) { return c.less (v); } - friend query + friend query_base operator> (const query_column& c, ref_bind r) { return c.greater (r); } - friend query + friend query_base operator> (ref_bind r, const query_column& c) { return c.less (r); @@ -836,83 +836,83 @@ namespace odb // <= // public: - query + query_base less_equal (const T& v) const { return less_equal (val_bind (v)); } - query + query_base less_equal (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += "<="; q.append (v, conversion_); return q; } template - query + query_base less_equal (val_bind v) const { copy_bind c (v.val); return less_equal (c); } - query + query_base less_equal (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += "<="; q.append (r, conversion_); return q; } - friend query + friend query_base operator<= (const query_column& c, const T& v) { return c.less_equal (v); } - friend query + friend query_base operator<= (const T& v, const query_column& c) { return c.greater_equal (v); } - friend query + friend query_base operator<= (const query_column& c, val_bind v) { return c.less_equal (v); } - friend query + friend query_base operator<= (val_bind v, const query_column& c) { return c.greater_equal (v); } template - friend query + friend query_base operator<= (const query_column& c, val_bind v) { return c.less_equal (v); } template - friend query + friend query_base operator<= (val_bind v, const query_column& c) { return c.greater_equal (v); } - friend query + friend query_base operator<= (const query_column& c, ref_bind r) { return c.less_equal (r); } - friend query + friend query_base operator<= (ref_bind r, const query_column& c) { return c.greater_equal (r); @@ -921,83 +921,83 @@ namespace odb // >= // public: - query + query_base greater_equal (const T& v) const { return greater_equal (val_bind (v)); } - query + query_base greater_equal (val_bind v) const { - query q (table_, column_); + query_base q (table_, column_); q += ">="; q.append (v, conversion_); return q; } template - query + query_base greater_equal (val_bind v) const { copy_bind c (v.val); return greater_equal (c); } - query + query_base greater_equal (ref_bind r) const { - query q (table_, column_); + query_base q (table_, column_); q += ">="; q.append (r, conversion_); return q; } - friend query + friend query_base operator>= (const query_column& c, const T& v) { return c.greater_equal (v); } - friend query + friend query_base operator>= (const T& v, const query_column& c) { return c.less_equal (v); } - friend query + friend query_base operator>= (const query_column& c, val_bind v) { return c.greater_equal (v); } - friend query + friend query_base operator>= (val_bind v, const query_column& c) { return c.less_equal (v); } template - friend query + friend query_base operator>= (const query_column& c, val_bind v) { return c.greater_equal (v); } template - friend query + friend query_base operator>= (val_bind v, const query_column& c) { return c.less_equal (v); } - friend query + friend query_base operator>= (const query_column& c, ref_bind r) { return c.greater_equal (r); } - friend query + friend query_base operator>= (ref_bind r, const query_column& c) { return c.less_equal (r); @@ -1007,84 +1007,84 @@ namespace odb // public: template - query + query_base operator== (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () == type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += "="; q.append (c.table (), c.column ()); return q; } template - query + query_base operator!= (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () != type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += "!="; q.append (c.table (), c.column ()); return q; } template - query + query_base operator< (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () < type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += "<"; q.append (c.table (), c.column ()); return q; } template - query + query_base operator> (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () > type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += ">"; q.append (c.table (), c.column ()); return q; } template - query + query_base operator<= (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () <= type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += "<="; q.append (c.table (), c.column ()); return q; } template - query + query_base operator>= (const query_column& c) const { // We can compare columns only if we can compare their C++ types. // (void) (sizeof (type_instance () >= type_instance ())); - query q (table_, column_); + query_base q (table_, column_); q += ">="; q.append (c.table (), c.column ()); return q; @@ -1100,37 +1100,37 @@ namespace odb // query fragments (e.g., ORDER BY). // template - inline query + inline query_base operator+ (const query_column& c, const std::string& s) { - query q (c.table (), c.column ()); + query_base q (c.table (), c.column ()); q += s; return q; } template - inline query + inline query_base operator+ (const std::string& s, const query_column& c) { - query q (s); + query_base q (s); q.append (c.table (), c.column ()); return q; } template - inline query - operator+ (const query_column& c, const query& q) + inline query_base + operator+ (const query_column& c, const query_base& q) { - query r (c.table (), c.column ()); + query_base r (c.table (), c.column ()); r += q; return r; } template - inline query - operator+ (const query& q, const query_column& c) + inline query_base + operator+ (const query_base& q, const query_column& c) { - query r (q); + query_base r (q); r.append (c.table (), c.column ()); return r; } @@ -1284,13 +1284,75 @@ namespace odb } } -// odb::query specialization for SQLite. +// odb::sqlite::query and odb::query specialization for SQLite. // namespace odb { + namespace sqlite + { + template + class query: public query_base, + public query_selector::columns_type + { + public: + // We don't define any typedefs here since they may clash with + // column names defined by our base type. + // + + query () + { + } + + explicit + query (bool v) + : query_base (v) + { + } + + explicit + query (const char* q) + : query_base (q) + { + } + + explicit + query (const std::string& q) + : query_base (q) + { + } + + template + explicit + query (val_bind v) + : query_base (v) + { + } + + template + explicit + query (ref_bind r) + : query_base (r) + { + } + + query (const query_base& q) + : query_base (q) + { + } + + template + query (const query_column& qc) + : query_base (qc) + { + } + }; + } + + // Derive odb::query from odb::sqlite::query so that it can be + // implicitly converted in sqlite::database::query() calls. + // template - class query: public sqlite::query, - public query_selector::columns_type + class query: public sqlite::query { public: // We don't define any typedefs here since they may clash with @@ -1303,44 +1365,44 @@ namespace odb explicit query (bool v) - : sqlite::query (v) + : sqlite::query (v) { } explicit query (const char* q) - : sqlite::query (q) + : sqlite::query (q) { } explicit query (const std::string& q) - : sqlite::query (q) + : sqlite::query (q) { } template explicit query (sqlite::val_bind v) - : sqlite::query (sqlite::query (v)) + : sqlite::query (v) { } template explicit query (sqlite::ref_bind r) - : sqlite::query (sqlite::query (r)) + : sqlite::query (r) { } - query (const sqlite::query& q) - : sqlite::query (q) + query (const sqlite::query_base& q) + : sqlite::query (q) { } template query (const sqlite::query_column& qc) - : sqlite::query (qc) + : sqlite::query (qc) { } }; diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 113b376..631749f 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -6,20 +6,20 @@ namespace odb { namespace sqlite { - inline binding& query:: + inline binding& query_base:: parameters_binding () const { return parameters_->binding (); } - inline details::shared_ptr query:: + inline details::shared_ptr query_base:: parameters () const { return parameters_; } template - inline void query:: + inline void query_base:: append (val_bind v, const char* conv) { add ( @@ -29,7 +29,7 @@ namespace odb } template - inline void query:: + inline void query_base:: append (ref_bind r, const char* conv) { add ( diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index ba3fac1..f719ece 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -6,12 +6,12 @@ namespace odb { namespace sqlite { - // query + // query_base // template - query:: - query (const query_column& c) + query_base:: + query_base (const query_column& c) : parameters_ (new (details::shared) query_params) { // Cannot use IS TRUE here since database type can be a non- @@ -25,10 +25,10 @@ namespace odb // query_column // template - query query_column:: + query_base query_column:: in (const T& v1, const T& v2) const { - query q (table_, column_); + query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; @@ -38,10 +38,10 @@ namespace odb } template - query query_column:: + query_base query_column:: in (const T& v1, const T& v2, const T& v3) const { - query q (table_, column_); + query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; @@ -53,10 +53,10 @@ namespace odb } template - query query_column:: + query_base query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4) const { - query q (table_, column_); + query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; @@ -70,10 +70,10 @@ namespace odb } template - query query_column:: + query_base query_column:: in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const { - query q (table_, column_); + query_base q (table_, column_); q += "IN ("; q.append (val_bind (v1), conversion_); q += ","; @@ -90,10 +90,10 @@ namespace odb template template - query query_column:: + query_base query_column:: in_range (I begin, I end) const { - query q (table_, column_); + query_base q (table_, column_); q += "IN ("; for (I i (begin); i != end; ++i) @@ -103,6 +103,7 @@ namespace odb q.append (val_bind (*i), conversion_); } + q += ")"; return q; } diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx index 2c950d0..f8b1073 100644 --- a/odb/sqlite/result.cxx +++ b/odb/sqlite/result.cxx @@ -10,7 +10,8 @@ namespace odb namespace sqlite { result_impl_base:: - result_impl_base (const query& q, details::shared_ptr s) + result_impl_base (const query_base& q, + details::shared_ptr s) : params_ (q.parameters ()), statement_ (s) { } diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index 92c1bb1..cd2d376 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -10,7 +10,7 @@ #include #include -#include // query, query_params +#include // query_base, query_params #include #include @@ -22,7 +22,8 @@ namespace odb class LIBODB_SQLITE_EXPORT result_impl_base { public: - result_impl_base (const query&, details::shared_ptr); + result_impl_base (const query_base&, + details::shared_ptr); protected: // We need to hold on to the query parameters because SQLite uses diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 8c748bc..08132b1 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -14,7 +14,7 @@ #include #include -#include // query +#include // query_base #include #include @@ -29,11 +29,11 @@ namespace odb public: typedef odb::object_result_impl base_type; - typedef typename base_type::object_traits object_traits; - typedef typename base_type::object_type object_type; typedef typename base_type::id_type id_type; - + typedef typename base_type::object_type object_type; typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; typedef typename base_type::pointer_traits pointer_traits; typedef typename object_traits::statements_type statements_type; @@ -41,7 +41,7 @@ namespace odb virtual ~object_result_impl (); - object_result_impl (const query&, + object_result_impl (const query_base&, details::shared_ptr, statements_type&); diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 2152a21..34eaab5 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -23,7 +23,7 @@ namespace odb template object_result_impl:: - object_result_impl (const query& q, + object_result_impl (const query_base& q, details::shared_ptr statement, statements_type& statements) : base_type (statements.connection ().database ()), diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 90f2494..66dc0f9 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -147,7 +147,7 @@ namespace odb struct optimistic_data { typedef T object_type; - typedef odb::object_traits object_traits; + typedef object_traits_impl object_traits; optimistic_data (bind*); @@ -170,7 +170,7 @@ namespace odb { public: typedef T object_type; - typedef odb::object_traits object_traits; + typedef object_traits_impl object_traits; typedef typename object_traits::id_type id_type; typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::image_type image_type; diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 5d94296..b08e4c7 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -69,7 +69,7 @@ namespace odb } template - typename object_traits::statements_type& + typename object_traits_impl::statements_type& find_object (); template diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index b702712..775a6a8 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -7,10 +7,13 @@ namespace odb namespace sqlite { template - typename object_traits::statements_type& statement_cache:: + typename object_traits_impl::statements_type& + statement_cache:: find_object () { - typedef typename object_traits::statements_type statements_type; + typedef + typename object_traits_impl::statements_type + statements_type; map::iterator i (map_.find (&typeid (T))); diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 82910db..846504f 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -14,7 +14,7 @@ #include #include -#include // query, view_statements +#include // query_base, view_statements #include namespace odb @@ -29,9 +29,9 @@ namespace odb typedef odb::view_result_impl base_type; typedef typename base_type::view_type view_type; - typedef typename base_type::view_traits view_traits; - typedef typename base_type::pointer_type pointer_type; + + typedef view_traits_impl view_traits; typedef typename base_type::pointer_traits pointer_traits; typedef view_statements statements_type; @@ -39,7 +39,7 @@ namespace odb virtual ~view_result_impl (); - view_result_impl (const query&, + view_result_impl (const query_base&, details::shared_ptr, statements_type&); diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index f2170c9..7d8ac5f 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -21,7 +21,7 @@ namespace odb template view_result_impl:: - view_result_impl (const query& q, + view_result_impl (const query_base& q, details::shared_ptr statement, statements_type& statements) : base_type (statements.connection ().database ()), diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 9a4f566..ca99bb1 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -26,7 +26,7 @@ namespace odb { public: typedef T view_type; - typedef odb::view_traits view_traits; + typedef view_traits_impl view_traits; typedef typename view_traits::pointer_type pointer_type; typedef typename view_traits::image_type image_type; -- cgit v1.1 From 74bb67e9825e06b68e2f5499b68da2323cb5bb34 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Oct 2012 11:33:49 +0200 Subject: Initial support for prepared queries --- odb/sqlite/prepared-query.hxx | 33 +++++++++++++++++++++++++ odb/sqlite/query.cxx | 16 ++++--------- odb/sqlite/query.hxx | 10 +++++++- odb/sqlite/query.ixx | 6 +++++ odb/sqlite/statement.cxx | 34 ++++++++++++++++---------- odb/sqlite/statement.hxx | 56 +++++++++++++++++++++++++++++-------------- 6 files changed, 111 insertions(+), 44 deletions(-) create mode 100644 odb/sqlite/prepared-query.hxx diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx new file mode 100644 index 0000000..dd23b41 --- /dev/null +++ b/odb/sqlite/prepared-query.hxx @@ -0,0 +1,33 @@ +// file : odb/sqlite/prepared-query.hxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_PREPARED_QUERY_HXX +#define ODB_SQLITE_PREPARED_QUERY_HXX + +#include + +#include +#include + +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + struct LIBODB_SQLITE_EXPORT prepared_query_impl: odb::prepared_query_impl + { + sqlite::query query; + details::shared_ptr stmt; + }; + } +} + +#include + +#endif // ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 15934fb..f6a4dc1 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -92,19 +92,13 @@ namespace odb p->bind (b); } - query_params::binding_type& query_params:: - binding () + void query_params:: + init () { - size_t n (params_.size ()); - binding_type& r (binding_); - - if (n == 0) - return r; - bool inc_ver (false); sqlite::bind* b (&bind_[0]); - for (size_t i (0); i < n; ++i) + for (size_t i (0); i < params_.size (); ++i) { query_param& p (*params_[i]); @@ -119,9 +113,7 @@ namespace odb } if (inc_ver) - r.version++; - - return r; + binding_.version++; } // query_base diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index fdae3a2..eebc7c3 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -82,8 +82,11 @@ namespace odb public: typedef sqlite::binding binding_type; + void + init (); + binding_type& - binding (); + binding () {return binding_;} private: friend class query_base; @@ -202,6 +205,11 @@ namespace odb const char* clause_prefix () const; + // Initialize the by-reference parameters from bound variables. + // + void + init_parameters () const; + binding& parameters_binding () const; diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 631749f..627ebb7 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -6,6 +6,12 @@ namespace odb { namespace sqlite { + inline void query_base:: + init_parameters () const + { + return parameters_->init (); + } + inline binding& query_base:: parameters_binding () const { diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index e1731ac..5955b33 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -245,21 +245,21 @@ namespace odb // generic_statement:: - generic_statement (connection& conn, const string& text) + generic_statement (connection_type& conn, const string& text) : statement (conn, text), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } generic_statement:: - generic_statement (connection& conn, const char* text) + generic_statement (connection_type& conn, const char* text) : statement (conn, text), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } generic_statement:: - generic_statement (connection& conn, + generic_statement (connection_type& conn, const char* text, std::size_t text_size) : statement (conn, text, text_size), @@ -319,7 +319,7 @@ namespace odb // select_statement:: - select_statement (connection& conn, + select_statement (connection_type& conn, const string& text, binding& param, binding& result) @@ -328,7 +328,7 @@ namespace odb } select_statement:: - select_statement (connection& conn, + select_statement (connection_type& conn, const char* text, binding& param, binding& result) @@ -337,13 +337,15 @@ namespace odb } select_statement:: - select_statement (connection& conn, const string& text, binding& result) + select_statement (connection_type& conn, + const string& text, + binding& result) : statement (conn, text), param_ (0), result_ (result) { } select_statement:: - select_statement (connection& conn, const char* text, binding& result) + select_statement (connection_type& conn, const char* text, binding& result) : statement (conn, text), param_ (0), result_ (result) { } @@ -433,13 +435,15 @@ namespace odb // insert_statement:: - insert_statement (connection& conn, const string& text, binding& param) + insert_statement (connection_type& conn, + const string& text, + binding& param) : statement (conn, text), param_ (param) { } insert_statement:: - insert_statement (connection& conn, const char* text, binding& param) + insert_statement (connection_type& conn, const char* text, binding& param) : statement (conn, text), param_ (param) { } @@ -502,13 +506,15 @@ namespace odb // update_statement:: - update_statement (connection& conn, const string& text, binding& param) + update_statement (connection_type& conn, + const string& text, + binding& param) : statement (conn, text), param_ (param) { } update_statement:: - update_statement (connection& conn, const char* text, binding& param) + update_statement (connection_type& conn, const char* text, binding& param) : statement (conn, text), param_ (param) { } @@ -554,13 +560,15 @@ namespace odb // delete_statement:: - delete_statement (connection& conn, const string& text, binding& param) + delete_statement (connection_type& conn, + const string& text, + binding& param) : statement (conn, text), param_ (param) { } delete_statement:: - delete_statement (connection& conn, const char* text, binding& param) + delete_statement (connection_type& conn, const char* text, binding& param) : statement (conn, text), param_ (param) { } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 0ed8aa8..3c57c74 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -33,6 +33,8 @@ namespace odb class LIBODB_SQLITE_EXPORT statement: public odb::statement { public: + typedef sqlite::connection connection_type; + virtual ~statement () = 0; @@ -45,6 +47,12 @@ namespace odb virtual const char* text () const; + virtual connection_type& + connection () + { + return conn_; + } + // Cached state (public part). // public: @@ -69,19 +77,21 @@ namespace odb } protected: - statement (connection& conn, const std::string& text) + statement (connection_type& conn, const std::string& text) : conn_ (conn) { init (text.c_str (), text.size ()); } - statement (connection& conn, const char* text) + statement (connection_type& conn, const char* text) : conn_ (conn) { init (text, std::strlen (text)); } - statement (connection& conn, const char* text, std::size_t text_size) + statement (connection_type& conn, + const char* text, + std::size_t text_size) : conn_ (conn) { init (text, text_size); @@ -142,9 +152,9 @@ namespace odb finilize (); protected: - friend class connection; + friend class sqlite::connection; - connection& conn_; + connection_type& conn_; // Cached static type. auto_handle stmt_; bool active_; @@ -199,9 +209,11 @@ namespace odb class LIBODB_SQLITE_EXPORT generic_statement: public statement { public: - generic_statement (connection&, const std::string& text); - generic_statement (connection&, const char* text); - generic_statement (connection&, const char* text, std::size_t text_size); + generic_statement (connection_type&, const std::string& text); + generic_statement (connection_type&, const char* text); + generic_statement (connection_type&, + const char* text, + std::size_t text_size); unsigned long long execute (); @@ -217,21 +229,23 @@ namespace odb class LIBODB_SQLITE_EXPORT select_statement: public statement { public: - select_statement (connection& conn, + select_statement (connection_type& conn, const std::string& text, binding& param, binding& result); - select_statement (connection& conn, + select_statement (connection_type& conn, const char* text, binding& param, binding& result); - select_statement (connection& conn, + select_statement (connection_type& conn, const std::string& text, binding& result); - select_statement (connection& conn, const char* text, binding& result); + select_statement (connection_type& conn, + const char* text, + binding& result); // Common select interface expected by the generated code. // @@ -310,11 +324,13 @@ namespace odb class LIBODB_SQLITE_EXPORT insert_statement: public statement { public: - insert_statement (connection& conn, + insert_statement (connection_type& conn, const std::string& text, binding& param); - insert_statement (connection& conn, const char* text, binding& param); + insert_statement (connection_type& conn, + const char* text, + binding& param); // Return true if successful and false if the row is a duplicate. // All other errors are reported by throwing exceptions. @@ -336,11 +352,13 @@ namespace odb class LIBODB_SQLITE_EXPORT update_statement: public statement { public: - update_statement (connection& conn, + update_statement (connection_type& conn, const std::string& text, binding& param); - update_statement (connection& conn, const char* text, binding& param); + update_statement (connection_type& conn, + const char* text, + binding& param); unsigned long long execute (); @@ -356,11 +374,13 @@ namespace odb class LIBODB_SQLITE_EXPORT delete_statement: public statement { public: - delete_statement (connection& conn, + delete_statement (connection_type& conn, const std::string& text, binding& param); - delete_statement (connection& conn, const char* text, binding& param); + delete_statement (connection_type& conn, + const char* text, + binding& param); unsigned long long execute (); -- cgit v1.1 From 1c8dc77a0feae8b33e8c06f7ba076bd26d278054 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Oct 2012 16:26:39 +0200 Subject: Update prepared statement code for multi-database support --- odb/sqlite/prepared-query.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index dd23b41..aee1d95 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -22,7 +22,7 @@ namespace odb { struct LIBODB_SQLITE_EXPORT prepared_query_impl: odb::prepared_query_impl { - sqlite::query query; + sqlite::query_base query; details::shared_ptr stmt; }; } -- cgit v1.1 From d94948b8bccfd8748245726487d54c41bb199baf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Oct 2012 17:24:44 +0200 Subject: Completion of prepared query support --- odb/sqlite/connection.cxx | 4 ++++ odb/sqlite/connection.hxx | 18 ++++++++++++++++++ odb/sqlite/connection.ixx | 30 ++++++++++++++++++++++++++++++ odb/sqlite/database.hxx | 14 ++++++++++++++ odb/sqlite/database.ixx | 26 ++++++++++++++++++++++++++ odb/sqlite/makefile | 1 + odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 10 +++++----- odb/sqlite/polymorphic-object-result.hxx | 7 ++++--- odb/sqlite/polymorphic-object-result.txx | 7 ++++--- odb/sqlite/prepared-query.cxx | 16 ++++++++++++++++ odb/sqlite/prepared-query.hxx | 6 +++--- odb/sqlite/query.cxx | 3 +-- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/result.cxx | 2 +- odb/sqlite/result.hxx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/statement.cxx | 16 ++++++++++++++-- odb/sqlite/statement.hxx | 26 ++++---------------------- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 4 ++-- 23 files changed, 154 insertions(+), 50 deletions(-) create mode 100644 odb/sqlite/connection.ixx create mode 100644 odb/sqlite/prepared-query.cxx diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index a477e28..bcf28a2 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include // deadlock @@ -101,6 +102,9 @@ namespace odb connection:: ~connection () { + // Destroy prepared query statements before freeing the connections. + // + prepared_map_.clear (); } transaction_impl* connection:: diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 5eb1995..3524a48 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -68,6 +69,21 @@ namespace odb virtual unsigned long long execute (const char* statement, std::size_t length); + // Query preparation. + // + public: + template + prepared_query + prepare_query (const char* name, const char*); + + template + prepared_query + prepare_query (const char* name, const std::string&); + + template + prepared_query + prepare_query (const char* name, const query&); + // SQL statement tracing. // public: @@ -153,6 +169,8 @@ namespace odb } } +#include + #include #endif // ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx new file mode 100644 index 0000000..9117bd4 --- /dev/null +++ b/odb/sqlite/connection.ixx @@ -0,0 +1,30 @@ +// file : odb/sqlite/connection.ixx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + template + inline prepared_query connection:: + prepare_query (const char* n, const char* q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const std::string& q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const query& q) + { + return query_::call (*this, n, q); + } + } +} diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index aa15a9b..318cb57 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -288,6 +288,20 @@ namespace odb result query (const sqlite::query&); + // Query preparation. + // + template + prepared_query + prepare_query (const char* name, const char*); + + template + prepared_query + prepare_query (const char* name, const std::string&); + + template + prepared_query + prepare_query (const char* name, const sqlite::query&); + // Transactions. // public: diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index c8b2a30..2b57912 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + namespace odb { namespace sqlite @@ -393,5 +395,29 @@ namespace odb // return query_::call (*this, q); } + + template + inline prepared_query database:: + prepare_query (const char* n, const char* q) + { + return prepare_query (n, sqlite::query (q)); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const std::string& q) + { + return prepare_query (n, sqlite::query (q)); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const sqlite::query& q) + { + // Throws if not in transaction. + // + sqlite::connection& c (transaction::current ().connection ()); + return c.prepare_query (n, q); + } } } diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 28cb2fe..1f9e0ae 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -10,6 +10,7 @@ connection-factory.cxx \ database.cxx \ error.cxx \ exceptions.cxx \ +prepared-query.cxx \ query.cxx \ query-const-expr.cxx \ result.cxx \ diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 7079678..60e69e3 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -41,7 +41,7 @@ namespace odb ~no_id_object_result_impl (); no_id_object_result_impl (const query_base&, - details::shared_ptr, + const details::shared_ptr&, statements_type&); virtual void diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 5dad5b2..3fe9fc2 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -22,11 +22,11 @@ namespace odb template no_id_object_result_impl:: no_id_object_result_impl (const query_base& q, - details::shared_ptr statement, - statements_type& statements) - : base_type (statements.connection ().database ()), - result_impl_base (q, statement), - statements_ (statements) + const details::shared_ptr& s, + statements_type& sts) + : base_type (sts.connection ().database ()), + result_impl_base (q, s), + statements_ (sts) { } diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 6023248..9cf9c6c 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -47,9 +47,10 @@ namespace odb virtual ~polymorphic_object_result_impl (); - polymorphic_object_result_impl (const query_base&, - details::shared_ptr, - statements_type&); + polymorphic_object_result_impl ( + const query_base&, + const details::shared_ptr&, + statements_type&); virtual void load (object_type*, bool fetch); diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 7e751b3..0dd68cf 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -23,9 +23,10 @@ namespace odb template polymorphic_object_result_impl:: - polymorphic_object_result_impl (const query_base& q, - details::shared_ptr st, - statements_type& sts) + polymorphic_object_result_impl ( + const query_base& q, + const details::shared_ptr& st, + statements_type& sts) : base_type (sts.connection ().database ()), result_impl_base (q, st), statements_ (sts) diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx new file mode 100644 index 0000000..1eb875d --- /dev/null +++ b/odb/sqlite/prepared-query.cxx @@ -0,0 +1,16 @@ +// file : odb/sqlite/prepared-query.cxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + prepared_query_impl:: + ~prepared_query_impl () + { + } + } +} diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index aee1d95..ddc2c9c 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -8,11 +8,9 @@ #include #include -#include #include #include -#include #include @@ -22,8 +20,10 @@ namespace odb { struct LIBODB_SQLITE_EXPORT prepared_query_impl: odb::prepared_query_impl { + virtual + ~prepared_query_impl (); + sqlite::query_base query; - details::shared_ptr stmt; }; } } diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index f6a4dc1..2a1c203 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -96,7 +96,6 @@ namespace odb init () { bool inc_ver (false); - sqlite::bind* b (&bind_[0]); for (size_t i (0); i < params_.size (); ++i) { @@ -106,7 +105,7 @@ namespace odb { if (p.init ()) { - p.bind (b + i); + p.bind (&bind_[i]); inc_ver = true; } } diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index eebc7c3..7264bf4 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -213,7 +213,7 @@ namespace odb binding& parameters_binding () const; - details::shared_ptr + const details::shared_ptr& parameters () const; public: diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 627ebb7..c3a5f14 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -18,7 +18,7 @@ namespace odb return parameters_->binding (); } - inline details::shared_ptr query_base:: + inline const details::shared_ptr& query_base:: parameters () const { return parameters_; diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx index f8b1073..ccd6c05 100644 --- a/odb/sqlite/result.cxx +++ b/odb/sqlite/result.cxx @@ -11,7 +11,7 @@ namespace odb { result_impl_base:: result_impl_base (const query_base& q, - details::shared_ptr s) + const details::shared_ptr& s) : params_ (q.parameters ()), statement_ (s) { } diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx index cd2d376..6e915d4 100644 --- a/odb/sqlite/result.hxx +++ b/odb/sqlite/result.hxx @@ -23,7 +23,7 @@ namespace odb { public: result_impl_base (const query_base&, - details::shared_ptr); + const details::shared_ptr&); protected: // We need to hold on to the query parameters because SQLite uses diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 08132b1..3e2a17b 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -42,7 +42,7 @@ namespace odb ~object_result_impl (); object_result_impl (const query_base&, - details::shared_ptr, + const details::shared_ptr&, statements_type&); virtual void diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 34eaab5..6763850 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -24,7 +24,7 @@ namespace odb template object_result_impl:: object_result_impl (const query_base& q, - details::shared_ptr statement, + const details::shared_ptr& statement, statements_type& statements) : base_type (statements.connection ().database ()), result_impl_base (q, statement), diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 5955b33..ce194ed 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -29,6 +29,20 @@ namespace odb } void statement:: + cached (bool cached) + { + assert (cached); + + if (!cached_) + { + if (!active_) + list_remove (); + + cached_ = true; + } + } + + void statement:: init (const char* text, std::size_t text_size) { int e; @@ -46,9 +60,7 @@ namespace odb translate_error (e, conn_); stmt_.reset (stmt); - active_ = false; - cached_ = false; prev_ = 0; next_ = this; diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 3c57c74..92b9c7c 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -53,28 +53,11 @@ namespace odb return conn_; } - // Cached state (public part). - // public: - bool - cached () const - { - return cached_; - } - - void - cached (bool cached) - { - assert (cached); - - if (!cached_) - { - if (!active_) - list_remove (); + using odb::statement::cached; - cached_ = true; - } - } + virtual void + cached (bool); protected: statement (connection_type& conn, const std::string& text) @@ -154,11 +137,10 @@ namespace odb protected: friend class sqlite::connection; - connection_type& conn_; // Cached static type. + connection_type& conn_; auto_handle stmt_; bool active_; - bool cached_; private: void diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 846504f..7d552b7 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -40,7 +40,7 @@ namespace odb ~view_result_impl (); view_result_impl (const query_base&, - details::shared_ptr, + const details::shared_ptr&, statements_type&); virtual void diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 7d8ac5f..5256467 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -22,8 +22,8 @@ namespace odb template view_result_impl:: view_result_impl (const query_base& q, - details::shared_ptr statement, - statements_type& statements) + const details::shared_ptr& statement, + statements_type& statements) : base_type (statements.connection ().database ()), result_impl_base (q, statement), statements_ (statements) -- cgit v1.1 From 8112bd0febcfa1e3a76e0d03363facbefc3822f7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Oct 2012 13:17:30 +0200 Subject: Implement early connection release --- odb/sqlite/connection-factory.cxx | 4 ++ odb/sqlite/connection.cxx | 14 ++----- odb/sqlite/connection.hxx | 7 +++- odb/sqlite/container-statements.hxx | 6 --- odb/sqlite/no-id-object-result.hxx | 3 ++ odb/sqlite/no-id-object-result.txx | 24 ++++++++--- odb/sqlite/no-id-object-statements.hxx | 2 - odb/sqlite/polymorphic-object-result.hxx | 3 ++ odb/sqlite/polymorphic-object-result.txx | 28 +++++++++---- odb/sqlite/polymorphic-object-statements.hxx | 10 ----- odb/sqlite/prepared-query.hxx | 2 + odb/sqlite/simple-object-result.hxx | 3 ++ odb/sqlite/simple-object-result.txx | 23 ++++++++--- odb/sqlite/simple-object-statements.hxx | 10 ----- odb/sqlite/statement-cache.cxx | 5 --- odb/sqlite/statement.cxx | 41 +++++-------------- odb/sqlite/statement.hxx | 61 ++++++++-------------------- odb/sqlite/transaction-impl.cxx | 25 ++++++++---- odb/sqlite/view-result.hxx | 3 ++ odb/sqlite/view-result.txx | 24 ++++++++--- 20 files changed, 148 insertions(+), 150 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 62e43f2..8eb9885 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -68,6 +68,7 @@ namespace odb { c->factory_ = 0; connection_.reset (inc_ref (c)); + connection_->recycle (); mutex_.unlock (); return false; } @@ -224,7 +225,10 @@ namespace odb in_use_--; if (keep) + { connections_.push_back (pooled_connection_ptr (inc_ref (c))); + connections_.back ()->recycle (); + } if (waiters_ != 0) cond_.signal (); diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index bcf28a2..b62ac8c 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -104,7 +104,8 @@ namespace odb { // Destroy prepared query statements before freeing the connections. // - prepared_map_.clear (); + recycle (); + clear_prepared_map (); } transaction_impl* connection:: @@ -176,15 +177,8 @@ namespace odb // The current first statement will remove itself from the list // and make the second statement (if any) the new first. // - while (statement* s = statements_) - { - if (!s->cached ()) - s->finilize (); - else if (s->active ()) - s->reset (); - else - assert (false); // Statement is neither active nor unached. - } + while (statements_ != 0) + statements_->reset (); } } } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 3524a48..2754102 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -123,7 +123,7 @@ namespace odb wait (); public: - // Reset active and finalize uncached statements. + // Reset active statements. // void clear (); @@ -159,7 +159,10 @@ namespace odb friend void connection_unlock_callback (void**, int); - // Linked list of active and uncached statements currently associated + private: + friend class transaction_impl; // invalidate_results() + + // Linked list of active statements currently associated // with this connection. // private: diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 80011d9..a7b39bf 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -173,8 +173,6 @@ namespace odb insert_one_.reset ( new (details::shared) insert_statement_type ( conn_, insert_one_text_, data_image_binding_)); - - insert_one_->cached (true); } return *insert_one_; @@ -191,8 +189,6 @@ namespace odb select_all_text_, cond_image_binding_, select_image_binding_)); - - select_all_->cached (true); } return *select_all_; @@ -206,8 +202,6 @@ namespace odb delete_all_.reset ( new (details::shared) delete_statement_type ( conn_, delete_all_text_, cond_image_binding_)); - - delete_all_->cached (true); } return *delete_all_; diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 60e69e3..3b653bb 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -56,6 +56,9 @@ namespace odb virtual std::size_t size (); + virtual void + invalidate (); + using base_type::current; private: diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 3fe9fc2..9ffb836 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -20,11 +20,25 @@ namespace odb } template + void no_id_object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template no_id_object_result_impl:: no_id_object_result_impl (const query_base& q, const details::shared_ptr& s, statements_type& sts) - : base_type (sts.connection ().database ()), + : base_type (sts.connection ()), result_impl_base (q, s), statements_ (sts) { @@ -64,11 +78,9 @@ namespace odb } } - odb::database& db (this->database ()); - - object_traits::callback (db, obj, callback_event::pre_load); - object_traits::init (obj, im, &db); - object_traits::callback (db, obj, callback_event::post_load); + object_traits::callback (this->db_, obj, callback_event::pre_load); + object_traits::init (obj, im, &this->db_); + object_traits::callback (this->db_, obj, callback_event::post_load); } template diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 93aedb0..f942cf4 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -88,8 +88,6 @@ namespace odb conn_, object_traits::persist_statement, insert_image_binding_)); - - persist_->cached (true); } return *persist_; diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 9cf9c6c..0b03456 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -70,6 +70,9 @@ namespace odb virtual std::size_t size (); + virtual void + invalidate (); + using base_type::current; private: diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 0dd68cf..8e09bf1 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -22,12 +22,26 @@ namespace odb } template + void polymorphic_object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template polymorphic_object_result_impl:: polymorphic_object_result_impl ( const query_base& q, const details::shared_ptr& st, statements_type& sts) - : base_type (sts.connection ().database ()), + : base_type (sts.connection ()), result_impl_base (q, st), statements_ (sts) { @@ -48,7 +62,6 @@ namespace odb assert (!rsts.locked ()); typename statements_type::auto_lock l (rsts); - odb::database& db (this->database ()); typename object_traits::image_type& i (statements_.image ()); typename root_traits::image_type& ri (rsts.image ()); @@ -85,7 +98,8 @@ namespace odb // Insert it as a root pointer (for non-unique pointers, rp should // still be valid and for unique pointers this is a no-op). // - ig.reset (object_traits::pointer_cache_traits::insert (db, id, rp)); + ig.reset ( + object_traits::pointer_cache_traits::insert (this->db_, id, rp)); pobj = &pointer_traits::get_ref (p); current (p); @@ -106,9 +120,9 @@ namespace odb } callback_event ce (callback_event::pre_load); - pi.dispatch (info_type::call_callback, db, pobj, &ce); + pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - object_traits::init (*pobj, i, &db); + object_traits::init (*pobj, i, &this->db_); // Initialize the id image and binding and load the rest of the object // (containers, dynamic part, etc). @@ -132,14 +146,14 @@ namespace odb if (&pi != &object_traits::info) { std::size_t d (object_traits::depth); - pi.dispatch (info_type::call_load, db, pobj, &d); + pi.dispatch (info_type::call_load, this->db_, pobj, &d); }; rsts.load_delayed (); l.unlock (); ce = callback_event::post_load; - pi.dispatch (info_type::call_callback, db, pobj, &ce); + pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); ig.release (); } diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 286b9e3..50d66a3 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -107,8 +107,6 @@ namespace odb object_traits::find_discriminator_statement, discriminator_id_image_binding_, discriminator_image_binding_)); - - find_discriminator_->cached (true); } return *find_discriminator_; @@ -296,8 +294,6 @@ namespace odb conn_, object_traits::persist_statement, insert_image_binding_)); - - persist_->cached (true); } return *persist_; @@ -317,8 +313,6 @@ namespace odb object_traits::find_statements[i], root_statements_.id_image_binding (), select_image_bindings_[i])); - - p->cached (true); } return *p; @@ -334,8 +328,6 @@ namespace odb conn_, object_traits::update_statement, update_image_binding_)); - - update_->cached (true); } return *update_; @@ -351,8 +343,6 @@ namespace odb conn_, object_traits::erase_statement, root_statements_.id_image_binding ())); - - erase_->cached (true); } return *erase_; diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index ddc2c9c..2615179 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -23,6 +23,8 @@ namespace odb virtual ~prepared_query_impl (); + prepared_query_impl (odb::connection& c): odb::prepared_query_impl (c) {} + sqlite::query_base query; }; } diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 3e2a17b..02b671e 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -60,6 +60,9 @@ namespace odb virtual std::size_t size (); + virtual void + invalidate (); + using base_type::current; private: diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 6763850..1de4b91 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -22,11 +22,25 @@ namespace odb } template + void object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template object_result_impl:: object_result_impl (const query_base& q, const details::shared_ptr& statement, statements_type& statements) - : base_type (statements.connection ().database ()), + : base_type (statements.connection ()), result_impl_base (q, statement), statements_ (statements) { @@ -44,11 +58,10 @@ namespace odb assert (!statements_.locked ()); typename statements_type::auto_lock l (statements_); - odb::database& db (this->database ()); - object_traits::callback (db, obj, callback_event::pre_load); + object_traits::callback (this->db_, obj, callback_event::pre_load); typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, &db); + object_traits::init (obj, i, &this->db_); // Initialize the id image and binding and load the rest of the object // (containers, etc). @@ -67,7 +80,7 @@ namespace odb object_traits::load_ (statements_, obj); statements_.load_delayed (); l.unlock (); - object_traits::callback (db, obj, callback_event::post_load); + object_traits::callback (this->db_, obj, callback_event::post_load); } template diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 66dc0f9..9ff3faf 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -345,8 +345,6 @@ namespace odb conn_, object_traits::persist_statement, insert_image_binding_)); - - persist_->cached (true); } return *persist_; @@ -363,8 +361,6 @@ namespace odb object_traits::find_statement, id_image_binding_, select_image_binding_)); - - find_->cached (true); } return *find_; @@ -380,8 +376,6 @@ namespace odb conn_, object_traits::update_statement, update_image_binding_)); - - update_->cached (true); } return *update_; @@ -397,8 +391,6 @@ namespace odb conn_, object_traits::erase_statement, id_image_binding_)); - - erase_->cached (true); } return *erase_; @@ -414,8 +406,6 @@ namespace odb conn_, object_traits::optimistic_erase_statement, od_.id_image_binding_)); - - od_.erase_->cached (true); } return *od_.erase_; diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 6262b25..c350e02 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -20,9 +20,6 @@ namespace odb commit_ (new (shared) generic_statement (conn_, "COMMIT", 7)), rollback_ (new (shared) generic_statement (conn_, "ROLLBACK", 9)) { - rollback_->cached (true); - commit_->cached (true); - begin_->cached (true); } void statement_cache:: @@ -30,7 +27,6 @@ namespace odb { begin_immediate_.reset ( new (shared) generic_statement (conn_, "BEGIN IMMEDIATE", 16)); - begin_immediate_->cached (true); } void statement_cache:: @@ -38,7 +34,6 @@ namespace odb { begin_exclusive_.reset ( new (shared) generic_statement (conn_, "BEGIN EXCLUSIVE", 16)); - begin_exclusive_->cached (true); } } } diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index ce194ed..09cf994 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -24,22 +24,18 @@ namespace odb statement:: ~statement () { - if (stmt_ != 0) - finilize (); - } - - void statement:: - cached (bool cached) - { - assert (cached); - - if (!cached_) { - if (!active_) - list_remove (); - - cached_ = true; + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->deallocate (conn_, *this); } + + if (next_ != this) + list_remove (); + + stmt_.reset (); } void statement:: @@ -65,8 +61,6 @@ namespace odb prev_ = 0; next_ = this; - list_add (); // Add to the list because we are uncached. - { odb::tracer* t; if ((t = conn_.transaction_tracer ()) || @@ -76,21 +70,6 @@ namespace odb } } - void statement:: - finilize () - { - { - odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->deallocate (conn_, *this); - } - - list_remove (); - stmt_.reset (); - } - const char* statement:: text () const { diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 92b9c7c..aabb57d 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -53,12 +53,6 @@ namespace odb return conn_; } - public: - using odb::statement::cached; - - virtual void - cached (bool); - protected: statement (connection_type& conn, const std::string& text) : conn_ (conn) @@ -118,22 +112,12 @@ namespace odb { if (active_) { - if (stmt_ != 0) - sqlite3_reset (stmt_); - - if (cached_) - list_remove (); - + sqlite3_reset (stmt_); + list_remove (); active_ = false; } } - // Cached state (protected part). - // - protected: - void - finilize (); - protected: friend class sqlite::connection; @@ -146,38 +130,29 @@ namespace odb void init (const char* text, std::size_t text_size); - // Doubly-linked list of active/uncached statements. + // Doubly-linked list of active statements. // private: - void list_add () + void + list_add () { - if (next_ == this) - { - next_ = conn_.statements_; - conn_.statements_ = this; + next_ = conn_.statements_; + conn_.statements_ = this; - if (next_ != 0) - next_->prev_ = this; - } + if (next_ != 0) + next_->prev_ = this; } - void list_remove () + void + list_remove () { - if (next_ != this) - { - if (prev_ == 0) - conn_.statements_ = next_; - else - { - prev_->next_ = next_; - } - - if (next_ != 0) - next_->prev_ = prev_; - - prev_ = 0; - next_ = this; - } + (prev_ == 0 ? conn_.statements_ : prev_->next_) = next_; + + if (next_ != 0) + next_->prev_ = prev_; + + prev_ = 0; + next_ = this; } // prev_ == 0 means we are the first element. diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 9497c0a..1975308 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -67,10 +67,15 @@ namespace odb void transaction_impl:: commit () { - // Reset active and finilize uncached statements. Active statements - // will prevent COMMIT from completing (write statements) or releasing - // the locks (read statements). Finilization of uncached statements is - // needed to release the connection. + // Invalidate query results. + // + connection_->invalidate_results (); + + // Reset active statements. Active statements will prevent COMMIT + // from completing (write statements) or releasing the locks (read + // statements). Normally, a statement is automatically reset on + // completion, however, if an exception is thrown, that may not + // happen. // connection_->clear (); @@ -84,9 +89,15 @@ namespace odb void transaction_impl:: rollback () { - // Reset active and finilize uncached statements. Active statements - // will prevent ROLLBACK from completing. Finilization of uncached - // statements is needed to release the connection. + // Invalidate query results. + // + connection_->invalidate_results (); + + // Reset active statements. Active statements will prevent ROLLBACK + // from completing (write statements) or releasing the locks (read + // statements). Normally, a statement is automatically reset on + // completion, however, if an exception is thrown, that may not + // happen. // connection_->clear (); diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 7d552b7..a6d07e7 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -55,6 +55,9 @@ namespace odb virtual std::size_t size (); + virtual void + invalidate (); + using base_type::current; private: diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 5256467..ed7fdc8 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -20,11 +20,25 @@ namespace odb } template + void view_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template view_result_impl:: view_result_impl (const query_base& q, const details::shared_ptr& statement, statements_type& statements) - : base_type (statements.connection ().database ()), + : base_type (statements.connection ()), result_impl_base (q, statement), statements_ (statements) { @@ -64,11 +78,9 @@ namespace odb } } - odb::database& db (this->database ()); - - view_traits::callback (db, view, callback_event::pre_load); - view_traits::init (view, im, &db); - view_traits::callback (db, view, callback_event::post_load); + view_traits::callback (this->db_, view, callback_event::pre_load); + view_traits::init (view, im, &this->db_); + view_traits::callback (this->db_, view, callback_event::post_load); } template -- cgit v1.1 From 5dd712307b5ee1e85cf7101c27e9bb978af26976 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Oct 2012 13:45:44 +0200 Subject: Get rid of result_impl_base --- odb/sqlite/makefile | 1 - odb/sqlite/no-id-object-result.hxx | 11 +++++---- odb/sqlite/no-id-object-result.txx | 3 ++- odb/sqlite/polymorphic-object-result.hxx | 11 +++++---- odb/sqlite/polymorphic-object-result.txx | 5 ++-- odb/sqlite/result.cxx | 19 --------------- odb/sqlite/result.hxx | 40 -------------------------------- odb/sqlite/simple-object-result.hxx | 11 +++++---- odb/sqlite/simple-object-result.txx | 11 +++++---- odb/sqlite/view-result.hxx | 10 +++++--- odb/sqlite/view-result.txx | 11 +++++---- 11 files changed, 45 insertions(+), 88 deletions(-) delete mode 100644 odb/sqlite/result.cxx delete mode 100644 odb/sqlite/result.hxx diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 1f9e0ae..30c55c7 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -13,7 +13,6 @@ exceptions.cxx \ prepared-query.cxx \ query.cxx \ query-const-expr.cxx \ -result.cxx \ simple-object-statements.cxx \ statement.cxx \ statements-base.cxx \ diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 3b653bb..f1b7b59 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -14,8 +14,7 @@ #include #include -#include // query_base -#include +#include // query_base, query_params #include namespace odb @@ -23,8 +22,7 @@ namespace odb namespace sqlite { template - class no_id_object_result_impl: public odb::no_id_object_result_impl, - public result_impl_base + class no_id_object_result_impl: public odb::no_id_object_result_impl { public: typedef odb::no_id_object_result_impl base_type; @@ -62,6 +60,11 @@ namespace odb using base_type::current; private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; statements_type& statements_; }; } diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 9ffb836..3cd3086 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -39,7 +39,8 @@ namespace odb const details::shared_ptr& s, statements_type& sts) : base_type (sts.connection ()), - result_impl_base (q, s), + params_ (q.parameters ()), + statement_ (s), statements_ (sts) { } diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 0b03456..a56eb5b 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -14,8 +14,7 @@ #include #include -#include // query_base -#include +#include // query_base, query_params #include namespace odb @@ -24,8 +23,7 @@ namespace odb { template class polymorphic_object_result_impl: - public odb::polymorphic_object_result_impl, - public result_impl_base + public odb::polymorphic_object_result_impl { public: typedef odb::polymorphic_object_result_impl base_type; @@ -80,6 +78,11 @@ namespace odb load_image (); private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; statements_type& statements_; }; } diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 8e09bf1..486af8e 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -39,10 +39,11 @@ namespace odb polymorphic_object_result_impl:: polymorphic_object_result_impl ( const query_base& q, - const details::shared_ptr& st, + const details::shared_ptr& s, statements_type& sts) : base_type (sts.connection ()), - result_impl_base (q, st), + params_ (q.parameters ()), + statement_ (s), statements_ (sts) { } diff --git a/odb/sqlite/result.cxx b/odb/sqlite/result.cxx deleted file mode 100644 index ccd6c05..0000000 --- a/odb/sqlite/result.cxx +++ /dev/null @@ -1,19 +0,0 @@ -// file : odb/sqlite/result.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include - -namespace odb -{ - namespace sqlite - { - result_impl_base:: - result_impl_base (const query_base& q, - const details::shared_ptr& s) - : params_ (q.parameters ()), statement_ (s) - { - } - } -} diff --git a/odb/sqlite/result.hxx b/odb/sqlite/result.hxx deleted file mode 100644 index 6e915d4..0000000 --- a/odb/sqlite/result.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : odb/sqlite/result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_RESULT_HXX -#define ODB_SQLITE_RESULT_HXX - -#include - -#include - -#include -#include // query_base, query_params -#include - -#include - -namespace odb -{ - namespace sqlite - { - class LIBODB_SQLITE_EXPORT result_impl_base - { - public: - result_impl_base (const query_base&, - const details::shared_ptr&); - - protected: - // We need to hold on to the query parameters because SQLite uses - // the parameter buffers to find each next row. - // - details::shared_ptr params_; - details::shared_ptr statement_; - }; - } -} - -#include - -#endif // ODB_SQLITE_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 02b671e..5632a13 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -14,8 +14,7 @@ #include #include -#include // query_base -#include +#include // query_base, query_params #include namespace odb @@ -23,8 +22,7 @@ namespace odb namespace sqlite { template - class object_result_impl: public odb::object_result_impl, - public result_impl_base + class object_result_impl: public odb::object_result_impl { public: typedef odb::object_result_impl base_type; @@ -70,6 +68,11 @@ namespace odb load_image (); private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; statements_type& statements_; }; } diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 1de4b91..e8f2233 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -38,11 +38,12 @@ namespace odb template object_result_impl:: object_result_impl (const query_base& q, - const details::shared_ptr& statement, - statements_type& statements) - : base_type (statements.connection ()), - result_impl_base (q, statement), - statements_ (statements) + const details::shared_ptr& s, + statements_type& sts) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts) { } diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index a6d07e7..4d27367 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -14,7 +14,7 @@ #include #include -#include // query_base, view_statements +#include // query_base, query_params #include namespace odb @@ -22,8 +22,7 @@ namespace odb namespace sqlite { template - class view_result_impl: public odb::view_result_impl, - public result_impl_base + class view_result_impl: public odb::view_result_impl { public: typedef odb::view_result_impl base_type; @@ -61,6 +60,11 @@ namespace odb using base_type::current; private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; statements_type& statements_; }; } diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index ed7fdc8..b6d8cb8 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -36,11 +36,12 @@ namespace odb template view_result_impl:: view_result_impl (const query_base& q, - const details::shared_ptr& statement, - statements_type& statements) - : base_type (statements.connection ()), - result_impl_base (q, statement), - statements_ (statements) + const details::shared_ptr& s, + statements_type& sts) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts) { } -- cgit v1.1 From 8cd01a51f0a5d5c8c988f831ba3315a058e7fe8e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Oct 2012 12:10:48 +0200 Subject: Bump version to 2.2.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 0c20a5a..0ad6ef6 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20100 +#if ODB_VERSION != 20101 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2010000 -#define LIBODB_SQLITE_VERSION_STR "2.1.0" +#define LIBODB_SQLITE_VERSION 2019901 +#define LIBODB_SQLITE_VERSION_STR "2.2.0.a1" #include diff --git a/version b/version index 7ec1d6d..722318f 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.1.0 +2.2.0.a1 -- cgit v1.1 From 14d0ecab529bc46ebadd319cd4dbc1c99bb53e6b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Oct 2012 16:33:00 +0200 Subject: Don't use boolean as identifier Some headers/systems defined it as a macro. --- odb/sqlite/query.cxx | 23 ++++++++++++----------- odb/sqlite/query.hxx | 16 ++++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 2a1c203..30e54f5 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -148,7 +148,8 @@ namespace odb void query_base:: append (const string& q) { - if (!clause_.empty () && clause_.back ().kind == clause_part::native) + if (!clause_.empty () && + clause_.back ().kind == clause_part::kind_native) { string& s (clause_.back ().part); @@ -165,7 +166,7 @@ namespace odb s += q; } else - clause_.push_back (clause_part (clause_part::native, q)); + clause_.push_back (clause_part (clause_part::kind_native, q)); } void query_base:: @@ -175,13 +176,13 @@ namespace odb s += '.'; s += column; - clause_.push_back (clause_part (clause_part::column, s)); + clause_.push_back (clause_part (clause_part::kind_column, s)); } void query_base:: add (details::shared_ptr p, const char* conv) { - clause_.push_back (clause_part (clause_part::param)); + clause_.push_back (clause_part (clause_part::kind_param)); if (conv != 0) clause_.back ().part = conv; @@ -229,12 +230,12 @@ namespace odb // clause_type::iterator i (clause_.begin ()), e (clause_.end ()); - if (i != e && i->kind == clause_part::boolean && i->bool_part) + if (i != e && i->kind == clause_part::kind_bool && i->bool_part) { clause_type::iterator j (i + 1); if (j == e || - (j->kind == clause_part::native && check_prefix (j->part))) + (j->kind == clause_part::kind_native && check_prefix (j->part))) clause_.erase (i); } } @@ -246,7 +247,7 @@ namespace odb { const clause_part& p (clause_.front ()); - if (p.kind == clause_part::native && check_prefix (p.part)) + if (p.kind == clause_part::kind_native && check_prefix (p.part)) return ""; return "WHERE "; @@ -269,7 +270,7 @@ namespace odb switch (i->kind) { - case clause_part::column: + case clause_part::kind_column: { if (last != ' ' && last != '(') r += ' '; @@ -277,7 +278,7 @@ namespace odb r += i->part; break; } - case clause_part::param: + case clause_part::kind_param: { if (last != ' ' && last != '(') r += ' '; @@ -298,7 +299,7 @@ namespace odb break; } - case clause_part::native: + case clause_part::kind_native: { // We don't want extra spaces after '(' as well as before ',' // and ')'. @@ -313,7 +314,7 @@ namespace odb r += p; break; } - case clause_part::boolean: + case clause_part::kind_bool: { if (last != ' ' && last != '(') r += ' '; diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 7264bf4..2a17b4f 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -123,15 +123,15 @@ namespace odb { enum kind_type { - column, - param, - native, - boolean + kind_column, + kind_param, + kind_native, + kind_bool }; clause_part (kind_type k): kind (k) {} clause_part (kind_type k, const std::string& p): kind (k), part (p) {} - clause_part (bool p): kind (boolean), bool_part (p) {} + clause_part (bool p): kind (kind_bool), bool_part (p) {} kind_type kind; std::string part; // If kind is param, then part is conversion expr. @@ -156,14 +156,14 @@ namespace odb query_base (const char* native) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (clause_part::native, native)); + clause_.push_back (clause_part (clause_part::kind_native, native)); } explicit query_base (const std::string& native) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (clause_part::native, native)); + clause_.push_back (clause_part (clause_part::kind_native, native)); } query_base (const char* table, const char* column) @@ -229,7 +229,7 @@ namespace odb const_true () const { return clause_.size () == 1 && - clause_.front ().kind == clause_part::boolean && + clause_.front ().kind == clause_part::kind_bool && clause_.front ().bool_part; } -- cgit v1.1 From a2914e837c6442db936fd035b49f60ee488df533 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Nov 2012 13:11:43 +0200 Subject: Add dynamic multi-database query support --- odb/sqlite/makefile | 1 + odb/sqlite/query-dynamic.cxx | 136 +++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/query-dynamic.hxx | 33 +++++++++++ odb/sqlite/query-dynamic.ixx | 27 +++++++++ odb/sqlite/query-dynamic.txx | 21 +++++++ odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 95 +++++++++++++++++++++--------- odb/sqlite/query.ixx | 4 +- odb/sqlite/traits.hxx | 12 ++-- 9 files changed, 297 insertions(+), 34 deletions(-) create mode 100644 odb/sqlite/query-dynamic.cxx create mode 100644 odb/sqlite/query-dynamic.hxx create mode 100644 odb/sqlite/query-dynamic.ixx create mode 100644 odb/sqlite/query-dynamic.txx diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 30c55c7..b215461 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -12,6 +12,7 @@ error.cxx \ exceptions.cxx \ prepared-query.cxx \ query.cxx \ +query-dynamic.cxx \ query-const-expr.cxx \ simple-object-statements.cxx \ statement.cxx \ diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx new file mode 100644 index 0000000..5f86b93 --- /dev/null +++ b/odb/sqlite/query-dynamic.cxx @@ -0,0 +1,136 @@ +// file : odb/sqlite/query-dynamic.cxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + static const char* logic_operators[] = {") AND (", ") OR ("}; + static const char* comp_operators[] = {"=", "!=", "<", ">", "<=", ">="}; + + static void + translate (query_base& q, const odb::query_base& s, size_t p) + { + typedef odb::query_base::clause_part part; + + const part& x (s.clause ()[p]); + + switch (x.kind) + { + case part::kind_column: + { + const query_column_base* c ( + static_cast ( + x.native_info[id_sqlite].column)); + + q.append (c->table (), c->column ()); + break; + } + case part::kind_param_val: + case part::kind_param_ref: + { + const query_column_base* c ( + static_cast ( + x.native_info[id_sqlite].column)); + + query_param_factory f ( + reinterpret_cast ( + x.native_info[id_sqlite].param_factory)); + + const odb::query_param* p ( + reinterpret_cast (x.data)); + + q.append (f (p->value, x.kind == part::kind_param_ref), + c->conversion ()); + break; + } + case part::kind_native: + { + q.append (s.strings ()[x.data]); + break; + } + case part::kind_true: + case part::kind_false: + { + q.append (x.kind == part::kind_true); + break; + } + case part::op_add: + { + translate (q, s, x.data); + translate (q, s, p - 1); + break; + } + case part::op_and: + case part::op_or: + { + q += "("; + translate (q, s, x.data); + q += logic_operators[x.kind - part::op_and]; + translate (q, s, p - 1); + q += ")"; + break; + } + case part::op_not: + { + q += "NOT ("; + translate (q, s, p - 1); + q += ")"; + break; + } + case part::op_null: + case part::op_not_null: + { + translate (q, s, p - 1); + q += (x.kind == part::op_null ? "IS NULL" : "IS NOT NULL"); + break; + } + case part::op_in: + { + size_t b (p - x.data); + + translate (q, s, b - 1); // column + q += "IN ("; + + for (size_t i (b); i != p; ++i) + { + if (i != b) + q += ","; + + translate (q, s, i); + } + + q += ")"; + break; + } + case part::op_eq: + case part::op_ne: + case part::op_lt: + case part::op_gt: + case part::op_le: + case part::op_ge: + { + translate (q, s, x.data); + q += comp_operators[x.kind - part::op_eq]; + translate (q, s, p - 1); + break; + } + } + } + + query_base:: + query_base (const odb::query_base& q) + : parameters_ (new (details::shared) query_params) + { + if (!q.empty ()) + translate (*this, q, q.clause ().size () - 1); + } + } +} diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx new file mode 100644 index 0000000..aaad7f8 --- /dev/null +++ b/odb/sqlite/query-dynamic.hxx @@ -0,0 +1,33 @@ +// file : odb/sqlite/query-dynamic.hxx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX +#define ODB_SQLITE_QUERY_DYNAMIC_HXX + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + typedef details::shared_ptr (*query_param_factory) ( + const void* val, bool by_ref); + + template + details::shared_ptr + query_param_factory_impl (const void*, bool); + } +} + +#include +#include + +#include + +#endif // ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx new file mode 100644 index 0000000..77f0f43 --- /dev/null +++ b/odb/sqlite/query-dynamic.ixx @@ -0,0 +1,27 @@ +// file : odb/sqlite/query-dynamic.ixx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // + template + inline query_column:: + query_column (odb::query_column& qc, + const char* table, const char* column, const char* conv) + : query_column_base (table, column, conv) + { + native_column_info& ci (qc.native_info[id_sqlite]); + ci.column = static_cast (this); + + // For some reason GCC needs this statically-typed pointer in + // order to instantiate the functions. + // + query_param_factory f (&query_param_factory_impl); + ci.param_factory = reinterpret_cast (f); + } + } +} diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx new file mode 100644 index 0000000..c7d88cb --- /dev/null +++ b/odb/sqlite/query-dynamic.txx @@ -0,0 +1,21 @@ +// file : odb/sqlite/query-dynamic.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + template + details::shared_ptr + query_param_factory_impl (const void* val, bool by_ref) + { + const T& v (*static_cast (val)); + + return details::shared_ptr ( + by_ref + ? new (details::shared) query_param_impl (ref_bind (v)) + : new (details::shared) query_param_impl (val_bind (v))); + } + } +} diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 30e54f5..bce005f 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -180,7 +180,7 @@ namespace odb } void query_base:: - add (details::shared_ptr p, const char* conv) + append (details::shared_ptr p, const char* conv) { clause_.push_back (clause_part (clause_part::kind_param)); diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 2a17b4f..18c10bb 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -11,6 +11,7 @@ #include #include // std::size_t +#include // odb::query_column #include #include #include @@ -149,7 +150,7 @@ namespace odb query_base (bool v) : parameters_ (new (details::shared) query_params) { - clause_.push_back (clause_part (v)); + append (v); } explicit @@ -193,6 +194,13 @@ namespace odb template query_base (const query_column&); + // Translate common query representation to SQLite native. Defined + // in query-dynamic.cxx + // + query_base (const odb::query_base&); + + // Copy c-tor and assignment. + // query_base (const query_base&); query_base& @@ -280,6 +288,8 @@ namespace odb return *this; } + // Implementation details. + // public: template void @@ -290,14 +300,25 @@ namespace odb append (ref_bind, const char* conv); void + append (details::shared_ptr, const char* conv); + + void + append (bool v) + { + clause_.push_back (clause_part (v)); + } + + void append (const std::string& native); void - append (const char* table, const char* column); + append (const char* native) // Clashes with append(bool). + { + append (std::string (native)); + } - private: void - add (details::shared_ptr, const char* conv); + append (const char* table, const char* column); private: typedef std::vector clause_type; @@ -417,28 +438,14 @@ namespace odb // query_column // - - template - class copy_bind: public val_bind - { - public: - explicit - copy_bind (const T2& v): val_bind (val), val (v) {} - - const T val; - }; - - template - const T& - type_instance (); - - template - struct query_column + struct LIBODB_SQLITE_EXPORT query_column_base { // Note that we keep shallow copies of the table, column, and conversion // expression. The latter can be NULL. // - query_column (const char* table, const char* column, const char* conv) + query_column_base (const char* table, + const char* column, + const char* conv) : table_ (table), column_ (column), conversion_ (conv) { } @@ -463,6 +470,40 @@ namespace odb return conversion_; } + protected: + const char* table_; + const char* column_; + const char* conversion_; + }; + + template + class copy_bind: public val_bind + { + public: + explicit + copy_bind (const T2& v): val_bind (val), val (v) {} + + const T val; + }; + + template + const T& + type_instance (); + + template + struct query_column: query_column_base + { + // Note that we keep shallow copies of the table, column, and conversion + // expression. The latter can be NULL. + // + query_column (const char* table, const char* column, const char* conv) + : query_column_base (table, column, conv) {} + + // Implementation is in query-dynamic.ixx. + // + query_column (odb::query_column&, + const char* table, const char* column, const char* conv); + // is_null, is_not_null // public: @@ -1097,11 +1138,6 @@ namespace odb q.append (c.table (), c.column ()); return q; } - - private: - const char* table_; - const char* column_; - const char* conversion_; }; // Provide operator+() for using columns to construct native @@ -1353,6 +1389,11 @@ namespace odb : query_base (qc) { } + + query (const odb::query_base& q) + : query_base (q) + { + } }; } diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index c3a5f14..7413691 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -28,7 +28,7 @@ namespace odb inline void query_base:: append (val_bind v, const char* conv) { - add ( + append ( details::shared_ptr ( new (details::shared) query_param_impl (v)), conv); @@ -38,7 +38,7 @@ namespace odb inline void query_base:: append (ref_bind r, const char* conv) { - add ( + append ( details::shared_ptr ( new (details::shared) query_param_impl (r)), conv); diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 20cd3f3..e6abf2d 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -293,7 +293,6 @@ namespace odb struct LIBODB_SQLITE_EXPORT c_string_value_traits { typedef const char* value_type; - typedef const char* query_type; typedef details::buffer image_type; static void @@ -307,16 +306,19 @@ namespace odb struct LIBODB_SQLITE_EXPORT default_value_traits: c_string_value_traits { + typedef const char* query_type; }; template struct default_value_traits: c_string_value_traits { + typedef char query_type[N]; }; template struct default_value_traits: c_string_value_traits { + typedef const char query_type[N]; }; #ifdef _WIN32 @@ -366,7 +368,6 @@ namespace odb struct LIBODB_SQLITE_EXPORT c_wstring_value_traits { typedef const wchar_t* value_type; - typedef const wchar_t* query_type; typedef details::buffer image_type; static void @@ -383,6 +384,7 @@ namespace odb struct LIBODB_SQLITE_EXPORT default_value_traits: c_wstring_value_traits { + typedef const wchar_t* query_type; }; template @@ -392,6 +394,7 @@ namespace odb struct default_value_traits: c_wstring_value_traits { + typedef wchar_t query_type[N]; }; template @@ -401,6 +404,7 @@ namespace odb struct default_value_traits: c_wstring_value_traits { + typedef const wchar_t query_type[N]; }; #endif // _WIN32 @@ -475,7 +479,7 @@ namespace odb { public: typedef char* value_type; - typedef const char* query_type; + typedef char query_type[N]; typedef details::buffer image_type; static void @@ -513,7 +517,7 @@ namespace odb { public: typedef unsigned char* value_type; - typedef const unsigned char* query_type; + typedef unsigned char query_type[N]; typedef details::buffer image_type; static void -- cgit v1.1 From bfc6d29f8ef4efc48334cf0c25af433d85c21ed6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Nov 2012 11:32:44 +0200 Subject: Namespace management for static multi-database support Now in libodb the odb::core namespace is split into odb::common (database- independent stuff) and odb::core proper, which imports odb::common. Each database runtime now defines odb::::core namespace which also imports odb::common and adds the database-specific bits. The overall idea is that one can do using namespace odb::::core just like for odb::core. --- odb/sqlite/connection.hxx | 1 - odb/sqlite/exceptions.hxx | 7 +++++++ odb/sqlite/forward.hxx | 16 ++++++++++++++++ odb/sqlite/query.hxx | 5 +++++ odb/sqlite/statement.hxx | 2 +- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 2754102..6dd8292 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -9,7 +9,6 @@ #include -#include #include #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 52a976f..a38237c 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -12,6 +12,7 @@ #include #include +#include #include namespace odb @@ -65,6 +66,12 @@ namespace odb private: std::string what_; }; + + namespace core + { + using sqlite::database_exception; + using sqlite::cli_exception; + } } } diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index e2f4df1..382284e 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -13,6 +13,13 @@ namespace odb { namespace sqlite { + namespace core + { + using namespace odb::common; + } + + // + // class database; class connection; typedef details::shared_ptr connection_ptr; @@ -21,6 +28,15 @@ namespace odb class transaction; class tracer; + namespace core + { + using sqlite::database; + using sqlite::connection; + using sqlite::connection_ptr; + using sqlite::transaction; + using sqlite::statement; + } + // Implementation details. // enum statement_kind diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 18c10bb..0f7657c 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1395,6 +1395,11 @@ namespace odb { } }; + + namespace core + { + using sqlite::query; + } } // Derive odb::query from odb::sqlite::query so that it can be diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index aabb57d..fe3a2a0 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -14,10 +14,10 @@ #include // std::strlen, std::memcpy #include -#include #include #include +#include #include #include #include -- cgit v1.1 From cb2add469737f428bc5df00b13b0bed82c30c187 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Dec 2012 13:12:13 +0200 Subject: Add support for executing common query using static interface --- odb/sqlite/connection.hxx | 6 +++++- odb/sqlite/connection.ixx | 11 +++++++++- odb/sqlite/database.hxx | 18 ++++++++++++++--- odb/sqlite/database.ixx | 51 ++++++++++++++++++++++++++++++++++++----------- 4 files changed, 69 insertions(+), 17 deletions(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 6dd8292..43c540c 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -81,7 +81,11 @@ namespace odb template prepared_query - prepare_query (const char* name, const query&); + prepare_query (const char* name, const sqlite::query_base&); + + template + prepared_query + prepare_query (const char* name, const odb::query_base&); // SQL statement tracing. // diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 9117bd4..f1f4183 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -22,9 +22,18 @@ namespace odb template inline prepared_query connection:: - prepare_query (const char* n, const query& q) + prepare_query (const char* n, const sqlite::query_base& q) { return query_::call (*this, n, q); } + + template + inline prepared_query connection:: + prepare_query (const char* n, const odb::query_base& q) + { + // Translate to native query. + // + return prepare_query (n, sqlite::query_base (q)); + } } } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 318cb57..e7650f7 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -268,7 +268,11 @@ namespace odb template unsigned long long - erase_query (const sqlite::query&); + erase_query (const sqlite::query_base&); + + template + unsigned long long + erase_query (const odb::query_base&); // Query API. // @@ -286,7 +290,11 @@ namespace odb template result - query (const sqlite::query&); + query (const sqlite::query_base&); + + template + result + query (const odb::query_base&); // Query preparation. // @@ -300,7 +308,11 @@ namespace odb template prepared_query - prepare_query (const char* name, const sqlite::query&); + prepare_query (const char* name, const sqlite::query_base&); + + template + prepared_query + prepare_query (const char* name, const odb::query_base&); // Transactions. // diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 2b57912..e20bbec 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -335,7 +335,7 @@ namespace odb { // T is always object_type. // - return erase_query (sqlite::query ()); + return erase_query (sqlite::query_base ()); } template @@ -344,7 +344,7 @@ namespace odb { // T is always object_type. // - return erase_query (sqlite::query (q)); + return erase_query (sqlite::query_base (q)); } template @@ -353,12 +353,12 @@ namespace odb { // T is always object_type. // - return erase_query (sqlite::query (q)); + return erase_query (sqlite::query_base (q)); } template inline unsigned long long database:: - erase_query (const sqlite::query& q) + erase_query (const sqlite::query_base& q) { // T is always object_type. // @@ -366,29 +366,38 @@ namespace odb } template + inline unsigned long long database:: + erase_query (const odb::query_base& q) + { + // Translate to native query. + // + return erase_query (sqlite::query_base (q)); + } + + template inline result database:: query () { - return query (sqlite::query ()); + return query (sqlite::query_base ()); } template inline result database:: query (const char* q) { - return query (sqlite::query (q)); + return query (sqlite::query_base (q)); } template inline result database:: query (const std::string& q) { - return query (sqlite::query (q)); + return query (sqlite::query_base (q)); } template inline result database:: - query (const sqlite::query& q) + query (const sqlite::query_base& q) { // T is always object_type. We also don't need to check for transaction // here; object_traits::query () does this. @@ -397,27 +406,45 @@ namespace odb } template + inline result database:: + query (const odb::query_base& q) + { + // Translate to native query. + // + return query (sqlite::query_base (q)); + } + + template inline prepared_query database:: prepare_query (const char* n, const char* q) { - return prepare_query (n, sqlite::query (q)); + return prepare_query (n, sqlite::query_base (q)); } template inline prepared_query database:: prepare_query (const char* n, const std::string& q) { - return prepare_query (n, sqlite::query (q)); + return prepare_query (n, sqlite::query_base (q)); } template inline prepared_query database:: - prepare_query (const char* n, const sqlite::query& q) + prepare_query (const char* n, const sqlite::query_base& q) { // Throws if not in transaction. // sqlite::connection& c (transaction::current ().connection ()); - return c.prepare_query (n, q); + return c.prepare_query (n, q); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const odb::query_base& q) + { + // Translate to native query. + // + return prepare_query (n, sqlite::query_base (q)); } } } -- cgit v1.1 From 805912c9c66a89bfbf5598f805eb5f664e32ae6e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Dec 2012 13:33:04 +0200 Subject: Bump version to 2.2.0.a2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 0ad6ef6..b8479cd 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20101 +#if ODB_VERSION != 20102 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2019901 -#define LIBODB_SQLITE_VERSION_STR "2.2.0.a1" +#define LIBODB_SQLITE_VERSION 2019902 +#define LIBODB_SQLITE_VERSION_STR "2.2.0.a2" #include diff --git a/version b/version index 722318f..7e35268 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.0.a1 +2.2.0.a2 -- cgit v1.1 From 54eac28ae913c6c18e6beb0f39c3c13091f62fb5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Jan 2013 14:57:06 +0200 Subject: Check that max connections is greater or equal than min in connection pool --- odb/sqlite/connection-factory.hxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 4f59791..e2274c2 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -9,6 +9,7 @@ #include #include // std::size_t +#include #include #include @@ -158,7 +159,9 @@ namespace odb db_ (0), cond_ (mutex_) { - // @@ check min_ <= max_ + // max_connections == 0 means unlimited. + // + assert (max_connections == 0 || max_connections >= min_connections); } virtual connection_ptr -- cgit v1.1 From 96571f2f1174ab0baafc335afbf5d699ee7bf4cd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Jan 2013 15:27:16 +0200 Subject: Bump version to 2.2.0.a3 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b8479cd..f8b71f7 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20102 +#if ODB_VERSION != 20103 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2019902 -#define LIBODB_SQLITE_VERSION_STR "2.2.0.a2" +#define LIBODB_SQLITE_VERSION 2019903 +#define LIBODB_SQLITE_VERSION_STR "2.2.0.a3" #include diff --git a/version b/version index 7e35268..90d185b 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.0.a2 +2.2.0.a3 -- cgit v1.1 From 3f8c83103af11906adbd9c399f1c9efb2eb9b0ed Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Jan 2013 14:50:26 +0200 Subject: Implement two-phase session insertion On the first step an uninitialized object is inserted into the cache as before (this is necessary to handle recursive loading). The second step is to notify the session that the object has been initialized. On this second step the session can perform change tracking preparations, such as make a copy of the object or reset the modification flag. New test: common/session/custom (implements a custom session that uses copies to track changes). --- odb/sqlite/polymorphic-object-result.txx | 1 + odb/sqlite/simple-object-statements.txx | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 486af8e..7591194 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -155,6 +155,7 @@ namespace odb ce = callback_event::post_load; pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); + object_traits::pointer_cache_traits::initialize (ig.position ()); ig.release (); } diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 8c61d5d..f3e617a 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -82,7 +82,7 @@ namespace odb while (!dls.empty ()) { delayed_load l (dls.back ()); - typename pointer_cache_traits::insert_guard g (l.pos); + typename pointer_cache_traits::insert_guard ig (l.pos); dls.pop_back (); if (l.loader == 0) @@ -118,7 +118,8 @@ namespace odb else l.loader (db, l.id, *l.obj); - g.release (); + pointer_cache_traits::initialize (ig.position ()); + ig.release (); } } @@ -126,11 +127,7 @@ namespace odb void object_statements:: clear_delayed_ () { - // Remove the objects from the session cache. This is not the most - // efficient way to do this (cache_traits::erase() will check for - // a session on every iteration), but the delay vector won't be - // empty only if something goes wrong (i.e., we are throwing an - // exception). + // Remove the objects from the session cache. // for (typename delayed_loads::iterator i (delayed_.begin ()), e (delayed_.end ()); i != e; ++i) -- cgit v1.1 From 137663953feb2362c973d7528cf103cadd50d845 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Jan 2013 16:31:29 +0200 Subject: Make session cache management functions static, add notifications --- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 7591194..a91aab0 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -155,7 +155,7 @@ namespace odb ce = callback_event::post_load; pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - object_traits::pointer_cache_traits::initialize (ig.position ()); + object_traits::pointer_cache_traits::load (ig.position ()); ig.release (); } diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index f3e617a..51c4948 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -118,7 +118,7 @@ namespace odb else l.loader (db, l.id, *l.obj); - pointer_cache_traits::initialize (ig.position ()); + pointer_cache_traits::load (ig.position ()); ig.release (); } } -- cgit v1.1 From ca50e5847f273e7834d94a8f3a6f847ae2a440f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Jan 2013 10:55:13 +0200 Subject: Add database id constant (useful for meta-programming) --- odb/sqlite/database.hxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index e7650f7..a626b73 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -350,6 +350,11 @@ namespace odb using odb::database::tracer; public: + // Database id constant (useful for meta-programming). + // + static const odb::database_id database_id = id_sqlite; + + public: virtual ~database (); -- cgit v1.1 From a849d159fd03d3c954df3fc60826680f5d1afd65 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Jan 2013 15:10:21 +0200 Subject: Add support for mapping char[N] to CHAR/VARCHAR database types Also improve query support for arrays (decaying). --- odb/sqlite/query.hxx | 324 +++++++++++++++++++++++++++++++++++++------------- odb/sqlite/query.txx | 10 +- odb/sqlite/traits.cxx | 101 ++++++++++++++-- odb/sqlite/traits.hxx | 255 ++++++++++++++++++++++++++++++++++----- 4 files changed, 569 insertions(+), 121 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 0f7657c..5ee377f 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -30,23 +30,72 @@ namespace odb namespace sqlite { template - class val_bind + struct val_bind { - public: + typedef const T& type; + + explicit + val_bind (type v): val (v) {} + + type val; + }; + + template + struct val_bind + { + typedef const T* type; + explicit - val_bind (const T& v): val (v) {} + val_bind (type v): val (v) {} - const T& val; + type val; }; template - class ref_bind + struct ref_bind + { + typedef const T& type; + + explicit + ref_bind (type r): ref (r) {} + + const void* + ptr () const {return &ref;} + + type ref; + }; + + template + struct ref_bind + { + typedef const T* type; + + explicit + ref_bind (type r): ref (r) {} + + // Allow implicit conversion from decayed ref_bind's. + // + ref_bind (ref_bind r): ref (r.ref) {} + ref_bind (ref_bind r): ref (r.ref) {} + + const void* + ptr () const {return ref;} + + type ref; + }; + + template + struct val_bind_typed: val_bind { - public: explicit - ref_bind (const T& r): ref (r) {} + val_bind_typed (typename val_bind::type v): val_bind (v) {} + }; - const T& ref; + template + struct ref_bind_typed: ref_bind + { + explicit + ref_bind_typed (typename ref_bind::type r): ref_bind (r) {} }; struct LIBODB_SQLITE_EXPORT query_param: details::shared_base @@ -178,8 +227,15 @@ namespace odb query_base (val_bind v) : parameters_ (new (details::shared) query_params) { - append::db_type_id> ( - v, details::conversion::to ()); + *this += v; + } + + template + explicit + query_base (val_bind_typed v) + : parameters_ (new (details::shared) query_params) + { + *this += v; } template @@ -187,8 +243,15 @@ namespace odb query_base (ref_bind r) : parameters_ (new (details::shared) query_params) { - append::db_type_id> ( - r, details::conversion::to ()); + *this += r; + } + + template + explicit + query_base (ref_bind_typed r) + : parameters_ (new (details::shared) query_params) + { + *this += r; } template @@ -252,6 +315,13 @@ namespace odb return val_bind (x); } + template + static val_bind_typed + _val (const T& x) + { + return val_bind_typed (x); + } + template static ref_bind _ref (const T& x) @@ -259,6 +329,13 @@ namespace odb return ref_bind (x); } + template + static ref_bind_typed + _ref (const T& x) + { + return ref_bind_typed (x); + } + public: query_base& operator+= (const query_base&); @@ -279,6 +356,17 @@ namespace odb return *this; } + template + query_base& + operator+= (val_bind_typed v) + { + // We are not using default type_traits so no default conversion + // either. + // + append (v, 0); + return *this; + } + template query_base& operator+= (ref_bind r) @@ -288,6 +376,17 @@ namespace odb return *this; } + template + query_base& + operator+= (ref_bind_typed r) + { + // We are not using default type_traits so no default conversion + // either. + // + append (r, 0); + return *this; + } + // Implementation details. // public: @@ -346,16 +445,26 @@ namespace odb template inline query_base - operator+ (const query_base& q, ref_bind b) + operator+ (val_bind b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + + template + inline query_base + operator+ (const query_base& q, val_bind_typed b) { query_base r (q); r += b; return r; } - template + template inline query_base - operator+ (val_bind b, const query_base& q) + operator+ (val_bind_typed b, const query_base& q) { query_base r; r += b; @@ -365,6 +474,15 @@ namespace odb template inline query_base + operator+ (const query_base& q, ref_bind b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base operator+ (ref_bind b, const query_base& q) { query_base r; @@ -373,6 +491,25 @@ namespace odb return r; } + template + inline query_base + operator+ (const query_base& q, ref_bind_typed b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind_typed b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + inline query_base operator+ (const query_base& q, const std::string& s) { @@ -400,16 +537,26 @@ namespace odb template inline query_base - operator+ (const std::string& s, ref_bind b) + operator+ (val_bind b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + + template + inline query_base + operator+ (const std::string& s, val_bind_typed b) { query_base r (s); r += b; return r; } - template + template inline query_base - operator+ (val_bind b, const std::string& s) + operator+ (val_bind_typed b, const std::string& s) { query_base r; r += b; @@ -419,6 +566,15 @@ namespace odb template inline query_base + operator+ (const std::string& s, ref_bind b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base operator+ (ref_bind b, const std::string& s) { query_base r; @@ -427,6 +583,25 @@ namespace odb return r; } + template + inline query_base + operator+ (const std::string& s, ref_bind_typed b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind_typed b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + LIBODB_SQLITE_EXPORT query_base operator&& (const query_base&, const query_base&); @@ -476,23 +651,11 @@ namespace odb const char* conversion_; }; - template - class copy_bind: public val_bind - { - public: - explicit - copy_bind (const T2& v): val_bind (val), val (v) {} - - const T val; - }; - - template - const T& - type_instance (); - template struct query_column: query_column_base { + typedef typename decay_traits::type decayed_type; + // Note that we keep shallow copies of the table, column, and conversion // expression. The latter can be NULL. // @@ -527,16 +690,17 @@ namespace odb // public: query_base - in (const T&, const T&) const; + in (decayed_type, decayed_type) const; query_base - in (const T&, const T&, const T&) const; + in (decayed_type, decayed_type, decayed_type) const; query_base - in (const T&, const T&, const T&, const T&) const; + in (decayed_type, decayed_type, decayed_type, decayed_type) const; query_base - in (const T&, const T&, const T&, const T&, const T&) const; + in (decayed_type, decayed_type, decayed_type, decayed_type, + decayed_type) const; template query_base @@ -546,7 +710,7 @@ namespace odb // public: query_base - equal (const T& v) const + equal (decayed_type v) const { return equal (val_bind (v)); } @@ -564,8 +728,7 @@ namespace odb query_base equal (val_bind v) const { - copy_bind c (v.val); - return equal (c); + return equal (val_bind (decayed_type (v.val))); } query_base @@ -578,13 +741,13 @@ namespace odb } friend query_base - operator== (const query_column& c, const T& v) + operator== (const query_column& c, decayed_type v) { return c.equal (v); } friend query_base - operator== (const T& v, const query_column& c) + operator== (decayed_type v, const query_column& c) { return c.equal (v); } @@ -631,7 +794,7 @@ namespace odb // public: query_base - unequal (const T& v) const + unequal (decayed_type v) const { return unequal (val_bind (v)); } @@ -649,8 +812,7 @@ namespace odb query_base unequal (val_bind v) const { - copy_bind c (v.val); - return unequal (c); + return unequal (val_bind (decayed_type (v.val))); } query_base @@ -663,13 +825,13 @@ namespace odb } friend query_base - operator!= (const query_column& c, const T& v) + operator!= (const query_column& c, decayed_type v) { return c.unequal (v); } friend query_base - operator!= (const T& v, const query_column& c) + operator!= (decayed_type v, const query_column& c) { return c.unequal (v); } @@ -716,7 +878,7 @@ namespace odb // public: query_base - less (const T& v) const + less (decayed_type v) const { return less (val_bind (v)); } @@ -734,8 +896,7 @@ namespace odb query_base less (val_bind v) const { - copy_bind c (v.val); - return less (c); + return less (val_bind (decayed_type (v.val))); } query_base @@ -748,13 +909,13 @@ namespace odb } friend query_base - operator< (const query_column& c, const T& v) + operator< (const query_column& c, decayed_type v) { return c.less (v); } friend query_base - operator< (const T& v, const query_column& c) + operator< (decayed_type v, const query_column& c) { return c.greater (v); } @@ -801,7 +962,7 @@ namespace odb // public: query_base - greater (const T& v) const + greater (decayed_type v) const { return greater (val_bind (v)); } @@ -819,8 +980,7 @@ namespace odb query_base greater (val_bind v) const { - copy_bind c (v.val); - return greater (c); + return greater (val_bind (decayed_type (v.val))); } query_base @@ -833,13 +993,13 @@ namespace odb } friend query_base - operator> (const query_column& c, const T& v) + operator> (const query_column& c, decayed_type v) { return c.greater (v); } friend query_base - operator> (const T& v, const query_column& c) + operator> (decayed_type v, const query_column& c) { return c.less (v); } @@ -886,7 +1046,7 @@ namespace odb // public: query_base - less_equal (const T& v) const + less_equal (decayed_type v) const { return less_equal (val_bind (v)); } @@ -904,8 +1064,7 @@ namespace odb query_base less_equal (val_bind v) const { - copy_bind c (v.val); - return less_equal (c); + return less_equal (val_bind (decayed_type (v.val))); } query_base @@ -918,13 +1077,13 @@ namespace odb } friend query_base - operator<= (const query_column& c, const T& v) + operator<= (const query_column& c, decayed_type v) { return c.less_equal (v); } friend query_base - operator<= (const T& v, const query_column& c) + operator<= (decayed_type v, const query_column& c) { return c.greater_equal (v); } @@ -971,7 +1130,7 @@ namespace odb // public: query_base - greater_equal (const T& v) const + greater_equal (decayed_type v) const { return greater_equal (val_bind (v)); } @@ -989,8 +1148,7 @@ namespace odb query_base greater_equal (val_bind v) const { - copy_bind c (v.val); - return greater_equal (c); + return greater_equal (val_bind (decayed_type (v.val))); } query_base @@ -1003,13 +1161,13 @@ namespace odb } friend query_base - operator>= (const query_column& c, const T& v) + operator>= (const query_column& c, decayed_type v) { return c.greater_equal (v); } friend query_base - operator>= (const T& v, const query_column& c) + operator>= (decayed_type v, const query_column& c) { return c.less_equal (v); } @@ -1061,7 +1219,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () == type_instance ())); + (void) (sizeof (decay_traits::instance () == + decay_traits::instance ())); query_base q (table_, column_); q += "="; @@ -1075,7 +1234,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () != type_instance ())); + (void) (sizeof (decay_traits::instance () != + decay_traits::instance ())); query_base q (table_, column_); q += "!="; @@ -1089,7 +1249,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () < type_instance ())); + (void) (sizeof (decay_traits::instance () < + decay_traits::instance ())); query_base q (table_, column_); q += "<"; @@ -1103,7 +1264,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () > type_instance ())); + (void) (sizeof (decay_traits::instance () > + decay_traits::instance ())); query_base q (table_, column_); q += ">"; @@ -1117,7 +1279,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () <= type_instance ())); + (void) (sizeof (decay_traits::instance () <= + decay_traits::instance ())); query_base q (table_, column_); q += "<="; @@ -1131,7 +1294,8 @@ namespace odb { // We can compare columns only if we can compare their C++ types. // - (void) (sizeof (type_instance () >= type_instance ())); + (void) (sizeof (decay_traits::instance () >= + decay_traits::instance ())); query_base q (table_, column_); q += ">="; @@ -1189,7 +1353,7 @@ namespace odb template struct query_param_impl: query_param { - query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} query_param_impl (val_bind v) : query_param (0) {init (v.val);} virtual bool @@ -1208,7 +1372,7 @@ namespace odb private: void - init (const T& v) + init (typename decay_traits::type v) { bool is_null (false); // Can't be NULL. value_traits::set_image (image_, is_null, v); @@ -1223,7 +1387,7 @@ namespace odb template struct query_param_impl: query_param { - query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} query_param_impl (val_bind v) : query_param (0) {init (v.val);} virtual bool @@ -1242,7 +1406,7 @@ namespace odb private: void - init (const T& v) + init (typename decay_traits::type v) { bool is_null (false); // Can't be NULL. value_traits::set_image (image_, is_null, v); @@ -1257,7 +1421,7 @@ namespace odb template struct query_param_impl: query_param { - query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} query_param_impl (val_bind v) : query_param (0) {init (v.val);} virtual bool @@ -1276,7 +1440,7 @@ namespace odb private: bool - init (const T& v) + init (typename decay_traits::type v) { bool is_null (false); // Can't be NULL. std::size_t cap (buffer_.capacity ()); @@ -1294,7 +1458,7 @@ namespace odb template struct query_param_impl: query_param { - query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} query_param_impl (val_bind v) : query_param (0) {init (v.val);} virtual bool @@ -1313,7 +1477,7 @@ namespace odb private: bool - init (const T& v) + init (typename decay_traits::type v) { bool is_null (false); // Can't be NULL. std::size_t cap (buffer_.capacity ()); diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index f719ece..7342187 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -26,7 +26,7 @@ namespace odb // template query_base query_column:: - in (const T& v1, const T& v2) const + in (decayed_type v1, decayed_type v2) const { query_base q (table_, column_); q += "IN ("; @@ -39,7 +39,7 @@ namespace odb template query_base query_column:: - in (const T& v1, const T& v2, const T& v3) const + in (decayed_type v1, decayed_type v2, decayed_type v3) const { query_base q (table_, column_); q += "IN ("; @@ -54,7 +54,8 @@ namespace odb template query_base query_column:: - in (const T& v1, const T& v2, const T& v3, const T& v4) const + in (decayed_type v1, decayed_type v2, decayed_type v3, + decayed_type v4) const { query_base q (table_, column_); q += "IN ("; @@ -71,7 +72,8 @@ namespace odb template query_base query_column:: - in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const + in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4, + decayed_type v5) const { query_base q (table_, column_); q += "IN ("; diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 3f9c5cb..753c181 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -15,7 +15,6 @@ namespace odb // // default_value_traits // - void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, const string& v) { @@ -32,7 +31,6 @@ namespace odb // // c_string_value_traits // - void c_string_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, const char* v) { @@ -46,11 +44,55 @@ namespace odb memcpy (b.data (), v, n); } -#ifdef _WIN32 // - // default_value_traits + // c_array_value_traits_base // + void c_array_value_traits_base:: + set_value (char* const& v, + const details::buffer& b, + size_t n, + bool is_null, + size_t N) + { + if (!is_null) + { + n = n < N ? n : N; + + if (n != 0) + memcpy (v, b.data (), n); + } + else + n = 0; + + if (n != N) // Append '\0' if there is space. + v[n] = '\0'; + } + void c_array_value_traits_base:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const char* v, + size_t N) + { + is_null = false; + + // Figure out the length. We cannot use strlen since it may + // not be 0-terminated (strnlen is not standard). + // + for (n = 0; n != N && v[n] != '\0'; ++n); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } + + // + // default_value_traits + // +#ifdef _WIN32 void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, const wstring& v) { @@ -67,7 +109,6 @@ namespace odb // // c_wstring_value_traits // - void c_wstring_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, const wchar_t* v) { @@ -80,12 +121,59 @@ namespace odb if (n != 0) memcpy (b.data (), v, n); } + + // + // c_warray_value_traits_base + // + void c_warray_value_traits_base:: + set_value (wchar_t* const& v, + const details::buffer& b, + size_t n, + bool is_null, + size_t N) + { + if (!is_null) + { + n /= 2; + n = n < N ? n : N; + + if (n != 0) + memcpy (v, b.data (), n * sizeof (wchar_t)); + } + else + n = 0; + + if (n != N) // Append '\0' if there is space. + v[n] = L'\0'; + } + + void c_warray_value_traits_base:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const wchar_t* v, + size_t N) + { + is_null = false; + + // Figure out the length. We cannot use wcslen since it may + // not be 0-terminated (wcsnlen is not standard). + // + for (n = 0; n != N && v[n] != L'\0'; ++n); + + n *= 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } #endif // _WIN32 // // default_value_traits, id_blob> // - void default_value_traits, id_blob>:: set_image (details::buffer& b, size_t& n, @@ -107,7 +195,6 @@ namespace odb // // default_value_traits, id_blob> // - void default_value_traits, id_blob>:: set_image (details::buffer& b, size_t& n, diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index e6abf2d..0cdf171 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -284,7 +284,7 @@ namespace odb const std::string&); }; - // const char* specialization + // char*/const char* specialization // // Specialization for const char* which only supports initialization // of an image from the value but not the other way around. This way @@ -303,35 +303,129 @@ namespace odb }; template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + c_string_value_traits {}; + + template <> struct LIBODB_SQLITE_EXPORT default_value_traits: - c_string_value_traits + c_string_value_traits {}; + + // char[N] specialization. + // + struct LIBODB_SQLITE_EXPORT c_array_value_traits_base { - typedef const char* query_type; + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null, + std::size_t N); + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v, + std::size_t N); }; template - struct default_value_traits: c_string_value_traits + struct default_value_traits { + typedef char* value_type; typedef char query_type[N]; + typedef details::buffer image_type; + + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (v, b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v) + { + c_array_value_traits_base::set_image (b, n, is_null, v, N); + } }; + // std::array (string) specialization. + // +#ifdef ODB_CXX11 template - struct default_value_traits: c_string_value_traits + struct default_value_traits, id_text> { - typedef const char query_type[N]; + typedef std::array value_type; + typedef std::array query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (v.data (), b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + c_array_value_traits_base::set_image (b, n, is_null, v.data (), N); + } + }; +#endif + + // char specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + typedef char value_type; + typedef char query_type; + typedef details::buffer image_type; + + static void + set_value (char& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (&v, b, n, is_null, 1); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + char v) + { + c_array_value_traits_base::set_image (b, n, is_null, &v, 1); + } }; #ifdef _WIN32 // std::wstring specialization. Using UTF-16 binding. // - template <> - struct image_traits + struct wstring_image_traits { typedef details::buffer image_type; static const bind::buffer_type bind_value = bind::text16; }; template <> + struct image_traits: wstring_image_traits {}; + + template <> struct LIBODB_SQLITE_EXPORT default_value_traits { typedef std::wstring value_type; @@ -357,14 +451,8 @@ namespace odb const std::wstring&); }; - // const wchar_t* specialization + // wchar_t*/const wchar_t* specialization. // - struct c_wstring_image_traits - { - typedef details::buffer image_type; - static const bind::buffer_type bind_value = bind::text16; - }; - struct LIBODB_SQLITE_EXPORT c_wstring_value_traits { typedef const wchar_t* value_type; @@ -378,33 +466,130 @@ namespace odb }; template <> - struct image_traits: c_wstring_image_traits {}; + struct image_traits: wstring_image_traits {}; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits: + c_wstring_value_traits {}; + + template <> + struct image_traits: wstring_image_traits {}; template <> struct LIBODB_SQLITE_EXPORT default_value_traits: - c_wstring_value_traits + c_wstring_value_traits {}; + + // wchar_t[N] specialization. + // + struct LIBODB_SQLITE_EXPORT c_warray_value_traits_base { - typedef const wchar_t* query_type; + static void + set_value (wchar_t* const& v, + const details::buffer& b, + std::size_t n, + bool is_null, + std::size_t N); + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const wchar_t* v, + std::size_t N); }; template - struct image_traits: c_wstring_image_traits {}; + struct image_traits: wstring_image_traits {}; template - struct default_value_traits: - c_wstring_value_traits + struct default_value_traits { + typedef wchar_t* value_type; typedef wchar_t query_type[N]; + typedef details::buffer image_type; + + static void + set_value (wchar_t* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (v, b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const wchar_t* v) + { + c_warray_value_traits_base::set_image (b, n, is_null, v, N); + } }; + // std::array (string) specialization. + // +#ifdef ODB_CXX11 template - struct image_traits: c_wstring_image_traits {}; + struct image_traits, id_text>: + wstring_image_traits {}; template - struct default_value_traits: - c_wstring_value_traits + struct default_value_traits, id_text> + { + typedef std::array value_type; + typedef std::array query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (v.data (), b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + c_warray_value_traits_base::set_image (b, n, is_null, v.data (), N); + } + }; +#endif + + // wchar_t specialization. + // + template <> + struct image_traits: wstring_image_traits {}; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits { - typedef const wchar_t query_type[N]; + typedef wchar_t value_type; + typedef wchar_t query_type; + typedef details::buffer image_type; + + static void + set_value (wchar_t& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (&v, b, n, is_null, 1); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + wchar_t v) + { + c_warray_value_traits_base::set_image (b, n, is_null, &v, 1); + } }; #endif // _WIN32 @@ -634,9 +819,7 @@ namespace odb struct default_type_traits; template - class type_traits: public default_type_traits - { - }; + class type_traits: public default_type_traits {}; // Integral types. // @@ -729,6 +912,12 @@ namespace odb }; template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + template <> struct default_type_traits { static const database_type_id db_type_id = id_text; @@ -740,14 +929,20 @@ namespace odb static const database_type_id db_type_id = id_text; }; - template - struct default_type_traits + template <> + struct default_type_traits { static const database_type_id db_type_id = id_text; }; // Binary types. // + template + struct default_type_traits + { + static const database_type_id db_type_id = id_blob; + }; + template <> struct default_type_traits > { -- cgit v1.1 From 3a9feb01e8cda69c41af126a7266ae7a6e545499 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Jan 2013 12:44:16 +0200 Subject: By default map std::array to string instead of binary --- odb/sqlite/traits.hxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 0cdf171..53d2db0 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -929,6 +929,14 @@ namespace odb static const database_type_id db_type_id = id_text; }; +#ifdef ODB_CXX11 + template + struct default_type_traits > + { + static const database_type_id db_type_id = id_text; + }; +#endif + template <> struct default_type_traits { @@ -957,12 +965,6 @@ namespace odb #ifdef ODB_CXX11 template - struct default_type_traits > - { - static const database_type_id db_type_id = id_blob; - }; - - template struct default_type_traits > { static const database_type_id db_type_id = id_blob; -- cgit v1.1 From 32613d718b36a6c400d6f05da50d30b3fd25c3b8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Feb 2013 15:50:07 +0200 Subject: Add support for change-tracking containers ODB now supports "smart" ordered containers. Such containers get extra functions for updating and deleting individual elements. Based on this functionality implement two change-tracking containers: odb::vector (equivalent to std::vector) and QOdbList (equivalent to QList). New tests: common/container/change-tracking and qt/common/container/change- tracking. --- odb/sqlite/container-statements.hxx | 291 ++++++++++++++++----------- odb/sqlite/container-statements.txx | 79 +++++--- odb/sqlite/forward.hxx | 3 + odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.hxx | 21 +- 5 files changed, 250 insertions(+), 146 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index a7b39bf..9217964 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -33,8 +33,6 @@ namespace odb typedef T traits; typedef typename traits::data_image_type data_image_type; - typedef typename traits::cond_image_type cond_image_type; - typedef typename traits::functions_type functions_type; typedef sqlite::insert_statement insert_statement_type; @@ -43,7 +41,7 @@ namespace odb typedef sqlite::connection connection_type; - container_statements (connection_type&); + container_statements (connection_type&, binding& id_binding); connection_type& connection () @@ -64,182 +62,233 @@ namespace odb const binding& id_binding () { - return *id_binding_; + return id_binding_; } - void - id_binding (const binding& b) + // Data image. The image is split into the id (that comes as a + // binding) and index/key plus value which are in data_image_type. + // The select binding is a subset of the full binding (no id). + // + data_image_type& + data_image () { - id_binding_ = &b; + return data_image_; } - // Condition image. - // - cond_image_type& - cond_image () + bind* + data_bind () { - return cond_image_; + return insert_image_binding_.bind; } - std::size_t - cond_image_version () const + bool + data_binding_test_version () const { - return cond_image_version_; + return data_id_binding_version_ != id_binding_.version || + data_image_version_ != data_image_.version || + insert_image_binding_.version == 0; } void - cond_image_version (std::size_t v) + data_binding_update_version () { - cond_image_version_ = v; + data_id_binding_version_ = id_binding_.version; + data_image_version_ = data_image_.version; + insert_image_binding_.version++; + select_image_binding_.version++; } - std::size_t - cond_id_binding_version () const + bool* + select_image_truncated () { - return cond_id_binding_version_; + return select_image_truncated_; } - void - cond_id_binding_version (std::size_t v) + // + // Statements. + // + + insert_statement_type& + insert_statement () { - cond_id_binding_version_ = v; + if (insert_ == 0) + insert_.reset ( + new (details::shared) insert_statement_type ( + conn_, insert_text_, insert_image_binding_)); + + return *insert_; } - binding& - cond_image_binding () + select_statement_type& + select_statement () { - return cond_image_binding_; + if (select_ == 0) + select_.reset ( + new (details::shared) select_statement_type ( + conn_, + select_text_, + id_binding_, + select_image_binding_)); + + return *select_; } - // Data image. - // - data_image_type& - data_image () + delete_statement_type& + delete_statement () { - return data_image_; + if (delete_ == 0) + delete_.reset ( + new (details::shared) delete_statement_type ( + conn_, delete_text_, id_binding_)); + + return *delete_; } - std::size_t - data_image_version () const + private: + container_statements (const container_statements&); + container_statements& operator= (const container_statements&); + + protected: + connection_type& conn_; + binding& id_binding_; + + functions_type functions_; + + data_image_type data_image_; + std::size_t data_image_version_; + std::size_t data_id_binding_version_; + + binding insert_image_binding_; + + binding select_image_binding_; + bool* select_image_truncated_; + + const char* insert_text_; + const char* select_text_; + const char* delete_text_; + + details::shared_ptr insert_; + details::shared_ptr select_; + details::shared_ptr delete_; + }; + + template + class smart_container_statements: public container_statements + { + public: + typedef T traits; + typedef typename traits::cond_image_type cond_image_type; + + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef sqlite::connection connection_type; + + smart_container_statements (connection_type&, binding& id_binding); + + // Condition image. The image is split into the id (that comes as + // a binding) and index/key/value which is in cond_image_type. + // + cond_image_type& + cond_image () { - return data_image_version_; + return cond_image_; } - void - data_image_version (std::size_t v) + bind* + cond_bind () { - data_image_version_ = v; + return cond_image_binding_.bind; } - std::size_t - data_id_binding_version () const + bool + cond_binding_test_version () const { - return data_id_binding_version_; + return cond_id_binding_version_ != this->id_binding_.version || + cond_image_version_ != cond_image_.version || + cond_image_binding_.version == 0; } void - data_id_binding_version (std::size_t v) + cond_binding_update_version () { - data_id_binding_version_ = v; + cond_id_binding_version_ = this->id_binding_.version; + cond_image_version_ = cond_image_.version; + cond_image_binding_.version++; } - binding& - data_image_binding () + // Update image. The image is split as follows: value comes + // from the data image, id comes as binding, and index/key + // comes from the condition image. + // + bind* + update_bind () { - return data_image_binding_; + return update_image_binding_.bind; } - binding& - select_image_binding () + bool + update_binding_test_version () const { - return select_image_binding_; + return update_id_binding_version_ != this->id_binding_.version || + update_cond_image_version_ != cond_image_.version || + update_data_image_version_ != this->data_image_.version || + update_image_binding_.version == 0; } - bool* - select_image_truncated () + void + update_binding_update_version () { - return select_image_truncated_; + update_id_binding_version_ = this->id_binding_.version; + update_cond_image_version_ = cond_image_.version; + update_data_image_version_ = this->data_image_.version; + update_image_binding_.version++; } // // Statements. // - insert_statement_type& - insert_one_statement () - { - if (insert_one_ == 0) - { - insert_one_.reset ( - new (details::shared) insert_statement_type ( - conn_, insert_one_text_, data_image_binding_)); - } - - return *insert_one_; - } - - select_statement_type& - select_all_statement () - { - if (select_all_ == 0) - { - select_all_.reset ( - new (details::shared) select_statement_type ( - conn_, - select_all_text_, - cond_image_binding_, - select_image_binding_)); - } - - return *select_all_; - } - delete_statement_type& - delete_all_statement () + delete_statement () { - if (delete_all_ == 0) - { - delete_all_.reset ( + if (this->delete_ == 0) + this->delete_.reset ( new (details::shared) delete_statement_type ( - conn_, delete_all_text_, cond_image_binding_)); - } + this->conn_, + this->delete_text_, + this->cond_image_binding_)); - return *delete_all_; + return *this->delete_; } - private: - container_statements (const container_statements&); - container_statements& operator= (const container_statements&); + update_statement_type& + update_statement () + { + if (update_ == 0) + update_.reset ( + new (details::shared) update_statement_type ( + this->conn_, + update_text_, + update_image_binding_)); + + return *update_; + } protected: - connection_type& conn_; - functions_type functions_; - - const binding* id_binding_; - cond_image_type cond_image_; std::size_t cond_image_version_; std::size_t cond_id_binding_version_; binding cond_image_binding_; - data_image_type data_image_; - std::size_t data_image_version_; - std::size_t data_id_binding_version_; + std::size_t update_id_binding_version_; + std::size_t update_cond_image_version_; + std::size_t update_data_image_version_; + binding update_image_binding_; - binding data_image_binding_; + const char* update_text_; - // Skips the id from data_image_binding. - // - binding select_image_binding_; - bool* select_image_truncated_; - - const char* insert_one_text_; - const char* select_all_text_; - const char* delete_all_text_; - - details::shared_ptr insert_one_; - details::shared_ptr select_all_; - details::shared_ptr delete_all_; + details::shared_ptr update_; }; // Template argument is the generated concrete container traits type. @@ -252,18 +301,32 @@ namespace odb typedef typename T::statements_type base; typedef sqlite::connection connection_type; - container_statements_impl (connection_type&); + container_statements_impl (connection_type&, binding&); private: container_statements_impl (const container_statements_impl&); container_statements_impl& operator= (const container_statements_impl&); private: - bind cond_image_bind_[traits::cond_column_count]; bind data_image_bind_[traits::data_column_count]; - bool select_image_truncated_array_[traits::data_column_count- + bool select_image_truncated_array_[traits::data_column_count - traits::id_column_count]; }; + + template + class smart_container_statements_impl: public container_statements_impl + { + public: + typedef T traits; + typedef sqlite::connection connection_type; + + smart_container_statements_impl (connection_type&, binding&); + + private: + bind cond_image_bind_[traits::cond_column_count]; + bind update_image_bind_[traits::value_column_count + + traits::cond_column_count]; + }; } } diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 19ecfdc..4d575b7 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -11,48 +11,61 @@ namespace odb { // container_statements // - template container_statements:: - container_statements (connection_type& conn) + container_statements (connection_type& conn, binding& id) : conn_ (conn), - functions_ (this, - &traits::insert_one, - &traits::load_all, - &traits::delete_all), - id_binding_ (0), + id_binding_ (id), + functions_ (this), + insert_image_binding_ (0, 0), // Initialized by impl. + select_image_binding_ (0, 0) // Initialized by impl. + { + functions_.insert_ = &traits::insert; + functions_.select_ = &traits::select; + functions_.delete__ = &traits::delete_; + + data_image_.version = 0; + data_image_version_ = 0; + data_id_binding_version_ = 0; + } + + // smart_container_statements + // + template + smart_container_statements:: + smart_container_statements (connection_type& conn, binding& id) + : container_statements (conn, id), cond_image_binding_ (0, 0), // Initialized by impl. - data_image_binding_ (0, 0), // Initialized by impl. - select_image_binding_ (0, 0) // Initialized by impl. + update_image_binding_ (0, 0) // Initialized by impl. { + this->functions_.update_ = &traits::update; + cond_image_.version = 0; cond_image_version_ = 0; cond_id_binding_version_ = 0; - data_image_.version = 0; - data_image_version_ = 0; - data_id_binding_version_ = 0; + update_id_binding_version_ = 0; + update_cond_image_version_ = 0; + update_data_image_version_ = 0; } + // container_statements_impl + // template container_statements_impl:: - container_statements_impl (connection_type& conn) - : base (conn) + container_statements_impl (connection_type& conn, binding& id) + : base (conn, id) { this->select_image_truncated_ = select_image_truncated_array_; - this->cond_image_binding_.bind = cond_image_bind_; - this->cond_image_binding_.count = traits::cond_column_count; - - this->data_image_binding_.bind = data_image_bind_; - this->data_image_binding_.count = traits::data_column_count; + this->insert_image_binding_.bind = data_image_bind_; + this->insert_image_binding_.count = traits::data_column_count; this->select_image_binding_.bind = data_image_bind_ + traits::id_column_count; this->select_image_binding_.count = traits::data_column_count - traits::id_column_count; - std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); std::memset (select_image_truncated_array_, 0, @@ -64,9 +77,29 @@ namespace odb data_image_bind_[i + traits::id_column_count].truncated = select_image_truncated_array_ + i; - this->insert_one_text_ = traits::insert_one_statement; - this->select_all_text_ = traits::select_all_statement; - this->delete_all_text_ = traits::delete_all_statement; + this->insert_text_ = traits::insert_statement; + this->select_text_ = traits::select_statement; + this->delete_text_ = traits::delete_statement; + } + + // smart_container_statements_impl + // + template + smart_container_statements_impl:: + smart_container_statements_impl (connection_type& conn, binding& id) + : container_statements_impl (conn, id) + { + this->cond_image_binding_.bind = cond_image_bind_; + this->cond_image_binding_.count = traits::cond_column_count; + + this->update_image_binding_.bind = update_image_bind_; + this->update_image_binding_.count = traits::value_column_count + + traits::cond_column_count; + + std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + + this->update_text_ = traits::update_statement; } } } diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 382284e..389b078 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -67,6 +67,9 @@ namespace odb template class container_statements; + template + class smart_container_statements; + class query_base; class query_params; } diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 50d66a3..64d9a7d 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -353,7 +353,7 @@ namespace odb container_statement_cache_type& container_statment_cache () { - return container_statement_cache_.get (conn_); + return container_statement_cache_.get (conn_, id_image_binding ()); } public: diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 9ff3faf..9fe3675 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -45,36 +45,41 @@ namespace odb typedef sqlite::connection connection_type; container_statement_cache_ptr (): p_ (0) {} - ~container_statement_cache_ptr () {if (p_ != 0) (this->*deleter_) (0);} + ~container_statement_cache_ptr () + { + if (p_ != 0) + (this->*deleter_) (0, 0); + } T& - get (connection_type& c) + get (connection_type& c, binding& id) { if (p_ == 0) - allocate (&c); + allocate (&c, &id); return *p_; } private: void - allocate (connection_type*); + allocate (connection_type*, binding*); private: T* p_; - void (container_statement_cache_ptr::*deleter_) (connection_type*); + void (container_statement_cache_ptr::*deleter_) ( + connection_type*, binding*); }; template void container_statement_cache_ptr:: - allocate (connection_type* c) + allocate (connection_type* c, binding* id) { // To reduce object code size, this function acts as both allocator // and deleter. // if (p_ == 0) { - p_ = new T (*c); + p_ = new T (*c, *id); deleter_ = &container_statement_cache_ptr::allocate; } else @@ -416,7 +421,7 @@ namespace odb container_statement_cache_type& container_statment_cache () { - return container_statement_cache_.get (conn_); + return container_statement_cache_.get (conn_, id_image_binding_); } public: -- cgit v1.1 From f19ae935d1ae09eb7b347d3ce198c3ccacba6bd8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 6 Feb 2013 07:43:11 +0200 Subject: Fix incorrect AC_LANG_SOURCE quoting Thanks to Hugo Mildenberger for the patch. --- m4/libodb.m4 | 6 +++--- m4/libsqlite.m4 | 12 ++++++------ m4/threads.m4 | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 6e282a6..7d3130b 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -31,8 +31,8 @@ fi save_LIBS="$LIBS" LIBS="-lodb $LIBS" -CXX_LIBTOOL_LINK_IFELSE( -AC_LANG_SOURCE([[ +CXX_LIBTOOL_LINK_IFELSE([ +AC_LANG_SOURCE([ #include void @@ -60,7 +60,7 @@ main () const char* m (g ()); return m != 0; } -]]), +])], [libodb_found=yes]) if test x"$libodb_found" = xno; then diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 5a353b9..e108c02 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -16,8 +16,8 @@ AC_MSG_CHECKING([for libsqlite3]) save_LIBS="$LIBS" LIBS="-lsqlite3 $LIBS" -CXX_LIBTOOL_LINK_IFELSE( -AC_LANG_SOURCE([[ +CXX_LIBTOOL_LINK_IFELSE([ +AC_LANG_SOURCE([ #include int @@ -30,7 +30,7 @@ main () sqlite3_finalize (stmt); sqlite3_close (handle); } -]]), +])], [ libsqlite_found=yes ]) @@ -42,8 +42,8 @@ fi # Check for unlock_notify. # if test x"$libsqlite_found" = xyes; then -CXX_LIBTOOL_LINK_IFELSE( -AC_LANG_SOURCE([[ +CXX_LIBTOOL_LINK_IFELSE([ +AC_LANG_SOURCE([ #include int @@ -52,7 +52,7 @@ main () sqlite3* handle (0); sqlite3_unlock_notify (handle, 0, 0); } -]]), +])], [ libsqlite_unlock_notify=yes ]) diff --git a/m4/threads.m4 b/m4/threads.m4 index fce3f39..4cd4c05 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -36,8 +36,8 @@ if test x$threads = xcheck; then # AC_MSG_CHECKING([for __thread keyword]) - CXX_LIBTOOL_LINK_IFELSE( - AC_LANG_SOURCE([[ + CXX_LIBTOOL_LINK_IFELSE([ + AC_LANG_SOURCE([ __thread int tls_var; int @@ -45,7 +45,7 @@ if test x$threads = xcheck; then { tls_var = 0; } - ]]), + ])], [threads_thread_keyword=yes]) AC_MSG_RESULT([$threads_thread_keyword]) -- cgit v1.1 From 6aec30e4d446c7d9ffb15bdfff260a3a5e994b97 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 6 Feb 2013 08:02:08 +0200 Subject: Add call to AM_PROG_AR which is required by newer automake Thanks to Hugo Mildenberger for the patch. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index b357aa2..fc0d9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([odb/sqlite/version.hxx]) AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc subdir-objects dist-bzip2 dist-zip tar-ustar]) +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # Required by automake 1.12. LT_INIT([win32-dll]) -- cgit v1.1 From 6689788dfa663881b2ecefd8d10b6b7af67e9e42 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 9 Feb 2013 10:05:31 +0200 Subject: Escape m4 macro --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fc0d9c1..8d79433 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([odb/sqlite/version.hxx]) AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc subdir-objects dist-bzip2 dist-zip tar-ustar]) -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # Required by automake 1.12. +m4_equote()[m4_ifdef]m4_dquote()([AM_PROG_AR], [AM_PROG_AR]) # Required by automake 1.12. LT_INIT([win32-dll]) -- cgit v1.1 From f8d54121142f97c7d155415208db30c8010e6e87 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 9 Feb 2013 10:19:18 +0200 Subject: Update copyright year --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.make | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/connection.ixx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/conversion.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/no-id-object-statements.txx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 2 +- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/prepared-query.cxx | 2 +- odb/sqlite/prepared-query.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query-dynamic.cxx | 2 +- odb/sqlite/query-dynamic.hxx | 2 +- odb/sqlite/query-dynamic.ixx | 2 +- odb/sqlite/query-dynamic.txx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.cxx | 2 +- odb/sqlite/simple-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.ixx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- 101 files changed, 101 insertions(+), 101 deletions(-) diff --git a/Makefile.am b/Makefile.am index d9543d8..cc4622b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index 39910bb..b1b4f3d 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.make b/build/bootstrap.make index 89a21af..ab0707a 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index b161b5d..1d8760a 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index 57ee246..b5ef38e 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2012 Code Synthesis Tools CC. +Copyright (c) 2009-2013 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index cd009d9..b537303 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index 5fb2485..56a686a 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index ae1e512..cc9d512 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 3704723..1933a0c 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index f5787e8..5981921 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index cf14ccd..41b07f4 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 872aa63..956d037 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 1fe7152..b25ddbb 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index 1217fee..cbf9f7d 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index 65ac80b..90eb372 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 6e3dafd..17dfa18 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index f13948e..d21a587 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 0e2b5e4..48aa1cd 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 06f52e5..2147d81 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/configure.ac b/configure.ac index 8d79433..5902fbd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index e81c54c..5066a4d 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index e0ef81d..8d70ffb 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 7d3130b..9ce2580 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index e108c02..a75062c 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index adecac1..c4972db 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 0e57142..460251f 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 6e0f45b..99c4a82 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index 4cd4c05..9a7da53 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index 6611491..d53519c 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index e03eedb..98d6698 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 368df00..65f365d 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index f55d48a..2a682fa 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 8eb9885..dec85bf 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index e2274c2..0db2cf1 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index b62ac8c..f4e7259 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 43c540c..241e626 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index f1f4183..02ad3ec 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 9217964..e9c2d3b 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 4d575b7..5024b5b 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 00618b5..5b47735 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index a626b73..ee758e5 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index e20bbec..fd2063e 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index bcd9553..3f54ae0 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index ea83884..b19a9fc 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index 9daf35c..690fe7f 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index bd29d6e..3411407 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index ee7529b..1e5646d 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 847e9c1..74822d3 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index c1471f6..0548680 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 6a1a7d9..40b2d4c 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index a38237c..5afcdf5 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 389b078..316fbbc 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index b215461..3c33009 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index f1b7b59..236bf82 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 3cd3086..e857820 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index f942cf4..6939fc7 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 9b531f6..096f13e 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index a56eb5b..493bced 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index a91aab0..9c79414 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 64d9a7d..f932234 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index 061215e..999eb3e 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index 1eb875d..d181f4f 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index 2615179..63d8bbc 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 9e48ace..a2d969f 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index 5f86b93..aeeb841 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index aaad7f8..bf0b48f 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index 77f0f43..86b86b8 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index c7d88cb..083e42f 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index bce005f..120be98 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 5ee377f..d24e66a 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 7413691..56c8e80 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 7342187..b63d5a1 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 5632a13..9dd258a 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index e8f2233..fe31300 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index 110795a..47a4790 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 9fe3675..2c5b321 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index 11d4fbc..e5951df 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 51c4948..f0e6138 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 295cd1f..d6b49ee 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index c350e02..bb34aed 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index b08e4c7..bd90a44 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 775a6a8..4c6e3cd 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 09cf994..de71e12 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index fe3a2a0..eb55e58 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index 53957af..b46e753 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index bd70c37..5db1369 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 63eaed1..1b48793 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index ac183ca..4ee7b19 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 753c181..5f3411c 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 53d2db0..b9d3b39 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 1975308..2a06288 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index dcc7cc2..d0894de 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index 72189cc..64c24d9 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 7fd3f08..caa6eb4 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index dfcd264..beb8d64 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 870f150..05be5c8 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index f8b71f7..b3a41f1 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VERSION_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 4d27367..fd189e6 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index b6d8cb8..d22a440 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index ca99bb1..63e48e7 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index c5f497b..46cb506 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t -- cgit v1.1 From 90e049300fb9dd7eec385ae3dab75600763ffcdf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 9 Feb 2013 10:33:13 +0200 Subject: Bump version to 2.2.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b3a41f1..38cd698 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20103 +#if ODB_VERSION != 20200 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2019903 -#define LIBODB_SQLITE_VERSION_STR "2.2.0.a3" +#define LIBODB_SQLITE_VERSION 2020000 +#define LIBODB_SQLITE_VERSION_STR "2.2.0" #include diff --git a/version b/version index 90d185b..ccbccc3 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.0.a3 +2.2.0 -- cgit v1.1 From 630d56f0b21b0031d3062cfe78c026080bc98eb7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Feb 2013 10:15:33 +0200 Subject: Detect POSIX threads on MinGW-W64 --- m4/threads.m4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/m4/threads.m4 b/m4/threads.m4 index 9a7da53..1609a04 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -22,7 +22,16 @@ if test x$threads = xcheck; then CXXFLAGS="$CXXFLAGS -mthreads" ;; esac - threads=win32 + + # Newer versions of GCC can be configured to use either Win32 or POSIX + # threads. It appears that -mthreads should be used in both cases but + # if the model is POSIX then GCC will also link -lpthread by default. + # Use that fact to test which model we have. + # + AC_TRY_LINK([#include ], + [pthread_create(0,0,0,0);], + [threads=posix], + [threads=win32]) ;; *) ACX_PTHREAD -- cgit v1.1 From 7069c262c0293e634f9172e8ee57b0f018f64861 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Feb 2013 13:20:12 +0200 Subject: Support compilers that deduce const arrays to const reference differently --- odb/sqlite/query.hxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index d24e66a..b6d5bb9 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -336,6 +336,41 @@ namespace odb return ref_bind_typed (x); } + // Some compilers (notably VC++), when deducing const T& from const + // array do not strip const from the array type. As a result, in the + // above signatures we get, for example, T = const char[4] instead + // of T = char[4], which is what we want. So to "fix" such compilers, + // we will have to provide the following specializations of the above + // functions. + // + template + static val_bind + _val (const T (&x) [N]) + { + return val_bind (x); + } + + template + static val_bind_typed + _val (const T (&x) [N]) + { + return val_bind_typed (x); + } + + template + static ref_bind + _ref (const T (&x) [N]) + { + return ref_bind (x); + } + + template + static ref_bind_typed + _ref (const T (&x) [N]) + { + return ref_bind_typed (x); + } + public: query_base& operator+= (const query_base&); -- cgit v1.1 From b84408a833511bb03b8dbe031ec06d6d09ca5bc5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Feb 2013 13:48:12 +0200 Subject: Qualify vector to work around Sun CC bugs --- odb/sqlite/traits.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 5f3411c..d3542d2 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -174,7 +174,9 @@ namespace odb // // default_value_traits, id_blob> // - void default_value_traits, id_blob>:: + // std::vector has to be qualified for Sun CC. + // + void default_value_traits, id_blob>:: set_image (details::buffer& b, size_t& n, bool& is_null, @@ -195,7 +197,9 @@ namespace odb // // default_value_traits, id_blob> // - void default_value_traits, id_blob>:: + // std::vector has to be qualified for Sun CC. + // + void default_value_traits, id_blob>:: set_image (details::buffer& b, size_t& n, bool& is_null, -- cgit v1.1 From 4b4cea7da1fbfd0ea90124932450fbde53a84c2e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Feb 2013 16:55:50 +0200 Subject: Factor windows.h inclusion into separate header, disable min/max macros --- odb/sqlite/database.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 5b47735..e8e5c77 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -3,10 +3,7 @@ // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include // WideCharToMultiByte +# include // WideCharToMultiByte #endif #include -- cgit v1.1 From 7e88b0a80618848d3a3c5f6cad886c8b7785787d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 13 Feb 2013 06:20:26 +0200 Subject: Suppress warning in empty for-loop --- odb/sqlite/traits.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index d3542d2..dae008c 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -80,7 +80,7 @@ namespace odb // Figure out the length. We cannot use strlen since it may // not be 0-terminated (strnlen is not standard). // - for (n = 0; n != N && v[n] != '\0'; ++n); + for (n = 0; n != N && v[n] != '\0'; ++n) ; if (n > b.capacity ()) b.capacity (n); @@ -159,7 +159,7 @@ namespace odb // Figure out the length. We cannot use wcslen since it may // not be 0-terminated (wcsnlen is not standard). // - for (n = 0; n != N && v[n] != L'\0'; ++n); + for (n = 0; n != N && v[n] != L'\0'; ++n) ; n *= 2; -- cgit v1.1 From b580f1548ff335a0e1fa004fc6626486535c94e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Feb 2013 11:07:25 +0200 Subject: Add support for pattern matching (SQL LIKE) --- odb/sqlite/query-dynamic.cxx | 16 ++++++++++++++ odb/sqlite/query.hxx | 41 +++++++++++++++++++++++++++++++++++ odb/sqlite/query.txx | 51 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index aeeb841..343e42c 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -110,6 +110,22 @@ namespace odb q += ")"; break; } + case part::op_like: + { + translate (q, s, p - 2); // column + q += "LIKE"; + translate (q, s, p - 1); // pattern + break; + } + case part::op_like_escape: + { + translate (q, s, p - 3); // column + q += "LIKE"; + translate (q, s, p - 2); // pattern + q += "ESCAPE"; + translate (q, s, p - 1); // escape + break; + } case part::op_eq: case part::op_ne: case part::op_lt: diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index b6d5bb9..31bd922 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -741,6 +741,47 @@ namespace odb query_base in_range (I begin, I end) const; + // like + // + public: + query_base + like (decayed_type pattern) const + { + return like (val_bind (pattern)); + } + + query_base + like (val_bind pattern) const; + + template + query_base + like (val_bind pattern) const + { + return like (val_bind (decayed_type (pattern.val))); + } + + query_base + like (ref_bind pattern) const; + + query_base + like (decayed_type pattern, decayed_type escape) const + { + return like (val_bind (pattern), escape); + } + + query_base + like (val_bind pattern, decayed_type escape) const; + + template + query_base + like (val_bind pattern, decayed_type escape) const + { + return like (val_bind (decayed_type (pattern.val)), escape); + } + + query_base + like (ref_bind pattern, decayed_type escape) const; + // = // public: diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index b63d5a1..ed2e5b4 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -6,6 +6,7 @@ namespace odb { namespace sqlite { + // // query_base // @@ -22,8 +23,12 @@ namespace odb append (val_bind (true), c.conversion ()); } + // // query_column // + + // in + // template query_base query_column:: in (decayed_type v1, decayed_type v2) const @@ -109,5 +114,51 @@ namespace odb q += ")"; return q; } + + // like + // + template + query_base query_column:: + like (val_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (val_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } } } -- cgit v1.1 From 43904af47c138feea6a5c6e04756c70bb2e41de7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Mar 2013 14:13:37 +0200 Subject: Add separate exception for SQLite forced rollbacks --- odb/sqlite/error.cxx | 20 ++++++++++++++------ odb/sqlite/exceptions.cxx | 10 ++++++++++ odb/sqlite/exceptions.hxx | 12 ++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 74822d3..6107427 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -47,6 +47,15 @@ namespace odb m = "SQLite API misuse"; break; } +#ifdef SQLITE_ABORT_ROLLBACK + case SQLITE_ABORT: + { + if (ee == SQLITE_ABORT_ROLLBACK) + throw forced_rollback (); + + break; + } +#endif case SQLITE_LOCKED: { #ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY @@ -65,16 +74,15 @@ namespace odb if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) throw timeout (); #endif - - // Fall throught. - } - default: - { - m = sqlite3_errmsg (h); break; } + default: + break; } + if (m.empty ()) + m = sqlite3_errmsg (h); + throw database_exception (e, ee, m); } } diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 40b2d4c..08cdf90 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -13,6 +13,16 @@ namespace odb namespace sqlite { // + // forced_rollback + // + + const char* forced_rollback:: + what () const throw () + { + return "transaction is forced to rollback"; + } + + // // database_exception // diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 5afcdf5..be13bbe 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -19,6 +19,18 @@ namespace odb { namespace sqlite { + // This exception is thrown if SQLite is forcing the current transaction + // to rollback. This can happen in SQLite 3.7.11 or later if one of the + // connections participating in the shared cache rolls back a transaction. + // See the SQLITE_ABORT_ROLLBACK extended error code for detail on this + // behavior. + // + struct LIBODB_EXPORT forced_rollback: recoverable + { + virtual const char* + what () const throw (); + }; + struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception { database_exception (int error, -- cgit v1.1 From fce0bab486c0086cf0f799dc4a2b6f11376c23e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Apr 2013 07:34:35 +0200 Subject: Add default constructor, finalized() accessor to transaction --- odb/sqlite/transaction.hxx | 4 +++- odb/sqlite/transaction.ixx | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index beb8d64..dcbbf09 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -27,7 +27,9 @@ namespace odb typedef sqlite::connection connection_type; explicit - transaction (transaction_impl*); + transaction (transaction_impl*, bool make_current = true); + + transaction (); // Return the database this transaction is on. // diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 05be5c8..58ee7b9 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -10,8 +10,14 @@ namespace odb namespace sqlite { inline transaction:: - transaction (transaction_impl* impl) - : odb::transaction (impl) + transaction (transaction_impl* impl, bool make_current) + : odb::transaction (impl, make_current) + { + } + + inline transaction:: + transaction () + : odb::transaction () { } -- cgit v1.1 From d062cc21ae1dc530a21017dfbf841e557d64c6c3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Apr 2013 07:35:45 +0200 Subject: Add support for schema version table --- odb/sqlite/database.cxx | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ odb/sqlite/database.hxx | 8 ++++- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index e8e5c77..d5399f7 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -6,11 +6,16 @@ # include // WideCharToMultiByte #endif +#include + +#include #include #include #include #include +#include +#include #include #include @@ -177,5 +182,92 @@ namespace odb connection_ptr c (factory_->connect ()); return c.release (); } + + const database::schema_version_info& database:: + load_schema_version (const string& name) const + { + schema_version_info& svi (schema_version_map_[name]); + + // Construct the SELECT statement text. + // + string text ("SELECT \"version\", \"migration\" FROM "); + + if (!svi.version_table.empty ()) + text += svi.version_table; // Already quoted. + else if (!schema_version_table_.empty ()) + text += schema_version_table_; // Already quoted. + else + text += "\"schema_version\""; + + text += " WHERE \"name\" = ?"; + + // Bind parameters and results. + // + size_t psize[1] = {name.size ()}; + bind pbind[1] = {{bind::text, + const_cast (name.c_str ()), + &psize[0], + 0, 0, 0}}; + binding param (pbind, 1); + param.version++; + + long long migration; + bool rnull[2]; + bind rbind[2] = {{bind::integer, &svi.version, 0, 0, &rnull[0], 0}, + {bind::integer, &migration, 0, 0, &rnull[1], 0}}; + binding result (rbind, 2); + result.version++; + + // If we are not in transaction, SQLite will start an implicit one + // which suits us just fine. + // + connection_ptr cp; + if (!transaction::has_current ()) + cp = factory_->connect (); + + sqlite::connection& c ( + cp != 0 ? *cp : transaction::current ().connection ()); + + try + { + select_statement st (c, text, param, result); + st.execute (); + auto_result ar (st); + + switch (st.fetch ()) + { + case select_statement::success: + { + svi.migration = migration != 0; + assert (st.fetch () == select_statement::no_data); + break; + } + case select_statement::no_data: + { + svi.version = 0; // No schema. + break; + } + case select_statement::truncated: + { + assert (false); + break; + } + } + } + catch (const database_exception& e) + { + // Try to detect the case where there is no version table. SQLite + // doesn't have an extended error code for this so we have to use + // the error text. + // + if (e.error () == SQLITE_ERROR && + e.message ().compare (0, 14, "no such table:") == 0) + svi.version = 0; // No schema. + else + throw; + } + + return svi; + } } } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index ee758e5..0471b64 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -349,9 +349,15 @@ namespace odb using odb::database::tracer; - public: + // Database schema version. + // + protected: + virtual const schema_version_info& + load_schema_version (const std::string& schema_name) const; + // Database id constant (useful for meta-programming). // + public: static const odb::database_id database_id = id_sqlite; public: -- cgit v1.1 From 30df328918e2017f17fec47ec80273910df5e6c5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 May 2013 10:59:02 -0400 Subject: Fix invalid export macro --- odb/sqlite/exceptions.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index be13bbe..8a21d5e 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -25,7 +25,7 @@ namespace odb // See the SQLITE_ABORT_ROLLBACK extended error code for detail on this // behavior. // - struct LIBODB_EXPORT forced_rollback: recoverable + struct LIBODB_SQLITE_EXPORT forced_rollback: recoverable { virtual const char* what () const throw (); -- cgit v1.1 From 3b683eaa935356ac960fca68c7173e1c9b1b3c1e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Jul 2013 14:54:19 +0200 Subject: Add support for Visual Studio 2005 --- INSTALL | 2 +- etc/sqlite/README | 2 +- etc/sqlite/sqlite3-vc8.sln | 26 +++ etc/sqlite/sqlite3-vc8.vcproj | 360 ++++++++++++++++++++++++++++++++++++ libodb-sqlite-vc8.sln | 26 +++ makefile | 4 +- odb/sqlite/libodb-sqlite-vc8.vcproj | 352 +++++++++++++++++++++++++++++++++++ odb/sqlite/makefile | 5 +- 8 files changed, 772 insertions(+), 5 deletions(-) create mode 100644 etc/sqlite/sqlite3-vc8.sln create mode 100644 etc/sqlite/sqlite3-vc8.vcproj create mode 100644 libodb-sqlite-vc8.sln create mode 100644 odb/sqlite/libodb-sqlite-vc8.vcproj diff --git a/INSTALL b/INSTALL index 842f545..2a55ef1 100644 --- a/INSTALL +++ b/INSTALL @@ -80,7 +80,7 @@ macro from the project's "Preprocessor Definitions" settings). The SQLite source distribution for Windows lacks Visual Studio project/solution files. To rectify this situation, the libodb-sqlite distribution includes, in the -etc\sqlite\ directory, Visual Studio 9, 10, and 11 project/solution files +etc\sqlite\ directory, Visual Studio 8, 9, 10, and 11 project/solution files for building 32 and 64-bit SQLite libraries with unlock notify support. Refer to the accompanying README file for information on how to build the libraries and configure VC++ Directories to automatically locate them. diff --git a/etc/sqlite/README b/etc/sqlite/README index b147916..126c52c 100644 --- a/etc/sqlite/README +++ b/etc/sqlite/README @@ -1,5 +1,5 @@ This directory contains project/solution files for building SQLite libraries -with Microsoft Visual Studio versions 9, 10, and 11. +with Microsoft Visual Studio versions 8, 9, 10, and 11. To build SQLite, you will need to download two SQLite packages: sqlite- amalgamation and sqlite-dll. Copy the sqlite3.c and sqlite3.h files from the diff --git a/etc/sqlite/sqlite3-vc8.sln b/etc/sqlite/sqlite3-vc8.sln new file mode 100644 index 0000000..e5ed1d0 --- /dev/null +++ b/etc/sqlite/sqlite3-vc8.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc8.vcproj", "{6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.ActiveCfg = Debug|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.Build.0 = Debug|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.ActiveCfg = Debug|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.Build.0 = Debug|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.ActiveCfg = Release|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.Build.0 = Release|Win32 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.ActiveCfg = Release|x64 + {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/etc/sqlite/sqlite3-vc8.vcproj b/etc/sqlite/sqlite3-vc8.vcproj new file mode 100644 index 0000000..8e1e552 --- /dev/null +++ b/etc/sqlite/sqlite3-vc8.vcproj @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libodb-sqlite-vc8.sln b/libodb-sqlite-vc8.sln new file mode 100644 index 0000000..94d3f87 --- /dev/null +++ b/libodb-sqlite-vc8.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc8.vcproj", "{E4055842-E6F1-4305-9FD2-EF70A92290C9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.ActiveCfg = Debug|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.Build.0 = Debug|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.ActiveCfg = Debug|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.Build.0 = Debug|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.ActiveCfg = Release|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.Build.0 = Release|Win32 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.ActiveCfg = Release|x64 + {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/makefile b/makefile index d53519c..19eee70 100644 --- a/makefile +++ b/makefile @@ -14,8 +14,8 @@ $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) $(dist): export docs := GPLv2 LICENSE README NEWS version -$(dist): data_dist := INSTALL libodb-sqlite-vc9.sln libodb-sqlite-vc10.sln \ -libodb-sqlite-vc11.sln \ +$(dist): data_dist := INSTALL libodb-sqlite-vc8.sln libodb-sqlite-vc9.sln \ +libodb-sqlite-vc10.sln libodb-sqlite-vc11.sln \ $(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) diff --git a/odb/sqlite/libodb-sqlite-vc8.vcproj b/odb/sqlite/libodb-sqlite-vc8.vcproj new file mode 100644 index 0000000..7bcc784 --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc8.vcproj @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entries__(sources) + + +__file_entries__(headers) + + + + + diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 3c33009..bfde3aa 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -100,7 +100,8 @@ $(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(dist): export headers = $(sort $(headers_dist) $(gen_headers)) $(dist): gen_dist := $(gen) $(dist): data_dist := $(cli_tun) details/config.h.in -$(dist): export extra_dist := $(data_dist) libodb-sqlite-vc9.vcproj \ +$(dist): export extra_dist := $(data_dist) \ +libodb-sqlite-vc8.vcproj libodb-sqlite-vc9.vcproj \ libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters $(dist): export interface_version = $(shell sed -e \ @@ -109,6 +110,7 @@ $(dist): export interface_version = $(shell sed -e \ $(dist): $(gen) $(call dist-data,$(sources_dist) $(headers_dist) $(data_dist)) $(call dist-data,$(gen_dist),$(dist_prefix)/odb/sqlite/details) + $(call meta-vc8proj,$(src_base)/libodb-sqlite-vc8.vcproj) $(call meta-vc9proj,$(src_base)/libodb-sqlite-vc9.vcproj) $(call meta-vc10proj,$(src_base)/libodb-sqlite-vc10.vcxproj) $(call meta-vc11proj,$(src_base)/libodb-sqlite-vc11.vcxproj) @@ -137,6 +139,7 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc8proj.make) $(call include,$(bld_root)/meta/vc9proj.make) $(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/vc11proj.make) -- cgit v1.1 From 534da0d899b11f6ca1fac161ea8901a62e5c07dc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Aug 2013 15:16:09 +0200 Subject: Add support for object sections Sections are an optimization mechanism that allows the partitioning of data members of a persistent class into groups that can be separately loaded and/or updated. --- odb/sqlite/database.hxx | 14 +++ odb/sqlite/database.ixx | 14 +++ odb/sqlite/forward.hxx | 3 + odb/sqlite/polymorphic-object-statements.hxx | 39 ++++-- odb/sqlite/section-statements.hxx | 182 +++++++++++++++++++++++++++ odb/sqlite/section-statements.txx | 42 +++++++ odb/sqlite/simple-object-statements.hxx | 100 ++++++++------- odb/sqlite/simple-object-statements.txx | 1 - 8 files changed, 337 insertions(+), 58 deletions(-) create mode 100644 odb/sqlite/section-statements.hxx create mode 100644 odb/sqlite/section-statements.txx diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 0471b64..6039f23 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -147,6 +147,12 @@ namespace odb void load (const typename object_traits::id_type& id, T& object); + // Load (or reload, if it is already loaded) a section of an object. + // + template + void + load (T& object, section&); + // Reload an object. // template @@ -217,6 +223,14 @@ namespace odb void update (const typename object_traits::pointer_type& obj_ptr); + // Update a section of an object. Throws the section_not_loaded + // exception if the section is not loaded. Note also that this + // function does not clear the changed flag if it is set. + // + template + void + update (const T& object, const section&); + // Make the object transient. Throw object_not_persistent if not // found. // diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index fd2063e..c2fd1a5 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -108,6 +108,13 @@ namespace odb } template + inline void database:: + load (T& obj, section& s) + { + return load_ (obj, s); + } + + template inline typename object_traits::pointer_type database:: find (const typename object_traits::id_type& id) { @@ -249,6 +256,13 @@ namespace odb template inline void database:: + update (const T& obj, const section& s) + { + update_ (obj, s); + } + + template + inline void database:: erase (const typename object_traits::id_type& id) { return erase_ (id); diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 316fbbc..456ff43 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -70,6 +70,9 @@ namespace odb template class smart_container_statements; + template + class section_statements; + class query_base; class query_params; } diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index f932234..fa5f6af 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -171,8 +171,8 @@ namespace odb base_statements_type; typedef - typename object_traits::container_statement_cache_type - container_statement_cache_type; + typename object_traits::extra_statement_cache_type + extra_statement_cache_type; typedef sqlite::insert_statement insert_statement_type; typedef sqlite::select_statement select_statement_type; @@ -282,6 +282,10 @@ namespace odb binding& id_image_binding () {return root_statements_.id_image_binding ();} + binding& + optimistic_id_image_binding () { + return root_statements_.optimistic_id_image_binding ();} + // Statements. // insert_statement_type& @@ -348,31 +352,40 @@ namespace odb return *erase_; } - // Container statement cache. + // Extra (container, section) statement cache. // - container_statement_cache_type& - container_statment_cache () + extra_statement_cache_type& + extra_statement_cache () { - return container_statement_cache_.get (conn_, id_image_binding ()); + return extra_statement_cache_.get ( + conn_, + image_, + id_image_binding (), + &id_image_binding ()); // Note, not id+version. } public: - // select = total - id + base::select + // select = total - id - separate_load + base::select // insert = total - inverse - // update = total - inverse - id - readonly + // update = total - inverse - id - readonly - separate_update // static const std::size_t id_column_count = object_traits::id_column_count; static const std::size_t select_column_count = - object_traits::column_count - id_column_count + + object_traits::column_count - + id_column_count - + object_traits::separate_load_column_count + base_statements_type::select_column_count; static const std::size_t insert_column_count = - object_traits::column_count - object_traits::inverse_column_count; + object_traits::column_count - + object_traits::inverse_column_count; static const std::size_t update_column_count = insert_column_count - - object_traits::id_column_count - object_traits::readonly_column_count; + object_traits::id_column_count - + object_traits::readonly_column_count - + object_traits::separate_update_column_count; private: polymorphic_derived_object_statements ( @@ -385,8 +398,8 @@ namespace odb root_statements_type& root_statements_; base_statements_type& base_statements_; - container_statement_cache_ptr - container_statement_cache_; + extra_statement_cache_ptr + extra_statement_cache_; image_type image_; diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx new file mode 100644 index 0000000..3f0d9c4 --- /dev/null +++ b/odb/sqlite/section-statements.hxx @@ -0,0 +1,182 @@ +// file : odb/sqlite/section-statements.hxx +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX +#define ODB_SQLITE_SECTION_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Template argument is the section traits type. + // + template + class section_statements + { + public: + typedef ST traits; + + typedef typename traits::image_type image_type; + + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + + typedef sqlite::connection connection_type; + + section_statements (connection_type&, + image_type&, + binding& id, binding& idv); + + connection_type& + connection () {return conn_;} + + image_type& + image () {return image_;} + + const binding& + id_binding () {return id_binding_;} + + // Id and optimistic concurrency version (if any). + // + const binding& + idv_binding () {return idv_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_binding_version () const { return update_id_binding_version_;} + + void + update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // + // Statements. + // + + select_statement_type& + select_statement () + { + if (select_ == 0) + select_.reset ( + new (details::shared) select_statement_type ( + conn_, + traits::select_statement, + id_binding_, + select_image_binding_)); + + return *select_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + traits::update_statement, + update_image_binding_)); + + return *update_; + } + + public: + static const std::size_t id_column_count = traits::id_column_count; + static const std::size_t managed_optimistic_load_column_count = + traits::managed_optimistic_load_column_count; + static const std::size_t managed_optimistic_update_column_count = + traits::managed_optimistic_update_column_count; + static const std::size_t select_column_count = traits::load_column_count; + static const std::size_t update_column_count = + traits::update_column_count; + + private: + section_statements (const section_statements&); + section_statements& operator= (const section_statements&); + + protected: + connection_type& conn_; + + // These come from object_statements. + // + image_type& image_; + binding& id_binding_; + binding& idv_binding_; + + // Select binding. + // + std::size_t select_image_version_; + + static const std::size_t select_bind_count = + select_column_count != 0 || managed_optimistic_load_column_count != 0 + ? select_column_count + managed_optimistic_load_column_count + : 1; + + binding select_image_binding_; + bind select_image_bind_[select_bind_count]; + bool select_image_truncated_[select_bind_count]; + + // Update binding. + // + std::size_t update_image_version_; + std::size_t update_id_binding_version_; + + static const std::size_t update_bind_count = + update_column_count != 0 || managed_optimistic_update_column_count != 0 + ? update_column_count + id_column_count + + managed_optimistic_update_column_count + : 1; + + binding update_image_binding_; + bind update_image_bind_[update_bind_count]; + + details::shared_ptr select_; + details::shared_ptr update_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx new file mode 100644 index 0000000..b6945d9 --- /dev/null +++ b/odb/sqlite/section-statements.txx @@ -0,0 +1,42 @@ +// file : odb/sqlite/section-statements.txx +// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + section_statements:: + section_statements (connection_type& conn, + image_type& im, + binding& id, binding& idv) + : conn_ (conn), + image_ (im), + id_binding_ (id), + idv_binding_ (idv), + select_image_binding_ (select_image_bind_, + select_column_count + + managed_optimistic_load_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count + + managed_optimistic_update_column_count) + { + select_image_version_ = 0; + update_image_version_ = 0; + update_id_binding_version_ = 0; + + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + + for (std::size_t i (0); + i < select_column_count + managed_optimistic_load_column_count; + ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + } +} diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 2c5b321..a1e7678 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -29,58 +29,59 @@ namespace odb { namespace sqlite { - // The container_statement_cache class is only defined (and used) in + // The extra_statement_cache class is only defined (and used) in // the generated source file. However, object_statements may be // referenced from another source file in the case of a polymorphic - // hierarchy (though in this case the container statement cache is + // hierarchy (though in this case the extra statement cache is // not used). As a result, we cannot have a by-value member and // instead will store a pointer and lazily allocate the cache if // and when needed. We will also need to store a pointer to the // deleter function which will be initialized during allocation // (at that point we know that the cache class is defined). // - template - struct container_statement_cache_ptr + template + struct extra_statement_cache_ptr { + typedef I image_type; typedef sqlite::connection connection_type; - container_statement_cache_ptr (): p_ (0) {} - ~container_statement_cache_ptr () + extra_statement_cache_ptr (): p_ (0) {} + ~extra_statement_cache_ptr () { if (p_ != 0) - (this->*deleter_) (0, 0); + (this->*deleter_) (0, 0, 0, 0); } T& - get (connection_type& c, binding& id) + get (connection_type& c, image_type& im, binding& id, binding* idv) { if (p_ == 0) - allocate (&c, &id); + allocate (&c, &im, &id, (idv != 0 ? idv : &id)); return *p_; } private: void - allocate (connection_type*, binding*); + allocate (connection_type*, image_type*, binding*, binding*); private: T* p_; - void (container_statement_cache_ptr::*deleter_) ( - connection_type*, binding*); + void (extra_statement_cache_ptr::*deleter_) ( + connection_type*, image_type*, binding*, binding*); }; - template - void container_statement_cache_ptr:: - allocate (connection_type* c, binding* id) + template + void extra_statement_cache_ptr:: + allocate (connection_type* c, image_type* im, binding* id, binding* idv) { // To reduce object code size, this function acts as both allocator // and deleter. // if (p_ == 0) { - p_ = new T (*c, *id); - deleter_ = &container_statement_cache_ptr::allocate; + p_ = new T (*c, *im, *id, *idv); + deleter_ = &extra_statement_cache_ptr::allocate; } else delete p_; @@ -156,9 +157,11 @@ namespace odb optimistic_data (bind*); + binding* + id_image_binding () {return &id_image_binding_;} + // The id + optimistic column binding. // - std::size_t id_image_version_; binding id_image_binding_; details::shared_ptr erase_; @@ -168,6 +171,9 @@ namespace odb struct optimistic_data { optimistic_data (bind*) {} + + binding* + id_image_binding () {return 0;} }; template @@ -186,8 +192,8 @@ namespace odb pointer_cache_traits; typedef - typename object_traits::container_statement_cache_type - container_statement_cache_type; + typename object_traits::extra_statement_cache_type + extra_statement_cache_type; typedef sqlite::insert_statement insert_statement_type; typedef sqlite::select_statement select_statement_type; @@ -327,14 +333,10 @@ namespace odb binding& id_image_binding () {return id_image_binding_;} - // Optimistic id + managed column image binding. + // Optimistic id + managed column image binding. It points to + // the same suffix as id binding and they are always updated + // at the same time. // - std::size_t - optimistic_id_image_version () const {return od_.id_image_version_;} - - void - optimistic_id_image_version (std::size_t v) {od_.id_image_version_ = v;} - binding& optimistic_id_image_binding () {return od_.id_image_binding_;} @@ -416,35 +418,42 @@ namespace odb return *od_.erase_; } - // Container statement cache. + // Extra (container, section) statement cache. // - container_statement_cache_type& - container_statment_cache () + extra_statement_cache_type& + extra_statement_cache () { - return container_statement_cache_.get (conn_, id_image_binding_); + return extra_statement_cache_.get ( + conn_, image_, id_image_binding_, od_.id_image_binding ()); } public: - // select = total + // select = total - separate_load // insert = total - inverse - managed_optimistic // update = total - inverse - managed_optimistic - id - readonly + // - separate_update // - static const std::size_t select_column_count = - object_traits::column_count; - - static const std::size_t insert_column_count = - object_traits::column_count - object_traits::inverse_column_count - - object_traits::managed_optimistic_column_count; - - static const std::size_t update_column_count = insert_column_count - - object_traits::id_column_count - object_traits::readonly_column_count; - static const std::size_t id_column_count = object_traits::id_column_count; static const std::size_t managed_optimistic_column_count = object_traits::managed_optimistic_column_count; + static const std::size_t select_column_count = + object_traits::column_count - + object_traits::separate_load_column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - + object_traits::inverse_column_count - + object_traits::managed_optimistic_column_count; + + static const std::size_t update_column_count = + insert_column_count - + id_column_count - + object_traits::readonly_column_count - + object_traits::separate_update_column_count; + private: object_statements (const object_statements&); object_statements& operator= (const object_statements&); @@ -457,8 +466,11 @@ namespace odb clear_delayed_ (); private: - container_statement_cache_ptr - container_statement_cache_; + template + friend class polymorphic_derived_object_statements; + + extra_statement_cache_ptr + extra_statement_cache_; image_type image_; diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index f0e6138..15689c6 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -25,7 +25,6 @@ namespace odb object_traits::id_column_count + object_traits::managed_optimistic_column_count) { - id_image_version_ = 0; } // -- cgit v1.1 From c3248cd60418cee935508f62a3436970f9d234b2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 2 Sep 2013 14:40:50 +0200 Subject: Handle SQLite commit failures that don't automatically rollback transaction --- odb/sqlite/transaction-impl.cxx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 2a06288..3df1250 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + #include #include #include @@ -64,6 +66,33 @@ namespace odb } } + // In SQLite, when a commit fails (e.g., because of the deferred + // foreign key constraint violation), the transaction may not + // be automatically rolled back. So we have to do it ourselves. + // + struct commit_guard + { + commit_guard (connection& c): c_ (&c) {} + void release () {c_ = 0;} + + ~commit_guard () + { + if (c_ != 0 && sqlite3_get_autocommit (c_->handle ()) == 0) + { + // This is happening while another exception is active. + // + try + { + c_->statement_cache ().rollback_statement ().execute (); + } + catch (...) {} + } + } + + private: + connection* c_; + }; + void transaction_impl:: commit () { @@ -79,7 +108,11 @@ namespace odb // connection_->clear (); - connection_->statement_cache ().commit_statement ().execute (); + { + commit_guard cg (*connection_); + connection_->statement_cache ().commit_statement ().execute (); + cg.release (); + } // Release the connection. // -- cgit v1.1 From 31fd2870497686667f20b2d43467a07482f8ab40 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Sep 2013 14:10:45 +0200 Subject: Schema versioning support --- odb/sqlite/container-statements.hxx | 20 ++- odb/sqlite/container-statements.txx | 5 +- odb/sqlite/database.cxx | 7 +- odb/sqlite/forward.hxx | 4 +- odb/sqlite/no-id-object-result.hxx | 6 +- odb/sqlite/no-id-object-result.txx | 14 +- odb/sqlite/no-id-object-statements.hxx | 1 + odb/sqlite/polymorphic-object-result.hxx | 6 +- odb/sqlite/polymorphic-object-result.txx | 30 ++-- odb/sqlite/polymorphic-object-statements.hxx | 23 ++- odb/sqlite/polymorphic-object-statements.txx | 16 +- odb/sqlite/query.cxx | 16 +- odb/sqlite/section-statements.hxx | 3 + odb/sqlite/simple-object-result.hxx | 6 +- odb/sqlite/simple-object-result.txx | 18 ++- odb/sqlite/simple-object-statements.hxx | 21 ++- odb/sqlite/simple-object-statements.txx | 19 ++- odb/sqlite/statement-cache.cxx | 1 + odb/sqlite/statement-cache.hxx | 1 + odb/sqlite/statement-cache.txx | 15 ++ odb/sqlite/statement.cxx | 206 +++++++++++++++++++------ odb/sqlite/statement.hxx | 54 ++++++- odb/sqlite/traits-calls.hxx | 215 +++++++++++++++++++++++++++ odb/sqlite/view-result.hxx | 6 +- odb/sqlite/view-result.txx | 14 +- 25 files changed, 607 insertions(+), 120 deletions(-) create mode 100644 odb/sqlite/traits-calls.hxx diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index e9c2d3b..058a255 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -10,6 +10,7 @@ #include // std::size_t #include +#include #include #include @@ -57,6 +58,14 @@ namespace odb return functions_; } + // Schema version. + // + const schema_version_migration& + version_migration () const {return *svm_;} + + void + version_migration (const schema_version_migration& svm) {svm_ = &svm;} + // Id image binding (external). // const binding& @@ -114,7 +123,10 @@ namespace odb if (insert_ == 0) insert_.reset ( new (details::shared) insert_statement_type ( - conn_, insert_text_, insert_image_binding_)); + conn_, + insert_text_, + versioned_, // Process if versioned. + insert_image_binding_)); return *insert_; } @@ -127,6 +139,8 @@ namespace odb new (details::shared) select_statement_type ( conn_, select_text_, + versioned_, // Process if versioned. + false, // Don't optimize. id_binding_, select_image_binding_)); @@ -167,6 +181,9 @@ namespace odb const char* select_text_; const char* delete_text_; + bool versioned_; + const schema_version_migration* svm_; + details::shared_ptr insert_; details::shared_ptr select_; details::shared_ptr delete_; @@ -270,6 +287,7 @@ namespace odb new (details::shared) update_statement_type ( this->conn_, update_text_, + this->versioned_, // Process if versioned. update_image_binding_)); return *update_; diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 5024b5b..6458be8 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -18,7 +18,8 @@ namespace odb id_binding_ (id), functions_ (this), insert_image_binding_ (0, 0), // Initialized by impl. - select_image_binding_ (0, 0) // Initialized by impl. + select_image_binding_ (0, 0), // Initialized by impl. + svm_ (0) { functions_.insert_ = &traits::insert; functions_.select_ = &traits::select; @@ -80,6 +81,8 @@ namespace odb this->insert_text_ = traits::insert_statement; this->select_text_ = traits::select_statement; this->delete_text_ = traits::delete_statement; + + this->versioned_ = traits::versioned; } // smart_container_statements_impl diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index d5399f7..bed0b32 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -230,7 +230,12 @@ namespace odb try { - select_statement st (c, text, param, result); + select_statement st (c, + text, + false, // Don't process. + false, // Don't optimize. + param, + result); st.execute (); auto_result ar (st); diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 456ff43..8904011 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -43,7 +43,9 @@ namespace odb { statement_select, statement_insert, - statement_update + statement_update, + statement_delete, + statement_generic }; class binding; diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 236bf82..49576c3 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -9,6 +9,7 @@ #include // std::size_t +#include #include #include @@ -16,6 +17,7 @@ #include #include // query_base, query_params #include +#include namespace odb { @@ -40,7 +42,8 @@ namespace odb no_id_object_result_impl (const query_base&, const details::shared_ptr&, - statements_type&); + statements_type&, + const schema_version_migration*); virtual void load (object_type&); @@ -66,6 +69,7 @@ namespace odb details::shared_ptr params_; details::shared_ptr statement_; statements_type& statements_; + object_traits_calls tc_; }; } } diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index e857820..cf0fc15 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -37,11 +37,13 @@ namespace odb no_id_object_result_impl:: no_id_object_result_impl (const query_base& q, const details::shared_ptr& s, - statements_type& sts) + statements_type& sts, + const schema_version_migration* svm) : base_type (sts.connection ()), params_ (q.parameters ()), statement_ (s), - statements_ (sts) + statements_ (sts), + tc_ (svm) { } @@ -57,7 +59,7 @@ namespace odb if (im.version != statements_.select_image_version ()) { binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); + tc_.bind (b.bind, im, statement_select); statements_.select_image_version (im.version); b.version++; } @@ -66,13 +68,13 @@ namespace odb if (r == select_statement::truncated) { - if (object_traits::grow (im, statements_.select_image_truncated ())) + if (tc_.grow (im, statements_.select_image_truncated ())) im.version++; if (im.version != statements_.select_image_version ()) { binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); + tc_.bind (b.bind, im, statement_select); statements_.select_image_version (im.version); b.version++; statement_->reload (); @@ -80,7 +82,7 @@ namespace odb } object_traits::callback (this->db_, obj, callback_event::pre_load); - object_traits::init (obj, im, &this->db_); + tc_.init (obj, im, &this->db_); object_traits::callback (this->db_, obj, callback_event::post_load); } diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 6939fc7..2e0cb05 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -87,6 +87,7 @@ namespace odb new (details::shared) insert_statement_type ( conn_, object_traits::persist_statement, + object_traits::versioned, // Process if versioned. insert_image_binding_)); } diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 493bced..7192a26 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -9,6 +9,7 @@ #include // std::size_t +#include #include #include @@ -16,6 +17,7 @@ #include #include // query_base, query_params #include +#include namespace odb { @@ -48,7 +50,8 @@ namespace odb polymorphic_object_result_impl ( const query_base&, const details::shared_ptr&, - statements_type&); + statements_type&, + const schema_version_migration*); virtual void load (object_type*, bool fetch); @@ -84,6 +87,7 @@ namespace odb details::shared_ptr params_; details::shared_ptr statement_; statements_type& statements_; + object_traits_calls tc_; }; } } diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 9c79414..6d761b5 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -40,11 +40,13 @@ namespace odb polymorphic_object_result_impl ( const query_base& q, const details::shared_ptr& s, - statements_type& sts) + statements_type& sts, + const schema_version_migration* svm) : base_type (sts.connection ()), params_ (q.parameters ()), statement_ (s), - statements_ (sts) + statements_ (sts), + tc_ (svm) { } @@ -123,7 +125,7 @@ namespace odb callback_event ce (callback_event::pre_load); pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - object_traits::init (*pobj, i, &this->db_); + tc_.init (*pobj, i, &this->db_); // Initialize the id image and binding and load the rest of the object // (containers, dynamic part, etc). @@ -139,7 +141,7 @@ namespace odb idb.version++; } - object_traits::load_ (statements_, *pobj); + tc_.load_ (statements_, *pobj, false); // Load the dynamic part of the object unless static and dynamic // types are the same. @@ -150,7 +152,7 @@ namespace odb pi.dispatch (info_type::call_load, this->db_, pobj, &d); }; - rsts.load_delayed (); + rsts.load_delayed (tc_.version ()); l.unlock (); ce = callback_event::post_load; @@ -199,14 +201,16 @@ namespace odb typedef object_traits_impl traits; static bool - rebind (typename traits::statements_type& sts) + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) { typename traits::image_type& im (sts.image ()); if (traits::check_version (sts.select_image_versions (), im)) { binding& b (sts.select_image_binding (traits::depth)); - traits::bind (b.bind, 0, 0, im, statement_select); + object_traits_calls tc (svm); + tc.bind (b.bind, 0, 0, im, statement_select); traits::update_version ( sts.select_image_versions (), im, sts.select_image_bindings ()); return true; @@ -224,14 +228,16 @@ namespace odb typedef object_traits_impl traits; static bool - rebind (typename traits::statements_type& sts) + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) { typename traits::image_type& im (sts.image ()); if (im.version != sts.select_image_version ()) { binding& b (sts.select_image_binding ()); - traits::bind (b.bind, im, statement_select); + object_traits_calls tc (svm); + tc.bind (b.bind, im, statement_select); sts.select_image_version (im.version); b.version++; return true; @@ -250,7 +256,7 @@ namespace odb // The image can grow between calls to load() as a result of other // statements execution. // - image_rebind::rebind (statements_); + image_rebind::rebind (statements_, tc_.version ()); select_statement::result r (statement_->load ()); @@ -258,10 +264,10 @@ namespace odb { typename object_traits::image_type& im (statements_.image ()); - if (object_traits::grow (im, statements_.select_image_truncated ())) + if (tc_.grow (im, statements_.select_image_truncated ())) im.version++; - if (image_rebind::rebind (statements_)) + if (image_rebind::rebind (statements_, tc_.version ())) statement_->reload (); } } diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index fa5f6af..2586cb0 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -105,6 +105,8 @@ namespace odb new (details::shared) select_statement_type ( this->conn_, object_traits::find_discriminator_statement, + false, // Doesn't need to be processed. + false, // Don't optimize. discriminator_id_image_binding_, discriminator_image_binding_)); } @@ -118,6 +120,18 @@ namespace odb virtual ~polymorphic_root_object_statements (); + // Static "override" (statements type). + // + void + load_delayed (const schema_version_migration* svm) + { + assert (this->locked ()); + + if (!this->delayed_.empty ()) + this->template load_delayed_ ( + svm); + } + public: static const std::size_t id_column_count = object_statements::id_column_count; @@ -191,7 +205,10 @@ namespace odb // Delayed loading. // static void - delayed_loader (odb::database&, const id_type&, root_type&); + delayed_loader (odb::database&, + const id_type&, + root_type&, + const schema_version_migration*); public: // Root and immediate base statements. @@ -297,6 +314,7 @@ namespace odb new (details::shared) insert_statement_type ( conn_, object_traits::persist_statement, + object_traits::versioned, // Process if versioned. insert_image_binding_)); } @@ -315,6 +333,8 @@ namespace odb new (details::shared) select_statement_type ( conn_, object_traits::find_statements[i], + object_traits::versioned, // Process if versioned. + false, // Don't optimize. root_statements_.id_image_binding (), select_image_bindings_[i])); } @@ -331,6 +351,7 @@ namespace odb new (details::shared) update_statement_type ( conn_, object_traits::update_statement, + object_traits::versioned, // Process if versioned. update_image_binding_)); } diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index 999eb3e..b97cd14 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -10,6 +10,7 @@ #include #include #include +#include namespace odb { @@ -111,7 +112,10 @@ namespace odb template void polymorphic_derived_object_statements:: - delayed_loader (odb::database& db, const id_type& id, root_type& robj) + delayed_loader (odb::database& db, + const id_type& id, + root_type& robj, + const schema_version_migration* svm) { connection_type& conn (transaction::current ().connection ()); polymorphic_derived_object_statements& sts ( @@ -122,14 +126,16 @@ namespace odb // The same code as in object_statements::load_delayed_(). // - if (!object_traits::find_ (sts, &id)) + object_traits_calls tc (svm); + + if (!tc.find_ (sts, &id)) throw object_not_persistent (); object_traits::callback (db, obj, callback_event::pre_load); - object_traits::init (obj, sts.image (), &db); - object_traits::load_ (sts, obj); // Load containers, etc. + tc.init (obj, sts.image (), &db); + tc.load_ (sts, obj, false); // Load containers, etc. - rsts.load_delayed (); + rsts.load_delayed (svm); { typename root_statements_type::auto_unlock u (rsts); diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 120be98..fc1a046 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -159,8 +159,8 @@ namespace odb // We don't want extra spaces after '(' as well as before ',' // and ')'. // - if (last != ' ' && last != '(' && - first != ' ' && first != ',' && first != ')') + if (last != ' ' && last != '\n' && last != '(' && + first != ' ' && first != '\n' && first != ',' && first != ')') s += ' '; s += q; @@ -213,7 +213,7 @@ namespace odb // It either has to be an exact match, or there should be // a whitespace following the keyword. // - if (s.size () == n || s[n] == ' ' || s[n] =='\t') + if (s.size () == n || s[n] == ' ' || s[n] == '\n' || s[n] =='\t') return true; } @@ -272,7 +272,7 @@ namespace odb { case clause_part::kind_column: { - if (last != ' ' && last != '(') + if (last != ' ' && last != '\n' && last != '(') r += ' '; r += i->part; @@ -280,7 +280,7 @@ namespace odb } case clause_part::kind_param: { - if (last != ' ' && last != '(') + if (last != ' ' && last != '\n' && last != '(') r += ' '; // Add the conversion expression, if any. @@ -307,8 +307,8 @@ namespace odb const string& p (i->part); char first (!p.empty () ? p[0] : ' '); - if (last != ' ' && last != '(' && - first != ' ' && first != ',' && first != ')') + if (last != ' ' && first != '\n' && last != '(' && + first != ' ' && last != '\n' && first != ',' && first != ')') r += ' '; r += p; @@ -316,7 +316,7 @@ namespace odb } case clause_part::kind_bool: { - if (last != ' ' && last != '(') + if (last != ' ' && last != '\n' && last != '(') r += ' '; r += i->bool_part ? "1" : "0"; diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 3f0d9c4..8bdbda1 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -100,6 +100,8 @@ namespace odb new (details::shared) select_statement_type ( conn_, traits::select_statement, + traits::versioned, // Process if versioned. + false, // Don't optimize. id_binding_, select_image_binding_)); @@ -114,6 +116,7 @@ namespace odb new (details::shared) update_statement_type ( conn_, traits::update_statement, + traits::versioned, // Process if versioned. update_image_binding_)); return *update_; diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 9dd258a..3888a56 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -9,6 +9,7 @@ #include // std::size_t +#include #include #include @@ -16,6 +17,7 @@ #include #include // query_base, query_params #include +#include namespace odb { @@ -41,7 +43,8 @@ namespace odb object_result_impl (const query_base&, const details::shared_ptr&, - statements_type&); + statements_type&, + const schema_version_migration*); virtual void load (object_type&, bool fetch); @@ -74,6 +77,7 @@ namespace odb details::shared_ptr params_; details::shared_ptr statement_; statements_type& statements_; + object_traits_calls tc_; }; } } diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index fe31300..2c4340d 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -39,11 +39,13 @@ namespace odb object_result_impl:: object_result_impl (const query_base& q, const details::shared_ptr& s, - statements_type& sts) + statements_type& sts, + const schema_version_migration* svm) : base_type (sts.connection ()), params_ (q.parameters ()), statement_ (s), - statements_ (sts) + statements_ (sts), + tc_ (svm) { } @@ -62,7 +64,7 @@ namespace odb object_traits::callback (this->db_, obj, callback_event::pre_load); typename object_traits::image_type& i (statements_.image ()); - object_traits::init (obj, i, &this->db_); + tc_.init (obj, i, &this->db_); // Initialize the id image and binding and load the rest of the object // (containers, etc). @@ -78,8 +80,8 @@ namespace odb idb.version++; } - object_traits::load_ (statements_, obj); - statements_.load_delayed (); + tc_.load_ (statements_, obj, false); + statements_.load_delayed (tc_.version ()); l.unlock (); object_traits::callback (this->db_, obj, callback_event::post_load); } @@ -118,7 +120,7 @@ namespace odb if (im.version != statements_.select_image_version ()) { binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); + tc_.bind (b.bind, im, statement_select); statements_.select_image_version (im.version); b.version++; } @@ -127,13 +129,13 @@ namespace odb if (r == select_statement::truncated) { - if (object_traits::grow (im, statements_.select_image_truncated ())) + if (tc_.grow (im, statements_.select_image_truncated ())) im.version++; if (im.version != statements_.select_image_version ()) { binding& b (statements_.select_image_binding ()); - object_traits::bind (b.bind, im, statement_select); + tc_.bind (b.bind, im, statement_select); statements_.select_image_version (im.version); b.version++; statement_->reload (); diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index a1e7678..f438d90 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -244,8 +244,10 @@ namespace odb // Delayed loading. // - typedef void (*loader_function) ( - odb::database&, const id_type&, object_type&); + typedef void (*loader_function) (odb::database&, + const id_type&, + object_type&, + const schema_version_migration*); void delay_load (const id_type& id, @@ -257,12 +259,12 @@ namespace odb } void - load_delayed () + load_delayed (const schema_version_migration* svm) { assert (locked ()); if (!delayed_.empty ()) - load_delayed_ (); + load_delayed_ (svm); } void @@ -351,6 +353,7 @@ namespace odb new (details::shared) insert_statement_type ( conn_, object_traits::persist_statement, + object_traits::versioned, // Process if versioned. insert_image_binding_)); } @@ -366,6 +369,8 @@ namespace odb new (details::shared) select_statement_type ( conn_, object_traits::find_statement, + object_traits::versioned, // Process if versioned. + false, // Don't optimize. id_image_binding_, select_image_binding_)); } @@ -382,6 +387,7 @@ namespace odb new (details::shared) update_statement_type ( conn_, object_traits::update_statement, + object_traits::versioned, // Process if versioned. update_image_binding_)); } @@ -458,14 +464,15 @@ namespace odb object_statements (const object_statements&); object_statements& operator= (const object_statements&); - private: + protected: + template void - load_delayed_ (); + load_delayed_ (const schema_version_migration*); void clear_delayed_ (); - private: + protected: template friend class polymorphic_derived_object_statements; diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 15689c6..552806c 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -8,6 +8,7 @@ #include #include +#include namespace odb { @@ -70,8 +71,9 @@ namespace odb } template + template void object_statements:: - load_delayed_ () + load_delayed_ (const schema_version_migration* svm) { database& db (connection ().database ()); @@ -86,7 +88,9 @@ namespace odb if (l.loader == 0) { - if (!object_traits::find_ (*this, &l.id)) + object_traits_calls tc (svm); + + if (!tc.find_ (static_cast (*this), &l.id)) throw object_not_persistent (); object_traits::callback (db, *l.obj, callback_event::pre_load); @@ -95,11 +99,14 @@ namespace odb // loads being added to the delayed_ vector. We need to process // those before we call the post callback. // - object_traits::init (*l.obj, image (), &db); - object_traits::load_ (*this, *l.obj); // Load containers, etc. + tc.init (*l.obj, image (), &db); + + // Load containers, etc. + // + tc.load_ (static_cast (*this), *l.obj, false); if (!delayed_.empty ()) - load_delayed_ (); + load_delayed_ (svm); // Temporarily unlock the statement for the post_load call so that // it can load objects of this type recursively. This is safe to do @@ -115,7 +122,7 @@ namespace odb } } else - l.loader (db, l.id, *l.obj); + l.loader (db, l.id, *l.obj, svm); pointer_cache_traits::load (ig.position ()); ig.release (); diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index bb34aed..e29f83e 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -13,6 +13,7 @@ namespace odb statement_cache:: statement_cache (connection& conn) : conn_ (conn), + version_seq_ (conn.database ().schema_version_sequence ()), // String lengths below include '\0', as per SQLite manual // suggestions. // diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index bd90a44..f943ffc 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -89,6 +89,7 @@ namespace odb details::type_info_comparator> map; connection& conn_; + unsigned int version_seq_; details::shared_ptr begin_; mutable details::shared_ptr begin_immediate_; diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 4c6e3cd..8d8e358 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + namespace odb { namespace sqlite @@ -15,6 +17,16 @@ namespace odb typename object_traits_impl::statements_type statements_type; + // Clear the cache if the database version has changed. This + // makes sure we don't re-use statements that correspond to + // the old schema. + // + if (version_seq_ != conn_.database ().schema_version_sequence ()) + { + map_.clear (); + version_seq_ = conn_.database ().schema_version_sequence (); + } + map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) @@ -31,6 +43,9 @@ namespace odb view_statements& statement_cache:: find_view () { + // We don't cache any statements for views so no need to clear + // the cache. + map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index de71e12..f20d8da 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -24,6 +24,9 @@ namespace odb statement:: ~statement () { + if (empty ()) + return; + { odb::tracer* t; if ((t = conn_.transaction_tracer ()) || @@ -39,8 +42,50 @@ namespace odb } void statement:: - init (const char* text, std::size_t text_size) + init (const char* text, + std::size_t text_size, + statement_kind sk, + const binding* proc, + bool optimize) { + string tmp; + if (proc != 0) + { + switch (sk) + { + case statement_select: + process_select (text, + &proc->bind->buffer, proc->count, sizeof (bind), + '"', '"', + optimize, + tmp); + break; + case statement_insert: + process_insert (text, + &proc->bind->buffer, proc->count, sizeof (bind), + '?', + tmp); + break; + case statement_update: + process_update (text, + &proc->bind->buffer, proc->count, sizeof (bind), + '?', + tmp); + break; + case statement_delete: + case statement_generic: + assert (false); + } + + text = tmp.c_str (); + text_size = tmp.size (); + } + + // Empty statement. + // + if (*text == '\0') + return; + int e; sqlite3_stmt* stmt (0); while ((e = sqlite3_prepare_v2 (conn_.handle (), @@ -83,15 +128,18 @@ namespace odb // SQLite parameters are counted from 1. // - n++; - for (size_t i (1); e == SQLITE_OK && i < n; ++i, ++p) + for (size_t i (0), j (1); e == SQLITE_OK && i < n; ++i) { - const bind& b (*p); - int j (static_cast (i)); + const bind& b (p[i]); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (static_cast (j++)); if (b.is_null != 0 && *b.is_null) { - e = sqlite3_bind_null (stmt_, j); + e = sqlite3_bind_null (stmt_, c); continue; } @@ -100,19 +148,19 @@ namespace odb case bind::integer: { long long v (*static_cast (b.buffer)); - e = sqlite3_bind_int64 (stmt_, j, static_cast (v)); + e = sqlite3_bind_int64 (stmt_, c, static_cast (v)); break; } case bind::real: { double v (*static_cast (b.buffer)); - e = sqlite3_bind_double (stmt_, j, v); + e = sqlite3_bind_double (stmt_, c, v); break; } case bind::text: { e = sqlite3_bind_text (stmt_, - j, + c, static_cast (b.buffer), static_cast (*b.size), SQLITE_STATIC); @@ -121,7 +169,7 @@ namespace odb case bind::text16: { e = sqlite3_bind_text16 (stmt_, - j, + c, b.buffer, static_cast (*b.size), SQLITE_STATIC); @@ -130,7 +178,7 @@ namespace odb case bind::blob: { e = sqlite3_bind_blob (stmt_, - j, + c, b.buffer, static_cast (*b.size), SQLITE_STATIC); @@ -144,21 +192,20 @@ namespace odb } bool statement:: - bind_result (const bind* p, size_t n, bool truncated) + bind_result (const bind* p, size_t count, bool truncated) { - // Make sure that the number of columns in the result returned by - // the database matches the number that we expect. A common cause - // of this assertion is a native view with a number of data members - // not matching the number of columns in the SELECT-list. - // - assert (static_cast (sqlite3_data_count (stmt_)) == n); - bool r (true); + int col_count (sqlite3_data_count (stmt_)); - for (size_t i (0); i < n; ++i) + int col (0); + for (size_t i (0); i != count && col != col_count; ++i) { const bind& b (p[i]); - int j (static_cast (i)); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (col++); if (truncated && (b.truncated == 0 || !*b.truncated)) continue; @@ -170,7 +217,7 @@ namespace odb // if (!truncated) { - *b.is_null = sqlite3_column_type (stmt_, j) == SQLITE_NULL; + *b.is_null = sqlite3_column_type (stmt_, c) == SQLITE_NULL; if (*b.is_null) continue; @@ -181,13 +228,13 @@ namespace odb case bind::integer: { *static_cast (b.buffer) = - static_cast (sqlite3_column_int64 (stmt_, j)); + static_cast (sqlite3_column_int64 (stmt_, c)); break; } case bind::real: { *static_cast (b.buffer) = - sqlite3_column_double (stmt_, j); + sqlite3_column_double (stmt_, c); break; } case bind::text: @@ -203,15 +250,15 @@ namespace odb if (b.type != bind::text16) { d = b.type == bind::text - ? sqlite3_column_text (stmt_, j) - : sqlite3_column_blob (stmt_, j); - *b.size = static_cast (sqlite3_column_bytes (stmt_, j)); + ? sqlite3_column_text (stmt_, c) + : sqlite3_column_blob (stmt_, c); + *b.size = static_cast (sqlite3_column_bytes (stmt_, c)); } else { - d = sqlite3_column_text16 (stmt_, j); + d = sqlite3_column_text16 (stmt_, c); *b.size = static_cast ( - sqlite3_column_bytes16 (stmt_, j)); + sqlite3_column_bytes16 (stmt_, c)); } if (*b.size > b.capacity) @@ -229,6 +276,13 @@ namespace odb } } + // Make sure that the number of columns in the result returned by + // the database matches the number that we expect. A common cause + // of this assertion is a native view with a number of data members + // not matching the number of columns in the SELECT-list. + // + assert (col == col_count); + return r; } @@ -237,14 +291,18 @@ namespace odb generic_statement:: generic_statement (connection_type& conn, const string& text) - : statement (conn, text), + : statement (conn, + text, statement_generic, + 0, false), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } generic_statement:: generic_statement (connection_type& conn, const char* text) - : statement (conn, text), + : statement (conn, + text, statement_generic, + 0, false), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } @@ -253,7 +311,9 @@ namespace odb generic_statement (connection_type& conn, const char* text, std::size_t text_size) - : statement (conn, text, text_size), + : statement (conn, + text, text_size, statement_generic, + 0, false), result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) { } @@ -312,32 +372,58 @@ namespace odb select_statement:: select_statement (connection_type& conn, const string& text, + bool process, + bool optimize, binding& param, binding& result) - : statement (conn, text), param_ (¶m), result_ (result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (¶m), + result_ (result) { } select_statement:: select_statement (connection_type& conn, const char* text, + bool process, + bool optimize, binding& param, binding& result) - : statement (conn, text), param_ (¶m), result_ (result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (¶m), + result_ (result) { } select_statement:: select_statement (connection_type& conn, const string& text, + bool process, + bool optimize, binding& result) - : statement (conn, text), param_ (0), result_ (result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (0), + result_ (result) { } select_statement:: - select_statement (connection_type& conn, const char* text, binding& result) - : statement (conn, text), param_ (0), result_ (result) + select_statement (connection_type& conn, + const char* text, + bool process, + bool optimize, + binding& result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (0), + result_ (result) { } @@ -428,14 +514,24 @@ namespace odb insert_statement:: insert_statement (connection_type& conn, const string& text, + bool process, binding& param) - : statement (conn, text), param_ (param) + : statement (conn, + text, statement_insert, + (process ? ¶m : 0), false), + param_ (param) { } insert_statement:: - insert_statement (connection_type& conn, const char* text, binding& param) - : statement (conn, text), param_ (param) + insert_statement (connection_type& conn, + const char* text, + bool process, + binding& param) + : statement (conn, + text, statement_insert, + (process ? ¶m : 0), false), + param_ (param) { } @@ -499,14 +595,24 @@ namespace odb update_statement:: update_statement (connection_type& conn, const string& text, + bool process, binding& param) - : statement (conn, text), param_ (param) + : statement (conn, + text, statement_update, + (process ? ¶m : 0), false), + param_ (param) { } update_statement:: - update_statement (connection_type& conn, const char* text, binding& param) - : statement (conn, text), param_ (param) + update_statement (connection_type& conn, + const char* text, + bool process, + binding& param) + : statement (conn, + text, statement_update, + (process ? ¶m : 0), false), + param_ (param) { } @@ -554,13 +660,21 @@ namespace odb delete_statement (connection_type& conn, const string& text, binding& param) - : statement (conn, text), param_ (param) + : statement (conn, + text, statement_delete, + 0, false), + param_ (param) { } delete_statement:: - delete_statement (connection_type& conn, const char* text, binding& param) - : statement (conn, text), param_ (param) + delete_statement (connection_type& conn, + const char* text, + binding& param) + : statement (conn, + text, statement_delete, + 0, false), + param_ (param) { } diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index eb55e58..05fa9bd 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -53,25 +53,49 @@ namespace odb return conn_; } + // A statement can be empty. This is used to handle situations + // where a SELECT or UPDATE statement ends up not having any + // columns after processing. An empty statement cannot be + // executed. + // + bool + empty () const + { + return stmt_ == 0; + } + protected: - statement (connection_type& conn, const std::string& text) + // We keep two versions to take advantage of std::string COW. + // + statement (connection_type& conn, + const std::string& text, + statement_kind sk, + const binding* process, + bool optimize) : conn_ (conn) { - init (text.c_str (), text.size ()); + init (text.c_str (), text.size (), sk, process, optimize); } - statement (connection_type& conn, const char* text) + statement (connection_type& conn, + const char* text, + statement_kind sk, + const binding* process, + bool optimize) : conn_ (conn) { - init (text, std::strlen (text)); + init (text, std::strlen (text), sk, process, optimize); } statement (connection_type& conn, const char* text, - std::size_t text_size) + std::size_t text_size, + statement_kind sk, + const binding* process, + bool optimize) : conn_ (conn) { - init (text, text_size); + init (text, text_size, sk, process, optimize); } protected: @@ -128,7 +152,11 @@ namespace odb private: void - init (const char* text, std::size_t text_size); + init (const char* text, + std::size_t text_size, + statement_kind, + const binding* process, + bool optimize); // Doubly-linked list of active statements. // @@ -188,20 +216,28 @@ namespace odb public: select_statement (connection_type& conn, const std::string& text, + bool process_text, + bool optimize_text, binding& param, binding& result); select_statement (connection_type& conn, const char* text, + bool process_text, + bool optimize_text, binding& param, binding& result); select_statement (connection_type& conn, const std::string& text, + bool process_text, + bool optimize_text, binding& result); select_statement (connection_type& conn, const char* text, + bool process_text, + bool optimize_text, binding& result); // Common select interface expected by the generated code. @@ -283,10 +319,12 @@ namespace odb public: insert_statement (connection_type& conn, const std::string& text, + bool process_text, binding& param); insert_statement (connection_type& conn, const char* text, + bool process_text, binding& param); // Return true if successful and false if the row is a duplicate. @@ -311,10 +349,12 @@ namespace odb public: update_statement (connection_type& conn, const std::string& text, + bool process_text, binding& param); update_statement (connection_type& conn, const char* text, + bool process_text, binding& param); unsigned long long diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx new file mode 100644 index 0000000..1e5bd8d --- /dev/null +++ b/odb/sqlite/traits-calls.hxx @@ -0,0 +1,215 @@ +// file : odb/sqlite/traits-calls.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRAITS_CALLS_HXX +#define ODB_SQLITE_TRAITS_CALLS_HXX + +#include + +#include // std::size_t + +#include +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // object_traits_calls + // + + template ::versioned> + struct object_traits_calls; + + template + struct object_traits_calls + { + typedef object_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + object_traits_calls (const schema_version_migration*) {} + + const schema_version_migration* + version () const {return 0;} + + static bool + grow (image_type& i, bool* t) + { + return traits::grow (i, t); + } + + static void + bind (bind_type* b, image_type& i, statement_kind sk) + { + traits::bind (b, i, sk); + } + + // Poly-derived version. + // + static void + bind (bind_type* b, + const bind_type* id, std::size_t id_size, + image_type& i, + statement_kind sk) + { + traits::bind (b, id, id_size, i, sk); + } + + static void + init (T& o, const image_type& i, odb::database* db) + { + traits::init (o, i, db); + } + + static bool + find_ (typename traits::statements_type& sts, + const typename traits::id_type* id) + { + return traits::find_ (sts, id); + } + + static void + load_ (typename traits::statements_type& sts, T& o, bool reload) + { + return traits::load_ (sts, o, reload); + } + }; + + template + struct object_traits_calls + { + typedef object_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + object_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + + const schema_version_migration* + version () const {return &svm_;} + + bool + grow (image_type& i, bool* t) const + { + return traits::grow (i, t, svm_); + } + + void + bind (bind_type* b, image_type& i, statement_kind sk) const + { + traits::bind (b, i, sk, svm_); + } + + // Poly-derived version. + // + void + bind (bind_type* b, + const bind_type* id, std::size_t id_size, + image_type& i, + statement_kind sk) const + { + traits::bind (b, id, id_size, i, sk, svm_); + } + + void + init (T& o, const image_type& i, odb::database* db) const + { + traits::init (o, i, db, svm_); + } + + bool + find_ (typename traits::statements_type& sts, + const typename traits::id_type* id) const + { + return traits::find_ (sts, id, svm_); + } + + void + load_ (typename traits::statements_type& sts, T& o, bool reload) const + { + return traits::load_ (sts, o, reload, svm_); + } + + private: + const schema_version_migration& svm_; + }; + + // + // view_traits_calls + // + + template ::versioned> + struct view_traits_calls; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + view_traits_calls (const schema_version_migration*) {} + + static bool + grow (image_type& i, bool* t) + { + return traits::grow (i, t); + } + + static void + bind (bind_type* b, image_type& i) + { + traits::bind (b, i); + } + + static void + init (T& o, const image_type& i, odb::database* db) + { + traits::init (o, i, db); + } + }; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + view_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + + bool + grow (image_type& i, bool* t) const + { + return traits::grow (i, t, svm_); + } + + void + bind (bind_type* b, image_type& i) const + { + traits::bind (b, i, svm_); + } + + void + init (T& o, const image_type& i, odb::database* db) const + { + traits::init (o, i, db, svm_); + } + + private: + const schema_version_migration& svm_; + }; + } +} + +#include + +#endif // ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index fd189e6..0e05adb 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -9,6 +9,7 @@ #include // std::size_t +#include #include #include @@ -16,6 +17,7 @@ #include #include // query_base, query_params #include +#include namespace odb { @@ -40,7 +42,8 @@ namespace odb view_result_impl (const query_base&, const details::shared_ptr&, - statements_type&); + statements_type&, + const schema_version_migration*); virtual void load (view_type&); @@ -66,6 +69,7 @@ namespace odb details::shared_ptr params_; details::shared_ptr statement_; statements_type& statements_; + view_traits_calls tc_; }; } } diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index d22a440..d13b58e 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -37,11 +37,13 @@ namespace odb view_result_impl:: view_result_impl (const query_base& q, const details::shared_ptr& s, - statements_type& sts) + statements_type& sts, + const schema_version_migration* svm) : base_type (sts.connection ()), params_ (q.parameters ()), statement_ (s), - statements_ (sts) + statements_ (sts), + tc_ (svm) { } @@ -57,7 +59,7 @@ namespace odb if (im.version != statements_.image_version ()) { binding& b (statements_.image_binding ()); - view_traits::bind (b.bind, im); + tc_.bind (b.bind, im); statements_.image_version (im.version); b.version++; } @@ -66,13 +68,13 @@ namespace odb if (r == select_statement::truncated) { - if (view_traits::grow (im, statements_.image_truncated ())) + if (tc_.grow (im, statements_.image_truncated ())) im.version++; if (im.version != statements_.image_version ()) { binding& b (statements_.image_binding ()); - view_traits::bind (b.bind, im); + tc_.bind (b.bind, im); statements_.image_version (im.version); b.version++; statement_->reload (); @@ -80,7 +82,7 @@ namespace odb } view_traits::callback (this->db_, view, callback_event::pre_load); - view_traits::init (view, im, &this->db_); + tc_.init (view, im, &this->db_); view_traits::callback (this->db_, view, callback_event::post_load); } -- cgit v1.1 From 0392ff4895fed7eb6a3f6befd53a07a7cd9990b4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Sep 2013 12:13:12 +0200 Subject: Bump version to 2.3.0.b1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 38cd698..3ec0771 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20200 +#if ODB_VERSION != 20251 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2020000 -#define LIBODB_SQLITE_VERSION_STR "2.2.0" +#define LIBODB_SQLITE_VERSION 2029951 +#define LIBODB_SQLITE_VERSION_STR "2.3.0.b1" #include diff --git a/version b/version index ccbccc3..44c7280 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.0 +2.3.0.b1 -- cgit v1.1 From 29f048816a31422685c44085ac20e45d97f95ecf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 28 Sep 2013 10:51:12 +0200 Subject: Make schema version access (but not modification) thread-safe Also cache the version in statements so that we don't have to lock the mutex (slow) every time we need to check the version. --- odb/sqlite/section-statements.hxx | 13 +++++++++++++ odb/sqlite/section-statements.txx | 1 + odb/sqlite/statements-base.hxx | 24 +++++++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 8bdbda1..dff5ec5 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -10,12 +10,15 @@ #include // std::size_t #include +#include #include #include #include #include #include +#include +#include #include namespace odb @@ -46,6 +49,15 @@ namespace odb connection_type& connection () {return conn_;} + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + image_type& image () {return image_;} @@ -138,6 +150,7 @@ namespace odb protected: connection_type& conn_; + mutable const schema_version_migration* svm_; // These come from object_statements. // diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index b6945d9..f097a5d 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -14,6 +14,7 @@ namespace odb image_type& im, binding& id, binding& idv) : conn_ (conn), + svm_ (0), image_ (im), id_binding_ (id), idv_binding_ (idv), diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 5db1369..1df53cd 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -7,10 +7,12 @@ #include +#include #include #include -#include // connection +#include +#include #include @@ -29,18 +31,30 @@ namespace odb return conn_; } + // Schema version. database::schema_version_migration() is thread- + // safe which means it is also slow. Cache the result in statements + // so we can avoid the mutex lock. This is thread-safe since if the + // version is updated, then the statements cache will be expired. + // + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + public: virtual ~statements_base (); protected: - statements_base (connection_type& conn) - : conn_ (conn) - { - } + statements_base (connection_type& conn): conn_ (conn), svm_ (0) {} protected: connection_type& conn_; + mutable const schema_version_migration* svm_; }; } } -- cgit v1.1 From 275f4e494cacd403d28b01f8e3356a6669ef8e13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Oct 2013 08:29:06 +0200 Subject: Add support for SQLite 3.3.6 That's what is still shipped with RHEL5. --- m4/libsqlite.m4 | 4 +- odb/sqlite/connection.cxx | 14 +++++- odb/sqlite/database.hxx | 9 ++++ odb/sqlite/statement.cxx | 109 +++++++++++++++++++++++++++++++++++++++++++++- odb/sqlite/statement.hxx | 14 ++++-- 5 files changed, 141 insertions(+), 9 deletions(-) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index a75062c..4bbe9a1 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -24,9 +24,9 @@ int main () { sqlite3* handle; - sqlite3_open_v2 ("", &handle, 0, 0); + sqlite3_open ("", &handle); sqlite3_stmt* stmt; - sqlite3_prepare_v2 (handle, "", 0, &stmt, 0); + sqlite3_prepare (handle, "", 0, &stmt, 0); sqlite3_finalize (stmt); sqlite3_close (handle); } diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index f4e7259..188d59f 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -51,12 +51,22 @@ namespace odb f |= SQLITE_OPEN_NOMUTEX; #endif - const string& vfs (db.vfs ()); - sqlite3* h (0); + + // sqlite3_open_v2() was only addedin SQLite 3.5.0. + // +#if SQLITE_VERSION_NUMBER >= 3005000 + const string& vfs (db.vfs ()); int e ( sqlite3_open_v2 ( n.c_str (), &h, f, (vfs.empty () ? 0 : vfs.c_str ()))); +#else + // Readonly opening not supported in SQLite earlier than 3.5.0. + // + assert ((f & SQLITE_OPEN_READONLY) == 0); + int e (sqlite3_open (n.c_str (), &h)); +#endif + handle_.reset (h); if (e != SQLITE_OK) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 6039f23..fd4a736 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -27,6 +27,15 @@ #include +// We use the sqlite3_open_v2() flags in our interface. Define them +// for SQLite earlier that 3.5.0. +// +#if SQLITE_VERSION_NUMBER < 3005000 +# define SQLITE_OPEN_READONLY 0x00000001 +# define SQLITE_OPEN_READWRITE 0x00000002 +# define SQLITE_OPEN_CREATE 0x00000004 +#endif + namespace odb { namespace sqlite diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index f20d8da..62103fc 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -88,6 +88,11 @@ namespace odb int e; sqlite3_stmt* stmt (0); + + // sqlite3_prepare_v2() is only available since SQLite 3.3.9 + // but is buggy until 3.3.11. + // +#if SQLITE_VERSION_NUMBER >= 3003011 while ((e = sqlite3_prepare_v2 (conn_.handle (), text, static_cast (text_size), @@ -96,11 +101,23 @@ namespace odb { conn_.wait (); } +#else + e = sqlite3_prepare (conn_.handle (), + text, + static_cast (text_size), + &stmt, + 0); +#endif if (e != SQLITE_OK) translate_error (e, conn_); stmt_.reset (stmt); + +#if SQLITE_VERSION_NUMBER < 3005003 + text_.assign (text, text_size); +#endif + active_ = false; prev_ = 0; @@ -118,7 +135,13 @@ namespace odb const char* statement:: text () const { + // sqlite3_sql() is only available since 3.5.3. + // +#if SQLITE_VERSION_NUMBER >= 3005003 return sqlite3_sql (stmt_); +#else + return text_.c_str (); +#endif } void statement:: @@ -148,7 +171,16 @@ namespace odb case bind::integer: { long long v (*static_cast (b.buffer)); - e = sqlite3_bind_int64 (stmt_, c, static_cast (v)); + + e = sqlite3_bind_int64 (stmt_, + c, + // Prior to 3.5.0, sqlite3_int64 was called sqlite_int64. +#if SQLITE_VERSION_NUMBER >= 3005000 + static_cast (v) +#else + static_cast (v) +#endif + ); break; } case bind::real: @@ -355,10 +387,42 @@ namespace odb for (; e == SQLITE_ROW; e = sqlite3_step (stmt_)) r++; + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 sqlite3_reset (stmt_); if (e != SQLITE_DONE) translate_error (e, conn_); +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) + { + // If the schema has changed, try to re-prepare and re-execute the + // statement. That's what newer versions of SQLite do automatically. + // + if (e == SQLITE_SCHEMA) + { + sqlite3_stmt* stmt (0); + e = sqlite3_prepare (h, + text_.c_str (), + static_cast (text_.size () + 1), + &stmt, + 0); + + if (e != SQLITE_OK) + translate_error (e, conn_); + + stmt_.reset (stmt); + return execute (); // Try again by recursively calling ourselves. + } + else + translate_error (e, conn_); + } +#endif if (!result_set_) r = static_cast (sqlite3_changes (h)); @@ -479,10 +543,21 @@ namespace odb if (e != SQLITE_ROW) { - reset (); done_ = true; + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + reset (); + if (e != SQLITE_DONE) +#else + e = reset (); + + if (e != SQLITE_OK) +#endif translate_error (e, conn_); } } @@ -564,9 +639,19 @@ namespace odb e = sqlite3_step (stmt_); #endif + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 sqlite3_reset (stmt_); if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif { // SQLITE_CONSTRAINT error code covers more than just a duplicate // primary key. Unfortunately, there is nothing more precise that @@ -645,9 +730,19 @@ namespace odb e = sqlite3_step (stmt_); #endif + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 sqlite3_reset (stmt_); if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif translate_error (e, conn_); return static_cast (sqlite3_changes (h)); @@ -707,9 +802,19 @@ namespace odb e = sqlite3_step (stmt_); #endif + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 sqlite3_reset (stmt_); if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif translate_error (e, conn_); return static_cast (sqlite3_changes (h)); diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 05fa9bd..7d7f021 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -131,15 +131,19 @@ namespace odb } } - void + int reset () { + int r (SQLITE_OK); + if (active_) { - sqlite3_reset (stmt_); + r = sqlite3_reset (stmt_); list_remove (); active_ = false; } + + return r; } protected: @@ -148,6 +152,10 @@ namespace odb connection_type& conn_; auto_handle stmt_; +#if SQLITE_VERSION_NUMBER < 3005003 + std::string text_; +#endif + bool active_; private: @@ -160,7 +168,7 @@ namespace odb // Doubly-linked list of active statements. // - private: + protected: void list_add () { -- cgit v1.1 From 712b5fa7da88b09bf031afbd260f863c8d26b642 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Oct 2013 06:06:31 +0200 Subject: Bump version to 2.3.0.b2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 3ec0771..e115d3a 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20251 +#if ODB_VERSION != 20252 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2029951 -#define LIBODB_SQLITE_VERSION_STR "2.3.0.b1" +#define LIBODB_SQLITE_VERSION 2029952 +#define LIBODB_SQLITE_VERSION_STR "2.3.0.b2" #include diff --git a/version b/version index 44c7280..5ec8dc2 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.3.0.b1 +2.3.0.b2 -- cgit v1.1 From 8ccdac9cb6b0aa45f99fd222502fbf6508938d13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 Oct 2013 08:16:29 +0200 Subject: Bump version to 2.3.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index e115d3a..d0f43e8 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20252 +#if ODB_VERSION != 20300 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2029952 -#define LIBODB_SQLITE_VERSION_STR "2.3.0.b2" +#define LIBODB_SQLITE_VERSION 2030000 +#define LIBODB_SQLITE_VERSION_STR "2.3.0" #include diff --git a/version b/version index 5ec8dc2..276cbf9 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.3.0.b2 +2.3.0 -- cgit v1.1 From 8db0409e97f73d2e090ec7a5aa54b1c176ab5629 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 21 Oct 2013 13:13:02 +0200 Subject: Suppress warning --- odb/sqlite/section-statements.txx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index f097a5d..f005f74 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -34,9 +34,7 @@ namespace odb select_image_truncated_, 0, sizeof (select_image_truncated_)); std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - for (std::size_t i (0); - i < select_column_count + managed_optimistic_load_column_count; - ++i) + for (std::size_t i (0); i < select_bind_count; ++i) select_image_bind_[i].truncated = select_image_truncated_ + i; } } -- cgit v1.1 From 096badf7460647b01ed91bec725586b731dd636f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Dec 2013 10:23:26 +0200 Subject: Bump version to 2.4.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d0f43e8..33946a8 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20300 +#if ODB_VERSION != 20301 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2030000 -#define LIBODB_SQLITE_VERSION_STR "2.3.0" +#define LIBODB_SQLITE_VERSION 2039901 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a1" #include diff --git a/version b/version index 276cbf9..af8e8ad 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.3.0 +2.4.0.a1 -- cgit v1.1 From a21c3389fef8434eedcad1645ddc28869d10e981 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 Mar 2014 08:47:33 +0200 Subject: Bump version to 2.4.0.a2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 33946a8..59227d8 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20301 +#if ODB_VERSION != 20302 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039901 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a1" +#define LIBODB_SQLITE_VERSION 2039902 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a2" #include diff --git a/version b/version index af8e8ad..dd4b617 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a1 +2.4.0.a2 -- cgit v1.1 From 85fdb97e33b65a5425a30efa4193b6686a5a252a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Mar 2014 13:34:28 +0200 Subject: Export pooled_connection class It can be used by derived connection factories. --- odb/sqlite/connection-factory.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 0db2cf1..7994785 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -62,7 +62,7 @@ namespace odb single_connection_factory& operator= (const single_connection_factory&); protected: - class single_connection: public connection + class LIBODB_SQLITE_EXPORT single_connection: public connection { public: single_connection (database_type&, int extra_flags = 0); @@ -178,7 +178,7 @@ namespace odb connection_pool_factory& operator= (const connection_pool_factory&); protected: - class pooled_connection: public connection + class LIBODB_SQLITE_EXPORT pooled_connection: public connection { public: pooled_connection (database_type&, int extra_flags = 0); -- cgit v1.1 From 68331aab23fff9264b9469ea737be3fb44d997b3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 3 Jun 2014 18:28:35 +0200 Subject: Support for VC12 (2013), initial work --- libodb-sqlite-vc12.sln | 28 ++++ makefile | 2 +- odb/sqlite/libodb-sqlite-vc12.vcxproj | 182 ++++++++++++++++++++++++++ odb/sqlite/libodb-sqlite-vc12.vcxproj.filters | 19 +++ odb/sqlite/makefile | 5 +- 5 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 libodb-sqlite-vc12.sln create mode 100644 odb/sqlite/libodb-sqlite-vc12.vcxproj create mode 100644 odb/sqlite/libodb-sqlite-vc12.vcxproj.filters diff --git a/libodb-sqlite-vc12.sln b/libodb-sqlite-vc12.sln new file mode 100644 index 0000000..baff9a4 --- /dev/null +++ b/libodb-sqlite-vc12.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc11.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/makefile b/makefile index 19eee70..902a5ae 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,7 @@ $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) $(dist): export docs := GPLv2 LICENSE README NEWS version $(dist): data_dist := INSTALL libodb-sqlite-vc8.sln libodb-sqlite-vc9.sln \ -libodb-sqlite-vc10.sln libodb-sqlite-vc11.sln \ +libodb-sqlite-vc10.sln libodb-sqlite-vc11.sln libodb-sqlite-vc12.sln \ $(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj b/odb/sqlite/libodb-sqlite-vc12.vcxproj new file mode 100644 index 0000000..7a7d82d --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc12.vcxproj @@ -0,0 +1,182 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} + Win32Proj + libodb-sqlite + + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + ..\..\bin\ + odb-sqlite-d-__value__(interface_version)-vc11 + + + true + ..\..\bin64\ + odb-sqlite-d-__value__(interface_version)-vc11 + + + false + ..\..\bin\ + odb-sqlite-__value__(interface_version)-vc11 + + + false + ..\..\bin64\ + odb-sqlite-__value__(interface_version)-vc11 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + true + + + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib\odb-sqlite-d.lib + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + true + + + odb-d.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\..\lib64\odb-sqlite-d.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + true + + + odb.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib\odb-sqlite.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + ..\.. + 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) + true + + + odb.lib;sqlite3.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\..\lib64\odb-sqlite.lib + + + +__header_entries__(headers) + + +__source_entries__(sources) + + + + + diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters new file mode 100644 index 0000000..6a1e44f --- /dev/null +++ b/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} + cxx + + + {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} + h;hxx;ixx;txx + + + +__header_filter_entries__(headers) + + +__source_filter_entries__(sources) + + diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index bfde3aa..1e16007 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -103,7 +103,8 @@ $(dist): data_dist := $(cli_tun) details/config.h.in $(dist): export extra_dist := $(data_dist) \ libodb-sqlite-vc8.vcproj libodb-sqlite-vc9.vcproj \ libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ -libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters +libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters \ +libodb-sqlite-vc12.vcxproj libodb-sqlite-vc12.vcxproj.filters $(dist): export interface_version = $(shell sed -e \ 's/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) @@ -114,6 +115,7 @@ $(dist): $(gen) $(call meta-vc9proj,$(src_base)/libodb-sqlite-vc9.vcproj) $(call meta-vc10proj,$(src_base)/libodb-sqlite-vc10.vcxproj) $(call meta-vc11proj,$(src_base)/libodb-sqlite-vc11.vcxproj) + $(call meta-vc12proj,$(src_base)/libodb-sqlite-vc12.vcxproj) $(call meta-automake) # Clean. @@ -143,6 +145,7 @@ $(call include,$(bld_root)/meta/vc8proj.make) $(call include,$(bld_root)/meta/vc9proj.make) $(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/vc11proj.make) +$(call include,$(bld_root)/meta/vc12proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(cli_rules)) -- cgit v1.1 From 50077215b40f35b4cef26b46e3b00a66f6430687 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 1 Aug 2014 11:27:07 +0200 Subject: Bump version to 2.4.0.a3 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 59227d8..f5dfbeb 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20302 +#if ODB_VERSION != 20303 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039902 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a2" +#define LIBODB_SQLITE_VERSION 2039903 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a3" #include diff --git a/version b/version index dd4b617..26d9ac3 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a2 +2.4.0.a3 -- cgit v1.1 From 89821afa0e8346df6772a479754c9a1947300b57 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Sep 2014 14:43:55 +0200 Subject: Call tracer::prepare() before actually preparing statement This way we give the user the ability to see an invalid statement that would cause the preparation step to fail. --- odb/sqlite/statement.cxx | 75 +++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 62103fc..d56f45f 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -24,21 +24,21 @@ namespace odb statement:: ~statement () { - if (empty ()) - return; - + if (stmt_ != 0) { - odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->deallocate (conn_, *this); - } + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->deallocate (conn_, *this); + } - if (next_ != this) - list_remove (); + if (next_ != this) + list_remove (); - stmt_.reset (); + stmt_.reset (); + } } void statement:: @@ -48,6 +48,10 @@ namespace odb const binding* proc, bool optimize) { + active_ = false; + prev_ = 0; + next_ = this; + string tmp; if (proc != 0) { @@ -81,11 +85,34 @@ namespace odb text_size = tmp.size (); } +#if SQLITE_VERSION_NUMBER < 3005003 + text_.assign (text, text_size); +#endif + // Empty statement. // if (*text == '\0') return; + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + { + // Temporarily store the statement text in prev_ so that + // text() which may be called by the tracer can access it. + // +#if SQLITE_VERSION_NUMBER >= 3005003 + prev_ = reinterpret_cast (const_cast (text)); +#endif + t->prepare (conn_, *this); +#if SQLITE_VERSION_NUMBER >= 3005003 + prev_ = 0; +#endif + } + } + int e; sqlite3_stmt* stmt (0); @@ -113,23 +140,6 @@ namespace odb translate_error (e, conn_); stmt_.reset (stmt); - -#if SQLITE_VERSION_NUMBER < 3005003 - text_.assign (text, text_size); -#endif - - active_ = false; - - prev_ = 0; - next_ = this; - - { - odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->prepare (conn_, *this); - } } const char* statement:: @@ -138,7 +148,12 @@ namespace odb // sqlite3_sql() is only available since 3.5.3. // #if SQLITE_VERSION_NUMBER >= 3005003 - return sqlite3_sql (stmt_); + if (stmt_ == 0) + // See init() above for details on what's going on here. + // + return prev_ != 0 ? reinterpret_cast (prev_) : ""; + else + return sqlite3_sql (stmt_); #else return text_.c_str (); #endif -- cgit v1.1 From 5d693f6a783b8b206b9543328eb34f942db10ecf Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Tue, 4 Nov 2014 16:10:03 +1100 Subject: Implement {query,execute}_{one,value}() shortcut functions Useful in situations where the query is know to return at most one element (*_one) or exactly one element (*_value). --- odb/sqlite/database.hxx | 62 +++++++++++++++++++++++++ odb/sqlite/database.ixx | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index fd4a736..0eef6d5 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -319,6 +319,68 @@ namespace odb result query (const odb::query_base&); + // Query one API. + // + template + typename object_traits::pointer_type + query_one (); + + template + bool + query_one (T& object); + + template + T + query_value (); + + template + typename object_traits::pointer_type + query_one (const char*); + + template + bool + query_one (const char*, T& object); + + template + T + query_value (const char*); + + template + typename object_traits::pointer_type + query_one (const std::string&); + + template + bool + query_one (const std::string&, T& object); + + template + T + query_value (const std::string&); + + template + typename object_traits::pointer_type + query_one (const sqlite::query_base&); + + template + bool + query_one (const sqlite::query_base&, T& object); + + template + T + query_value (const sqlite::query_base&); + + template + typename object_traits::pointer_type + query_one (const odb::query_base&); + + template + bool + query_one (const odb::query_base&, T& object); + + template + T + query_value (const odb::query_base&); + // Query preparation. // template diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index c2fd1a5..d5918f0 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -429,6 +429,126 @@ namespace odb } template + inline typename object_traits::pointer_type database:: + query_one () + { + return query_one (sqlite::query_base ()); + } + + template + inline bool database:: + query_one (T& o) + { + return query_one (sqlite::query_base (), o); + } + + template + inline T database:: + query_value () + { + return query_value (sqlite::query_base ()); + } + + template + inline typename object_traits::pointer_type database:: + query_one (const char* q) + { + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const char* q, T& o) + { + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const char* q) + { + return query_value (sqlite::query_base (q)); + } + + template + inline typename object_traits::pointer_type database:: + query_one (const std::string& q) + { + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const std::string& q, T& o) + { + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const std::string& q) + { + return query_value (sqlite::query_base (q)); + } + + template + inline typename object_traits::pointer_type database:: + query_one (const sqlite::query_base& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_one_ (q); + } + + template + inline bool database:: + query_one (const sqlite::query_base& q, T& o) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_one_ (q, o); + } + + template + inline T database:: + query_value (const sqlite::query_base& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_value_ (q); + } + + template + inline typename object_traits::pointer_type database:: + query_one (const odb::query_base& q) + { + // Translate to native query. + // + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const odb::query_base& q, T& o) + { + // Translate to native query. + // + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const odb::query_base& q) + { + // Translate to native query. + // + return query_value (sqlite::query_base (q)); + } + + template inline prepared_query database:: prepare_query (const char* n, const char* q) { -- cgit v1.1 From 3bb29e43f60229bcac00777c839174703f848c16 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Nov 2014 14:48:06 +0200 Subject: Bump version to 2.4.0.a4 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index f5dfbeb..c6ac475 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20303 +#if ODB_VERSION != 20304 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039903 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a3" +#define LIBODB_SQLITE_VERSION 2039904 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a4" #include diff --git a/version b/version index 26d9ac3..42645da 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a3 +2.4.0.a4 -- cgit v1.1 From 6ba692aabf2afae6dab83139ca5e219bfc614890 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 17 Nov 2014 13:34:17 +0200 Subject: Implement bulk database operation support for Oracle and SQL Server --- odb/sqlite/container-statements.hxx | 3 +- odb/sqlite/database.hxx | 4 +++ odb/sqlite/database.ixx | 7 +++++ odb/sqlite/exceptions.cxx | 18 ++++++++++++ odb/sqlite/exceptions.hxx | 9 ++++++ odb/sqlite/no-id-object-statements.hxx | 3 +- odb/sqlite/polymorphic-object-statements.hxx | 9 ++++-- odb/sqlite/section-statements.hxx | 3 +- odb/sqlite/section-statements.txx | 2 +- odb/sqlite/simple-object-statements.hxx | 41 ++++++++++++++++++---------- odb/sqlite/statement.cxx | 29 ++++++++++++-------- odb/sqlite/statement.hxx | 10 +++---- 12 files changed, 100 insertions(+), 38 deletions(-) diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 058a255..4871fe8 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -126,7 +126,8 @@ namespace odb conn_, insert_text_, versioned_, // Process if versioned. - insert_image_binding_)); + insert_image_binding_, + 0)); return *insert_; } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 0eef6d5..f3d8248 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -124,6 +124,10 @@ namespace odb template typename object_traits::id_type + persist (const T& object); + + template + typename object_traits::id_type persist (T* obj_ptr); template class P> diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index d5918f0..5b21e36 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -27,6 +27,13 @@ namespace odb template inline typename object_traits::id_type database:: + persist (const T& obj) + { + return persist_ (obj); + } + + template + inline typename object_traits::id_type database:: persist (T* p) { typedef typename object_traits::pointer_type object_pointer; diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 08cdf90..ece5def 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -22,6 +22,12 @@ namespace odb return "transaction is forced to rollback"; } + forced_rollback* forced_rollback:: + clone () const + { + return new forced_rollback (*this); + } + // // database_exception // @@ -51,6 +57,12 @@ namespace odb return what_.c_str (); } + database_exception* database_exception:: + clone () const + { + return new database_exception (*this); + } + // // cli_exception // @@ -71,5 +83,11 @@ namespace odb { return what_.c_str (); } + + cli_exception* cli_exception:: + clone () const + { + return new cli_exception (*this); + } } } diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 8a21d5e..6bae164 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -29,6 +29,9 @@ namespace odb { virtual const char* what () const throw (); + + virtual forced_rollback* + clone () const; }; struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception @@ -60,6 +63,9 @@ namespace odb virtual const char* what () const throw (); + virtual database_exception* + clone () const; + private: int error_; int extended_error_; @@ -75,6 +81,9 @@ namespace odb virtual const char* what () const throw (); + virtual cli_exception* + clone () const; + private: std::string what_; }; diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 2e0cb05..a42616d 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -88,7 +88,8 @@ namespace odb conn_, object_traits::persist_statement, object_traits::versioned, // Process if versioned. - insert_image_binding_)); + insert_image_binding_, + 0)); } return *persist_; diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 2586cb0..4464fa3 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -315,7 +315,8 @@ namespace odb conn_, object_traits::persist_statement, object_traits::versioned, // Process if versioned. - insert_image_binding_)); + insert_image_binding_, + 0)); } return *persist_; @@ -381,6 +382,7 @@ namespace odb return extra_statement_cache_.get ( conn_, image_, + id_image (), id_image_binding (), &id_image_binding ()); // Note, not id+version. } @@ -419,8 +421,9 @@ namespace odb root_statements_type& root_statements_; base_statements_type& base_statements_; - extra_statement_cache_ptr - extra_statement_cache_; + extra_statement_cache_ptr extra_statement_cache_; image_type image_; diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index dff5ec5..f52d531 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -36,6 +36,7 @@ namespace odb typedef ST traits; typedef typename traits::image_type image_type; + typedef typename traits::id_image_type id_image_type; typedef sqlite::select_statement select_statement_type; typedef sqlite::update_statement update_statement_type; @@ -43,7 +44,7 @@ namespace odb typedef sqlite::connection connection_type; section_statements (connection_type&, - image_type&, + image_type&, id_image_type&, binding& id, binding& idv); connection_type& diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index f005f74..19f6968 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -11,7 +11,7 @@ namespace odb template section_statements:: section_statements (connection_type& conn, - image_type& im, + image_type& im, id_image_type&, binding& id, binding& idv) : conn_ (conn), svm_ (0), diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index f438d90..801f791 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -39,49 +39,56 @@ namespace odb // deleter function which will be initialized during allocation // (at that point we know that the cache class is defined). // - template + template struct extra_statement_cache_ptr { typedef I image_type; + typedef ID id_image_type; typedef sqlite::connection connection_type; extra_statement_cache_ptr (): p_ (0) {} ~extra_statement_cache_ptr () { if (p_ != 0) - (this->*deleter_) (0, 0, 0, 0); + (this->*deleter_) (0, 0, 0, 0, 0); } T& - get (connection_type& c, image_type& im, binding& id, binding* idv) + get (connection_type& c, + image_type& im, id_image_type& idim, + binding& id, binding* idv) { if (p_ == 0) - allocate (&c, &im, &id, (idv != 0 ? idv : &id)); + allocate (&c, &im, &idim, &id, (idv != 0 ? idv : &id)); return *p_; } private: void - allocate (connection_type*, image_type*, binding*, binding*); + allocate (connection_type*, + image_type*, id_image_type*, + binding*, binding*); private: T* p_; void (extra_statement_cache_ptr::*deleter_) ( - connection_type*, image_type*, binding*, binding*); + connection_type*, image_type*, id_image_type*, binding*, binding*); }; - template - void extra_statement_cache_ptr:: - allocate (connection_type* c, image_type* im, binding* id, binding* idv) + template + void extra_statement_cache_ptr:: + allocate (connection_type* c, + image_type* im, id_image_type* idim, + binding* id, binding* idv) { // To reduce object code size, this function acts as both allocator // and deleter. // if (p_ == 0) { - p_ = new T (*c, *im, *id, *idv); - deleter_ = &extra_statement_cache_ptr::allocate; + p_ = new T (*c, *im, *idim, *id, *idv); + deleter_ = &extra_statement_cache_ptr::allocate; } else delete p_; @@ -354,7 +361,8 @@ namespace odb conn_, object_traits::persist_statement, object_traits::versioned, // Process if versioned. - insert_image_binding_)); + insert_image_binding_, + (object_traits::auto_id ? &id_image_binding_ : 0))); } return *persist_; @@ -430,7 +438,9 @@ namespace odb extra_statement_cache () { return extra_statement_cache_.get ( - conn_, image_, id_image_binding_, od_.id_image_binding ()); + conn_, + image_, id_image_, + id_image_binding_, od_.id_image_binding ()); } public: @@ -476,8 +486,9 @@ namespace odb template friend class polymorphic_derived_object_statements; - extra_statement_cache_ptr - extra_statement_cache_; + extra_statement_cache_ptr extra_statement_cache_; image_type image_; diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index d56f45f..09188cb 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -605,11 +605,13 @@ namespace odb insert_statement (connection_type& conn, const string& text, bool process, - binding& param) + binding& param, + binding* returning) : statement (conn, text, statement_insert, (process ? ¶m : 0), false), - param_ (param) + param_ (param), + returning_ (returning) { } @@ -617,11 +619,13 @@ namespace odb insert_statement (connection_type& conn, const char* text, bool process, - binding& param) + binding& param, + binding* returning) : statement (conn, text, statement_insert, (process ? ¶m : 0), false), - param_ (param) + param_ (param), + returning_ (returning) { } @@ -679,14 +683,17 @@ namespace odb translate_error (e, conn_); } - return true; - } + if (returning_ != 0) + { + bind& b (returning_->bind[0]); - unsigned long long insert_statement:: - id () - { - return static_cast ( - sqlite3_last_insert_rowid (conn_.handle ())); + *b.is_null = false; + *static_cast (b.buffer) = + static_cast ( + sqlite3_last_insert_rowid (conn_.handle ())); + } + + return true; } // update_statement diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 7d7f021..84d90d7 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -328,12 +328,14 @@ namespace odb insert_statement (connection_type& conn, const std::string& text, bool process_text, - binding& param); + binding& param, + binding* returning); insert_statement (connection_type& conn, const char* text, bool process_text, - binding& param); + binding& param, + binding* returning); // Return true if successful and false if the row is a duplicate. // All other errors are reported by throwing exceptions. @@ -341,15 +343,13 @@ namespace odb bool execute (); - unsigned long long - id (); - private: insert_statement (const insert_statement&); insert_statement& operator= (const insert_statement&); private: binding& param_; + binding* returning_; }; class LIBODB_SQLITE_EXPORT update_statement: public statement -- cgit v1.1 From 9cbf27d6de0b868c4c21a4d58e10a906a47f4d92 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 Nov 2014 07:02:55 +0200 Subject: Don't try to translate duplicate primary key for auto-assigned id An auto-assigned object id should never cause a duplicate primary key. --- odb/sqlite/statement.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 09188cb..5601047 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -675,9 +675,10 @@ namespace odb // SQLITE_CONSTRAINT error code covers more than just a duplicate // primary key. Unfortunately, there is nothing more precise that // we can use (even sqlite3_errmsg() returns generic "constraint - // failed"). + // failed"). But an auto-assigned object id should never cause a + // duplicate primary key. // - if (e == SQLITE_CONSTRAINT) + if (returning_ == 0 && e == SQLITE_CONSTRAINT) return false; else translate_error (e, conn_); -- cgit v1.1 From 5031f119479be1cb7a3880535ccdd76ccdcf330b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 Nov 2014 08:53:16 +0200 Subject: Get rid of trailing newlines in error messages --- odb/sqlite/error.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 6107427..6fae9d5 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -83,6 +83,12 @@ namespace odb if (m.empty ()) m = sqlite3_errmsg (h); + // Get rid of a trailing newline if there is one. + // + string::size_type n (m.size ()); + if (n != 0 && m[n - 1] == '\n') + m.resize (n - 1); + throw database_exception (e, ee, m); } } -- cgit v1.1 From c1df503654c713a350d4aaf734f04af111c8fb6a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 26 Nov 2014 12:03:13 +0200 Subject: VC12 fixes --- libodb-sqlite-vc12.sln | 2 +- odb/sqlite/libodb-sqlite-vc12.vcxproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libodb-sqlite-vc12.sln b/libodb-sqlite-vc12.sln index baff9a4..878e1e2 100644 --- a/libodb-sqlite-vc12.sln +++ b/libodb-sqlite-vc12.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc11.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc12.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj b/odb/sqlite/libodb-sqlite-vc12.vcxproj index 7a7d82d..d83b7f7 100644 --- a/odb/sqlite/libodb-sqlite-vc12.vcxproj +++ b/odb/sqlite/libodb-sqlite-vc12.vcxproj @@ -69,22 +69,22 @@ true ..\..\bin\ - odb-sqlite-d-__value__(interface_version)-vc11 + odb-sqlite-d-__value__(interface_version)-vc12 true ..\..\bin64\ - odb-sqlite-d-__value__(interface_version)-vc11 + odb-sqlite-d-__value__(interface_version)-vc12 false ..\..\bin\ - odb-sqlite-__value__(interface_version)-vc11 + odb-sqlite-__value__(interface_version)-vc12 false ..\..\bin64\ - odb-sqlite-__value__(interface_version)-vc11 + odb-sqlite-__value__(interface_version)-vc12 -- cgit v1.1 From ba7ce70ddce85d7a24f6ff4396de950d2ebe39e8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 17 Dec 2014 15:26:22 +0200 Subject: Bump version to 2.4.0.a5 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index c6ac475..d8d6e73 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20304 +#if ODB_VERSION != 20305 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039904 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a4" +#define LIBODB_SQLITE_VERSION 2039905 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a5" #include diff --git a/version b/version index 42645da..2a4e75c 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a4 +2.4.0.a5 -- cgit v1.1 From 2ee079e08ce3ca08d2120e7bafad581d46f66368 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 27 Jan 2015 09:58:42 +0200 Subject: Bump version to 2.4.0.a6 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d8d6e73..6f7d99b 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20305 +#if ODB_VERSION != 20306 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039905 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a5" +#define LIBODB_SQLITE_VERSION 2039906 +#define LIBODB_SQLITE_VERSION_STR "2.4.0.a6" #include diff --git a/version b/version index 2a4e75c..770201d 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a5 +2.4.0.a6 -- cgit v1.1 From 3b325f173c430a11c59c151c9bea9d7f96845674 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 6 Feb 2015 09:31:16 +0200 Subject: Update copyright --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.make | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/connection.ixx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/conversion.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/no-id-object-statements.txx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 2 +- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/prepared-query.cxx | 2 +- odb/sqlite/prepared-query.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query-dynamic.cxx | 2 +- odb/sqlite/query-dynamic.hxx | 2 +- odb/sqlite/query-dynamic.ixx | 2 +- odb/sqlite/query-dynamic.txx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/section-statements.hxx | 2 +- odb/sqlite/section-statements.txx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.cxx | 2 +- odb/sqlite/simple-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.ixx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits-calls.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- 104 files changed, 104 insertions(+), 104 deletions(-) diff --git a/Makefile.am b/Makefile.am index cc4622b..e3fd75b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index b1b4f3d..8953df9 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.make b/build/bootstrap.make index ab0707a..f2033db 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index 1d8760a..55fb0e4 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index b5ef38e..70fe025 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2013 Code Synthesis Tools CC. +Copyright (c) 2009-2015 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index b537303..f603bb5 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index 56a686a..e771de1 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index cc9d512..08a78fc 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 1933a0c..436ac31 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 5981921..05f8a3f 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index 41b07f4..2ea2618 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 956d037..42d0eef 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index b25ddbb..3fa72f5 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index cbf9f7d..7fc3aa1 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index 90eb372..a5d7bc2 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 17dfa18..98f96b8 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index d21a587..d7e2a00 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 48aa1cd..a1edf1e 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 2147d81..9fe829f 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/configure.ac b/configure.ac index 5902fbd..4e9b4a5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 5066a4d..0f92918 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index 8d70ffb..bf31ddc 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 9ce2580..2dd2634 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 4bbe9a1..a8fe4f7 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index c4972db..6b04b63 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 460251f..63a62b5 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 99c4a82..1f49f8f 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index 1609a04..f02850f 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index 902a5ae..af3bde2 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index 98d6698..6430131 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 65f365d..3a42099 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index 2a682fa..f6cef5b 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index dec85bf..c40190a 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 7994785..c0d15ff 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 188d59f..dd30f1f 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 241e626..8e54388 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 02ad3ec..e0ed736 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 4871fe8..fb8412d 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 6458be8..6a764c5 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index bed0b32..60e65b0 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index f3d8248..906d91b 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 5b21e36..becf308 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 3f54ae0..c8158be 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index b19a9fc..5d19aad 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index 690fe7f..fb53f66 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 3411407..30e9f8b 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 1e5646d..737a3d1 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 6fae9d5..ce320a1 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 0548680..3b48d39 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index ece5def..77436ae 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 6bae164..067abcc 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 8904011..4d9a063 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 1e16007..cd80e53 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 49576c3..0e0df00 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index cf0fc15..87d919b 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index a42616d..4fec8ef 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 096f13e..287a5d8 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 7192a26..fa0a3d3 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 6d761b5..277aa98 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 4464fa3..53b1e31 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index b97cd14..0565ae0 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index d181f4f..c204de6 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index 63d8bbc..4a63786 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index a2d969f..e26fb30 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index 343e42c..dd89e78 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index bf0b48f..cb03393 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index 86b86b8..b691d7b 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index 083e42f..67af539 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index fc1a046..a1bc5ac 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 31bd922..6d7dd0d 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 56c8e80..70fadec 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index ed2e5b4..b51b45a 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index f52d531..40ac4d1 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index 19f6968..3c4d10e 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 3888a56..ec42bf5 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 2c4340d..b1563bb 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index 47a4790..1bec013 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 801f791..6ea7f6d 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index e5951df..5a7407d 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 552806c..fe46063 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index d6b49ee..38376d9 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index e29f83e..8723e42 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index f943ffc..f9ce7a1 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 8d8e358..9f15a15 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 5601047..3bd5e4c 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 84d90d7..1be0cab 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index b46e753..4a5aa6e 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 1df53cd..6ed5813 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 1b48793..10ce0b0 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 4ee7b19..023ac6b 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx index 1e5bd8d..d1fb72f 100644 --- a/odb/sqlite/traits-calls.hxx +++ b/odb/sqlite/traits-calls.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits-calls.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index dae008c..9258d5b 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index b9d3b39..de8e3c3 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 3df1250..2f83071 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index d0894de..92de110 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index 64c24d9..40eeb5a 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index caa6eb4..9cd9303 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index dcbbf09..5651694 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 58ee7b9..3757175 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 6f7d99b..c8857ce 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VERSION_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 0e05adb..2b3b167 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index d13b58e..6b88971 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 63e48e7..6ecaaaa 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index 46cb506..bd46aa3 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t -- cgit v1.1 From 638e9ab36d7c10b48da4d9082ceecc26aacc5742 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 7 Feb 2015 14:00:39 +0200 Subject: Bump version to 2.4.0 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index c8857ce..ae0fb75 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20306 +#if ODB_VERSION != 20400 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2039906 -#define LIBODB_SQLITE_VERSION_STR "2.4.0.a6" +#define LIBODB_SQLITE_VERSION 2040000 +#define LIBODB_SQLITE_VERSION_STR "2.4.0" #include diff --git a/version b/version index 770201d..197c4d5 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0.a6 +2.4.0 -- cgit v1.1 From 29dcdd6ea6b4c3e760f4dd102fa108eaced03ec9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 8 Feb 2015 09:46:16 +0200 Subject: Add VC12 project/solution for SQlite --- etc/sqlite/README | 2 +- etc/sqlite/sqlite3-vc12.sln | 28 +++++ etc/sqlite/sqlite3-vc12.vcxproj | 178 ++++++++++++++++++++++++++++++++ etc/sqlite/sqlite3-vc12.vcxproj.filters | 23 +++++ 4 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 etc/sqlite/sqlite3-vc12.sln create mode 100644 etc/sqlite/sqlite3-vc12.vcxproj create mode 100644 etc/sqlite/sqlite3-vc12.vcxproj.filters diff --git a/etc/sqlite/README b/etc/sqlite/README index 126c52c..0d493f0 100644 --- a/etc/sqlite/README +++ b/etc/sqlite/README @@ -1,5 +1,5 @@ This directory contains project/solution files for building SQLite libraries -with Microsoft Visual Studio versions 8, 9, 10, and 11. +with Microsoft Visual Studio versions 8, 9, 10, 11, and 12. To build SQLite, you will need to download two SQLite packages: sqlite- amalgamation and sqlite-dll. Copy the sqlite3.c and sqlite3.h files from the diff --git a/etc/sqlite/sqlite3-vc12.sln b/etc/sqlite/sqlite3-vc12.sln new file mode 100644 index 0000000..6d901fb --- /dev/null +++ b/etc/sqlite/sqlite3-vc12.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc12.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 + {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/etc/sqlite/sqlite3-vc12.vcxproj b/etc/sqlite/sqlite3-vc12.vcxproj new file mode 100644 index 0000000..79dac0f --- /dev/null +++ b/etc/sqlite/sqlite3-vc12.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3409C5BB-974C-44FC-A9DB-2176837E9035} + Win32Proj + sqlite3 + + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + bin\ + sqlite3-d + + + true + bin64\ + sqlite3-d + + + false + bin\ + sqlite3 + + + false + bin64\ + sqlite3 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + true + + + Windows + true + $(TargetPath) + lib\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + true + + + Windows + true + $(TargetPath) + lib64\sqlite3-d.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + $(TargetPath) + lib\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + $(TargetPath) + lib64\sqlite3.lib + sqlite3.def + /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) + + + + + + + + + + + + diff --git a/etc/sqlite/sqlite3-vc12.vcxproj.filters b/etc/sqlite/sqlite3-vc12.vcxproj.filters new file mode 100644 index 0000000..13685a4 --- /dev/null +++ b/etc/sqlite/sqlite3-vc12.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file -- cgit v1.1 From 27a578709046a81bb0efc0027bfc74318615447e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Mar 2015 16:30:36 +0200 Subject: Get pointer_type from correct traits (object, view), part 2 --- odb/sqlite/database.hxx | 10 +++++----- odb/sqlite/database.ixx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 906d91b..f7f3994 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -326,7 +326,7 @@ namespace odb // Query one API. // template - typename object_traits::pointer_type + typename result::pointer_type query_one (); template @@ -338,7 +338,7 @@ namespace odb query_value (); template - typename object_traits::pointer_type + typename result::pointer_type query_one (const char*); template @@ -350,7 +350,7 @@ namespace odb query_value (const char*); template - typename object_traits::pointer_type + typename result::pointer_type query_one (const std::string&); template @@ -362,7 +362,7 @@ namespace odb query_value (const std::string&); template - typename object_traits::pointer_type + typename result::pointer_type query_one (const sqlite::query_base&); template @@ -374,7 +374,7 @@ namespace odb query_value (const sqlite::query_base&); template - typename object_traits::pointer_type + typename result::pointer_type query_one (const odb::query_base&); template diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index becf308..c1e8f07 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -436,7 +436,7 @@ namespace odb } template - inline typename object_traits::pointer_type database:: + inline typename result::pointer_type database:: query_one () { return query_one (sqlite::query_base ()); @@ -457,7 +457,7 @@ namespace odb } template - inline typename object_traits::pointer_type database:: + inline typename result::pointer_type database:: query_one (const char* q) { return query_one (sqlite::query_base (q)); @@ -478,7 +478,7 @@ namespace odb } template - inline typename object_traits::pointer_type database:: + inline typename result::pointer_type database:: query_one (const std::string& q) { return query_one (sqlite::query_base (q)); @@ -499,7 +499,7 @@ namespace odb } template - inline typename object_traits::pointer_type database:: + inline typename result::pointer_type database:: query_one (const sqlite::query_base& q) { // T is always object_type. We also don't need to check for transaction @@ -529,7 +529,7 @@ namespace odb } template - inline typename object_traits::pointer_type database:: + inline typename result::pointer_type database:: query_one (const odb::query_base& q) { // Translate to native query. -- cgit v1.1 From 0f9cfacd6cc45f78f1453a8eeb7ffa542dc5dc48 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Jul 2015 18:43:03 +0200 Subject: Implement SQLite incremental BLOB/TEXT I/O --- odb/sqlite/blob-stream.hxx | 33 +++++++++ odb/sqlite/blob.hxx | 70 +++++++++++++++++++ odb/sqlite/connection.cxx | 12 ++-- odb/sqlite/connection.hxx | 39 ++++++++++- odb/sqlite/connection.ixx | 26 +++++++ odb/sqlite/forward.hxx | 13 ++++ odb/sqlite/makefile | 1 + odb/sqlite/query.hxx | 18 +++++ odb/sqlite/sqlite-types.hxx | 18 ++++- odb/sqlite/statement.cxx | 163 +++++++++++++++++++++++++++++++++++++++----- odb/sqlite/statement.hxx | 68 ++++++++---------- odb/sqlite/stream.cxx | 121 ++++++++++++++++++++++++++++++++ odb/sqlite/stream.hxx | 82 ++++++++++++++++++++++ odb/sqlite/text-stream.hxx | 33 +++++++++ odb/sqlite/text.hxx | 70 +++++++++++++++++++ odb/sqlite/traits.hxx | 146 ++++++++++++++++++++++++++++++++++++--- 16 files changed, 837 insertions(+), 76 deletions(-) create mode 100644 odb/sqlite/blob-stream.hxx create mode 100644 odb/sqlite/blob.hxx create mode 100644 odb/sqlite/stream.cxx create mode 100644 odb/sqlite/stream.hxx create mode 100644 odb/sqlite/text-stream.hxx create mode 100644 odb/sqlite/text.hxx diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx new file mode 100644 index 0000000..58be6ba --- /dev/null +++ b/odb/sqlite/blob-stream.hxx @@ -0,0 +1,33 @@ +// file : odb/sqlite/blob-stream.hxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BLOB_STREAM_HXX +#define ODB_SQLITE_BLOB_STREAM_HXX + +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT blob_stream: public stream + { + public: + blob_stream (const blob& b, bool rw) + : stream (b.db ().c_str (), + b.table ().c_str (), + b.column ().c_str (), + b.rowid (), + rw) {} + }; + } +} + +#include + +#endif // ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx new file mode 100644 index 0000000..eccb3ab --- /dev/null +++ b/odb/sqlite/blob.hxx @@ -0,0 +1,70 @@ +// file : odb/sqlite/blob.hxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BLOB_HXX +#define ODB_SQLITE_BLOB_HXX + +#include + +#include +#include // std::size_t + +// Carefully allow this header to be included into the ODB compilation. +// +#ifndef ODB_COMPILER +# include +# include +#endif + +namespace odb +{ + namespace sqlite + { +#ifdef ODB_COMPILER + #pragma db sqlite:type("BLOB STREAM") + class blob +#else + class LIBODB_SQLITE_EXPORT blob +#endif + { + public: + // BLOB size to provision for. Set before calling persist() or update(). + // + explicit + blob (std::size_t size = 0): size_ (size) {} + + std::size_t size () const {return size_;} + void size (std::size_t s) {size_ = s;} + + const std::string& db () const {return db_;} + const std::string& table () const {return table_;} + const std::string& column () const {return column_;} + long long rowid () const {return rowid_;} + + void + clear () + { + size_ = 0; + db_.clear (); + table_.clear (); + column_.clear (); + rowid_ = 0; + } + + private: +#ifndef ODB_COMPILER + friend struct default_value_traits; +#endif + std::size_t size_; + mutable std::string db_; + mutable std::string table_; + mutable std::string column_; + mutable long long rowid_; + }; + } +} + +#include + +#endif // ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index dd30f1f..c44d648 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -33,7 +33,7 @@ namespace odb : odb::connection (db), db_ (db), unlock_cond_ (unlock_mutex_), - statements_ (0) + active_objects_ (0) { int f (db.flags () | extra_flags); const string& n (db.name ()); @@ -86,7 +86,7 @@ namespace odb db_ (db), handle_ (handle), unlock_cond_ (unlock_mutex_), - statements_ (0) + active_objects_ (0) { init (); } @@ -184,11 +184,11 @@ namespace odb void connection:: clear () { - // The current first statement will remove itself from the list - // and make the second statement (if any) the new first. + // The current first active_object will remove itself from the list + // and make the second object (if any) the new first. // - while (statements_ != 0) - statements_->reset (); + while (active_objects_ != 0) + active_objects_->clear (); } } } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 8e54388..f8378fb 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -34,6 +34,39 @@ namespace odb class connection; typedef details::shared_ptr connection_ptr; + // SQLite "active object", i.e., an object that needs to be + // "cleared" before the transaction can be committed and the + // connection release. These form a doubly-linked list. + // + class active_object + { + public: + // This function should remove the object from the list, since + // it shall no longer be "active". + // + virtual void + clear () = 0; + + protected: + active_object (connection& c): prev_ (0), next_ (this), conn_ (c) {} + + void + list_add (); + + void + list_remove (); + + protected: + // prev_ == 0 means we are the first element. + // next_ == 0 means we are the last element. + // next_ == this means we are not on the list (prev_ should be 0). + // + active_object* prev_; + active_object* next_; + + connection& conn_; + }; + class LIBODB_SQLITE_EXPORT connection: public odb::connection { public: @@ -165,12 +198,12 @@ namespace odb private: friend class transaction_impl; // invalidate_results() - // Linked list of active statements currently associated + // Linked list of active objects currently associated // with this connection. // private: - friend class statement; - statement* statements_; + friend class active_object; + active_object* active_objects_; }; } } diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index e0ed736..23df27c 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -6,6 +6,32 @@ namespace odb { namespace sqlite { + // active_objects + // + inline void active_object:: + list_add () + { + next_ = conn_.active_objects_; + conn_.active_objects_ = this; + + if (next_ != 0) + next_->prev_ = this; + } + + inline void active_object:: + list_remove () + { + (prev_ == 0 ? conn_.active_objects_ : prev_->next_) = next_; + + if (next_ != 0) + next_->prev_ = prev_; + + prev_ = 0; + next_ = this; + } + + // connection + // template inline prepared_query connection:: prepare_query (const char* n, const char* q) diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 4d9a063..1bc5da5 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -39,6 +39,19 @@ namespace odb // Implementation details. // + enum database_type_id + { + id_integer, + id_real, + id_text, + id_blob, + id_text_stream, + id_blob_stream + }; + + template + struct default_value_traits; + enum statement_kind { statement_select, diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index cd80e53..e2ea0e9 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -18,6 +18,7 @@ simple-object-statements.cxx \ statement.cxx \ statements-base.cxx \ statement-cache.cxx \ +stream.cxx \ tracer.cxx \ traits.cxx \ transaction.cxx \ diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 6d7dd0d..bb1f50e 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1565,6 +1565,24 @@ namespace odb details::buffer buffer_; std::size_t size_; }; + + // TEXT STREAM (reduce to id_text). + // + template + struct query_param_impl: query_param_impl + { + query_param_impl (ref_bind r) : query_param_impl (r) {} + query_param_impl (val_bind v) : query_param_impl (v) {} + }; + + // BLOB STREAM (reduce to id_blob). + // + template + struct query_param_impl: query_param_impl + { + query_param_impl (ref_bind r) : query_param_impl (r) {} + query_param_impl (val_bind v) : query_param_impl (v) {} + }; } } diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 38376d9..80ffbd2 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -7,6 +7,7 @@ #include +#include #include // std::size_t namespace odb @@ -24,7 +25,9 @@ namespace odb real, // Buffer is double; size, capacity, truncated are unused. text, // Buffer is a UTF-8 char array. text16, // Buffer is a UTF-16 2-byte char array (sizes in bytes). - blob // Buffer is a char array. + blob, // Buffer is a char array. + stream // Buffer is stream_buffers. Size specifies the BLOB size + // (input only). Capacity and truncated unused. }; buffer_type type; @@ -34,6 +37,19 @@ namespace odb bool* is_null; bool* truncated; }; + + // The "out" values should be set in set_image() to point to + // variables that will be receiving the data. The "in" values + // are used in set_value() and contain the data that needs to + // be copied over. + // + struct stream_buffers + { + union {std::string* out; const char* in;} db; + union {std::string* out; const char* in;} table; + union {std::string* out; const char* in;} column; + union {long long* out; long long in;} rowid; + }; } } diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 3bd5e4c..f7ce632 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -42,6 +42,12 @@ namespace odb } void statement:: + clear () + { + reset (); + } + + void statement:: init (const char* text, std::size_t text_size, statement_kind sk, @@ -49,8 +55,6 @@ namespace odb bool optimize) { active_ = false; - prev_ = 0; - next_ = this; string tmp; if (proc != 0) @@ -58,23 +62,25 @@ namespace odb switch (sk) { case statement_select: - process_select (text, + process_select (tmp, + text, &proc->bind->buffer, proc->count, sizeof (bind), '"', '"', - optimize, - tmp); + optimize); break; case statement_insert: - process_insert (text, + process_insert (tmp, + text, &proc->bind->buffer, proc->count, sizeof (bind), '?', - tmp); + '$'); break; case statement_update: - process_update (text, + process_update (tmp, + text, &proc->bind->buffer, proc->count, sizeof (bind), '?', - tmp); + '$'); break; case statement_delete: case statement_generic: @@ -102,9 +108,10 @@ namespace odb { // Temporarily store the statement text in prev_ so that // text() which may be called by the tracer can access it. + // Dirty but efficient. // #if SQLITE_VERSION_NUMBER >= 3005003 - prev_ = reinterpret_cast (const_cast (text)); + prev_ = reinterpret_cast (const_cast (text)); #endif t->prepare (conn_, *this); #if SQLITE_VERSION_NUMBER >= 3005003 @@ -159,10 +166,11 @@ namespace odb #endif } - void statement:: + bool statement:: bind_param (const bind* p, size_t n) { int e (SQLITE_OK); + bool r (false); // SQLite parameters are counted from 1. // @@ -231,11 +239,25 @@ namespace odb SQLITE_STATIC); break; } + case bind::stream: + { +#if SQLITE_VERSION_NUMBER >= 3004000 + e = sqlite3_bind_zeroblob (stmt_, + c, + static_cast (*b.size)); + r = true; +#else + assert (false); +#endif + break; + } } } if (e != SQLITE_OK) translate_error (e, conn_); + + return r; } bool statement:: @@ -254,6 +276,9 @@ namespace odb int c (col++); + if (b.type == bind::stream) + col++; // Skip ROWID value that follows. + if (truncated && (b.truncated == 0 || !*b.truncated)) continue; @@ -320,6 +345,27 @@ namespace odb memcpy (b.buffer, d, *b.size); break; } + case bind::stream: + { + stream_buffers& sb (*static_cast (b.buffer)); + + // SQLite documentation states that these are valid until the + // statement is finalized (or reprepared). For our case, we + // only need it to stay alive until we call set_value() which + // we do while executing the statement (i.e., we don't copy + // images for later processing). + // + sb.db.in = sqlite3_column_database_name (stmt_, c); + sb.table.in = sqlite3_column_table_name (stmt_, c); + sb.column.in = sqlite3_column_origin_name (stmt_, c); + + // The ROWID comes in the following column. + // + sb.rowid.in = static_cast ( + sqlite3_column_int64 (stmt_, c + 1)); + + break; + } } } @@ -333,6 +379,61 @@ namespace odb return r; } + void statement:: + stream_param (const bind* p, size_t n, const stream_data& d) + { + // Code similar to bind_param(). + // + for (size_t i (0), j (1); i < n; ++i) + { + const bind& b (p[i]); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (static_cast (j++)); + + if ((b.is_null != 0 && *b.is_null) || b.type != bind::stream) + continue; + + // Get column name. + // + const char* col (sqlite3_bind_parameter_name (stmt_, c)); + assert (col != 0); // Statement doesn't contain column name. + + stream_buffers& sb (*static_cast (b.buffer)); + + *sb.db.out = d.db; + *sb.table.out = d.table; + *sb.column.out = col + 1; // Skip '$'. + *sb.rowid.out = d.rowid; + } + } + + inline void + update_hook (void* v, const char* db, const char* table, long long rowid) + { + statement::stream_data& d (*static_cast (v)); + d.db = db; + d.table = table; + d.rowid = rowid; + } + + extern "C" void + odb_sqlite_update_hook (void* v, + int, + const char* db, + const char* table, +#if SQLITE_VERSION_NUMBER >= 3005000 + sqlite3_int64 rowid +#else + sqlite_int64 rowid +#endif + ) + { + update_hook (v, db, table, static_cast (rowid)); + } + // generic_statement // @@ -357,7 +458,7 @@ namespace odb generic_statement:: generic_statement (connection_type& conn, const char* text, - std::size_t text_size) + size_t text_size) : statement (conn, text, text_size, statement_generic, 0, false), @@ -640,12 +741,16 @@ namespace odb t->execute (conn_, *this); } - bind_param (param_.bind, param_.count); + sqlite3* h (conn_.handle ()); + bool stream (bind_param (param_.bind, param_.count)); + + stream_data sd; + if (stream) + sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); int e; #ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - sqlite3* h (conn_.handle ()); while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) { if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) @@ -658,6 +763,9 @@ namespace odb e = sqlite3_step (stmt_); #endif + if (stream) + sqlite3_update_hook (h, 0, 0); // Clear the hook. + // sqlite3_step() will return a detailed error code only if we used // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the // error. @@ -684,6 +792,11 @@ namespace odb translate_error (e, conn_); } + // Stream parameters, if any. + // + if (stream) + stream_param (param_.bind, param_.count, sd); + if (returning_ != 0) { bind& b (returning_->bind[0]); @@ -691,7 +804,7 @@ namespace odb *b.is_null = false; *static_cast (b.buffer) = static_cast ( - sqlite3_last_insert_rowid (conn_.handle ())); + sqlite3_last_insert_rowid (h)); } return true; @@ -735,10 +848,14 @@ namespace odb t->execute (conn_, *this); } - bind_param (param_.bind, param_.count); + sqlite3* h (conn_.handle ()); + bool stream (bind_param (param_.bind, param_.count)); + + stream_data sd; + if (stream) + sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); int e; - sqlite3* h (conn_.handle ()); #ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) @@ -753,6 +870,9 @@ namespace odb e = sqlite3_step (stmt_); #endif + if (stream) + sqlite3_update_hook (h, 0, 0); // Clear the hook. + // sqlite3_step() will return a detailed error code only if we used // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the // error. @@ -768,7 +888,14 @@ namespace odb #endif translate_error (e, conn_); - return static_cast (sqlite3_changes (h)); + int r (sqlite3_changes (h)); + + // Stream parameters, if any. + // + if (stream && r != 0) + stream_param (param_.bind, param_.count, sd); + + return static_cast (r); } // delete_statement diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 1be0cab..7344daf 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -30,7 +30,8 @@ namespace odb { class connection; - class LIBODB_SQLITE_EXPORT statement: public odb::statement + class LIBODB_SQLITE_EXPORT statement: public odb::statement, + public active_object { public: typedef sqlite::connection connection_type; @@ -72,7 +73,7 @@ namespace odb statement_kind sk, const binding* process, bool optimize) - : conn_ (conn) + : active_object (conn) { init (text.c_str (), text.size (), sk, process, optimize); } @@ -82,7 +83,7 @@ namespace odb statement_kind sk, const binding* process, bool optimize) - : conn_ (conn) + : active_object (conn) { init (text, std::strlen (text), sk, process, optimize); } @@ -93,13 +94,15 @@ namespace odb statement_kind sk, const binding* process, bool optimize) - : conn_ (conn) + : active_object (conn) { init (text, text_size, sk, process, optimize); } protected: - void + // Return true if we bound any stream parameters. + // + bool bind_param (const bind*, std::size_t count); // Extract row columns into the bound buffers. If the truncated @@ -110,6 +113,21 @@ namespace odb bool bind_result (const bind*, std::size_t count, bool truncated = false); + // Stream (so to speak) parameters. + // + struct stream_data + { + std::string db; + std::string table; + long long rowid; + }; + + void + stream_param (const bind*, std::size_t count, const stream_data&); + + friend void + update_hook (void*, const char*, const char*, long long); + // Active state. // protected: @@ -146,10 +164,12 @@ namespace odb return r; } - protected: - friend class sqlite::connection; + // The active_object interface. + // + virtual void + clear (); - connection_type& conn_; + protected: auto_handle stmt_; #if SQLITE_VERSION_NUMBER < 3005003 @@ -165,38 +185,6 @@ namespace odb statement_kind, const binding* process, bool optimize); - - // Doubly-linked list of active statements. - // - protected: - void - list_add () - { - next_ = conn_.statements_; - conn_.statements_ = this; - - if (next_ != 0) - next_->prev_ = this; - } - - void - list_remove () - { - (prev_ == 0 ? conn_.statements_ : prev_->next_) = next_; - - if (next_ != 0) - next_->prev_ = prev_; - - prev_ = 0; - next_ = this; - } - - // prev_ == 0 means we are the first element. - // next_ == 0 means we are the last element. - // next_ == this means we are not on the list (prev_ should be 0). - // - statement* prev_; - statement* next_; }; class LIBODB_SQLITE_EXPORT generic_statement: public statement diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx new file mode 100644 index 0000000..8de199e --- /dev/null +++ b/odb/sqlite/stream.cxx @@ -0,0 +1,121 @@ +// file : odb/sqlite/stream.cxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#if SQLITE_VERSION_NUMBER >= 3004000 + +#include + +#include // invalid_argument + +#include +#include +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + stream:: + stream (const char* db, + const char* table, + const char* column, + long long rowid, + bool rw) + : active_object (transaction::current ().connection ()) + { + int e (sqlite3_blob_open (conn_.handle (), + db, + table, + column, + static_cast (rowid), + rw, + &h_)); + + if (e != SQLITE_OK) + translate_error (e, conn_); + + list_add (); // Add ourselves to the active objects list. + } + + size_t stream:: + size () const + { + return static_cast (sqlite3_blob_bytes (h_)); + } + + void stream:: + read (void* buf, size_t n, size_t o) + { + int e (sqlite3_blob_read ( + h_, buf, static_cast (n), static_cast (o))); + + if (e != SQLITE_OK) + { + if (e == SQLITE_ERROR) + throw invalid_argument ("read past end"); + else + translate_error (e, conn_); + } + } + + void stream:: + write (const void* buf, size_t n, size_t o) + { + int e (sqlite3_blob_write ( + h_, buf, static_cast (n), static_cast (o))); + + if (e != SQLITE_OK) + { + if (e == SQLITE_ERROR) + throw invalid_argument ("write past end"); + else + translate_error (e, conn_); + } + } + + void stream:: + close (bool check) + { + if (h_ != 0) + { + list_remove (); + + int e (sqlite3_blob_close (h_)); + h_ = 0; // No use trying again. + + if (check && e != SQLITE_OK) + translate_error (e, conn_); + } + } + +#if SQLITE_VERSION_NUMBER >= 3007004 + void stream:: + reopen (long long rowid) + { + int e (sqlite3_blob_reopen (h_, rowid)); + + if (e != SQLITE_OK) + // According to the SQLite documentation, the handle is now + // considered aborted, which means we still need to close it. + // + translate_error (e, conn_); + } +#endif + + void stream:: + clear () + { + // This call can be part of the stack unwinding, so don't check + // for the errors. + // + close (false); + } + } +} + +#endif // SQLITE_VERSION_NUMBER >= 3004000 diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx new file mode 100644 index 0000000..387dcf0 --- /dev/null +++ b/odb/sqlite/stream.hxx @@ -0,0 +1,82 @@ +// file : odb/sqlite/stream.hxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STREAM_HXX +#define ODB_SQLITE_STREAM_HXX + +#include + +#include + +#include // std::size_t + +#include +#include + +namespace odb +{ + namespace sqlite + { + // SQLite incremental BLOB/TEXT I/O stream. Available since + // SQLite 3.4.0. + // + class LIBODB_SQLITE_EXPORT stream: public active_object + { + public: + stream (const char* db, + const char* table, + const char* column, + long long rowid, + bool rw); + + std::size_t + size () const; + + // The following two functions throw std::invalid_argument if + // offset + n is past size(). + // + void + read (void* buf, std::size_t n, std::size_t offset = 0); + + void + write (const void* buf, std::size_t n, std::size_t offset = 0); + + sqlite3_blob* + handle () const {return h_;} + + // Close without reporting errors, if any. + // + virtual + ~stream () {close (false);} + + // Close, by default with reporting errors, if any. + // + void + close (bool check = true); + + // Open the same BLOB but in a different row. Can be faster + // than creating a new stream instance. Note that the stream + // must be in the open state prior to calling this function. + // Only available since SQLite 3.7.4. + // +#if SQLITE_VERSION_NUMBER >= 3007004 + void + reopen (long long rowid); +#endif + + protected: + // The active_object interface. + // + virtual void + clear (); + + private: + sqlite3_blob* h_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx new file mode 100644 index 0000000..71d3053 --- /dev/null +++ b/odb/sqlite/text-stream.hxx @@ -0,0 +1,33 @@ +// file : odb/sqlite/text-stream.hxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TEXT_STREAM_HXX +#define ODB_SQLITE_TEXT_STREAM_HXX + +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT text_stream: public stream + { + public: + text_stream (const text& b, bool rw) + : stream (b.db ().c_str (), + b.table ().c_str (), + b.column ().c_str (), + b.rowid (), + rw) {} + }; + } +} + +#include + +#endif // ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx new file mode 100644 index 0000000..1e7e25f --- /dev/null +++ b/odb/sqlite/text.hxx @@ -0,0 +1,70 @@ +// file : odb/sqlite/text.hxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TEXT_HXX +#define ODB_SQLITE_TEXT_HXX + +#include + +#include +#include // std::size_t + +// Carefully allow this header to be included into the ODB compilation. +// +#ifndef ODB_COMPILER +# include +# include +#endif + +namespace odb +{ + namespace sqlite + { +#ifdef ODB_COMPILER + #pragma db sqlite:type("TEXT STREAM") + class text +#else + class LIBODB_SQLITE_EXPORT text +#endif + { + public: + // TEXT size to provision for. Set before calling persist() or update(). + // + explicit + text (std::size_t size = 0): size_ (size) {} + + std::size_t size () const {return size_;} + void size (std::size_t s) {size_ = s;} + + const std::string& db () const {return db_;} + const std::string& table () const {return table_;} + const std::string& column () const {return column_;} + long long rowid () const {return rowid_;} + + void + clear () + { + size_ = 0; + db_.clear (); + table_.clear (); + column_.clear (); + rowid_ = 0; + } + + private: +#ifndef ODB_COMPILER + friend struct default_value_traits; +#endif + std::size_t size_; + mutable std::string db_; + mutable std::string table_; + mutable std::string column_; + mutable long long rowid_; + }; + } +} + +#include + +#endif // ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index de8e3c3..dc4d113 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -25,22 +25,18 @@ #include #include +#include #include #include #include +#include +#include + namespace odb { namespace sqlite { - enum database_type_id - { - id_integer, - id_real, - id_text, - id_blob - }; - // // image_traits // @@ -67,6 +63,18 @@ namespace odb template struct image_traits {typedef details::buffer image_type;}; + template + struct image_traits + { + typedef stream_buffers image_type; + }; + + template + struct image_traits + { + typedef stream_buffers image_type; + }; + // // value_traits // @@ -140,6 +148,20 @@ namespace odb { vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); } + + // TEXT and BLOB STREAM. + // + static void + set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) + { + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } }; template @@ -191,6 +213,26 @@ namespace odb if (!is_null) vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); } + + // TEXT and BLOB STREAM. + // + static void + set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } }; template @@ -811,6 +853,82 @@ namespace odb }; #endif + // text (stream) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + public: + typedef text value_type; + typedef std::string query_type; + typedef stream_buffers image_type; + + static void + set_value (text& v, const stream_buffers& b, std::size_t, bool is_null) + { + if (!is_null) + { + v.db_ = b.db.in; + v.table_ = b.table.in; + v.column_ = b.column.in; + v.rowid_ = b.rowid.in; + } + } + + static void + set_image (stream_buffers& b, + std::size_t& n, + bool& is_null, + const text& v) + { + is_null = false; + n = v.size_; + + b.db.out = &v.db_; + b.table.out = &v.table_; + b.column.out = &v.column_; + b.rowid.out = &v.rowid_; + } + }; + + // blob (stream) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + public: + typedef blob value_type; + typedef std::vector query_type; + typedef stream_buffers image_type; + + static void + set_value (blob& v, const stream_buffers& b, std::size_t, bool is_null) + { + if (!is_null) + { + v.db_ = b.db.in; + v.table_ = b.table.in; + v.column_ = b.column.in; + v.rowid_ = b.rowid.in; + } + } + + static void + set_image (stream_buffers& b, + std::size_t& n, + bool& is_null, + const blob& v) + { + is_null = false; + n = v.size_; + + b.db.out = &v.db_; + b.table.out = &v.table_; + b.column.out = &v.column_; + b.rowid.out = &v.rowid_; + } + }; + // // type_traits // @@ -970,6 +1088,18 @@ namespace odb static const database_type_id db_type_id = id_blob; }; #endif + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text_stream; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_blob_stream; + }; } } -- cgit v1.1 From a39485c2dd91c1083a434eb02b833b0094dd87cb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Jul 2015 14:16:53 +0200 Subject: Handle empty query::in_range() case --- odb/sqlite/query-dynamic.cxx | 24 +++++++++++++++--------- odb/sqlite/query.txx | 25 +++++++++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index dd89e78..02f6322 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -94,20 +94,26 @@ namespace odb } case part::op_in: { - size_t b (p - x.data); + if (x.data != 0) + { + size_t b (p - x.data); - translate (q, s, b - 1); // column - q += "IN ("; + translate (q, s, b - 1); // column + q += "IN ("; - for (size_t i (b); i != p; ++i) - { - if (i != b) - q += ","; + for (size_t i (b); i != p; ++i) + { + if (i != b) + q += ","; - translate (q, s, i); + translate (q, s, i); + } + + q += ")"; } + else + q.append (false); - q += ")"; break; } case part::op_like: diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index b51b45a..909807f 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -100,19 +100,24 @@ namespace odb query_base query_column:: in_range (I begin, I end) const { - query_base q (table_, column_); - q += "IN ("; - - for (I i (begin); i != end; ++i) + if (begin != end) { - if (i != begin) - q += ","; + query_base q (table_, column_); + q += "IN ("; - q.append (val_bind (*i), conversion_); - } + for (I i (begin); i != end; ++i) + { + if (i != begin) + q += ","; - q += ")"; - return q; + q.append (val_bind (*i), conversion_); + } + + q += ")"; + return q; + } + else + return query_base (false); } // like -- cgit v1.1 From 8a81f3258a617a466163e0ec08e35f45db7f2348 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Jul 2015 17:43:39 +0200 Subject: Bump version to 2.5.0.a1 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index ae0fb75..71c2bb8 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20400 +#if ODB_VERSION != 20401 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2040000 -#define LIBODB_SQLITE_VERSION_STR "2.4.0" +#define LIBODB_SQLITE_VERSION 2049901 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a1" #include diff --git a/version b/version index 197c4d5..3a437d9 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.4.0 +2.5.0.a1 -- cgit v1.1 From b9b88f847f203dd92c42618334f60d2523a64465 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 31 Aug 2015 14:57:56 +0200 Subject: Add missing export symbol --- odb/sqlite/connection.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index f8378fb..7499eb9 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -38,7 +38,7 @@ namespace odb // "cleared" before the transaction can be committed and the // connection release. These form a doubly-linked list. // - class active_object + class LIBODB_SQLITE_EXPORT active_object { public: // This function should remove the object from the list, since -- cgit v1.1 From 857fabab0c537a286e8a39503bf987029669d854 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Sep 2015 16:48:21 +0200 Subject: Add dummy source files to make Win32 export working --- odb/sqlite/blob-stream.cxx | 7 +++++++ odb/sqlite/makefile | 2 ++ odb/sqlite/text-stream.cxx | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 odb/sqlite/blob-stream.cxx create mode 100644 odb/sqlite/text-stream.cxx diff --git a/odb/sqlite/blob-stream.cxx b/odb/sqlite/blob-stream.cxx new file mode 100644 index 0000000..4bcedeb --- /dev/null +++ b/odb/sqlite/blob-stream.cxx @@ -0,0 +1,7 @@ +// file : odb/sqlite/blob-stream.cxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +// Dummy source file to get Win32 DLL export working. diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index e2ea0e9..0b3f8b2 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -5,6 +5,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make cxx := \ +blob-stream.cxx \ connection.cxx \ connection-factory.cxx \ database.cxx \ @@ -19,6 +20,7 @@ statement.cxx \ statements-base.cxx \ statement-cache.cxx \ stream.cxx \ +text-stream.cxx \ tracer.cxx \ traits.cxx \ transaction.cxx \ diff --git a/odb/sqlite/text-stream.cxx b/odb/sqlite/text-stream.cxx new file mode 100644 index 0000000..f5642e4 --- /dev/null +++ b/odb/sqlite/text-stream.cxx @@ -0,0 +1,7 @@ +// file : odb/sqlite/text-stream.cxx +// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +// Dummy source file to get Win32 DLL export working. -- cgit v1.1 From 2bf2944a844d002267d3508ce81a2128ccbb8af7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 9 Nov 2015 18:14:37 +0200 Subject: Make database class move-constructible This means it can be returned by value from a function in C++11. --- odb/sqlite/connection-factory.cxx | 86 +++++++++++++++++++-------------------- odb/sqlite/connection-factory.hxx | 46 ++++----------------- odb/sqlite/connection.cxx | 32 +++++++++++---- odb/sqlite/connection.hxx | 42 ++++++++++++++----- odb/sqlite/connection.ixx | 6 +++ odb/sqlite/database.hxx | 9 ++++ odb/sqlite/database.ixx | 16 ++++++++ 7 files changed, 136 insertions(+), 101 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index c40190a..317d048 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -18,15 +18,6 @@ namespace odb namespace sqlite { // - // connection_factory - // - - connection_factory:: - ~connection_factory () - { - } - - // // single_connection_factory // @@ -43,14 +34,14 @@ namespace odb single_connection_factory:: create () { - return single_connection_ptr (new (shared) single_connection (*db_)); + return single_connection_ptr (new (shared) single_connection (*this)); } connection_ptr single_connection_factory:: connect () { mutex_.lock (); - connection_->factory_ = this; + connection_->callback_ = &connection_->cb_; connection_ptr r (connection_); connection_.reset (); return r; @@ -59,14 +50,16 @@ namespace odb void single_connection_factory:: database (database_type& db) { - db_ = &db; - connection_ = create (); + connection_factory::database (db); + + if (!connection_) + connection_ = create (); } bool single_connection_factory:: release (single_connection* c) { - c->factory_ = 0; + c->callback_ = 0; connection_.reset (inc_ref (c)); connection_->recycle (); mutex_.unlock (); @@ -78,28 +71,26 @@ namespace odb // single_connection_factory::single_connection:: - single_connection (database_type& db, int extra_flags) - : connection (db, extra_flags), factory_ (0) + single_connection (single_connection_factory& f, int extra_flags) + : connection (f, extra_flags) { - callback_.arg = this; - callback_.zero_counter = &zero_counter; - shared_base::callback_ = &callback_; + cb_.arg = this; + cb_.zero_counter = &zero_counter; } single_connection_factory::single_connection:: - single_connection (database_type& db, sqlite3* handle) - : connection (db, handle), factory_ (0) + single_connection (single_connection_factory& f, sqlite3* handle) + : connection (f, handle) { - callback_.arg = this; - callback_.zero_counter = &zero_counter; - shared_base::callback_ = &callback_; + cb_.arg = this; + cb_.zero_counter = &zero_counter; } bool single_connection_factory::single_connection:: zero_counter (void* arg) { single_connection* c (static_cast (arg)); - return c->factory_ ? c->factory_->release (c) : true; + return static_cast (c->factory_).release (c); } // @@ -109,14 +100,18 @@ namespace odb connection_ptr new_connection_factory:: connect () { - return connection_ptr ( - new (shared) connection (*db_, extra_flags_)); + return connection_ptr (new (shared) connection (*this, extra_flags_)); } void new_connection_factory:: database (database_type& db) { - db_ = &db; + bool first (db_ == 0); + + connection_factory::database (db); + + if (!first) + return; // Unless explicitly disabled, enable shared cache. // @@ -134,7 +129,7 @@ namespace odb create () { return pooled_connection_ptr ( - new (shared) pooled_connection (*db_, extra_flags_)); + new (shared) pooled_connection (*this, extra_flags_)); } connection_pool_factory:: @@ -165,7 +160,7 @@ namespace odb shared_ptr c (connections_.back ()); connections_.pop_back (); - c->pool_ = this; + c->callback_ = &c->cb_; in_use_++; return c; } @@ -175,7 +170,7 @@ namespace odb if(max_ == 0 || in_use_ < max_) { shared_ptr c (create ()); - c->pool_ = this; + c->callback_ = &c->cb_; in_use_++; return c; } @@ -191,7 +186,12 @@ namespace odb void connection_pool_factory:: database (database_type& db) { - db_ = &db; + bool first (db_ == 0); + + connection_factory::database (db); + + if (!first) + return; // Unless explicitly disabled, enable shared cache. // @@ -212,7 +212,7 @@ namespace odb bool connection_pool_factory:: release (pooled_connection* c) { - c->pool_ = 0; + c->callback_ = 0; lock l (mutex_); @@ -241,28 +241,26 @@ namespace odb // connection_pool_factory::pooled_connection:: - pooled_connection (database_type& db, int extra_flags) - : connection (db, extra_flags), pool_ (0) + pooled_connection (connection_pool_factory& f, int extra_flags) + : connection (f, extra_flags) { - callback_.arg = this; - callback_.zero_counter = &zero_counter; - shared_base::callback_ = &callback_; + cb_.arg = this; + cb_.zero_counter = &zero_counter; } connection_pool_factory::pooled_connection:: - pooled_connection (database_type& db, sqlite3* handle) - : connection (db, handle), pool_ (0) + pooled_connection (connection_pool_factory& f, sqlite3* handle) + : connection (f, handle) { - callback_.arg = this; - callback_.zero_counter = &zero_counter; - shared_base::callback_ = &callback_; + cb_.arg = this; + cb_.zero_counter = &zero_counter; } bool connection_pool_factory::pooled_connection:: zero_counter (void* arg) { pooled_connection* c (static_cast (arg)); - return c->pool_ ? c->pool_->release (c) : true; + return static_cast (c->factory_).release (c); } } } diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index c0d15ff..d3d6aea 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -24,29 +24,13 @@ namespace odb { namespace sqlite { - class LIBODB_SQLITE_EXPORT connection_factory - { - public: - virtual connection_ptr - connect () = 0; - - public: - typedef sqlite::database database_type; - - virtual void - database (database_type&) = 0; - - virtual - ~connection_factory (); - }; - // Share a single connection. // class LIBODB_SQLITE_EXPORT single_connection_factory: public connection_factory { public: - single_connection_factory (): db_ (0) {} + single_connection_factory () {} virtual connection_ptr connect (); @@ -65,8 +49,8 @@ namespace odb class LIBODB_SQLITE_EXPORT single_connection: public connection { public: - single_connection (database_type&, int extra_flags = 0); - single_connection (database_type&, sqlite3*); + single_connection (single_connection_factory&, int extra_flags = 0); + single_connection (single_connection_factory&, sqlite3*); private: static bool @@ -74,12 +58,7 @@ namespace odb private: friend class single_connection_factory; - - shared_base::refcount_callback callback_; - - // NULL factory value indicates that the connection is not in use. - // - single_connection_factory* factory_; + shared_base::refcount_callback cb_; }; friend class single_connection; @@ -99,7 +78,6 @@ namespace odb release (single_connection*); protected: - database_type* db_; details::mutex mutex_; single_connection_ptr connection_; }; @@ -110,7 +88,7 @@ namespace odb public connection_factory { public: - new_connection_factory (): db_ (0), extra_flags_ (0) {} + new_connection_factory (): extra_flags_ (0) {} virtual connection_ptr connect (); @@ -123,7 +101,6 @@ namespace odb new_connection_factory& operator= (const new_connection_factory&); private: - database_type* db_; int extra_flags_; }; @@ -156,7 +133,6 @@ namespace odb extra_flags_ (0), in_use_ (0), waiters_ (0), - db_ (0), cond_ (mutex_) { // max_connections == 0 means unlimited. @@ -181,8 +157,8 @@ namespace odb class LIBODB_SQLITE_EXPORT pooled_connection: public connection { public: - pooled_connection (database_type&, int extra_flags = 0); - pooled_connection (database_type&, sqlite3*); + pooled_connection (connection_pool_factory&, int extra_flags = 0); + pooled_connection (connection_pool_factory&, sqlite3*); private: static bool @@ -190,12 +166,7 @@ namespace odb private: friend class connection_pool_factory; - - shared_base::refcount_callback callback_; - - // NULL pool value indicates that the connection is not in use. - // - connection_pool_factory* pool_; + shared_base::refcount_callback cb_; }; friend class pooled_connection; @@ -223,7 +194,6 @@ namespace odb std::size_t in_use_; // Number of connections currently in use. std::size_t waiters_; // Number of threads waiting for a connection. - database_type* db_; connections connections_; details::mutex mutex_; diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index c44d648..b150470 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -29,12 +29,13 @@ namespace odb namespace sqlite { connection:: - connection (database_type& db, int extra_flags) - : odb::connection (db), - db_ (db), + connection (connection_factory& cf, int extra_flags) + : odb::connection (cf), unlock_cond_ (unlock_mutex_), active_objects_ (0) { + database_type& db (database ()); + int f (db.flags () | extra_flags); const string& n (db.name ()); @@ -81,9 +82,8 @@ namespace odb } connection:: - connection (database_type& db, sqlite3* handle) - : odb::connection (db), - db_ (db), + connection (connection_factory& cf, sqlite3* handle) + : odb::connection (cf), handle_ (handle), unlock_cond_ (unlock_mutex_), active_objects_ (0) @@ -94,14 +94,16 @@ namespace odb void connection:: init () { + database_type& db (database ()); + // Enable/disable foreign key constraints. // generic_statement st ( *this, - db_.foreign_keys () + db.foreign_keys () ? "PRAGMA foreign_keys=ON" : "PRAGMA foreign_keys=OFF", - db_.foreign_keys () ? 22 : 23); + db.foreign_keys () ? 22 : 23); st.execute (); // Create statement cache. @@ -190,6 +192,20 @@ namespace odb while (active_objects_ != 0) active_objects_->clear (); } + + // connection_factory + // + connection_factory:: + ~connection_factory () + { + } + + void connection_factory:: + database (database_type& db) + { + odb::connection_factory::db_ = &db; + db_ = &db; + } } } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 7499eb9..5110163 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -30,6 +30,7 @@ namespace odb namespace sqlite { class statement_cache; + class connection_factory; class connection; typedef details::shared_ptr connection_ptr; @@ -76,14 +77,11 @@ namespace odb virtual ~connection (); - connection (database_type&, int extra_flags = 0); - connection (database_type&, sqlite3* handle); + connection (connection_factory&, int extra_flags = 0); + connection (connection_factory&, sqlite3* handle); database_type& - database () - { - return db_; - } + database (); public: virtual transaction_impl* @@ -173,11 +171,6 @@ namespace odb init (); private: - // Needed to break the circular connection-database dependency - // (odb::connection has the odb::database member). - // - database_type& db_; - auto_handle handle_; // Keep statement_cache_ after handle_ so that it is destroyed before @@ -205,6 +198,33 @@ namespace odb friend class active_object; active_object* active_objects_; }; + + class LIBODB_SQLITE_EXPORT connection_factory: + public odb::connection_factory + { + public: + typedef sqlite::database database_type; + + virtual void + database (database_type&); + + database_type& + database () {return *db_;} + + virtual connection_ptr + connect () = 0; + + virtual + ~connection_factory (); + + connection_factory (): db_ (0) {} + + // Needed to break the circular connection_factory-database dependency + // (odb::connection_factory has the odb::database member). + // + protected: + database_type* db_; + }; } } diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 23df27c..ab6d72e 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -32,6 +32,12 @@ namespace odb // connection // + inline database& connection:: + database () + { + return static_cast (factory_).database (); + } + template inline prepared_query connection:: prepare_query (const char* n, const char* q) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index f7f3994..f846f9e 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -14,6 +14,7 @@ #include // std::ostream #include +#include // ODB_CXX11 #include #include @@ -84,6 +85,12 @@ namespace odb details::transfer_ptr = details::transfer_ptr ()); + // Move-constructible but not move-assignable. + // +#ifdef ODB_CXX11 + database (database&&); +#endif + static void print_usage (std::ostream&); @@ -458,6 +465,8 @@ namespace odb connection_ (); private: + // Note: remember to update move ctor if adding any new members. + // std::string name_; int flags_; bool foreign_keys_; diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index c1e8f07..aec4ba5 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -2,12 +2,28 @@ // copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include // move() + #include namespace odb { namespace sqlite { +#ifdef ODB_CXX11 + inline database:: + database (database&& db) // Has to be inline. + : odb::database (std::move (db)), + name_ (std::move (db.name_)), + flags_ (db.flags_), + foreign_keys_ (db.foreign_keys_), + vfs_ (std::move (db.vfs_)), + factory_ (std::move (db.factory_)) + { + factory_->database (*this); // New database instance. + } +#endif + inline connection_ptr database:: connection () { -- cgit v1.1 From 71f475d470670da9e771e8bed64393223d1ca179 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 9 Nov 2015 18:18:49 +0200 Subject: Bump version to 2.5.0.a2 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 71c2bb8..4a11983 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20401 +#if ODB_VERSION != 20402 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049901 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a1" +#define LIBODB_SQLITE_VERSION 2049902 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a2" #include diff --git a/version b/version index 3a437d9..b7f6fd3 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a1 +2.5.0.a2 -- cgit v1.1 From cea9f5cb274bd206314e1a111956f23e829e03e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Nov 2015 16:31:13 +0200 Subject: Don't try to depend on installed cli executable --- odb/sqlite/makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 0b3f8b2..812e153 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -63,7 +63,12 @@ $(cxx_obj) $(cxx_od): $(odb_sqlite.l.cpp-options) $(out_base)/details/config.h genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) gen := $(addprefix $(out_base)/,$(genf)) +# Don't try to depend on the installed executable. +# +ifneq ($(cli),cli) $(gen): $(cli) +endif + $(gen): cli := $(cli) $(gen): cli_options += \ --long-usage \ -- cgit v1.1 From 4e31e3dcf3efcc20ca3aee6f888fe3ec56ba78e3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Jan 2016 18:59:12 +0200 Subject: Bump version to 2.5.0.a4 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 4a11983..26b1604 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20402 +#if ODB_VERSION != 20404 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049902 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a2" +#define LIBODB_SQLITE_VERSION 2049904 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a4" #include diff --git a/version b/version index b7f6fd3..608404c 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a2 +2.5.0.a4 -- cgit v1.1 From 8c41d647fab4dfbd0a9979514f95431dfc19e00b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 Jan 2016 18:34:18 +0200 Subject: Detect if column metadata functions are available For example, system-default build of SQLite doesn't have SQLITE_ENABLE_COLUMN_METADATA. --- INSTALL | 10 +++++++--- configure.ac | 3 +++ m4/libsqlite.m4 | 25 +++++++++++++++++++++++++ odb/sqlite/details/config.h.in | 1 + odb/sqlite/libodb-sqlite-vc10.vcxproj | 8 ++++---- odb/sqlite/libodb-sqlite-vc11.vcxproj | 8 ++++---- odb/sqlite/libodb-sqlite-vc12.vcxproj | 8 ++++---- odb/sqlite/libodb-sqlite-vc8.vcproj | 8 ++++---- odb/sqlite/libodb-sqlite-vc9.vcproj | 8 ++++---- odb/sqlite/makefile | 1 + odb/sqlite/statement.cxx | 6 +++++- 11 files changed, 62 insertions(+), 24 deletions(-) diff --git a/INSTALL b/INSTALL index 2a55ef1..63fae36 100644 --- a/INSTALL +++ b/INSTALL @@ -4,9 +4,13 @@ Prerequisites - libodb http://www.codesynthesis.com/products/odb/ - libsqlite3 http://www.sqlite.org -If you plan to access an SQLite database from multiple threads, then -you will need SQLite version 3.5.0 or later built with the unlock -notify feature (SQLITE_ENABLE_UNLOCK_NOTIFY) enabled. +If you plan to access an SQLite database from multiple threads, then you will +need SQLite version 3.5.0 or later built with the unlock notify feature +(SQLITE_ENABLE_UNLOCK_NOTIFY) enabled. + +If you plant to use SQLite incremental BLOB/TEXT I/O support, then you will +need SQLite version 3.4.0 or later built with the column metadata functions +(SQLITE_ENABLE_COLUMN_METADATA) enabled. Building on UNIX diff --git a/configure.ac b/configure.ac index 4e9b4a5..40c84e8 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,9 @@ LIBSQLITE( AS_IF([test x$libsqlite_unlock_notify = xyes], AC_DEFINE([LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY], [1], [Have sqlite3_unlock_notify.])) +AS_IF([test x$libsqlite_column_metadata = xyes], +AC_DEFINE([LIBODB_SQLITE_HAVE_COLUMN_METADATA], [1], [Have column metadata functions.])) + AS_IF([test x$threads != xnone -a x$libsqlite_unlock_notify = xno], AC_MSG_WARN([libsqlite3 is built without sqlite3_unlock_notify support; multi-threaded support will be limited])) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index a8fe4f7..36f92f8 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -7,9 +7,13 @@ dnl dnl Also sets libsqlite_unlock_notify to yes if sqlite3_unlock_notify() dnl functionality is available. dnl +dnl Also sets libsqlite_column_metadata to yes if sqlite3_column_*() +dnl functions are available. +dnl AC_DEFUN([LIBSQLITE], [ libsqlite_found=no libsqlite_unlock_notify=no +libsqlite_column_metadata=no AC_MSG_CHECKING([for libsqlite3]) @@ -58,6 +62,27 @@ libsqlite_unlock_notify=yes ]) fi +# Check for column_metadata. +# +if test x"$libsqlite_found" = xyes; then +CXX_LIBTOOL_LINK_IFELSE([ +AC_LANG_SOURCE([ +#include + +int +main () +{ + sqlite3_stmt* stmt (0); + sqlite3_column_database_name (stmt, 0); + sqlite3_column_table_name (stmt, 0); + sqlite3_column_origin_name (stmt, 0); +} +])], +[ +libsqlite_column_metadata=yes +]) +fi + if test x"$libsqlite_found" = xyes; then AC_MSG_RESULT([yes]) $1 diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index c8158be..9c2d2d7 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -10,5 +10,6 @@ #undef LIBODB_SQLITE_STATIC_LIB #undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY +#undef LIBODB_SQLITE_HAVE_COLUMN_METADATA #endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj b/odb/sqlite/libodb-sqlite-vc10.vcxproj index 974aa48..844eeb4 100644 --- a/odb/sqlite/libodb-sqlite-vc10.vcxproj +++ b/odb/sqlite/libodb-sqlite-vc10.vcxproj @@ -88,7 +88,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -106,7 +106,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -126,7 +126,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -148,7 +148,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) diff --git a/odb/sqlite/libodb-sqlite-vc11.vcxproj b/odb/sqlite/libodb-sqlite-vc11.vcxproj index 3ec1701..670370c 100644 --- a/odb/sqlite/libodb-sqlite-vc11.vcxproj +++ b/odb/sqlite/libodb-sqlite-vc11.vcxproj @@ -92,7 +92,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -110,7 +110,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -130,7 +130,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) @@ -152,7 +152,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj b/odb/sqlite/libodb-sqlite-vc12.vcxproj index d83b7f7..f74ccbc 100644 --- a/odb/sqlite/libodb-sqlite-vc12.vcxproj +++ b/odb/sqlite/libodb-sqlite-vc12.vcxproj @@ -92,7 +92,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) true @@ -111,7 +111,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) true @@ -132,7 +132,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) true @@ -155,7 +155,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) ..\.. 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) true diff --git a/odb/sqlite/libodb-sqlite-vc8.vcproj b/odb/sqlite/libodb-sqlite-vc8.vcproj index 7bcc784..ef5c743 100644 --- a/odb/sqlite/libodb-sqlite-vc8.vcproj +++ b/odb/sqlite/libodb-sqlite-vc8.vcproj @@ -45,7 +45,7 @@ AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -123,7 +123,7 @@ AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -200,7 +200,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" @@ -278,7 +278,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" diff --git a/odb/sqlite/libodb-sqlite-vc9.vcproj b/odb/sqlite/libodb-sqlite-vc9.vcproj index 1bcec78..f21c203 100644 --- a/odb/sqlite/libodb-sqlite-vc9.vcproj +++ b/odb/sqlite/libodb-sqlite-vc9.vcproj @@ -46,7 +46,7 @@ AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -124,7 +124,7 @@ AdditionalOptions="/wd4355 /wd4800 /wd4290 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -203,7 +203,7 @@ Optimization="2" EnableIntrinsicFunctions="true" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" RuntimeLibrary="2" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" @@ -284,7 +284,7 @@ Optimization="2" EnableIntrinsicFunctions="true" AdditionalIncludeDirectories="..\.." - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA" RuntimeLibrary="2" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 812e153..abee73e 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -89,6 +89,7 @@ $(out_base)/details/config.h: | $(out_base)/details/. @echo '#if SQLITE_VERSION_NUMBER >= 3006012' >>$@ @echo ' #define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1' >>$@ @echo '#endif' >>$@ + @echo '#define LIBODB_SQLITE_HAVE_COLUMN_METADATA 1' >>$@ @echo '' >>$@ @echo '#endif /* ODB_SQLITE_DETAILS_CONFIG_H */' >>$@ diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index f7ce632..ce6458a 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -11,7 +11,7 @@ #include #include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - + // LIBODB_SQLITE_HAVE_COLUMN_METADATA using namespace std; namespace odb @@ -355,9 +355,13 @@ namespace odb // we do while executing the statement (i.e., we don't copy // images for later processing). // +#ifdef LIBODB_SQLITE_HAVE_COLUMN_METADATA sb.db.in = sqlite3_column_database_name (stmt_, c); sb.table.in = sqlite3_column_table_name (stmt_, c); sb.column.in = sqlite3_column_origin_name (stmt_, c); +#else + assert (false); +#endif // The ROWID comes in the following column. // -- cgit v1.1 From c63b9d25ba1b69ae4998da97a518ce0bbdbc83a9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Feb 2016 12:11:16 +0200 Subject: Bump version to 2.5.0.a5 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 26b1604..07f72b4 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20404 +#if ODB_VERSION != 20405 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049904 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a4" +#define LIBODB_SQLITE_VERSION 2049905 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a5" #include diff --git a/version b/version index 608404c..9518eae 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a4 +2.5.0.a5 -- cgit v1.1 From a8585d295bded21aefb87f68e34178128a77317e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 6 Apr 2016 14:32:22 +0200 Subject: Bump version to 2.5.0.a6 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 07f72b4..145b31f 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20405 +#if ODB_VERSION != 20406 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049905 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a5" +#define LIBODB_SQLITE_VERSION 2049906 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a6" #include diff --git a/version b/version index 9518eae..5ae477a 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a5 +2.5.0.a6 -- cgit v1.1 From 8f7e466213c46a419694c9960fb0c53687329210 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 6 May 2016 21:38:08 +0200 Subject: Bump version to 2.5.0.a7 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 145b31f..0e578ba 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20406 +#if ODB_VERSION != 20407 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049906 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a6" +#define LIBODB_SQLITE_VERSION 2049907 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a7" #include diff --git a/version b/version index 5ae477a..c3af3cc 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a6 +2.5.0.a7 -- cgit v1.1 From 293c30123235e3c0ed724143234d6494afd2f6c8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Jun 2016 18:50:51 +0200 Subject: Get rid of C++11 deprecation warnings for auto_ptr, exception specs In particular, std::auto_ptr is no longer mapped in C++11. --- odb/sqlite/database.hxx | 1 - odb/sqlite/exceptions.cxx | 10 +++++----- odb/sqlite/exceptions.hxx | 11 ++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index f846f9e..cb837b4 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -10,7 +10,6 @@ #include #include -#include // std::auto_ptr, std::unique_ptr #include // std::ostream #include diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 77436ae..ab54340 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -17,7 +17,7 @@ namespace odb // const char* forced_rollback:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return "transaction is forced to rollback"; } @@ -33,7 +33,7 @@ namespace odb // database_exception:: - ~database_exception () throw () + ~database_exception () ODB_NOTHROW_NOEXCEPT { } @@ -52,7 +52,7 @@ namespace odb } const char* database_exception:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return what_.c_str (); } @@ -74,12 +74,12 @@ namespace odb } cli_exception:: - ~cli_exception () throw () + ~cli_exception () ODB_NOTHROW_NOEXCEPT { } const char* cli_exception:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return what_.c_str (); } diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 067abcc..01bf5ec 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -10,6 +10,7 @@ #include #include +#include // ODB_NOTHROW_NOEXCEPT #include #include @@ -28,7 +29,7 @@ namespace odb struct LIBODB_SQLITE_EXPORT forced_rollback: recoverable { virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual forced_rollback* clone () const; @@ -40,7 +41,7 @@ namespace odb int extended_error, const std::string& message); - ~database_exception () throw (); + ~database_exception () ODB_NOTHROW_NOEXCEPT; int error () const @@ -61,7 +62,7 @@ namespace odb } virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual database_exception* clone () const; @@ -76,10 +77,10 @@ namespace odb struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception { cli_exception (const std::string& what); - ~cli_exception () throw (); + ~cli_exception () ODB_NOTHROW_NOEXCEPT; virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual cli_exception* clone () const; -- cgit v1.1 From 0d7613a5731de4114d408c03cab581c3e255df69 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Jun 2016 18:56:49 +0200 Subject: Bump version to 2.5.0.a8 --- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 0e578ba..a09e659 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20407 +#if ODB_VERSION != 20408 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049907 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a7" +#define LIBODB_SQLITE_VERSION 2049908 +#define LIBODB_SQLITE_VERSION_STR "2.5.0.a8" #include diff --git a/version b/version index c3af3cc..bdfefee 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a7 +2.5.0.a8 -- cgit v1.1 From 35d869be3529a043f3bc5444f1503f408474896c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 5 Aug 2016 17:55:04 +0200 Subject: Adjust to threading API changes in libodb --- odb/sqlite/connection-factory.cxx | 4 ++-- odb/sqlite/connection.cxx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 317d048..4444167 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -141,7 +141,7 @@ namespace odb while (in_use_ != 0) { waiters_++; - cond_.wait (); + cond_.wait (l); waiters_--; } } @@ -178,7 +178,7 @@ namespace odb // Wait until someone releases a connection. // waiters_++; - cond_.wait (); + cond_.wait (l); waiters_--; } } diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index b150470..2425244 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -177,7 +177,7 @@ namespace odb details::lock l (unlock_mutex_); while (!unlocked_) - unlock_cond_.wait (); + unlock_cond_.wait (l); #else translate_error (SQLITE_LOCKED, *this); #endif -- cgit v1.1 From faeb51bca04b658c5473bdd7a8f71f8a70113118 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 7 Aug 2016 09:02:29 +0200 Subject: Minor config file restructuring in preparation for build2 support --- odb/sqlite/details/config-vc.h | 6 ++++++ odb/sqlite/details/config.hxx | 11 +++++++---- odb/sqlite/makefile | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 odb/sqlite/details/config-vc.h diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h new file mode 100644 index 0000000..2ecc24a --- /dev/null +++ b/odb/sqlite/details/config-vc.h @@ -0,0 +1,6 @@ +/* file : odb/sqlite/details/config-vc.h + * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Dummy configuration file for Windows/VC++. */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 5d19aad..ec89ed6 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -7,11 +7,14 @@ // no pre -#ifdef _MSC_VER -#elif defined(ODB_COMPILER) +#ifdef ODB_COMPILER # error libodb-sqlite header included in odb-compiled header -#else -# include +#elif !defined(LIBODB_SQLITE_BUILD2) +# elif defined(_MSC_VER) +# include +# else +# include +# endif #endif // no post diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index abee73e..aa411e7 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -108,7 +108,7 @@ $(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \ $(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(dist): export headers = $(sort $(headers_dist) $(gen_headers)) $(dist): gen_dist := $(gen) -$(dist): data_dist := $(cli_tun) details/config.h.in +$(dist): data_dist := $(cli_tun) details/config.h.in details/config-vc.h $(dist): export extra_dist := $(data_dist) \ libodb-sqlite-vc8.vcproj libodb-sqlite-vc9.vcproj \ libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ -- cgit v1.1 From 2dbfb23e8ada74da6d54e5398cd3071de6b10423 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 7 Aug 2016 09:03:09 +0200 Subject: Fix SQLite VC12 project to export using SQLITE_API instead of .def file Other projects are still a TODO. --- etc/sqlite/sqlite3-vc12.vcxproj | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/etc/sqlite/sqlite3-vc12.vcxproj b/etc/sqlite/sqlite3-vc12.vcxproj index 79dac0f..1b74865 100644 --- a/etc/sqlite/sqlite3-vc12.vcxproj +++ b/etc/sqlite/sqlite3-vc12.vcxproj @@ -92,7 +92,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) true @@ -100,8 +100,6 @@ true $(TargetPath) lib\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) @@ -110,7 +108,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) true @@ -118,8 +116,6 @@ true $(TargetPath) lib64\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) @@ -130,7 +126,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) true @@ -140,8 +136,6 @@ true $(TargetPath) lib\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) @@ -152,7 +146,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) true @@ -162,8 +156,6 @@ true $(TargetPath) lib64\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) -- cgit v1.1 From 1135f674150e9486c91bc16e9fb09aa755591e25 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Aug 2016 08:41:01 +0200 Subject: Initial build2 build support --- .gitignore | 6 +- build/bootstrap.build | 18 ++++++ build/export.build | 10 ++++ build/root.build | 14 +++++ buildfile | 9 +++ odb/sqlite/buildfile | 107 ++++++++++++++++++++++++++++++++++ odb/sqlite/details/build2/config-vc.h | 16 +++++ odb/sqlite/details/build2/config.h | 18 ++++++ odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/export.hxx | 39 +++++++++++++ tests/basics/buildfile | 8 +++ tests/basics/driver.cxx | 46 +++++++++++++++ tests/build/bootstrap.build | 9 +++ tests/build/root.build | 14 +++++ tests/buildfile | 7 +++ 15 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 build/bootstrap.build create mode 100644 build/export.build create mode 100644 build/root.build create mode 100644 buildfile create mode 100644 odb/sqlite/buildfile create mode 100644 odb/sqlite/details/build2/config-vc.h create mode 100644 odb/sqlite/details/build2/config.h create mode 100644 tests/basics/buildfile create mode 100644 tests/basics/driver.cxx create mode 100644 tests/build/bootstrap.build create mode 100644 tests/build/root.build create mode 100644 tests/buildfile diff --git a/.gitignore b/.gitignore index 3b9998d..cfb7ae0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ # Compiler/linker output. # +*.d *.o -*.o.d +*.obj *.so +*.dll *.a +*.lib + *.l *.l.cpp-options diff --git a/build/bootstrap.build b/build/bootstrap.build new file mode 100644 index 0000000..1d3ca56 --- /dev/null +++ b/build/bootstrap.build @@ -0,0 +1,18 @@ +# file : build/bootstrap.build +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project = libodb-sqlite +version = 2.5.0-a8 +revision = 0 + +using build@0.4.0-a1 +using config +using dist +using test +using install + +dist.package = $project-$version + +if ($revision != 0) + dist.package += +$revision diff --git a/build/export.build b/build/export.build new file mode 100644 index 0000000..18bb2b2 --- /dev/null +++ b/build/export.build @@ -0,0 +1,10 @@ +# file : build/export.build +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$out_root/: +{ + include odb/sqlite/ +} + +export $out_root/odb/sqlite/lib{odb-sqlite} diff --git a/build/root.build b/build/root.build new file mode 100644 index 0000000..44b2195 --- /dev/null +++ b/build/root.build @@ -0,0 +1,14 @@ +# file : build/root.build +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +cxx.std = 11 + +tests/: install = false # Don't install tests. diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..016dd6f --- /dev/null +++ b/buildfile @@ -0,0 +1,9 @@ +# file : buildfile +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +d = odb/sqlite/ tests/ +./: $d doc{GPLv2 INSTALL LICENSE NEWS README version} file{manifest} +include $d + +doc{INSTALL}@./: install = false diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile new file mode 100644 index 0000000..ff42128 --- /dev/null +++ b/odb/sqlite/buildfile @@ -0,0 +1,107 @@ +# file : odb/buildfile +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libsqlite3%lib{sqlite3} +import libs += libodb%lib{odb} + +lib{odb-sqlite}: \ + {hxx }{ auto-handle } \ + {hxx }{ binding } \ + {hxx }{ blob } \ + {hxx cxx}{ blob-stream } \ + {hxx ixx cxx}{ connection } \ + {hxx cxx}{ connection-factory } \ + {hxx txx }{ container-statements } \ + {hxx ixx cxx}{ database } \ + {hxx cxx}{ error } \ + {hxx cxx}{ exceptions } \ + {hxx }{ forward } \ + {hxx txx }{ no-id-object-result } \ + {hxx txx }{ no-id-object-statements } \ + {hxx txx }{ polymorphic-object-result } \ + {hxx txx }{ polymorphic-object-statements } \ + {hxx cxx}{ prepared-query } \ + {hxx ixx txx cxx}{ query } \ + { cxx}{ query-const-expr } \ + {hxx ixx txx cxx}{ query-dynamic } \ + {hxx txx }{ section-statements } \ + {hxx txx }{ simple-object-result } \ + {hxx ixx txx cxx}{ simple-object-statements } \ + {hxx }{ sqlite-types } \ + {hxx txx cxx}{ statement-cache } \ + {hxx cxx}{ statement } \ + {hxx cxx}{ statements-base } \ + {hxx cxx}{ stream } \ + {hxx }{ text } \ + {hxx cxx}{ text-stream } \ + {hxx cxx}{ tracer } \ + {hxx cxx}{ traits } \ + {hxx }{ traits-calls } \ + {hxx ixx cxx}{ transaction } \ + {hxx ixx cxx}{ transaction-impl } \ + {hxx }{ version } \ + {hxx txx }{ view-result } \ + {hxx txx }{ view-statements } \ + details/{hxx }{ config } \ + details/{hxx }{ conversion } \ + details/{hxx }{ export } \ + details/{hxx ixx cxx}{ options } \ +details/build2/{h }{ config } \ +details/build2/{h }{ config-vc } \ + $libs + +cxx.poptions =+ -I$out_root -I$src_root -DLIBODB_SQLITE_BUILD2 +obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD + +lib{odb-sqlite}: cxx.export.poptions = -I$src_root -DLIBODB_SQLITE_BUILD2 +liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC +libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED + +# Load the cli module but only if it's available. This way a distribution that +# includes pre-generated files can be built without installing cli. +# +using? cli + +if! $cli.loaded +{ + define cli: file + cli{*}: extension = cli +} + +details/: +{ + {hxx ixx cxx}{options}: cli{options} + + cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ +--guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ +--cli-namespace odb::sqlite::details::cli --long-usage + + # Include generated cli files into the distribution. But don't install them + # since they are only used internally in the database implementation. + # + {hxx ixx cxx}{options}: dist = true + {hxx ixx}{options}: install = false +} + +# Install into the odb/sqlite/ subdirectory of, say, /usr/include/. +# +install.include = $install.include/odb/sqlite/ +install.include.subdirs = true # Recreate subdirectories. + +# We want these to be picked up even when LIBODB_SQLITE_BUILD2 is not defined. +# +details/build2/: +{ + if ($cxx.id == "msvc") + { + h{config}@./: install = false + h{config-vc}@./: install = $install.include/details + } + else + { + h{config}@./: install = $install.include/details + h{config-vc}@./: install = false + } +} diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h new file mode 100644 index 0000000..0fd79ee --- /dev/null +++ b/odb/sqlite/details/build2/config-vc.h @@ -0,0 +1,16 @@ +/* file : odb/details/build2/config-vc.h + * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_VC_H +#define ODB_SQLITE_DETAILS_CONFIG_VC_H + +/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ +#ifndef LIBODB_SQLITE_BUILD2 +# define LIBODB_SQLITE_BUILD2 +#endif + +#endif /* ODB_SQLITE_DETAILS_CONFIG_VC_H */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h new file mode 100644 index 0000000..2aa7d54 --- /dev/null +++ b/odb/sqlite/details/build2/config.h @@ -0,0 +1,18 @@ +/* file : odb/sqlite/details/build2/config.h + * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. The installed case + (when LIBODB_SQLITE_BUILD2 is not necessarily defined) is the only + reason we have it. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_H +#define ODB_SQLITE_DETAILS_CONFIG_H + +/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ +#ifndef LIBODB_SQLITE_BUILD2 +# define LIBODB_SQLITE_BUILD2 +#endif + +#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index ec89ed6..1f31178 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -10,7 +10,7 @@ #ifdef ODB_COMPILER # error libodb-sqlite header included in odb-compiled header #elif !defined(LIBODB_SQLITE_BUILD2) -# elif defined(_MSC_VER) +# ifdef _MSC_VER # include # else # include diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 30e9f8b..11a5f0a 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -9,6 +9,43 @@ #include +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported function being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#ifdef LIBODB_SQLITE_BUILD2 + +#if defined(LIBODB_SQLITE_STATIC) // Using static. +# define LIBODB_SQLITE_EXPORT +#elif defined(LIBODB_SQLITE_STATIC_BUILD) // Building static. +# define LIBODB_SQLITE_EXPORT +#elif defined(LIBODB_SQLITE_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +#elif defined(LIBODB_SQLITE_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared but in case +// of shared will be sub-optimal compared to having dllimport. +// +# define LIBODB_SQLITE_EXPORT // Using static or shared. +#endif + +#else // LIBODB_SQLITE_BUILD2 + #ifdef LIBODB_SQLITE_STATIC_LIB # define LIBODB_SQLITE_EXPORT #else @@ -35,6 +72,8 @@ # endif #endif +#endif // LIBODB_SQLITE_BUILD2 + #include #endif // ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/tests/basics/buildfile b/tests/basics/buildfile new file mode 100644 index 0000000..833a7c8 --- /dev/null +++ b/tests/basics/buildfile @@ -0,0 +1,8 @@ +# file : tests/basics/buildfile +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb%lib{odb} # @@ +import libs += libodb-sqlite%lib{odb-sqlite} + +exe{driver}: cxx{driver} $libs diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx new file mode 100644 index 0000000..bcdd210 --- /dev/null +++ b/tests/basics/driver.cxx @@ -0,0 +1,46 @@ +// file : tests/basics/driver.cxx +// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// Basic test to make sure the library is usable. Functionality testing +// is done in the odb-tests package. + +#include + +#include +#include +#include + +using namespace odb::sqlite; + +int +main () +{ + database db (":memory:"); + + { + transaction t (db.begin ()); + db.execute ("CREATE TABLE test (id INTEGER PRIMARY KEY, str TEXT)"); + t.commit (); + } + + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'abc')"); + t.commit (); + } + + try + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'ABC')"); + assert (false); + } + catch (const database_exception&) {} + + { + transaction t (db.begin ()); + db.execute ("DROP TABLE test"); + t.commit (); + } +} diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build new file mode 100644 index 0000000..2f8aad2 --- /dev/null +++ b/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/tests/build/root.build b/tests/build/root.build new file mode 100644 index 0000000..c731d60 --- /dev/null +++ b/tests/build/root.build @@ -0,0 +1,14 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +using cxx + +hxx{*}: extension = hxx +cxx{*}: extension = cxx + +cxx.std = 11 + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true diff --git a/tests/buildfile b/tests/buildfile new file mode 100644 index 0000000..0341b61 --- /dev/null +++ b/tests/buildfile @@ -0,0 +1,7 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +d = basics/ +./: $d +include $d -- cgit v1.1 From a01dd3b9381dd6856917e490fb4433578ae1d4f9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Aug 2016 09:09:43 +0200 Subject: Add initial bpkg manifest --- manifest | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 manifest diff --git a/manifest b/manifest new file mode 100644 index 0000000..050e191 --- /dev/null +++ b/manifest @@ -0,0 +1,16 @@ +: 1 +name: libodb-sqlite +version: 2.5.0-a8 +summary: SQLite ODB runtime library +license: GPLv2 +license: proprietary +tags: c++, orm, sqlite, database, relational, object, persistence, sql +description-file: README +changes-file: NEWS +url: http://www.codesynthesis.com/products/odb/ +email: odb-users@codesynthesis.com +requires: c++11 +requires: build2 >= 0.4.0 +depends: libsqlite3 >= 3.6.18 +#depends: libodb [2.5.0 2.6.0-); libodb-2.5.X +depends: libodb == 2.5.0-a8 -- cgit v1.1 From ab9a9ff7ad45afedb2286d958e2126ab8ff33dd6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Aug 2016 17:47:30 +0200 Subject: Recognize WITH as beginning of complete query --- odb/sqlite/query.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index a1bc5ac..04ae043 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -208,7 +208,9 @@ namespace odb s.compare (0, (n = 8), "GROUP BY") == 0 || s.compare (0, (n = 8), "group by") == 0 || s.compare (0, (n = 6), "HAVING") == 0 || - s.compare (0, (n = 6), "having") == 0) + s.compare (0, (n = 6), "having") == 0 || + s.compare (0, (n = 4), "WITH") == 0 || + s.compare (0, (n = 4), "with") == 0) { // It either has to be an exact match, or there should be // a whitespace following the keyword. -- cgit v1.1 From 78a24698bef01448f7754e3fe6754d37c00a84c5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 14 Aug 2016 10:14:06 +0200 Subject: Update .gitignore files --- .gitignore | 4 ++++ build/.gitignore | 1 + tests/.gitignore | 1 + 3 files changed, 6 insertions(+) create mode 100644 build/.gitignore create mode 100644 tests/.gitignore diff --git a/.gitignore b/.gitignore index cfb7ae0..209706c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ *.dll *.a *.lib +*.exp +*.exe +*.exe.dlls/ +*.exe.manifest *.l *.l.cpp-options diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..e54525b --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +driver -- cgit v1.1 From 0c0c237ab3904cb82b85f96984ed81e8c726ebb0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 14 Aug 2016 12:28:17 +0200 Subject: Various build2-related fixes --- odb/sqlite/buildfile | 2 +- odb/sqlite/details/build2/config-vc.h | 2 +- odb/sqlite/details/config.hxx | 4 ++-- tests/basics/driver.cxx | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index ff42128..94d5f2a 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,4 +1,4 @@ -# file : odb/buildfile +# file : odb/sqlite/buildfile # copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h index 0fd79ee..a492e4e 100644 --- a/odb/sqlite/details/build2/config-vc.h +++ b/odb/sqlite/details/build2/config-vc.h @@ -1,4 +1,4 @@ -/* file : odb/details/build2/config-vc.h +/* file : odb/sqlite/details/build2/config-vc.h * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 1f31178..57cbd17 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -11,9 +11,9 @@ # error libodb-sqlite header included in odb-compiled header #elif !defined(LIBODB_SQLITE_BUILD2) # ifdef _MSC_VER -# include +# include # else -# include +# include # endif #endif diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx index bcdd210..f45985a 100644 --- a/tests/basics/driver.cxx +++ b/tests/basics/driver.cxx @@ -6,6 +6,7 @@ // is done in the odb-tests package. #include +#include #include #include @@ -16,6 +17,12 @@ using namespace odb::sqlite; int main () { + { + std::ostringstream os; + database::print_usage (os); + assert (!os.str ().empty ()); + } + database db (":memory:"); { -- cgit v1.1 From 7927ccadf479157d7f75b9abc96a40292ca33f73 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 14 Aug 2016 12:30:51 +0200 Subject: Use default build2 extensions for C++ files --- build/root.build | 5 ----- tests/build/root.build | 3 --- 2 files changed, 8 deletions(-) diff --git a/build/root.build b/build/root.build index 44b2195..174f292 100644 --- a/build/root.build +++ b/build/root.build @@ -4,11 +4,6 @@ using cxx -hxx{*}: extension = hxx -ixx{*}: extension = ixx -txx{*}: extension = txx -cxx{*}: extension = cxx - cxx.std = 11 tests/: install = false # Don't install tests. diff --git a/tests/build/root.build b/tests/build/root.build index c731d60..9d11dd5 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -4,9 +4,6 @@ using cxx -hxx{*}: extension = hxx -cxx{*}: extension = cxx - cxx.std = 11 # Every exe{} in this subproject is by default a test. -- cgit v1.1 From 8a18a5f4b0ed4ecedf675a2e5319386d16e9cd12 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 14 Aug 2016 12:34:01 +0200 Subject: Bump version to 2.5.0-a9 Note that we now use the -[ab]N schema rather than .[ab]N. --- build/bootstrap.build | 2 +- manifest | 7 +++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/build/bootstrap.build b/build/bootstrap.build index 1d3ca56..0a958fb 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -3,7 +3,7 @@ # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite -version = 2.5.0-a8 +version = 2.5.0-a9 revision = 0 using build@0.4.0-a1 diff --git a/manifest b/manifest index 050e191..6f1db27 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-a8 +version: 2.5.0-a9 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -10,7 +10,6 @@ changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com requires: c++11 -requires: build2 >= 0.4.0 +requires: build2 >= 0.4.0-a1 depends: libsqlite3 >= 3.6.18 -#depends: libodb [2.5.0 2.6.0-); libodb-2.5.X -depends: libodb == 2.5.0-a8 +depends: libodb == 2.5.0-a9 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index a09e659..7f65b7a 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20408 +#if ODB_VERSION != 20409 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049908 -#define LIBODB_SQLITE_VERSION_STR "2.5.0.a8" +#define LIBODB_SQLITE_VERSION 2049909 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-a9" #include diff --git a/version b/version index bdfefee..d9711fc 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0.a8 +2.5.0-a9 -- cgit v1.1 From 9e6d8d7e4619c1c0becbc385f1faaed62fdaa10e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 16 Aug 2016 14:00:00 +0200 Subject: Try to clean up inline exports --- odb/sqlite/binding.hxx | 3 +-- odb/sqlite/blob-stream.cxx | 7 ------- odb/sqlite/blob-stream.hxx | 3 +-- odb/sqlite/blob.hxx | 3 +-- odb/sqlite/buildfile | 4 ++-- odb/sqlite/makefile | 2 -- odb/sqlite/query.hxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/text-stream.cxx | 7 ------- odb/sqlite/text-stream.hxx | 3 +-- odb/sqlite/text.hxx | 2 +- odb/sqlite/traits.hxx | 28 ++++++++++------------------ 12 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 odb/sqlite/blob-stream.cxx delete mode 100644 odb/sqlite/text-stream.cxx diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index f6cef5b..aa6a3cc 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -12,13 +12,12 @@ #include #include -#include namespace odb { namespace sqlite { - class LIBODB_SQLITE_EXPORT binding + class binding { public: typedef sqlite::bind bind_type; diff --git a/odb/sqlite/blob-stream.cxx b/odb/sqlite/blob-stream.cxx deleted file mode 100644 index 4bcedeb..0000000 --- a/odb/sqlite/blob-stream.cxx +++ /dev/null @@ -1,7 +0,0 @@ -// file : odb/sqlite/blob-stream.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -// Dummy source file to get Win32 DLL export working. diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx index 58be6ba..a2a1727 100644 --- a/odb/sqlite/blob-stream.hxx +++ b/odb/sqlite/blob-stream.hxx @@ -9,13 +9,12 @@ #include #include -#include namespace odb { namespace sqlite { - class LIBODB_SQLITE_EXPORT blob_stream: public stream + class blob_stream: public stream { public: blob_stream (const blob& b, bool rw) diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx index eccb3ab..8c1b197 100644 --- a/odb/sqlite/blob.hxx +++ b/odb/sqlite/blob.hxx @@ -14,7 +14,6 @@ // #ifndef ODB_COMPILER # include -# include #endif namespace odb @@ -25,7 +24,7 @@ namespace odb #pragma db sqlite:type("BLOB STREAM") class blob #else - class LIBODB_SQLITE_EXPORT blob + class blob #endif { public: diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 94d5f2a..f4c5ed5 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -9,7 +9,7 @@ lib{odb-sqlite}: \ {hxx }{ auto-handle } \ {hxx }{ binding } \ {hxx }{ blob } \ - {hxx cxx}{ blob-stream } \ + {hxx }{ blob-stream } \ {hxx ixx cxx}{ connection } \ {hxx cxx}{ connection-factory } \ {hxx txx }{ container-statements } \ @@ -34,7 +34,7 @@ lib{odb-sqlite}: \ {hxx cxx}{ statements-base } \ {hxx cxx}{ stream } \ {hxx }{ text } \ - {hxx cxx}{ text-stream } \ + {hxx }{ text-stream } \ {hxx cxx}{ tracer } \ {hxx cxx}{ traits } \ {hxx }{ traits-calls } \ diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index aa411e7..9f471b0 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -5,7 +5,6 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make cxx := \ -blob-stream.cxx \ connection.cxx \ connection-factory.cxx \ database.cxx \ @@ -20,7 +19,6 @@ statement.cxx \ statements-base.cxx \ statement-cache.cxx \ stream.cxx \ -text-stream.cxx \ tracer.cxx \ traits.cxx \ transaction.cxx \ diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index bb1f50e..199ab27 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -648,7 +648,7 @@ namespace odb // query_column // - struct LIBODB_SQLITE_EXPORT query_column_base + struct query_column_base { // Note that we keep shallow copies of the table, column, and conversion // expression. The latter can be NULL. diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 7344daf..fdc0807 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -297,7 +297,7 @@ namespace odb binding& result_; }; - struct LIBODB_SQLITE_EXPORT auto_result + struct auto_result { explicit auto_result (select_statement& s): s_ (s) {} ~auto_result () {s_.free_result ();} diff --git a/odb/sqlite/text-stream.cxx b/odb/sqlite/text-stream.cxx deleted file mode 100644 index f5642e4..0000000 --- a/odb/sqlite/text-stream.cxx +++ /dev/null @@ -1,7 +0,0 @@ -// file : odb/sqlite/text-stream.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -// Dummy source file to get Win32 DLL export working. diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx index 71d3053..4e14d19 100644 --- a/odb/sqlite/text-stream.hxx +++ b/odb/sqlite/text-stream.hxx @@ -9,13 +9,12 @@ #include #include -#include namespace odb { namespace sqlite { - class LIBODB_SQLITE_EXPORT text_stream: public stream + class text_stream: public stream { public: text_stream (const text& b, bool rw) diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx index 1e7e25f..8ecf81d 100644 --- a/odb/sqlite/text.hxx +++ b/odb/sqlite/text.hxx @@ -25,7 +25,7 @@ namespace odb #pragma db sqlite:type("TEXT STREAM") class text #else - class LIBODB_SQLITE_EXPORT text + class text #endif { public: diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index dc4d113..0cb82db 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -287,16 +287,10 @@ namespace odb }; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: - real_value_traits - { - }; + struct default_value_traits: real_value_traits {}; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: - real_value_traits - { - }; + struct default_value_traits: real_value_traits {}; // std::string specialization. // @@ -345,11 +339,10 @@ namespace odb }; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: - c_string_value_traits {}; + struct default_value_traits: c_string_value_traits {}; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: + struct default_value_traits: c_string_value_traits {}; // char[N] specialization. @@ -430,7 +423,7 @@ namespace odb // char specialization. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits + struct default_value_traits { typedef char value_type; typedef char query_type; @@ -511,14 +504,13 @@ namespace odb struct image_traits: wstring_image_traits {}; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: - c_wstring_value_traits {}; + struct default_value_traits: c_wstring_value_traits {}; template <> struct image_traits: wstring_image_traits {}; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits: + struct default_value_traits: c_wstring_value_traits {}; // wchar_t[N] specialization. @@ -609,7 +601,7 @@ namespace odb struct image_traits: wstring_image_traits {}; template <> - struct LIBODB_SQLITE_EXPORT default_value_traits + struct default_value_traits { typedef wchar_t value_type; typedef wchar_t query_type; @@ -856,7 +848,7 @@ namespace odb // text (stream) specialization. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits + struct default_value_traits { public: typedef text value_type; @@ -894,7 +886,7 @@ namespace odb // blob (stream) specialization. // template <> - struct LIBODB_SQLITE_EXPORT default_value_traits + struct default_value_traits { public: typedef blob value_type; -- cgit v1.1 From f876f301798d3d8452b93f33546e74a245286857 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2016 12:59:41 +0200 Subject: Bump version to 2.5.0-a10 --- build/bootstrap.build | 2 +- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/bootstrap.build b/build/bootstrap.build index 0a958fb..a7c7eed 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -3,7 +3,7 @@ # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite -version = 2.5.0-a9 +version = 2.5.0-a10 revision = 0 using build@0.4.0-a1 diff --git a/manifest b/manifest index 6f1db27..9003733 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-a9 +version: 2.5.0-a10 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -12,4 +12,4 @@ email: odb-users@codesynthesis.com requires: c++11 requires: build2 >= 0.4.0-a1 depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-a9 +depends: libodb == 2.5.0-a10 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 7f65b7a..36b0203 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20409 +#if ODB_VERSION != 20410 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049909 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-a9" +#define LIBODB_SQLITE_VERSION 2049910 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-a10" #include diff --git a/version b/version index d9711fc..eefbad9 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-a9 +2.5.0-a10 -- cgit v1.1 From 22f3ffe90badb381c07e943b65aca9bde4911992 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 23 Aug 2016 10:50:28 +0200 Subject: Fix install.* variable values in buildfiles --- odb/sqlite/buildfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index f4c5ed5..9fb6615 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -97,11 +97,11 @@ details/build2/: if ($cxx.id == "msvc") { h{config}@./: install = false - h{config-vc}@./: install = $install.include/details + h{config-vc}@./: install = $install.include/details/ } else { - h{config}@./: install = $install.include/details + h{config}@./: install = $install.include/details/ h{config-vc}@./: install = false } } -- cgit v1.1 From b2b169b6a5d92bb662637721a2bafa73d88bce35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 31 Aug 2016 11:28:44 +0200 Subject: build2 build system fixes --- build/root.build | 4 +--- buildfile | 3 +++ odb/sqlite/buildfile | 8 +++++--- tests/basics/buildfile | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build/root.build b/build/root.build index 174f292..fb0de84 100644 --- a/build/root.build +++ b/build/root.build @@ -2,8 +2,6 @@ # copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -using cxx - cxx.std = 11 -tests/: install = false # Don't install tests. +using cxx diff --git a/buildfile b/buildfile index 016dd6f..0c7de41 100644 --- a/buildfile +++ b/buildfile @@ -6,4 +6,7 @@ d = odb/sqlite/ tests/ ./: $d doc{GPLv2 INSTALL LICENSE NEWS README version} file{manifest} include $d +# Don't install tests or the INSTALL file. +# +dir{tests/}: install = false doc{INSTALL}@./: install = false diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 9fb6615..d5f1d13 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -2,8 +2,8 @@ # copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -import libs = libsqlite3%lib{sqlite3} -import libs += libodb%lib{odb} +import int_libs = libodb%lib{odb} +import int_libs += libsqlite3%lib{sqlite3} lib{odb-sqlite}: \ {hxx }{ auto-handle } \ @@ -49,7 +49,7 @@ lib{odb-sqlite}: \ details/{hxx ixx cxx}{ options } \ details/build2/{h }{ config } \ details/build2/{h }{ config-vc } \ - $libs + $int_libs cxx.poptions =+ -I$out_root -I$src_root -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD @@ -59,6 +59,8 @@ lib{odb-sqlite}: cxx.export.poptions = -I$src_root -DLIBODB_SQLITE_BUILD2 liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED +lib{odb-sqlite}: cxx.export.libs = $int_libs + # Load the cli module but only if it's available. This way a distribution that # includes pre-generated files can be built without installing cli. # diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 833a7c8..606b450 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -2,7 +2,6 @@ # copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -import libs = libodb%lib{odb} # @@ -import libs += libodb-sqlite%lib{odb-sqlite} +import libs = libodb-sqlite%lib{odb-sqlite} exe{driver}: cxx{driver} $libs -- cgit v1.1 From 39c76ef8c9b664c94d5d7b789457fa4045fdce04 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 31 Aug 2016 19:27:53 +0300 Subject: Build infrastructure update --- build/bootstrap.build | 20 ++++++++++++++------ build/root.build | 18 ++++++++++++++++++ manifest | 2 +- odb/sqlite/buildfile | 21 +++++++++------------ odb/sqlite/details/.gitignore | 1 + tests/build/.gitignore | 1 + tests/build/root.build | 5 ++++- 7 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 odb/sqlite/details/.gitignore create mode 100644 tests/build/.gitignore diff --git a/build/bootstrap.build b/build/bootstrap.build index a7c7eed..351fe40 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -3,16 +3,24 @@ # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite -version = 2.5.0-a10 -revision = 0 using build@0.4.0-a1 -using config -using dist -using test -using install + +version = 2.5.0-a10 + +abi_major = 2 +abi_minor = 5 +abi_patch = 0 +abi_prerelease = true + +revision = 0 dist.package = $project-$version if ($revision != 0) dist.package += +$revision + +using config +using dist +using test +using install diff --git a/build/root.build b/build/root.build index fb0de84..5898b63 100644 --- a/build/root.build +++ b/build/root.build @@ -5,3 +5,21 @@ cxx.std = 11 using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +cxx.poptions =+ -I$out_root -I$src_root + +# Load the cli module but only if it's available. This way a distribution that +# includes pre-generated files can be built without installing cli. +# +using? cli + +if! $cli.loaded +{ + define cli: file + cli{*}: extension = cli +} diff --git a/manifest b/manifest index 9003733..3db30d9 100644 --- a/manifest +++ b/manifest @@ -10,6 +10,6 @@ changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com requires: c++11 -requires: build2 >= 0.4.0-a1 +requires: build2 >= 0.4.0 depends: libsqlite3 >= 3.6.18 depends: libodb == 2.5.0-a10 diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index d5f1d13..d32d3b4 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -51,7 +51,15 @@ details/build2/{h }{ config } \ details/build2/{h }{ config-vc } \ $int_libs -cxx.poptions =+ -I$out_root -I$src_root -DLIBODB_SQLITE_BUILD2 +# For pre-releases use the complete version to make sure they cannot be used +# in place of another pre-release or the final version. +# +if $abi_prerelease + lib{odb-sqlite}: bin.lib.version = @-$version +else + lib{odb-sqlite}: bin.lib.version = @-$abi_major.$abi_minor + +cxx.poptions =+ -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD @@ -61,17 +69,6 @@ libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED lib{odb-sqlite}: cxx.export.libs = $int_libs -# Load the cli module but only if it's available. This way a distribution that -# includes pre-generated files can be built without installing cli. -# -using? cli - -if! $cli.loaded -{ - define cli: file - cli{*}: extension = cli -} - details/: { {hxx ixx cxx}{options}: cli{options} diff --git a/odb/sqlite/details/.gitignore b/odb/sqlite/details/.gitignore new file mode 100644 index 0000000..c6e608b --- /dev/null +++ b/odb/sqlite/details/.gitignore @@ -0,0 +1 @@ +options.?xx diff --git a/tests/build/.gitignore b/tests/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/tests/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/tests/build/root.build b/tests/build/root.build index 9d11dd5..5dd8142 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -2,9 +2,12 @@ # copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file +cxx.std = 11 + using cxx -cxx.std = 11 +hxx{*}: extension = hxx +cxx{*}: extension = cxx # Every exe{} in this subproject is by default a test. # -- cgit v1.1 From 18a9c29e5ac61e6ee5f1349a1242540874c32cad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Sep 2016 06:55:41 +0200 Subject: Minor build2-related updates --- build/root.build | 4 +--- odb/sqlite/buildfile | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/root.build b/build/root.build index 5898b63..0d01e14 100644 --- a/build/root.build +++ b/build/root.build @@ -11,14 +11,12 @@ ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx -cxx.poptions =+ -I$out_root -I$src_root - # Load the cli module but only if it's available. This way a distribution that # includes pre-generated files can be built without installing cli. # using? cli -if! $cli.loaded +if! $cli.configured { define cli: file cli{*}: extension = cli diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index d32d3b4..2ce398f 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -59,7 +59,7 @@ if $abi_prerelease else lib{odb-sqlite}: bin.lib.version = @-$abi_major.$abi_minor -cxx.poptions =+ -DLIBODB_SQLITE_BUILD2 +cxx.poptions =+ -I$out_root -I$src_root -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD -- cgit v1.1 From cccaee14d1a987f739556a6bc429ab4457916506 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Sep 2016 17:21:34 +0200 Subject: Only set cli.options if cli is configured --- odb/sqlite/buildfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 2ce398f..12d1a37 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -73,9 +73,12 @@ details/: { {hxx ixx cxx}{options}: cli{options} - cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ + if $cli.configured + { + cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ --cli-namespace odb::sqlite::details::cli --long-usage + } # Include generated cli files into the distribution. But don't install them # since they are only used internally in the database implementation. -- cgit v1.1 From f0cd1030f8f8f174e6c04ffaccce6269b4f38328 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Sep 2016 16:27:44 +0200 Subject: Update to latest build2 changes --- build/bootstrap.build | 2 +- manifest | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/bootstrap.build b/build/bootstrap.build index 351fe40..d2f5592 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -4,7 +4,7 @@ project = libodb-sqlite -using build@0.4.0-a1 +using build@0.4.0 version = 2.5.0-a10 diff --git a/manifest b/manifest index 3db30d9..ab3859e 100644 --- a/manifest +++ b/manifest @@ -10,6 +10,7 @@ changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com requires: c++11 -requires: build2 >= 0.4.0 +depends: * build2 >= 0.4.0 +depends: * bpkg >= 0.4.0 depends: libsqlite3 >= 3.6.18 depends: libodb == 2.5.0-a10 -- cgit v1.1 From f1c1387969f23b48addd0b84b7347c37aeb6a389 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 8 Sep 2016 16:24:43 +0200 Subject: Bump version to 2.5.0-a11 --- build/bootstrap.build | 2 +- manifest | 4 ++-- odb/sqlite/version.hxx | 4 ++-- version | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/bootstrap.build b/build/bootstrap.build index d2f5592..6f6c079 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -6,7 +6,7 @@ project = libodb-sqlite using build@0.4.0 -version = 2.5.0-a10 +version = 2.5.0-a11 abi_major = 2 abi_minor = 5 diff --git a/manifest b/manifest index ab3859e..d3815d6 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-a10 +version: 2.5.0-a11 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -13,4 +13,4 @@ requires: c++11 depends: * build2 >= 0.4.0 depends: * bpkg >= 0.4.0 depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-a10 +depends: libodb == 2.5.0-a11 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 36b0203..3911a30 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -35,8 +35,8 @@ // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049910 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-a10" +#define LIBODB_SQLITE_VERSION 2049911 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-a11" #include diff --git a/version b/version index eefbad9..b6012ca 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-a10 +2.5.0-a11 -- cgit v1.1 From 2f4f86c20eba0cd88856ce0c0c88d440d742574b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 5 Dec 2016 18:26:03 +0300 Subject: Adapt buildfiles to expansion change --- odb/sqlite/buildfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 12d1a37..3caea59 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -59,11 +59,11 @@ if $abi_prerelease else lib{odb-sqlite}: bin.lib.version = @-$abi_major.$abi_minor -cxx.poptions =+ -I$out_root -I$src_root -DLIBODB_SQLITE_BUILD2 +cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD -lib{odb-sqlite}: cxx.export.poptions = -I$src_root -DLIBODB_SQLITE_BUILD2 +lib{odb-sqlite}: cxx.export.poptions = "-I$src_root" -DLIBODB_SQLITE_BUILD2 liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED -- cgit v1.1 From d68a5a2fcc6fe22510df23cfe62f361280aa133b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Dec 2016 18:13:27 +0200 Subject: Fix incomplete 2.5.0-a11 version update --- odb/sqlite/version.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 3911a30..f2c5107 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,7 +28,7 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20410 +#if ODB_VERSION != 20411 # error incompatible odb interface version detected #endif -- cgit v1.1 From 399d2ddf0d5b124e189b4d37dd61f5788acfa2c5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 3 Jan 2017 14:18:28 +0200 Subject: Update copyright year --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.build | 2 +- build/bootstrap.make | 2 +- build/export.build | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- build/root.build | 2 +- buildfile | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/blob-stream.hxx | 2 +- odb/sqlite/blob.hxx | 2 +- odb/sqlite/buildfile | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/connection.ixx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/build2/config-vc.h | 2 +- odb/sqlite/details/build2/config.h | 2 +- odb/sqlite/details/config-vc.h | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/conversion.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/no-id-object-statements.txx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 2 +- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/prepared-query.cxx | 2 +- odb/sqlite/prepared-query.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query-dynamic.cxx | 2 +- odb/sqlite/query-dynamic.hxx | 2 +- odb/sqlite/query-dynamic.ixx | 2 +- odb/sqlite/query-dynamic.txx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/section-statements.hxx | 2 +- odb/sqlite/section-statements.txx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.cxx | 2 +- odb/sqlite/simple-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.ixx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/stream.cxx | 2 +- odb/sqlite/stream.hxx | 2 +- odb/sqlite/text-stream.hxx | 2 +- odb/sqlite/text.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits-calls.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- tests/basics/buildfile | 2 +- tests/basics/driver.cxx | 2 +- tests/build/bootstrap.build | 2 +- tests/build/root.build | 2 +- tests/buildfile | 2 +- 123 files changed, 123 insertions(+), 123 deletions(-) diff --git a/Makefile.am b/Makefile.am index e3fd75b..63d8349 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index 8953df9..46dcfd0 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.build b/build/bootstrap.build index 6f6c079..e622c90 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -1,5 +1,5 @@ # file : build/bootstrap.build -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite diff --git a/build/bootstrap.make b/build/bootstrap.make index f2033db..5576f9e 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export.build b/build/export.build index 18bb2b2..df3d49f 100644 --- a/build/export.build +++ b/build/export.build @@ -1,5 +1,5 @@ # file : build/export.build -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $out_root/: diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index 55fb0e4..5441e23 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index 70fe025..e3e517c 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2015 Code Synthesis Tools CC. +Copyright (c) 2009-2017 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index f603bb5..d9ee187 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index e771de1..cc21ce1 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index 08a78fc..9622f6f 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 436ac31..9ea25ca 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 05f8a3f..960a8a2 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index 2ea2618..6677789 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 42d0eef..e34bbd1 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 3fa72f5..7e8c620 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index 7fc3aa1..db7a7ab 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index a5d7bc2..cb5ce6f 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 98f96b8..841075f 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index d7e2a00..84b1e5f 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index a1edf1e..1b5a266 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 9fe829f..8b45979 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/root.build b/build/root.build index 0d01e14..5e80277 100644 --- a/build/root.build +++ b/build/root.build @@ -1,5 +1,5 @@ # file : build/root.build -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/buildfile b/buildfile index 0c7de41..35a2d40 100644 --- a/buildfile +++ b/buildfile @@ -1,5 +1,5 @@ # file : buildfile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file d = odb/sqlite/ tests/ diff --git a/configure.ac b/configure.ac index 40c84e8..0b0ef7a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 0f92918..66cf36b 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index bf31ddc..6695e1b 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 2dd2634..ad1d316 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 36f92f8..0695ed7 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index 6b04b63..acafbb0 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 63a62b5..546ee0f 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 1f49f8f..fb07f49 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index f02850f..e07a37d 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index af3bde2..e623259 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index 6430131..1fed793 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 3a42099..7b4592b 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index aa6a3cc..aff2125 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx index a2a1727..30befbc 100644 --- a/odb/sqlite/blob-stream.hxx +++ b/odb/sqlite/blob-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob-stream.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx index 8c1b197..448a717 100644 --- a/odb/sqlite/blob.hxx +++ b/odb/sqlite/blob.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 3caea59..4f27da6 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,5 +1,5 @@ # file : odb/sqlite/buildfile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import int_libs = libodb%lib{odb} diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 4444167..9f7b919 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index d3d6aea..2765ba1 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 2425244..8351ed6 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 5110163..188d259 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index ab6d72e..525ac96 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index fb8412d..c9a6e24 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 6a764c5..5b11198 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 60e65b0..5fd41d7 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index cb837b4..9c3c88f 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index aec4ba5..8861db8 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // move() diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h index a492e4e..01e040d 100644 --- a/odb/sqlite/details/build2/config-vc.h +++ b/odb/sqlite/details/build2/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-vc.h - * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h index 2aa7d54..7d97a32 100644 --- a/odb/sqlite/details/build2/config.h +++ b/odb/sqlite/details/build2/config.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config.h - * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h index 2ecc24a..b6e86e1 100644 --- a/odb/sqlite/details/config-vc.h +++ b/odb/sqlite/details/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config-vc.h - * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 9c2d2d7..48af4c3 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 57cbd17..9214dbe 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index fb53f66..ca9ec55 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 11a5f0a..2dac338 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 737a3d1..36f06c0 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index ce320a1..e7d39d5 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 3b48d39..6148d79 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index ab54340..16f093e 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 01bf5ec..edd2901 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 1bc5da5..180ce25 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 9f471b0..37e697e 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 0e0df00..991b597 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 87d919b..721d75d 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 4fec8ef..913da0c 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 287a5d8..36f349b 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index fa0a3d3..4990835 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 277aa98..133231b 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 53b1e31..e0504b0 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index 0565ae0..ecf5da9 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index c204de6..d9521bd 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index 4a63786..9bc5906 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index e26fb30..9f4b6b9 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index 02f6322..b887de1 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index cb03393..4e68f9e 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index b691d7b..42aa4dd 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index 67af539..fc63bed 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 04ae043..6e475d8 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 199ab27..933b1e9 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 70fadec..a9deb4f 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 909807f..409e3db 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 40ac4d1..26d2685 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index 3c4d10e..d77c84c 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index ec42bf5..5b41968 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index b1563bb..3f330ae 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index 1bec013..7c3fc1a 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 6ea7f6d..7003960 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index 5a7407d..17f008d 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index fe46063..f6b9419 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 80ffbd2..7c6ca60 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 8723e42..55cbc4e 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index f9ce7a1..75e72b9 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 9f15a15..2a7565d 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index ce6458a..30b3f59 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index fdc0807..1fd0acf 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index 4a5aa6e..dd07803 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 6ed5813..a4c29e2 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx index 8de199e..7ff02e8 100644 --- a/odb/sqlite/stream.cxx +++ b/odb/sqlite/stream.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx index 387dcf0..3630d46 100644 --- a/odb/sqlite/stream.hxx +++ b/odb/sqlite/stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx index 4e14d19..e1d4ea0 100644 --- a/odb/sqlite/text-stream.hxx +++ b/odb/sqlite/text-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text-stream.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx index 8ecf81d..893efc9 100644 --- a/odb/sqlite/text.hxx +++ b/odb/sqlite/text.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 10ce0b0..13f8d70 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 023ac6b..4b3129e 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx index d1fb72f..3368994 100644 --- a/odb/sqlite/traits-calls.hxx +++ b/odb/sqlite/traits-calls.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits-calls.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 9258d5b..44d2afc 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 0cb82db..13caade 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 2f83071..baae085 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 92de110..9dae372 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index 40eeb5a..61f03f0 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 9cd9303..1719679 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index 5651694..5b9c5c5 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 3757175..13720e8 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index f2c5107..2b13ecd 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VERSION_HXX diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 2b3b167..b8b8106 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 6b88971..7b2b4e2 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 6ecaaaa..6e22918 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index bd46aa3..cbca5a6 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 606b450..6290172 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -1,5 +1,5 @@ # file : tests/basics/buildfile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import libs = libodb-sqlite%lib{odb-sqlite} diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx index f45985a..0251197 100644 --- a/tests/basics/driver.cxx +++ b/tests/basics/driver.cxx @@ -1,5 +1,5 @@ // file : tests/basics/driver.cxx -// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // Basic test to make sure the library is usable. Functionality testing diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build index 2f8aad2..f573687 100644 --- a/tests/build/bootstrap.build +++ b/tests/build/bootstrap.build @@ -1,5 +1,5 @@ # file : tests/build/bootstrap.build -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = # Unnamed subproject. diff --git a/tests/build/root.build b/tests/build/root.build index 5dd8142..e1098b7 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,5 +1,5 @@ # file : tests/build/root.build -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/tests/buildfile b/tests/buildfile index 0341b61..8502dbe 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -1,5 +1,5 @@ # file : tests/buildfile -# copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file d = basics/ -- cgit v1.1 From 0d099d1930b1870db7f20761388b9772d0abfedc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Jan 2017 17:25:20 +0200 Subject: Add PRAGMA to list of complete query prefixes 'PRAGMA integrity_check' is like SELECT. --- odb/sqlite/query.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 6e475d8..31d81be 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -199,18 +199,20 @@ namespace odb // rather than getting involved with the portable case- // insensitive string comparison mess. // - if (s.compare (0, (n = 5), "WHERE") == 0 || - s.compare (0, (n = 5), "where") == 0 || - s.compare (0, (n = 6), "SELECT") == 0 || - s.compare (0, (n = 6), "select") == 0 || + if (s.compare (0, (n = 5), "WHERE") == 0 || + s.compare (0, (n = 5), "where") == 0 || + s.compare (0, (n = 6), "SELECT") == 0 || + s.compare (0, (n = 6), "select") == 0 || s.compare (0, (n = 8), "ORDER BY") == 0 || s.compare (0, (n = 8), "order by") == 0 || s.compare (0, (n = 8), "GROUP BY") == 0 || s.compare (0, (n = 8), "group by") == 0 || - s.compare (0, (n = 6), "HAVING") == 0 || - s.compare (0, (n = 6), "having") == 0 || - s.compare (0, (n = 4), "WITH") == 0 || - s.compare (0, (n = 4), "with") == 0) + s.compare (0, (n = 6), "HAVING") == 0 || + s.compare (0, (n = 6), "having") == 0 || + s.compare (0, (n = 4), "WITH") == 0 || + s.compare (0, (n = 4), "with") == 0 || + s.compare (0, (n = 6), "PRAGMA") == 0 || + s.compare (0, (n = 6), "pragma") == 0) { // It either has to be an exact match, or there should be // a whitespace following the keyword. -- cgit v1.1 From a028fa9a535070ec9a1eecda297c34c4fe3fd4f5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 24 Jan 2017 18:57:03 +0300 Subject: Specify test.target --- tests/build/root.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/build/root.build b/tests/build/root.build index e1098b7..1f471b6 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -12,3 +12,7 @@ cxx{*}: extension = cxx # Every exe{} in this subproject is by default a test. # exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target -- cgit v1.1 From 6715325d046f3b9663fa3b290324ba9b8c3e052a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 3 Mar 2017 15:58:34 +0200 Subject: Rework build2 cli compilation --- build/root.build | 15 ++++++--------- odb/sqlite/buildfile | 13 ++++++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/root.build b/build/root.build index 5e80277..63bed14 100644 --- a/build/root.build +++ b/build/root.build @@ -11,13 +11,10 @@ ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx -# Load the cli module but only if it's available. This way a distribution that -# includes pre-generated files can be built without installing cli. +# Load the cli module but only if it's available. This way a distribution +# that includes pre-generated files can be built without installing cli. +# This is also the reason why we need to explicitly spell out individual +# source file prerequisites instead of using the cli.cxx{} group (it won't +# be there unless the module is configured). # -using? cli - -if! $cli.configured -{ - define cli: file - cli{*}: extension = cli -} +using? cliusing? cli diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 4f27da6..02c3238 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -71,19 +71,22 @@ lib{odb-sqlite}: cxx.export.libs = $int_libs details/: { - {hxx ixx cxx}{options}: cli{options} - if $cli.configured { + cli.cxx{options}: cli{options} + cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ --cli-namespace odb::sqlite::details::cli --long-usage + + # Include generated cli files into the distribution. + # + cli.cxx{*}: dist = true } - # Include generated cli files into the distribution. But don't install them - # since they are only used internally in the database implementation. + # But don't install their headers since they are only used internally in the + # database implementation. # - {hxx ixx cxx}{options}: dist = true {hxx ixx}{options}: install = false } -- cgit v1.1 From 9874780f84ed6c19a7a0a7e7f266c873c64e7ced Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 24 Apr 2017 16:45:13 +0300 Subject: Add build-email value to manifest file --- manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest b/manifest index d3815d6..51379df 100644 --- a/manifest +++ b/manifest @@ -9,6 +9,7 @@ description-file: README changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com +build-email: odb-builds@codesynthesis.com requires: c++11 depends: * build2 >= 0.4.0 depends: * bpkg >= 0.4.0 -- cgit v1.1 From d012b5ee971668b68bc9161784f340bb547c7427 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Apr 2017 16:17:22 +0200 Subject: Bump version to 2.5.0.b.1.z, switch to build2 version module --- build/bootstrap.build | 17 +---------------- manifest | 8 ++++---- odb/sqlite/buildfile | 6 +++--- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/build/bootstrap.build b/build/bootstrap.build index e622c90..59ec5b8 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -4,22 +4,7 @@ project = libodb-sqlite -using build@0.4.0 - -version = 2.5.0-a11 - -abi_major = 2 -abi_minor = 5 -abi_patch = 0 -abi_prerelease = true - -revision = 0 - -dist.package = $project-$version - -if ($revision != 0) - dist.package += +$revision - +using version using config using dist using test diff --git a/manifest b/manifest index 51379df..c099c6e 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-a11 +version: 2.5.0-b.1.z summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -11,7 +11,7 @@ url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com requires: c++11 -depends: * build2 >= 0.4.0 -depends: * bpkg >= 0.4.0 +depends: * build2 >= 0.5.0- +depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-a11 +depends: libodb [2.5.0.b.1.1 2.5.0.b.2) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 02c3238..293992e 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -54,10 +54,10 @@ details/build2/{h }{ config-vc } \ # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. # -if $abi_prerelease - lib{odb-sqlite}: bin.lib.version = @-$version +if $version.pre_release + lib{odb-sqlite}: bin.lib.version = @"-$version.project_id" else - lib{odb-sqlite}: bin.lib.version = @-$abi_major.$abi_minor + lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 2b13ecd..33ca611 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -28,15 +28,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20411 +#if ODB_VERSION != 20451 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049911 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-a11" +#define LIBODB_SQLITE_VERSION 2049951 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.1" #include diff --git a/version b/version index b6012ca..07ad3e3 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-a11 +2.5.0-b.1 -- cgit v1.1 From dde1f1739f3864497ecf07289af37feea7b82ab0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Apr 2017 16:34:29 +0200 Subject: Add out_root to include search path now that we auto-generate version --- odb/sqlite/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 293992e..81f89bb 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -63,7 +63,7 @@ cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD -lib{odb-sqlite}: cxx.export.poptions = "-I$src_root" -DLIBODB_SQLITE_BUILD2 +lib{odb-sqlite}: cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED -- cgit v1.1 From 17e417d9c1ef48245bbb86386856524278c49128 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Apr 2017 19:15:55 +0200 Subject: Fix incorrect version range --- manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest b/manifest index c099c6e..035e592 100644 --- a/manifest +++ b/manifest @@ -14,4 +14,4 @@ requires: c++11 depends: * build2 >= 0.5.0- depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb [2.5.0.b.1.1 2.5.0.b.2) +depends: libodb [2.5.0-b.1.1 2.5.0-b.2) -- cgit v1.1 From c5cece92dab1595fdc84c7b19a767218dae31acf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 29 Apr 2017 16:54:40 +0200 Subject: Add parallel version headers for build2 --- .gitignore | 4 ++++ odb/sqlite/buildfile | 7 +++++++ odb/sqlite/version-build2.hxx.in | 44 ++++++++++++++++++++++++++++++++++++++++ odb/sqlite/version.hxx | 5 +++++ 4 files changed, 60 insertions(+) create mode 100644 odb/sqlite/version-build2.hxx.in diff --git a/.gitignore b/.gitignore index 209706c..e1079b1 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ # Generated .gitignore files. # .gitignore + +# Temporarily here because of auto-generated odb/sqlite/.gitignore. +# +odb/sqlite/version-build2.hxx diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 81f89bb..c2f99d4 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -41,6 +41,7 @@ lib{odb-sqlite}: \ {hxx ixx cxx}{ transaction } \ {hxx ixx cxx}{ transaction-impl } \ {hxx }{ version } \ + {hxx }{ version-build2 } \ {hxx txx }{ view-result } \ {hxx txx }{ view-statements } \ details/{hxx }{ config } \ @@ -51,6 +52,9 @@ details/build2/{h }{ config } \ details/build2/{h }{ config-vc } \ $int_libs +hxx{version-build2}: in{version-build2} $src_root/file{manifest} +hxx{version-build2}: dist = true + # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. # @@ -97,6 +101,9 @@ install.include.subdirs = true # Recreate subdirectories. # We want these to be picked up even when LIBODB_SQLITE_BUILD2 is not defined. # +hxx{version}@./: install = false +hxx{version-build2}: install = $install.include/version.hxx + details/build2/: { if ($cxx.id == "msvc") diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in new file mode 100644 index 0000000..9c48376 --- /dev/null +++ b/odb/sqlite/version-build2.hxx.in @@ -0,0 +1,44 @@ +// file : odb/sqlite/version-build2.hxx.in +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. + +// Note: using build2 standard versioning scheme. The numeric version format +// is AAABBBCCCDDDE where: +// +// AAA - major version number +// BBB - minor version number +// CCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) +// +// When DDDE is not 0, 1 is subtracted from AAABBBCCC. For example: +// +// Version AAABBBCCCDDDE +// +// 0.1.0 0000010000000 +// 0.1.2 0000010010000 +// 1.2.3 0010020030000 +// 2.2.0-a.1 0020019990010 +// 3.0.0-b.2 0029999995020 +// 2.2.0-a.1.z 0020019990011 +// +#define LIBODB_SQLITE_VERSION $libodb-sqlite.version.project_number$ULL +#define LIBODB_SQLITE_VERSION_STR "$libodb-sqlite.version.project$" +#define LIBODB_SQLITE_VERSION_ID "$libodb-sqlite.version.project_id$" + +#define LIBODB_SQLITE_VERSION_MAJOR $libodb-sqlite.version.major$ +#define LIBODB_SQLITE_VERSION_MINOR $libodb-sqlite.version.minor$ +#define LIBODB_SQLITE_VERSION_PATCH $libodb-sqlite.version.patch$ + +#define LIBODB_SQLITE_PRE_RELEASE $libodb-sqlite.version.pre_release$ + +#define LIBODB_SQLITE_SNAPSHOT $libodb-sqlite.version.snapshot_sn$ULL +#define LIBODB_SQLITE_SNAPSHOT_ID "$libodb-sqlite.version.snapshot_id$" + +#include + +$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ + +#endif // LIBODB_SQLITE_VERSION diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 33ca611..4d9758f 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -2,6 +2,10 @@ // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#ifdef LIBODB_SQLITE_BUILD2 +# include +#else + #ifndef ODB_SQLITE_VERSION_HXX #define ODB_SQLITE_VERSION_HXX @@ -41,3 +45,4 @@ #include #endif // ODB_SQLITE_VERSION_HXX +#endif // LIBODB_SQLITE_BUILD2 -- cgit v1.1 From a4097bb332ac4acfd85e898a5c34f566b4926754 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 3 May 2017 16:46:35 +0200 Subject: Bump version to 2.5.0-b.1 final --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index 035e592..5303d91 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.1.z +version: 2.5.0-b.1 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -14,4 +14,4 @@ requires: c++11 depends: * build2 >= 0.5.0- depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb [2.5.0-b.1.1 2.5.0-b.2) +depends: libodb == 2.5.0-b.1 -- cgit v1.1 From aeed12c793dc2138bcdcb4be1bf8de65dc74887c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 5 May 2017 12:50:10 +0200 Subject: Bump version to 2.5.0-b.2.z, master is open for business --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 5303d91..796e533 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.1 +version: 2.5.0-b.2.z summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -14,4 +14,4 @@ requires: c++11 depends: * build2 >= 0.5.0- depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-b.1 +depends: libodb [2.5.0-b.2.1 2.5.0-b.3) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 4d9758f..36ad881 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20451 +#if ODB_VERSION != 20452 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049951 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.1" +#define LIBODB_SQLITE_VERSION 2049952 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.2" #include diff --git a/version b/version index 07ad3e3..00e2348 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.1 +2.5.0-b.2 -- cgit v1.1 From d01b5f3a9f82ccec23b9551b3c40c99a7a4060fa Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 20 May 2017 17:45:21 +0300 Subject: Add *.ii to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e1079b1..c47f671 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Compiler/linker output. # *.d +*.ii *.o *.obj *.so -- cgit v1.1 From 180e7a06f1c150265e9ad4bb4342661eb3d782bc Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 20 May 2017 17:46:53 +0300 Subject: Fix root.build --- build/root.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/root.build b/build/root.build index 63bed14..595d66e 100644 --- a/build/root.build +++ b/build/root.build @@ -17,4 +17,4 @@ cxx{*}: extension = cxx # source file prerequisites instead of using the cli.cxx{} group (it won't # be there unless the module is configured). # -using? cliusing? cli +using? cli -- cgit v1.1 From b053ede1b07c44590b94e3b14df3fe3319462bc5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 23 May 2017 15:17:51 +0200 Subject: Bump version to 2.5.0-b.3 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 796e533..fb859b2 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.2.z +version: 2.5.0-b.3 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -14,4 +14,4 @@ requires: c++11 depends: * build2 >= 0.5.0- depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb [2.5.0-b.2.1 2.5.0-b.3) +depends: libodb == 2.5.0-b.3 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 36ad881..4b1d33c 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20452 +#if ODB_VERSION != 20453 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049952 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.2" +#define LIBODB_SQLITE_VERSION 2049953 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.3" #include diff --git a/version b/version index 00e2348..7aa40f6 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.2 +2.5.0-b.3 -- cgit v1.1 From f2a8225f094e0d1ace43f81d2f3b456c83efdda9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 May 2017 13:47:37 +0200 Subject: Bump version to 2.5.0-b.4.z, master is open for business --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index fb859b2..fbd548e 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.3 +version: 2.5.0-b.4.z summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -14,4 +14,4 @@ requires: c++11 depends: * build2 >= 0.5.0- depends: * bpkg >= 0.5.0- depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-b.3 +depends: libodb [2.5.0-b.4.1 2.5.0-b.5) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 4b1d33c..f2379a3 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20453 +#if ODB_VERSION != 20454 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049953 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.3" +#define LIBODB_SQLITE_VERSION 2049954 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.4" #include diff --git a/version b/version index 7aa40f6..9cce3ff 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.3 +2.5.0-b.4 -- cgit v1.1 From ad31d1e1c85d4c95771326a1bd5923b30c04421d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 14 Jul 2017 22:46:56 +0300 Subject: Make use of wildcards in buildfiles --- buildfile | 7 +++---- odb/sqlite/buildfile | 50 ++++---------------------------------------------- tests/basics/buildfile | 2 +- tests/buildfile | 4 +--- 4 files changed, 9 insertions(+), 54 deletions(-) diff --git a/buildfile b/buildfile index 35a2d40..b951682 100644 --- a/buildfile +++ b/buildfile @@ -2,11 +2,10 @@ # copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -d = odb/sqlite/ tests/ -./: $d doc{GPLv2 INSTALL LICENSE NEWS README version} file{manifest} -include $d +./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README version} \ + file{manifest} # Don't install tests or the INSTALL file. # -dir{tests/}: install = false +dir{tests/}: install = false doc{INSTALL}@./: install = false diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index c2f99d4..9d648cb 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -5,52 +5,10 @@ import int_libs = libodb%lib{odb} import int_libs += libsqlite3%lib{sqlite3} -lib{odb-sqlite}: \ - {hxx }{ auto-handle } \ - {hxx }{ binding } \ - {hxx }{ blob } \ - {hxx }{ blob-stream } \ - {hxx ixx cxx}{ connection } \ - {hxx cxx}{ connection-factory } \ - {hxx txx }{ container-statements } \ - {hxx ixx cxx}{ database } \ - {hxx cxx}{ error } \ - {hxx cxx}{ exceptions } \ - {hxx }{ forward } \ - {hxx txx }{ no-id-object-result } \ - {hxx txx }{ no-id-object-statements } \ - {hxx txx }{ polymorphic-object-result } \ - {hxx txx }{ polymorphic-object-statements } \ - {hxx cxx}{ prepared-query } \ - {hxx ixx txx cxx}{ query } \ - { cxx}{ query-const-expr } \ - {hxx ixx txx cxx}{ query-dynamic } \ - {hxx txx }{ section-statements } \ - {hxx txx }{ simple-object-result } \ - {hxx ixx txx cxx}{ simple-object-statements } \ - {hxx }{ sqlite-types } \ - {hxx txx cxx}{ statement-cache } \ - {hxx cxx}{ statement } \ - {hxx cxx}{ statements-base } \ - {hxx cxx}{ stream } \ - {hxx }{ text } \ - {hxx }{ text-stream } \ - {hxx cxx}{ tracer } \ - {hxx cxx}{ traits } \ - {hxx }{ traits-calls } \ - {hxx ixx cxx}{ transaction } \ - {hxx ixx cxx}{ transaction-impl } \ - {hxx }{ version } \ - {hxx }{ version-build2 } \ - {hxx txx }{ view-result } \ - {hxx txx }{ view-statements } \ - details/{hxx }{ config } \ - details/{hxx }{ conversion } \ - details/{hxx }{ export } \ - details/{hxx ixx cxx}{ options } \ -details/build2/{h }{ config } \ -details/build2/{h }{ config-vc } \ - $int_libs +lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ + details/{hxx ixx txx cxx}{* -options} details/{hxx ixx cxx}{options} \ + details/build2/{h}{*} \ + $int_libs hxx{version-build2}: in{version-build2} $src_root/file{manifest} hxx{version-build2}: dist = true diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 6290172..824c638 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -4,4 +4,4 @@ import libs = libodb-sqlite%lib{odb-sqlite} -exe{driver}: cxx{driver} $libs +exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/buildfile b/tests/buildfile index 8502dbe..545984d 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -2,6 +2,4 @@ # copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -d = basics/ -./: $d -include $d +./: {*/ -build/} -- cgit v1.1 From 3c0c16aa01bfc2c73668d73412f2bca3242d8865 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 30 Jul 2017 22:10:12 +0300 Subject: Add doc-url and src-url manifest values --- manifest | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifest b/manifest index fbd548e..c944869 100644 --- a/manifest +++ b/manifest @@ -9,6 +9,8 @@ description-file: README changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ email: odb-users@codesynthesis.com +doc-url: http://codesynthesis.com/products/odb/doc/manual.xhtml +src-url: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=tree build-email: odb-builds@codesynthesis.com requires: c++11 depends: * build2 >= 0.5.0- -- cgit v1.1 From ec34d84f9c245daf7ab4d98f1f0f14ce38e7f11c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 31 Jul 2017 12:06:34 +0300 Subject: Add .pc to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c47f671..2ef20a4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.exe *.exe.dlls/ *.exe.manifest +*.pc *.l *.l.cpp-options -- cgit v1.1 From 5c113ced153a413585b63c14cb77813f8982e836 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 31 Jul 2017 13:54:27 +0300 Subject: Redo header installation setup --- odb/sqlite/buildfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 9d648cb..08a6abc 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -52,26 +52,28 @@ details/: {hxx ixx}{options}: install = false } -# Install into the odb/sqlite/ subdirectory of, say, /usr/include/. +# Install into the odb/sqlite/ subdirectory of, say, /usr/include/ recreating +# subdirectories. # -install.include = $install.include/odb/sqlite/ -install.include.subdirs = true # Recreate subdirectories. +install_include = include/odb/sqlite/ +{hxx ixx txx}{*}: install = $install_include +{hxx ixx txx}{*}: install.subdirs = true # We want these to be picked up even when LIBODB_SQLITE_BUILD2 is not defined. # hxx{version}@./: install = false -hxx{version-build2}: install = $install.include/version.hxx +hxx{version-build2}: install = $install_include/version.hxx details/build2/: { if ($cxx.id == "msvc") { h{config}@./: install = false - h{config-vc}@./: install = $install.include/details/ + h{config-vc}@./: install = $install_include/details/ } else { - h{config}@./: install = $install.include/details/ + h{config}@./: install = $install_include/details/ h{config-vc}@./: install = false } } -- cgit v1.1 From e84c973b4f3f0c5503c187f9799b7c8054b41ebd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 2 Aug 2017 01:18:02 +0300 Subject: Fix installation directory path for headers --- odb/sqlite/buildfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 08a6abc..f225a64 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -55,7 +55,8 @@ details/: # Install into the odb/sqlite/ subdirectory of, say, /usr/include/ recreating # subdirectories. # -install_include = include/odb/sqlite/ +install_include = [dir_path] include/odb/sqlite/ + {hxx ixx txx}{*}: install = $install_include {hxx ixx txx}{*}: install.subdirs = true -- cgit v1.1 From ea23ae9eb7f5fe7badda1c3341070b58f1f31dd4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 2 Aug 2017 11:56:09 +0300 Subject: Fix doc-url and src-url manifest values --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index c944869..9b148b5 100644 --- a/manifest +++ b/manifest @@ -8,9 +8,9 @@ tags: c++, orm, sqlite, database, relational, object, persistence, sql description-file: README changes-file: NEWS url: http://www.codesynthesis.com/products/odb/ +doc-url: http://www.codesynthesis.com/products/odb/doc/manual.xhtml +src-url: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git\;a=tree email: odb-users@codesynthesis.com -doc-url: http://codesynthesis.com/products/odb/doc/manual.xhtml -src-url: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=tree build-email: odb-builds@codesynthesis.com requires: c++11 depends: * build2 >= 0.5.0- -- cgit v1.1 From 839ce3f20206dcdc0e2c1ab04f9a40bad0b87302 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 2 Aug 2017 13:59:32 +0300 Subject: Add support for build2-aware installation --- odb/sqlite/buildfile | 17 ++++++++++------- odb/sqlite/details/build2/config-stub.h | 6 ++++++ odb/sqlite/details/build2/config-vc-stub.h | 6 ++++++ odb/sqlite/version-build2-stub.hxx | 5 +++++ 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 odb/sqlite/details/build2/config-stub.h create mode 100644 odb/sqlite/details/build2/config-vc-stub.h create mode 100644 odb/sqlite/version-build2-stub.hxx diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index f225a64..047f209 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -60,21 +60,24 @@ install_include = [dir_path] include/odb/sqlite/ {hxx ixx txx}{*}: install = $install_include {hxx ixx txx}{*}: install.subdirs = true -# We want these to be picked up even when LIBODB_SQLITE_BUILD2 is not defined. +# We want these to be picked up whether LIBODB_SQLITE_BUILD2 is defined or not. # -hxx{version}@./: install = false -hxx{version-build2}: install = $install_include/version.hxx +hxx{version}@./: install = false +hxx{version-build2}: install = $install_include/version.hxx +hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx details/build2/: { + h{*}: install = false + if ($cxx.id == "msvc") { - h{config}@./: install = false - h{config-vc}@./: install = $install_include/details/ + h{config-vc}@./: install = $install_include/details/ + h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h } else { - h{config}@./: install = $install_include/details/ - h{config-vc}@./: install = false + h{config}@./: install = $install_include/details/ + h{config-stub}@./: install = $install_include/details/build2/config.h } } diff --git a/odb/sqlite/details/build2/config-stub.h b/odb/sqlite/details/build2/config-stub.h new file mode 100644 index 0000000..3777383 --- /dev/null +++ b/odb/sqlite/details/build2/config-stub.h @@ -0,0 +1,6 @@ +/* file : odb/sqlite/details/build2/config-stub.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/odb/sqlite/details/build2/config-vc-stub.h b/odb/sqlite/details/build2/config-vc-stub.h new file mode 100644 index 0000000..2499c76 --- /dev/null +++ b/odb/sqlite/details/build2/config-vc-stub.h @@ -0,0 +1,6 @@ +/* file : odb/sqlite/details/build2/config-vc-stub.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/odb/sqlite/version-build2-stub.hxx b/odb/sqlite/version-build2-stub.hxx new file mode 100644 index 0000000..437b309 --- /dev/null +++ b/odb/sqlite/version-build2-stub.hxx @@ -0,0 +1,5 @@ +// file : odb/sqlite/version-build2-stub.hxx +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include -- cgit v1.1 From 0538b31ec17a17ec1962339b11e2c5540da72550 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Aug 2017 09:18:51 +0200 Subject: Fix bug in non-installation of generated option headers --- odb/sqlite/buildfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 047f209..c5efe05 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -41,15 +41,19 @@ details/: --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ --cli-namespace odb::sqlite::details::cli --long-usage - # Include generated cli files into the distribution. + # Include generated cli files into the distribution. But don't install + # their headers since they are only used internally in the database + # implementation. # - cli.cxx{*}: dist = true + cli.cxx{*}: dist = true + cli.cxx{*}: install = false + } + else + { + # No install for the pre-generated case. + # + {hxx ixx}{options}@/: install = false } - - # But don't install their headers since they are only used internally in the - # database implementation. - # - {hxx ixx}{options}: install = false } # Install into the odb/sqlite/ subdirectory of, say, /usr/include/ recreating -- cgit v1.1 From 14244e8466e73f8da6055a6a986d61837747e725 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Aug 2017 18:43:00 +0200 Subject: Fix bug in buildfile --- odb/sqlite/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index c5efe05..8524f8a 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -52,7 +52,7 @@ details/: { # No install for the pre-generated case. # - {hxx ixx}{options}@/: install = false + {hxx ixx}{options}@./: install = false } } -- cgit v1.1 From 72834bb1dee443e05fdd6c3c4347cd6b4cc35d6f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Aug 2017 19:06:48 +0200 Subject: Fix bug in buildfile some more --- odb/sqlite/buildfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 8524f8a..d2bb231 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -49,11 +49,9 @@ details/: cli.cxx{*}: install = false } else - { # No install for the pre-generated case. # - {hxx ixx}{options}@./: install = false - } + hxx{options}@./ ixx{options}@./: install = false } # Install into the odb/sqlite/ subdirectory of, say, /usr/include/ recreating -- cgit v1.1 From 8ebb319057f4600982fd9a292939090edef342c9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Aug 2017 12:56:02 +0200 Subject: Bump version to 2.5.0-b.5 --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9b148b5..b254f3c 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.4.z +version: 2.5.0-b.5 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -13,7 +13,7 @@ src-url: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git\;a=tree email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com requires: c++11 -depends: * build2 >= 0.5.0- -depends: * bpkg >= 0.5.0- +depends: * build2 >= 0.6.0- +depends: * bpkg >= 0.6.0- depends: libsqlite3 >= 3.6.18 -depends: libodb [2.5.0-b.4.1 2.5.0-b.5) +depends: libodb == 2.5.0-b.5 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index f2379a3..6bce432 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20454 +#if ODB_VERSION != 20455 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049954 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.4" +#define LIBODB_SQLITE_VERSION 2049955 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.5" #include diff --git a/version b/version index 9cce3ff..22c5d3e 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.4 +2.5.0-b.5 -- cgit v1.1 From 77e3889872fba88eb3577fa382524f0d6e045ba4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Aug 2017 14:08:25 +0200 Subject: Bump version to 2.5.0-b.6.z, master is open for business --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index b254f3c..5f42e8c 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.5 +version: 2.5.0-b.6.z summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -16,4 +16,4 @@ requires: c++11 depends: * build2 >= 0.6.0- depends: * bpkg >= 0.6.0- depends: libsqlite3 >= 3.6.18 -depends: libodb == 2.5.0-b.5 +depends: libodb [2.5.0-b.6.1 2.5.0-b.7) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 6bce432..baedabe 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20455 +#if ODB_VERSION != 20456 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049955 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.5" +#define LIBODB_SQLITE_VERSION 2049956 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.6" #include diff --git a/version b/version index 22c5d3e..62aaa61 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.5 +2.5.0-b.6 -- cgit v1.1 From 12ab71cf5d464456d38fb99426f9f579e2950d01 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 21 Aug 2017 03:12:03 +0300 Subject: Don't distribute generated version-build2.hxx --- odb/sqlite/buildfile | 1 - 1 file changed, 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index d2bb231..4f438c7 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -11,7 +11,6 @@ lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ $int_libs hxx{version-build2}: in{version-build2} $src_root/file{manifest} -hxx{version-build2}: dist = true # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. -- cgit v1.1 From a685c476343a4959197c639661fe5ef4d8d4f216 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 24 Aug 2017 15:15:02 +0300 Subject: Don't clean generated cli files from src --- odb/sqlite/buildfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 4f438c7..6df413d 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -40,11 +40,13 @@ details/: --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ --cli-namespace odb::sqlite::details::cli --long-usage - # Include generated cli files into the distribution. But don't install - # their headers since they are only used internally in the database - # implementation. + # Include generated cli files into the distribution and don't remove them + # when cleaning in src (so that clean results in a state identical to + # distributed). But don't install their headers since they are only used + # internally in the database implementation. # cli.cxx{*}: dist = true + cli.cxx{*}: clean = ($src_root != $out_root) cli.cxx{*}: install = false } else -- cgit v1.1 From 30df505b480917800c5876a51b159240e2a002e2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 24 Aug 2017 15:41:20 +0300 Subject: Add version-build2.hxx back into distribution and don't clean it up from src --- .gitignore | 4 ---- README-GIT | 5 +++++ odb/sqlite/buildfile | 6 ++++++ odb/sqlite/version-build2.hxx | 0 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 README-GIT create mode 100644 odb/sqlite/version-build2.hxx diff --git a/.gitignore b/.gitignore index 2ef20a4..a06aa4b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,3 @@ # Generated .gitignore files. # .gitignore - -# Temporarily here because of auto-generated odb/sqlite/.gitignore. -# -odb/sqlite/version-build2.hxx diff --git a/README-GIT b/README-GIT new file mode 100644 index 0000000..be3ee92 --- /dev/null +++ b/README-GIT @@ -0,0 +1,5 @@ +The checked out odb/sqlite/version-build2.hxx will be overwritten during the +build process but these changes should be ignored. To do this automatically, +run: + +git update-index --assume-unchanged odb/sqlite/version-build2.hxx diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 6df413d..b0244ed 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -10,7 +10,13 @@ lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ details/build2/{h}{*} \ $int_libs +# Include the generated version header into the distribution (so that we don't +# pick up an installed one) and don't remove it when cleaning in src (so that +# clean results in a state identical to distributed). +# hxx{version-build2}: in{version-build2} $src_root/file{manifest} +hxx{version-build2}: dist = true +hxx{version-build2}: clean = ($src_root != $out_root) # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. diff --git a/odb/sqlite/version-build2.hxx b/odb/sqlite/version-build2.hxx new file mode 100644 index 0000000..e69de29 -- cgit v1.1 From f99b0536fc0f34b29638ff3bca3d07a4939824c0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Nov 2017 15:02:57 +0200 Subject: Fix URLs in manifest (https instead of http, git.* instead of scm.*) --- manifest | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest b/manifest index 5f42e8c..cbb3316 100644 --- a/manifest +++ b/manifest @@ -7,9 +7,9 @@ license: proprietary tags: c++, orm, sqlite, database, relational, object, persistence, sql description-file: README changes-file: NEWS -url: http://www.codesynthesis.com/products/odb/ -doc-url: http://www.codesynthesis.com/products/odb/doc/manual.xhtml -src-url: http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git\;a=tree +url: https://www.codesynthesis.com/products/odb/ +doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml +src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com requires: c++11 -- cgit v1.1 From e07bd8cee43bd3557d9aa8ae9756c1e8dedb2ef7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 30 Nov 2017 04:18:13 +0300 Subject: Bump toolchain version dependency to 0.7.0 in manifest --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index cbb3316..cf4366b 100644 --- a/manifest +++ b/manifest @@ -13,7 +13,7 @@ src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com requires: c++11 -depends: * build2 >= 0.6.0- -depends: * bpkg >= 0.6.0- +depends: * build2 >= 0.7.0- +depends: * bpkg >= 0.7.0- depends: libsqlite3 >= 3.6.18 depends: libodb [2.5.0-b.6.1 2.5.0-b.7) -- cgit v1.1 From 5fb0357e3be5d940d43bcab4ba8910afbc7f2c13 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 30 Nov 2017 04:20:50 +0300 Subject: Use compiler class instead of id where appropriate --- odb/sqlite/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index b0244ed..7653d3c 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -79,7 +79,7 @@ details/build2/: { h{*}: install = false - if ($cxx.id == "msvc") + if ($cxx.class == 'msvc') { h{config-vc}@./: install = $install_include/details/ h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h -- cgit v1.1 From 0daa3cb3c917ba235fcbbc28244c793c8cc60d44 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 2 Jan 2018 15:19:10 +0200 Subject: Fix undefined behavior (ubsan) bug --- odb/sqlite/query.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 933b1e9..c057a47 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -185,7 +185,7 @@ namespace odb kind_type kind; std::string part; // If kind is param, then part is conversion expr. - bool bool_part; + bool bool_part = false; }; query_base () -- cgit v1.1 From f75a9a9c3790f28ed5341c76aae92a54833e2c2e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 4 May 2018 00:05:00 +0300 Subject: Adjust to new scope syntax --- build/export.build | 2 +- odb/sqlite/buildfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/export.build b/build/export.build index df3d49f..1db3b17 100644 --- a/build/export.build +++ b/build/export.build @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -$out_root/: +$out_root/ { include odb/sqlite/ } diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 7653d3c..7dd40cf 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -36,7 +36,7 @@ libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED lib{odb-sqlite}: cxx.export.libs = $int_libs -details/: +details/ { if $cli.configured { @@ -75,7 +75,7 @@ hxx{version}@./: install = false hxx{version-build2}: install = $install_include/version.hxx hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx -details/build2/: +details/build2/ { h{*}: install = false -- cgit v1.1 From f989ac69b22794e3a98feebc604c5f132b1f3ae1 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 19 May 2018 18:00:53 +0300 Subject: Get rid of doc{version} and types for testscript and manifest in buildfiles --- buildfile | 3 +-- odb/sqlite/buildfile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/buildfile b/buildfile index b951682..76b2f5d 100644 --- a/buildfile +++ b/buildfile @@ -2,8 +2,7 @@ # copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README version} \ - file{manifest} +./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README} manifest # Don't install tests or the INSTALL file. # diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 7dd40cf..52a96c9 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -14,7 +14,7 @@ lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ # pick up an installed one) and don't remove it when cleaning in src (so that # clean results in a state identical to distributed). # -hxx{version-build2}: in{version-build2} $src_root/file{manifest} +hxx{version-build2}: in{version-build2} $src_root/manifest hxx{version-build2}: dist = true hxx{version-build2}: clean = ($src_root != $out_root) -- cgit v1.1 From 617bfeed4843cb2e54faf02c36b33807d383be1f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 24 May 2018 21:47:21 +0300 Subject: Update copyright year --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.build | 2 +- build/bootstrap.make | 2 +- build/export.build | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- build/root.build | 2 +- buildfile | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/blob-stream.hxx | 2 +- odb/sqlite/blob.hxx | 2 +- odb/sqlite/buildfile | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/connection.ixx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/build2/config-stub.h | 2 +- odb/sqlite/details/build2/config-vc-stub.h | 2 +- odb/sqlite/details/build2/config-vc.h | 2 +- odb/sqlite/details/build2/config.h | 2 +- odb/sqlite/details/config-vc.h | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/conversion.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/no-id-object-statements.txx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 2 +- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/prepared-query.cxx | 2 +- odb/sqlite/prepared-query.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query-dynamic.cxx | 2 +- odb/sqlite/query-dynamic.hxx | 2 +- odb/sqlite/query-dynamic.ixx | 2 +- odb/sqlite/query-dynamic.txx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/section-statements.hxx | 2 +- odb/sqlite/section-statements.txx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.cxx | 2 +- odb/sqlite/simple-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.ixx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/stream.cxx | 2 +- odb/sqlite/stream.hxx | 2 +- odb/sqlite/text-stream.hxx | 2 +- odb/sqlite/text.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits-calls.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version-build2-stub.hxx | 2 +- odb/sqlite/version-build2.hxx.in | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- tests/basics/buildfile | 2 +- tests/basics/driver.cxx | 2 +- tests/build/bootstrap.build | 2 +- tests/build/root.build | 2 +- tests/buildfile | 2 +- 127 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Makefile.am b/Makefile.am index 63d8349..5de4239 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index 46dcfd0..f489800 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.build b/build/bootstrap.build index 59ec5b8..e46debb 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -1,5 +1,5 @@ # file : build/bootstrap.build -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite diff --git a/build/bootstrap.make b/build/bootstrap.make index 5576f9e..8282938 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export.build b/build/export.build index 1db3b17..48f98dc 100644 --- a/build/export.build +++ b/build/export.build @@ -1,5 +1,5 @@ # file : build/export.build -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $out_root/ diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index 5441e23..9cf7a5b 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index e3e517c..ba1973a 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2017 Code Synthesis Tools CC. +Copyright (c) 2009-2018 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index d9ee187..913ce1f 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index cc21ce1..8af2efc 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index 9622f6f..704773b 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 9ea25ca..a21aa40 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 960a8a2..10b7e4b 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index 6677789..0ef60bb 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index e34bbd1..0f87364 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 7e8c620..2fbb636 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index db7a7ab..b2df157 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index cb5ce6f..a96dc45 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 841075f..b4e18c0 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index 84b1e5f..2d5b19d 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 1b5a266..89e29c7 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 8b45979..7425aca 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/root.build b/build/root.build index 595d66e..417209c 100644 --- a/build/root.build +++ b/build/root.build @@ -1,5 +1,5 @@ # file : build/root.build -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/buildfile b/buildfile index 76b2f5d..51a2217 100644 --- a/buildfile +++ b/buildfile @@ -1,5 +1,5 @@ # file : buildfile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README} manifest diff --git a/configure.ac b/configure.ac index 0b0ef7a..4f6a0f4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 66cf36b..19eb5a8 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index 6695e1b..fa26621 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index ad1d316..7cffd60 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 0695ed7..35d3b6f 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index acafbb0..772b821 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 546ee0f..241311d 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index fb07f49..96e3706 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index e07a37d..b095d18 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index e623259..0bb698e 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index 1fed793..aba72f8 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 7b4592b..e6ec555 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index aff2125..ce76f9b 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx index 30befbc..68459aa 100644 --- a/odb/sqlite/blob-stream.hxx +++ b/odb/sqlite/blob-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob-stream.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx index 448a717..a5128d1 100644 --- a/odb/sqlite/blob.hxx +++ b/odb/sqlite/blob.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 52a96c9..9c88a0e 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,5 +1,5 @@ # file : odb/sqlite/buildfile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import int_libs = libodb%lib{odb} diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 9f7b919..b4bbcf1 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 2765ba1..90a582a 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 8351ed6..9fc413a 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 188d259..d57cf80 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 525ac96..7e874e2 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index c9a6e24..15a1349 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 5b11198..187bf23 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 5fd41d7..4e06896 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 9c3c88f..dd9bbc5 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 8861db8..3c2248e 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // move() diff --git a/odb/sqlite/details/build2/config-stub.h b/odb/sqlite/details/build2/config-stub.h index 3777383..253cecc 100644 --- a/odb/sqlite/details/build2/config-stub.h +++ b/odb/sqlite/details/build2/config-stub.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-stub.h - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc-stub.h b/odb/sqlite/details/build2/config-vc-stub.h index 2499c76..7d444fe 100644 --- a/odb/sqlite/details/build2/config-vc-stub.h +++ b/odb/sqlite/details/build2/config-vc-stub.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-vc-stub.h - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h index 01e040d..294664f 100644 --- a/odb/sqlite/details/build2/config-vc.h +++ b/odb/sqlite/details/build2/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-vc.h - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h index 7d97a32..e950514 100644 --- a/odb/sqlite/details/build2/config.h +++ b/odb/sqlite/details/build2/config.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config.h - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h index b6e86e1..8aeee10 100644 --- a/odb/sqlite/details/config-vc.h +++ b/odb/sqlite/details/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config-vc.h - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 48af4c3..8d0a919 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 9214dbe..ca27215 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index ca9ec55..f5be930 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 2dac338..e3223ef 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 36f06c0..a738f5b 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index e7d39d5..f251571 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 6148d79..391434d 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 16f093e..8dd2159 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index edd2901..0bb7cd6 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index 180ce25..f5ac3b1 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 37e697e..9501370 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 991b597..b69177d 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 721d75d..cd47d40 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 913da0c..26729b7 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 36f349b..0283457 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 4990835..66f839b 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 133231b..96597a4 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index e0504b0..1700dfa 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index ecf5da9..d7b3acd 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index d9521bd..73821ea 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index 9bc5906..dcb32cc 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 9f4b6b9..6c47d19 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index b887de1..437b226 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index 4e68f9e..32f825e 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index 42aa4dd..298bcc8 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index fc63bed..72eaeba 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 31d81be..9e56621 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index c057a47..11368fa 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index a9deb4f..980fb6a 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 409e3db..3fb5462 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 26d2685..5730d2a 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index d77c84c..992b579 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 5b41968..67c19f0 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 3f330ae..96ee818 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index 7c3fc1a..812ed79 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 7003960..dae4171 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index 17f008d..b67a7ad 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index f6b9419..a76906a 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 7c6ca60..5772b09 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 55cbc4e..fe17cdd 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 75e72b9..926a507 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 2a7565d..35d332a 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 30b3f59..f0eca7b 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 1fd0acf..aec9746 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index dd07803..4282cb5 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index a4c29e2..1ed75b9 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx index 7ff02e8..6d966f7 100644 --- a/odb/sqlite/stream.cxx +++ b/odb/sqlite/stream.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx index 3630d46..0216497 100644 --- a/odb/sqlite/stream.hxx +++ b/odb/sqlite/stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx index e1d4ea0..1cd8c48 100644 --- a/odb/sqlite/text-stream.hxx +++ b/odb/sqlite/text-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text-stream.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx index 893efc9..cb29cfb 100644 --- a/odb/sqlite/text.hxx +++ b/odb/sqlite/text.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 13f8d70..a5df2a7 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 4b3129e..73e08ed 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx index 3368994..ece0b05 100644 --- a/odb/sqlite/traits-calls.hxx +++ b/odb/sqlite/traits-calls.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits-calls.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 44d2afc..598eb12 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 13caade..084868e 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index baae085..7aab780 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 9dae372..fc7ca44 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index 61f03f0..a9b5413 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 1719679..7ff93df 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index 5b9c5c5..f819be3 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 13720e8..0d45402 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2-stub.hxx b/odb/sqlite/version-build2-stub.hxx index 437b309..9eb6301 100644 --- a/odb/sqlite/version-build2-stub.hxx +++ b/odb/sqlite/version-build2-stub.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version-build2-stub.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in index 9c48376..a6b1645 100644 --- a/odb/sqlite/version-build2.hxx.in +++ b/odb/sqlite/version-build2.hxx.in @@ -1,5 +1,5 @@ // file : odb/sqlite/version-build2.hxx.in -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index baedabe..d47113b 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef LIBODB_SQLITE_BUILD2 diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index b8b8106..1b51e9d 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 7b2b4e2..4273f7d 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 6e22918..d05a000 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index cbca5a6..d07e39c 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 824c638..7a4df2a 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -1,5 +1,5 @@ # file : tests/basics/buildfile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import libs = libodb-sqlite%lib{odb-sqlite} diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx index 0251197..ab7f67e 100644 --- a/tests/basics/driver.cxx +++ b/tests/basics/driver.cxx @@ -1,5 +1,5 @@ // file : tests/basics/driver.cxx -// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // Basic test to make sure the library is usable. Functionality testing diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build index f573687..805bc82 100644 --- a/tests/build/bootstrap.build +++ b/tests/build/bootstrap.build @@ -1,5 +1,5 @@ # file : tests/build/bootstrap.build -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = # Unnamed subproject. diff --git a/tests/build/root.build b/tests/build/root.build index 1f471b6..687d3ec 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,5 +1,5 @@ # file : tests/build/root.build -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/tests/buildfile b/tests/buildfile index 545984d..bb1ce38 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -1,5 +1,5 @@ # file : tests/buildfile -# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/} -- cgit v1.1 From e8541beb854430ef182bfee99393ca26b74e21de Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 May 2018 14:46:09 +0200 Subject: Bump version to 2.5.0-b.7 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index cf4366b..8ce737e 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.6.z +version: 2.5.0-b.7 summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -16,4 +16,4 @@ requires: c++11 depends: * build2 >= 0.7.0- depends: * bpkg >= 0.7.0- depends: libsqlite3 >= 3.6.18 -depends: libodb [2.5.0-b.6.1 2.5.0-b.7) +depends: libodb == 2.5.0-b.7 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d47113b..4ee3bde 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20456 +#if ODB_VERSION != 20457 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049956 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.6" +#define LIBODB_SQLITE_VERSION 2049957 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.7" #include diff --git a/version b/version index 62aaa61..9042314 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.6 +2.5.0-b.7 -- cgit v1.1 From 29bb914fc69138321cb9514905303484a03a0f4a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 May 2018 15:18:38 +0200 Subject: Adjust external dependencies to use ^-constraint --- manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest b/manifest index 8ce737e..8a81a6f 100644 --- a/manifest +++ b/manifest @@ -15,5 +15,5 @@ build-email: odb-builds@codesynthesis.com requires: c++11 depends: * build2 >= 0.7.0- depends: * bpkg >= 0.7.0- -depends: libsqlite3 >= 3.6.18 +depends: libsqlite3 ^3.6.18 depends: libodb == 2.5.0-b.7 -- cgit v1.1 From d64311d6ce2cace76f1a7e09251be9d8d1ea6bd1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 May 2018 09:19:39 +0200 Subject: Bump version to 2.5.0-b.8.z, master is open for business --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 8a81a6f..653dd2a 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.7 +version: 2.5.0-b.8.z summary: SQLite ODB runtime library license: GPLv2 license: proprietary @@ -16,4 +16,4 @@ requires: c++11 depends: * build2 >= 0.7.0- depends: * bpkg >= 0.7.0- depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.7 +depends: libodb [2.5.0-b.8.1 2.5.0-b.9) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 4ee3bde..d04075f 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20457 +#if ODB_VERSION != 20458 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049957 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.7" +#define LIBODB_SQLITE_VERSION 2049958 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.8" #include diff --git a/version b/version index 9042314..1f23e23 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.7 +2.5.0-b.8 -- cgit v1.1 From 35f4c13b8587dadc8fdf1fc2f70f616876ea11f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 May 2018 12:50:46 +0200 Subject: Add repositories.manifest file --- repositories.manifest | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 repositories.manifest diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..ba891b9 --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,10 @@ +: 1 +summary: SQLite ODB runtime library repository + +: +role: prerequisite +location: https://git.build2.org/packaging/sqlite/libsqlite3.git##HEAD + +: +role: prerequisite +location: ../libodb.git##HEAD -- cgit v1.1 From dc24553fd249ccf2025cbbb654fb57f01ff139fa Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 1 Jun 2018 20:41:23 +0300 Subject: Remove target/scope irregularity workarounds --- buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildfile b/buildfile index 51a2217..1ffa1e2 100644 --- a/buildfile +++ b/buildfile @@ -6,5 +6,5 @@ # Don't install tests or the INSTALL file. # -dir{tests/}: install = false +tests/: install = false doc{INSTALL}@./: install = false -- cgit v1.1 From ad2f4ee8af479a3825ec8e7c48796c65afe1748a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Jun 2018 14:53:22 +0200 Subject: Suppress support for combined CLI flags (--no-combined-flags) We don't have any short options and this is incompatible with the skip mode we are using. --- odb/sqlite/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 9c88a0e..da10d13 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -44,7 +44,7 @@ details/ cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ ---cli-namespace odb::sqlite::details::cli --long-usage +--cli-namespace odb::sqlite::details::cli --long-usage --no-combined-flags # Include generated cli files into the distribution and don't remove them # when cleaning in src (so that clean results in a state identical to -- cgit v1.1 From 5077c96f3bde4828fe3ea874f331bada96f5f6ec Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 20 Jun 2018 19:51:03 +0300 Subject: Regularize .gitignore files --- .gitignore | 6 ++++++ build/.gitignore | 2 ++ tests/build/.gitignore | 2 ++ 3 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index a06aa4b..3004ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ +.bdep/ + # Compiler/linker output. # *.d +*.t +*.i *.ii *.o *.obj @@ -9,6 +13,8 @@ *.a *.lib *.exp +*.pdb +*.ilk *.exe *.exe.dlls/ *.exe.manifest diff --git a/build/.gitignore b/build/.gitignore index 225c27f..4a730a3 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1 +1,3 @@ config.build +root/ +bootstrap/ diff --git a/tests/build/.gitignore b/tests/build/.gitignore index 225c27f..4a730a3 100644 --- a/tests/build/.gitignore +++ b/tests/build/.gitignore @@ -1 +1,3 @@ config.build +root/ +bootstrap/ -- cgit v1.1 From f7ca129ad2223073ae52229b29d352f583022958 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jun 2018 11:07:06 +0200 Subject: Bump build2 requirement to 0.8.0 --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index 653dd2a..af05897 100644 --- a/manifest +++ b/manifest @@ -13,7 +13,7 @@ src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com requires: c++11 -depends: * build2 >= 0.7.0- -depends: * bpkg >= 0.7.0- +depends: * build2 >= 0.8.0- +depends: * bpkg >= 0.8.0- depends: libsqlite3 ^3.6.18 depends: libodb [2.5.0-b.8.1 2.5.0-b.9) -- cgit v1.1 From 3c6a4cda9f4e1ca50acf30815d68a4c9f2746ae6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 11 Jul 2018 22:25:13 +0300 Subject: Add project manifest value --- manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest b/manifest index af05897..63bbf83 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,7 @@ : 1 name: libodb-sqlite version: 2.5.0-b.8.z +project: odb summary: SQLite ODB runtime library license: GPLv2 license: proprietary -- cgit v1.1 From 65a05654d9f8a9793e2112e8ba8045603736528b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Jul 2018 13:22:10 +0300 Subject: Sanitize version substitutions --- odb/sqlite/version-build2.hxx.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in index a6b1645..9017924 100644 --- a/odb/sqlite/version-build2.hxx.in +++ b/odb/sqlite/version-build2.hxx.in @@ -24,18 +24,18 @@ // 3.0.0-b.2 0029999995020 // 2.2.0-a.1.z 0020019990011 // -#define LIBODB_SQLITE_VERSION $libodb-sqlite.version.project_number$ULL -#define LIBODB_SQLITE_VERSION_STR "$libodb-sqlite.version.project$" -#define LIBODB_SQLITE_VERSION_ID "$libodb-sqlite.version.project_id$" +#define LIBODB_SQLITE_VERSION $libodb_sqlite.version.project_number$ULL +#define LIBODB_SQLITE_VERSION_STR "$libodb_sqlite.version.project$" +#define LIBODB_SQLITE_VERSION_ID "$libodb_sqlite.version.project_id$" -#define LIBODB_SQLITE_VERSION_MAJOR $libodb-sqlite.version.major$ -#define LIBODB_SQLITE_VERSION_MINOR $libodb-sqlite.version.minor$ -#define LIBODB_SQLITE_VERSION_PATCH $libodb-sqlite.version.patch$ +#define LIBODB_SQLITE_VERSION_MAJOR $libodb_sqlite.version.major$ +#define LIBODB_SQLITE_VERSION_MINOR $libodb_sqlite.version.minor$ +#define LIBODB_SQLITE_VERSION_PATCH $libodb_sqlite.version.patch$ -#define LIBODB_SQLITE_PRE_RELEASE $libodb-sqlite.version.pre_release$ +#define LIBODB_SQLITE_PRE_RELEASE $libodb_sqlite.version.pre_release$ -#define LIBODB_SQLITE_SNAPSHOT $libodb-sqlite.version.snapshot_sn$ULL -#define LIBODB_SQLITE_SNAPSHOT_ID "$libodb-sqlite.version.snapshot_id$" +#define LIBODB_SQLITE_SNAPSHOT $libodb_sqlite.version.snapshot_sn$ULL +#define LIBODB_SQLITE_SNAPSHOT_ID "$libodb_sqlite.version.snapshot_id$" #include -- cgit v1.1 From 62d632e6e2bdb1c18105a8ece44652ed52c6cccd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Sep 2018 10:27:53 +0200 Subject: Release version 2.5.0-b.9 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 63bbf83..ef67562 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.8.z +version: 2.5.0-b.9 project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -17,4 +17,4 @@ requires: c++11 depends: * build2 >= 0.8.0- depends: * bpkg >= 0.8.0- depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.8.1 2.5.0-b.9) +depends: libodb == 2.5.0-b.9 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d04075f..444621b 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20458 +#if ODB_VERSION != 20459 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049958 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.8" +#define LIBODB_SQLITE_VERSION 2049959 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.9" #include diff --git a/version b/version index 1f23e23..fcff677 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.8 +2.5.0-b.9 -- cgit v1.1 From b88364e94415caa015f7a77b3b55f9d5cccb519f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Sep 2018 14:26:01 +0200 Subject: Bump version to 2.5.0-b.10.z, master is open for business --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index ef67562..b7d5b7b 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.9 +version: 2.5.0-b.10.z project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -17,4 +17,4 @@ requires: c++11 depends: * build2 >= 0.8.0- depends: * bpkg >= 0.8.0- depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.9 +depends: libodb [2.5.0-b.10.1 2.5.0-b.11) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 444621b..7852f74 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20459 +#if ODB_VERSION != 20460 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049959 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.9" +#define LIBODB_SQLITE_VERSION 2049960 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.10" #include diff --git a/version b/version index fcff677..c8f4946 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.9 +2.5.0-b.10 -- cgit v1.1 From af1724999b342848cfc2a399ca940af4abcc6a56 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 2 Dec 2018 00:47:08 +0300 Subject: Add commented out builds value to manifest --- manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest b/manifest index b7d5b7b..64e9c05 100644 --- a/manifest +++ b/manifest @@ -13,6 +13,7 @@ doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com +#builds: all requires: c++11 depends: * build2 >= 0.8.0- depends: * bpkg >= 0.8.0- -- cgit v1.1 From e026811c699a92a497be5efaf9a5b4c1dc74183e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 3 Dec 2018 12:36:29 +0300 Subject: Suppress MSVC warnings at project level --- build/root.build | 6 ++++++ tests/build/root.build | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/build/root.build b/build/root.build index 417209c..3695b46 100644 --- a/build/root.build +++ b/build/root.build @@ -11,6 +11,12 @@ ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx +if ($cxx.class == 'msvc') +{ + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + cxx.coptions += /wd4251 /wd4275 /wd4800 +} + # Load the cli module but only if it's available. This way a distribution # that includes pre-generated files can be built without installing cli. # This is also the reason why we need to explicitly spell out individual diff --git a/tests/build/root.build b/tests/build/root.build index 687d3ec..8aff1ee 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -9,6 +9,12 @@ using cxx hxx{*}: extension = hxx cxx{*}: extension = cxx +if ($cxx.class == 'msvc') +{ + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + cxx.coptions += /wd4251 /wd4275 /wd4800 +} + # Every exe{} in this subproject is by default a test. # exe{*}: test = true -- cgit v1.1 From c4ccd3db7b83b2cf015c1dee328ea83e526e6402 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 16 Jan 2019 21:33:30 +0300 Subject: Update copyright year --- Makefile.am | 2 +- bootstrap | 2 +- build/bootstrap.build | 2 +- build/bootstrap.make | 2 +- build/export.build | 2 +- build/export/libodb-sqlite/stub.make | 2 +- build/import/cli/LICENSE | 2 +- build/import/cli/cli-cxx.make | 2 +- build/import/cli/configuration-rules.make | 2 +- build/import/cli/configure | 2 +- build/import/cli/stub.make | 2 +- build/import/libodb-sqlite/configuration-rules.make | 2 +- build/import/libodb-sqlite/configure | 2 +- build/import/libodb-sqlite/stub.make | 2 +- build/import/libodb/configuration-rules.make | 2 +- build/import/libodb/configure | 2 +- build/import/libodb/stub.make | 2 +- build/import/libsqlite/configuration-rules.make | 2 +- build/import/libsqlite/configure | 2 +- build/import/libsqlite/rules.make | 2 +- build/import/libsqlite/stub.make | 2 +- build/root.build | 2 +- buildfile | 2 +- configure.ac | 2 +- libodb-sqlite.pc.in | 2 +- m4/disable-rpath.m4 | 2 +- m4/libodb.m4 | 2 +- m4/libsqlite.m4 | 2 +- m4/libtool-link.m4 | 2 +- m4/pkgconfig.m4 | 2 +- m4/static-lib.m4 | 2 +- m4/threads.m4 | 2 +- makefile | 2 +- odb/sqlite/Makefile.am | 2 +- odb/sqlite/auto-handle.hxx | 2 +- odb/sqlite/binding.hxx | 2 +- odb/sqlite/blob-stream.hxx | 2 +- odb/sqlite/blob.hxx | 2 +- odb/sqlite/buildfile | 2 +- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 2 +- odb/sqlite/connection.cxx | 2 +- odb/sqlite/connection.hxx | 2 +- odb/sqlite/connection.ixx | 2 +- odb/sqlite/container-statements.hxx | 2 +- odb/sqlite/container-statements.txx | 2 +- odb/sqlite/database.cxx | 2 +- odb/sqlite/database.hxx | 2 +- odb/sqlite/database.ixx | 2 +- odb/sqlite/details/build2/config-stub.h | 2 +- odb/sqlite/details/build2/config-vc-stub.h | 2 +- odb/sqlite/details/build2/config-vc.h | 2 +- odb/sqlite/details/build2/config.h | 2 +- odb/sqlite/details/config-vc.h | 2 +- odb/sqlite/details/config.h.in | 2 +- odb/sqlite/details/config.hxx | 2 +- odb/sqlite/details/conversion.hxx | 2 +- odb/sqlite/details/export.hxx | 2 +- odb/sqlite/details/options.cli | 2 +- odb/sqlite/error.cxx | 2 +- odb/sqlite/error.hxx | 2 +- odb/sqlite/exceptions.cxx | 2 +- odb/sqlite/exceptions.hxx | 2 +- odb/sqlite/forward.hxx | 2 +- odb/sqlite/makefile | 2 +- odb/sqlite/no-id-object-result.hxx | 2 +- odb/sqlite/no-id-object-result.txx | 2 +- odb/sqlite/no-id-object-statements.hxx | 2 +- odb/sqlite/no-id-object-statements.txx | 2 +- odb/sqlite/polymorphic-object-result.hxx | 2 +- odb/sqlite/polymorphic-object-result.txx | 2 +- odb/sqlite/polymorphic-object-statements.hxx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/prepared-query.cxx | 2 +- odb/sqlite/prepared-query.hxx | 2 +- odb/sqlite/query-const-expr.cxx | 2 +- odb/sqlite/query-dynamic.cxx | 2 +- odb/sqlite/query-dynamic.hxx | 2 +- odb/sqlite/query-dynamic.ixx | 2 +- odb/sqlite/query-dynamic.txx | 2 +- odb/sqlite/query.cxx | 2 +- odb/sqlite/query.hxx | 2 +- odb/sqlite/query.ixx | 2 +- odb/sqlite/query.txx | 2 +- odb/sqlite/section-statements.hxx | 2 +- odb/sqlite/section-statements.txx | 2 +- odb/sqlite/simple-object-result.hxx | 2 +- odb/sqlite/simple-object-result.txx | 2 +- odb/sqlite/simple-object-statements.cxx | 2 +- odb/sqlite/simple-object-statements.hxx | 2 +- odb/sqlite/simple-object-statements.ixx | 2 +- odb/sqlite/simple-object-statements.txx | 2 +- odb/sqlite/sqlite-types.hxx | 2 +- odb/sqlite/statement-cache.cxx | 2 +- odb/sqlite/statement-cache.hxx | 2 +- odb/sqlite/statement-cache.txx | 2 +- odb/sqlite/statement.cxx | 2 +- odb/sqlite/statement.hxx | 2 +- odb/sqlite/statements-base.cxx | 2 +- odb/sqlite/statements-base.hxx | 2 +- odb/sqlite/stream.cxx | 2 +- odb/sqlite/stream.hxx | 2 +- odb/sqlite/text-stream.hxx | 2 +- odb/sqlite/text.hxx | 2 +- odb/sqlite/tracer.cxx | 2 +- odb/sqlite/tracer.hxx | 2 +- odb/sqlite/traits-calls.hxx | 2 +- odb/sqlite/traits.cxx | 2 +- odb/sqlite/traits.hxx | 2 +- odb/sqlite/transaction-impl.cxx | 2 +- odb/sqlite/transaction-impl.hxx | 2 +- odb/sqlite/transaction-impl.ixx | 2 +- odb/sqlite/transaction.cxx | 2 +- odb/sqlite/transaction.hxx | 2 +- odb/sqlite/transaction.ixx | 2 +- odb/sqlite/version-build2-stub.hxx | 2 +- odb/sqlite/version-build2.hxx.in | 2 +- odb/sqlite/version.hxx | 2 +- odb/sqlite/view-result.hxx | 2 +- odb/sqlite/view-result.txx | 2 +- odb/sqlite/view-statements.hxx | 2 +- odb/sqlite/view-statements.txx | 2 +- tests/basics/buildfile | 2 +- tests/basics/driver.cxx | 2 +- tests/build/bootstrap.build | 2 +- tests/build/root.build | 2 +- tests/buildfile | 2 +- 127 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5de4239..5ae3d5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index f489800..0e786df 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,7 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.build b/build/bootstrap.build index e46debb..a5a24ab 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -1,5 +1,5 @@ # file : build/bootstrap.build -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite diff --git a/build/bootstrap.make b/build/bootstrap.make index 8282938..82d2e63 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,5 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export.build b/build/export.build index 48f98dc..7d740c5 100644 --- a/build/export.build +++ b/build/export.build @@ -1,5 +1,5 @@ # file : build/export.build -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $out_root/ diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index 9cf7a5b..ed533c8 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE index ba1973a..f6b2d2b 100644 --- a/build/import/cli/LICENSE +++ b/build/import/cli/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2018 Code Synthesis Tools CC. +Copyright (c) 2009-2019 Code Synthesis Tools CC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index 913ce1f..3d01453 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,5 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index 8af2efc..f13d01b 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index 704773b..944f48c 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index a21aa40..047ba40 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,5 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 10b7e4b..260dcb6 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index 0ef60bb..2d61e29 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index 0f87364..add7c39 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 2fbb636..872cbb3 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index b2df157..0d57a5f 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index a96dc45..6b7088d 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,5 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index b4e18c0..52db522 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index 2d5b19d..81cf42b 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,7 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 89e29c7..8cc81e3 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 7425aca..2038625 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,5 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/root.build b/build/root.build index 3695b46..5aa371d 100644 --- a/build/root.build +++ b/build/root.build @@ -1,5 +1,5 @@ # file : build/root.build -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/buildfile b/buildfile index 1ffa1e2..b74794a 100644 --- a/buildfile +++ b/buildfile @@ -1,5 +1,5 @@ # file : buildfile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README} manifest diff --git a/configure.ac b/configure.ac index 4f6a0f4..21b0b51 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index 19eb5a8..dc682a2 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,5 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index fa26621..7874d4b 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,5 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 7cffd60..5f140bd 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,5 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 35d3b6f..3985706 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,5 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index 772b821..635793f 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,5 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index 241311d..d5aa2d0 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,5 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 96e3706..79b89cd 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,5 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index b095d18..10bdfdd 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,5 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index 0bb698e..c107e17 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # file : makefile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index aba72f8..f6be926 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,5 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index e6ec555..22f0cf9 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index ce76f9b..09d4927 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx index 68459aa..1531fd1 100644 --- a/odb/sqlite/blob-stream.hxx +++ b/odb/sqlite/blob-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob-stream.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx index a5128d1..0c559df 100644 --- a/odb/sqlite/blob.hxx +++ b/odb/sqlite/blob.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/blob.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index da10d13..09f05fc 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,5 +1,5 @@ # file : odb/sqlite/buildfile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import int_libs = libodb%lib{odb} diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index b4bbcf1..579cb61 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 90a582a..616a940 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 9fc413a..ab17c7c 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index d57cf80..a71f07e 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 7e874e2..87b599f 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 15a1349..7edc2dc 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 187bf23..8f3844c 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 4e06896..79c8666 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index dd9bbc5..024372c 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 3c2248e..a62dad1 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // move() diff --git a/odb/sqlite/details/build2/config-stub.h b/odb/sqlite/details/build2/config-stub.h index 253cecc..c5f34dd 100644 --- a/odb/sqlite/details/build2/config-stub.h +++ b/odb/sqlite/details/build2/config-stub.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-stub.h - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc-stub.h b/odb/sqlite/details/build2/config-vc-stub.h index 7d444fe..f24b0c0 100644 --- a/odb/sqlite/details/build2/config-vc-stub.h +++ b/odb/sqlite/details/build2/config-vc-stub.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-vc-stub.h - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h index 294664f..a3b0299 100644 --- a/odb/sqlite/details/build2/config-vc.h +++ b/odb/sqlite/details/build2/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config-vc.h - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h index e950514..f304825 100644 --- a/odb/sqlite/details/build2/config.h +++ b/odb/sqlite/details/build2/config.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/build2/config.h - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h index 8aeee10..1f1fc61 100644 --- a/odb/sqlite/details/config-vc.h +++ b/odb/sqlite/details/config-vc.h @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config-vc.h - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index 8d0a919..e819fda 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,5 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index ca27215..25c976d 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index f5be930..687c9d0 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index e3223ef..3d838e7 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index a738f5b..7cc6649 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,5 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index f251571..49bdc96 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 391434d..441e8ff 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index 8dd2159..be06891 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 0bb7cd6..4312c31 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index f5ac3b1..e31b156 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 9501370..b0baab1 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,5 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index b69177d..4b6b3d5 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index cd47d40..0d3cae8 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index 26729b7..fb57967 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 0283457..1fe1db8 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index 66f839b..a9d34da 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 96597a4..960c477 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index 1700dfa..ddee2f0 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index d7b3acd..6757e4b 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index 73821ea..6812b39 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index dcb32cc..d688b06 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 6c47d19..17ef809 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index 437b226..5a05011 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index 32f825e..ee14f32 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index 298bcc8..0a51893 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index 72eaeba..faebf25 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 9e56621..5862f83 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 11368fa..8e45c32 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 980fb6a..2b4cd3f 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 3fb5462..3ee8bdf 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 5730d2a..2ac489f 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index 992b579..1fdc7a2 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/section-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 67c19f0..223257a 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 96ee818..542a006 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index 812ed79..bb93645 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index dae4171..41bcba9 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index b67a7ad..0cd08e7 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index a76906a..43efd28 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index 5772b09..fa46b32 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index fe17cdd..36d71ee 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 926a507..ffa7f34 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 35d332a..1dedb58 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index f0eca7b..da72d38 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index aec9746..4be1c5a 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index 4282cb5..d0bd786 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 1ed75b9..60619df 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx index 6d966f7..ff39a88 100644 --- a/odb/sqlite/stream.cxx +++ b/odb/sqlite/stream.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx index 0216497..3569082 100644 --- a/odb/sqlite/stream.hxx +++ b/odb/sqlite/stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/stream.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx index 1cd8c48..851d82d 100644 --- a/odb/sqlite/text-stream.hxx +++ b/odb/sqlite/text-stream.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text-stream.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx index cb29cfb..b95f248 100644 --- a/odb/sqlite/text.hxx +++ b/odb/sqlite/text.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/text.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index a5df2a7..4c3def8 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 73e08ed..8f8ac8b 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx index ece0b05..dbc77a1 100644 --- a/odb/sqlite/traits-calls.hxx +++ b/odb/sqlite/traits-calls.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits-calls.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 598eb12..73c5521 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 084868e..0c10e69 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 7aab780..aabb900 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index fc7ca44..263fa1a 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index a9b5413..ae66cfa 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 7ff93df..3e98984 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index f819be3..b41ed10 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 0d45402..accf263 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,5 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2-stub.hxx b/odb/sqlite/version-build2-stub.hxx index 9eb6301..697d375 100644 --- a/odb/sqlite/version-build2-stub.hxx +++ b/odb/sqlite/version-build2-stub.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version-build2-stub.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in index 9017924..5ea1d39 100644 --- a/odb/sqlite/version-build2.hxx.in +++ b/odb/sqlite/version-build2.hxx.in @@ -1,5 +1,5 @@ // file : odb/sqlite/version-build2.hxx.in -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 7852f74..c118cdf 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef LIBODB_SQLITE_BUILD2 diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 1b51e9d..5b300b8 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 4273f7d..9e5957c 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index d05a000..555884a 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index d07e39c..0f06f1c 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,5 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 7a4df2a..9759243 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -1,5 +1,5 @@ # file : tests/basics/buildfile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import libs = libodb-sqlite%lib{odb-sqlite} diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx index ab7f67e..053d76b 100644 --- a/tests/basics/driver.cxx +++ b/tests/basics/driver.cxx @@ -1,5 +1,5 @@ // file : tests/basics/driver.cxx -// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // Basic test to make sure the library is usable. Functionality testing diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build index 805bc82..c5c067b 100644 --- a/tests/build/bootstrap.build +++ b/tests/build/bootstrap.build @@ -1,5 +1,5 @@ # file : tests/build/bootstrap.build -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = # Unnamed subproject. diff --git a/tests/build/root.build b/tests/build/root.build index 8aff1ee..ac9d361 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,5 +1,5 @@ # file : tests/build/root.build -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = 11 diff --git a/tests/buildfile b/tests/buildfile index bb1ce38..3614001 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -1,5 +1,5 @@ # file : tests/buildfile -# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/} -- cgit v1.1 From 590db6791557753f0fd59581ed2b95af56b915d2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Feb 2019 07:44:57 +0200 Subject: Release version 2.5.0-b.11 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 64e9c05..1a825c8 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.10.z +version: 2.5.0-b.11 project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.8.0- depends: * bpkg >= 0.8.0- depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.10.1 2.5.0-b.11) +depends: libodb == 2.5.0-b.11 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index c118cdf..d1318bd 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20460 +#if ODB_VERSION != 20461 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049960 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.10" +#define LIBODB_SQLITE_VERSION 2049961 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.11" #include diff --git a/version b/version index c8f4946..3ba4219 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.10 +2.5.0-b.11 -- cgit v1.1 From cf4d922729d9daced90b660386d6c77a36eb2f66 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Feb 2019 16:24:13 +0200 Subject: Change version to 2.5.0-b.12.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1a825c8..feab40a 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.11 +version: 2.5.0-b.12.z project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com #builds: all requires: c++11 -depends: * build2 >= 0.8.0- -depends: * bpkg >= 0.8.0- +depends: * build2 >= 0.9.0 +depends: * bpkg >= 0.9.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.11 +depends: libodb [2.5.0-b.12.1 2.5.0-b.13) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d1318bd..acb4b13 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20461 +#if ODB_VERSION != 20462 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049961 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.11" +#define LIBODB_SQLITE_VERSION 2049962 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.12" #include diff --git a/version b/version index 3ba4219..4a125a9 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.11 +2.5.0-b.12 -- cgit v1.1 From c869d577f664881358f1ccd81fb5fce3d477efb7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 4 Mar 2019 18:19:40 +0300 Subject: Add 'builds: all' value to manifest --- manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest b/manifest index feab40a..c512c33 100644 --- a/manifest +++ b/manifest @@ -13,7 +13,7 @@ doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com -#builds: all +builds: all requires: c++11 depends: * build2 >= 0.9.0 depends: * bpkg >= 0.9.0 -- cgit v1.1 From 4bcf4e57d25252c4de8aa7f1551d61eafebe19d5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 5 Mar 2019 15:14:02 +0300 Subject: Align with latest bdep-new --- odb/sqlite/buildfile | 56 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 09f05fc..26ea2b8 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -15,27 +15,41 @@ lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ # clean results in a state identical to distributed). # hxx{version-build2}: in{version-build2} $src_root/manifest -hxx{version-build2}: dist = true -hxx{version-build2}: clean = ($src_root != $out_root) +hxx{version-build2}: +{ + dist = true + clean = ($src_root != $out_root) +} -# For pre-releases use the complete version to make sure they cannot be used -# in place of another pre-release or the final version. +# Build options. # -if $version.pre_release - lib{odb-sqlite}: bin.lib.version = @"-$version.project_id" -else - lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" - cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 + obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD -lib{odb-sqlite}: cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 +# Export options. +# +lib{odb-sqlite}: +{ + cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 + cxx.export.libs = $int_libs +} + liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED -lib{odb-sqlite}: cxx.export.libs = $int_libs +# For pre-releases use the complete version to make sure they cannot be used +# in place of another pre-release or the final version. See the version module +# for details on the version.* variable values. +# +if $version.pre_release + lib{odb-sqlite}: bin.lib.version = @"-$version.project_id" +else + lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" +# Generated options parser. +# details/ { if $cli.configured @@ -51,9 +65,12 @@ details/ # distributed). But don't install their headers since they are only used # internally in the database implementation. # - cli.cxx{*}: dist = true - cli.cxx{*}: clean = ($src_root != $out_root) - cli.cxx{*}: install = false + cli.cxx{*}: + { + dist = true + clean = ($src_root != $out_root) + install = false + } } else # No install for the pre-generated case. @@ -61,13 +78,16 @@ details/ hxx{options}@./ ixx{options}@./: install = false } -# Install into the odb/sqlite/ subdirectory of, say, /usr/include/ recreating -# subdirectories. +# Install into the odb/sqlite/ subdirectory of, say, /usr/include/ +# recreating subdirectories. # install_include = [dir_path] include/odb/sqlite/ -{hxx ixx txx}{*}: install = $install_include -{hxx ixx txx}{*}: install.subdirs = true +{hxx ixx txx}{*}: +{ + install = $install_include + install.subdirs = true +} # We want these to be picked up whether LIBODB_SQLITE_BUILD2 is defined or not. # -- cgit v1.1 From 663ae306ed9cc327f32c3cf53dd6f7e2896b4906 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 11 Mar 2019 17:02:49 +0300 Subject: Update sqlite repository location in repositories.manifest --- repositories.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repositories.manifest b/repositories.manifest index ba891b9..b45f391 100644 --- a/repositories.manifest +++ b/repositories.manifest @@ -3,7 +3,7 @@ summary: SQLite ODB runtime library repository : role: prerequisite -location: https://git.build2.org/packaging/sqlite/libsqlite3.git##HEAD +location: https://git.build2.org/packaging/sqlite/sqlite.git##HEAD : role: prerequisite -- cgit v1.1 From 7a6282af2a7685ac6e45edf3fe4c9616bdef38ca Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Mar 2019 16:01:55 +0200 Subject: Release version 2.5.0-b.13 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index c512c33..975fead 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.12.z +version: 2.5.0-b.13 project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.9.0 depends: * bpkg >= 0.9.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.12.1 2.5.0-b.13) +depends: libodb == 2.5.0-b.13 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index acb4b13..1d9f72e 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20462 +#if ODB_VERSION != 20463 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049962 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.12" +#define LIBODB_SQLITE_VERSION 2049963 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.13" #include diff --git a/version b/version index 4a125a9..e3350c4 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.12 +2.5.0-b.13 -- cgit v1.1 From 30f29e47a38dcf1433ffc448b3e31382761e9669 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Mar 2019 17:13:50 +0200 Subject: Change version to 2.5.0-b.14.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 975fead..7acf731 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.13 +version: 2.5.0-b.14.z project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.9.0 -depends: * bpkg >= 0.9.0 +depends: * build2 >= 0.10.0 +depends: * bpkg >= 0.10.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.13 +depends: libodb [2.5.0-b.14.1 2.5.0-b.15) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 1d9f72e..06624d6 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20463 +#if ODB_VERSION != 20464 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049963 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.13" +#define LIBODB_SQLITE_VERSION 2049964 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.14" #include diff --git a/version b/version index e3350c4..17ef4f0 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.13 +2.5.0-b.14 -- cgit v1.1 From a5714a90472633e9a238b058110850771e6b6206 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 4 Apr 2019 18:20:55 +0300 Subject: Update --options-file option description --- odb/sqlite/details/options.cli | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 7cc6649..901457f 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -37,9 +37,10 @@ namespace odb std::string --options-file { "", - "Read additional options from . Each option appearing on a - separate line optionally followed by space and an option value. - Empty lines and lines starting with \cb{#} are ignored." + "Read additional options from . Each option should appear on a + separate line optionally followed by space or equal sign (\cb{=}) + and an option value. Empty lines and lines starting with \cb{#} are + ignored." }; }; } -- cgit v1.1 From 9395bb885baf428d87bc99a9bd92f194c11492df Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 24 May 2019 18:49:40 +0300 Subject: Adapt version-build2.hxx.in to increasing standard version major, minor, and patch max values up to 99999 --- odb/sqlite/version-build2.hxx.in | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in index 5ea1d39..0e0d238 100644 --- a/odb/sqlite/version-build2.hxx.in +++ b/odb/sqlite/version-build2.hxx.in @@ -4,25 +4,24 @@ #ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. -// Note: using build2 standard versioning scheme. The numeric version format -// is AAABBBCCCDDDE where: +// The numeric version format is AAAAABBBBBCCCCCDDDE where: // -// AAA - major version number -// BBB - minor version number -// CCC - bugfix version number -// DDD - alpha / beta (DDD + 500) version number -// E - final (0) / snapshot (1) +// AAAAA - major version number +// BBBBB - minor version number +// CCCCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) // -// When DDDE is not 0, 1 is subtracted from AAABBBCCC. For example: +// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: // -// Version AAABBBCCCDDDE +// Version AAAAABBBBBCCCCCDDDE // -// 0.1.0 0000010000000 -// 0.1.2 0000010010000 -// 1.2.3 0010020030000 -// 2.2.0-a.1 0020019990010 -// 3.0.0-b.2 0029999995020 -// 2.2.0-a.1.z 0020019990011 +// 0.1.0 0000000001000000000 +// 0.1.2 0000000001000020000 +// 1.2.3 0000100002000030000 +// 2.2.0-a.1 0000200001999990010 +// 3.0.0-b.2 0000299999999995020 +// 2.2.0-a.1.z 0000200001999990011 // #define LIBODB_SQLITE_VERSION $libodb_sqlite.version.project_number$ULL #define LIBODB_SQLITE_VERSION_STR "$libodb_sqlite.version.project$" -- cgit v1.1 From 41e9453fcb81c7f4e459bea4ecaac779f0bf9c92 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 8 Jun 2019 10:06:20 +0200 Subject: Release version 2.5.0-b.15 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 7acf731..6bd9767 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.14.z +version: 2.5.0-b.15 project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.10.0 depends: * bpkg >= 0.10.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.14.1 2.5.0-b.15) +depends: libodb == 2.5.0-b.15 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 06624d6..c47bd75 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20464 +#if ODB_VERSION != 20465 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049964 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.14" +#define LIBODB_SQLITE_VERSION 2049965 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.15" #include diff --git a/version b/version index 17ef4f0..48aee48 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.14 +2.5.0-b.15 -- cgit v1.1 From d48694b3e354f9527bc1069c43bc40020b56b8ee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Jun 2019 11:59:44 +0200 Subject: Change version to 2.5.0-b.16.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6bd9767..e041cef 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.15 +version: 2.5.0-b.16.z project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.10.0 -depends: * bpkg >= 0.10.0 +depends: * build2 >= 0.11.0 +depends: * bpkg >= 0.11.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.15 +depends: libodb [2.5.0-b.16.1 2.5.0-b.17) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index c47bd75..32365f8 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20465 +#if ODB_VERSION != 20466 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049965 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.15" +#define LIBODB_SQLITE_VERSION 2049966 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.16" #include diff --git a/version b/version index 48aee48..dfe1a80 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.15 +2.5.0-b.16 -- cgit v1.1 From b9cbd573accbac433d26feee75be44afa7e6e29e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Jun 2019 12:42:58 +0200 Subject: Replace tags with topics in package manifest --- manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest b/manifest index e041cef..c59e941 100644 --- a/manifest +++ b/manifest @@ -5,7 +5,7 @@ project: odb summary: SQLite ODB runtime library license: GPLv2 license: proprietary -tags: c++, orm, sqlite, database, relational, object, persistence, sql +topics: C++, ORM, SQLite, SQL description-file: README changes-file: NEWS url: https://www.codesynthesis.com/products/odb/ -- cgit v1.1 From 2c19d95d48a64b8c7c0d097c7de7afe2f3e4264c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 1 Oct 2019 19:33:53 +0300 Subject: Use cxx.std=latest --- build/root.build | 2 +- tests/build/root.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/root.build b/build/root.build index 5aa371d..cdbd7ef 100644 --- a/build/root.build +++ b/build/root.build @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -cxx.std = 11 +cxx.std = latest using cxx diff --git a/tests/build/root.build b/tests/build/root.build index ac9d361..216fa84 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -cxx.std = 11 +cxx.std = latest using cxx -- cgit v1.1 From e1c3dbd9ccf56ba4427e644017c4ad1309c54912 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 6 Oct 2019 21:52:04 +0300 Subject: Adapt for building with Clang on Windows --- build/root.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/root.build b/build/root.build index cdbd7ef..ece30fb 100644 --- a/build/root.build +++ b/build/root.build @@ -11,11 +11,11 @@ ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx -if ($cxx.class == 'msvc') -{ +if ($cxx.target.system == 'win32-msvc') cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') cxx.coptions += /wd4251 /wd4275 /wd4800 -} # Load the cli module but only if it's available. This way a distribution # that includes pre-generated files can be built without installing cli. -- cgit v1.1 From 9b9ab3c0d6e7756bfe1f0977663b0b42c53070e0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 7 Oct 2019 12:59:47 +0300 Subject: Adapt tests for building with Clang on Windows --- tests/build/root.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/build/root.build b/tests/build/root.build index 216fa84..da6ff40 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -9,11 +9,11 @@ using cxx hxx{*}: extension = hxx cxx{*}: extension = cxx -if ($cxx.class == 'msvc') -{ +if ($cxx.target.system == 'win32-msvc') cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') cxx.coptions += /wd4251 /wd4275 /wd4800 -} # Every exe{} in this subproject is by default a test. # -- cgit v1.1 From 5eaa876faab4b2528277e5cfee4a1f129c25688e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 9 Oct 2019 13:50:33 +0300 Subject: Fix buildfile to install proper headers for Clang on Windows --- odb/sqlite/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 26ea2b8..d50aa37 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -99,7 +99,7 @@ details/build2/ { h{*}: install = false - if ($cxx.class == 'msvc') + if ($cxx.target.system == 'win32-msvc') { h{config-vc}@./: install = $install_include/details/ h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h -- cgit v1.1 From d5ed377744f314fba04c305f1ab016f4af4c175c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Nov 2019 07:21:02 +0200 Subject: Release version 2.5.0-b.17 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index c59e941..e076010 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.16.z +version: 2.5.0-b.17 project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.11.0 depends: * bpkg >= 0.11.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.16.1 2.5.0-b.17) +depends: libodb == 2.5.0-b.17 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 32365f8..02fe2cc 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20466 +#if ODB_VERSION != 20467 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049966 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.16" +#define LIBODB_SQLITE_VERSION 2049967 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.17" #include diff --git a/version b/version index dfe1a80..020c790 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.16 +2.5.0-b.17 -- cgit v1.1 From 9578e31d99245f4519cd013006d46f1a7200acd4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Nov 2019 06:30:31 +0200 Subject: Change version to 2.5.0-b.18.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e076010..2954072 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.17 +version: 2.5.0-b.18.z project: odb summary: SQLite ODB runtime library license: GPLv2 @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.11.0 -depends: * bpkg >= 0.11.0 +depends: * build2 >= 0.12.0 +depends: * bpkg >= 0.12.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.17 +depends: libodb [2.5.0-b.18.1 2.5.0-b.19) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 02fe2cc..cf47bd4 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -32,15 +32,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20467 +#if ODB_VERSION != 20468 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049967 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.17" +#define LIBODB_SQLITE_VERSION 2049968 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.18" #include diff --git a/version b/version index 020c790..a9b5191 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.17 +2.5.0-b.18 -- cgit v1.1 From 10ef2f9ac8e6216ea1276fe9f55c70db64f1c55f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 23 Jan 2020 15:09:05 +0200 Subject: Fix C++98 incompatibility --- odb/sqlite/query.hxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 8e45c32..70e4aa1 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -179,13 +179,14 @@ namespace odb kind_bool }; - clause_part (kind_type k): kind (k) {} - clause_part (kind_type k, const std::string& p): kind (k), part (p) {} + clause_part (kind_type k): kind (k), bool_part (false) {} + clause_part (kind_type k, const std::string& p) + : kind (k), part (p), bool_part (false) {} clause_part (bool p): kind (kind_bool), bool_part (p) {} kind_type kind; std::string part; // If kind is param, then part is conversion expr. - bool bool_part = false; + bool bool_part; }; query_base () -- cgit v1.1 From 666b8b0f1e24b632278b9fa5fcaaaaf3cb039a0c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Feb 2020 12:47:01 +0300 Subject: Add copyright notice to LICENSE file --- LICENSE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LICENSE b/LICENSE index 612c66c..9917599 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +Copyright (c) 2009-2019 Code Synthesis Tools CC. + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. -- cgit v1.1 From 4b7d1dc6aea926ae977afbba7410e7cea754dbf6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Feb 2020 12:47:39 +0300 Subject: Remove build/import/*/LICENSE files --- build/import/cli/LICENSE | 21 --- build/import/libodb-sqlite/LICENSE | 1 - build/import/libodb/LICENSE | 12 -- build/import/libsqlite/LICENSE | 340 ------------------------------------- 4 files changed, 374 deletions(-) delete mode 100644 build/import/cli/LICENSE delete mode 120000 build/import/libodb-sqlite/LICENSE delete mode 100644 build/import/libodb/LICENSE delete mode 100644 build/import/libsqlite/LICENSE diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE deleted file mode 100644 index f6b2d2b..0000000 --- a/build/import/cli/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2009-2019 Code Synthesis Tools CC. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -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 AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/build/import/libodb-sqlite/LICENSE b/build/import/libodb-sqlite/LICENSE deleted file mode 120000 index 5853aae..0000000 --- a/build/import/libodb-sqlite/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/build/import/libodb/LICENSE b/build/import/libodb/LICENSE deleted file mode 100644 index ed9c55c..0000000 --- a/build/import/libodb/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/build/import/libsqlite/LICENSE b/build/import/libsqlite/LICENSE deleted file mode 100644 index 3912109..0000000 --- a/build/import/libsqlite/LICENSE +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. -- cgit v1.1 From b805d6b7c75c243a52dc65f4a49cb0a2556c0615 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Feb 2020 12:47:51 +0300 Subject: Update last year in LICENSE file --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9917599..d106b92 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2019 Code Synthesis Tools CC. +Copyright (c) 2009-2020 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as -- cgit v1.1 From db06aa25c9dc259f6da5ff42b703d6d535bceb8d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Feb 2020 12:48:40 +0300 Subject: Drop copyright notice from source code --- Makefile.am | 1 - bootstrap | 1 - build/bootstrap.build | 1 - build/bootstrap.make | 1 - build/export.build | 1 - build/export/libodb-sqlite/stub.make | 1 - build/import/cli/cli-cxx.make | 1 - build/import/cli/configuration-rules.make | 1 - build/import/cli/configure | 1 - build/import/cli/stub.make | 1 - build/import/libodb-sqlite/configuration-rules.make | 1 - build/import/libodb-sqlite/configure | 1 - build/import/libodb-sqlite/stub.make | 1 - build/import/libodb/configuration-rules.make | 1 - build/import/libodb/configure | 1 - build/import/libodb/stub.make | 1 - build/import/libsqlite/configuration-rules.make | 1 - build/import/libsqlite/configure | 1 - build/import/libsqlite/rules.make | 1 - build/import/libsqlite/stub.make | 1 - build/root.build | 1 - buildfile | 1 - configure.ac | 1 - libodb-sqlite.pc.in | 1 - m4/disable-rpath.m4 | 1 - m4/libodb.m4 | 1 - m4/libsqlite.m4 | 1 - m4/libtool-link.m4 | 1 - m4/pkgconfig.m4 | 1 - m4/static-lib.m4 | 1 - m4/threads.m4 | 1 - makefile | 1 - odb/sqlite/Makefile.am | 1 - odb/sqlite/auto-handle.hxx | 1 - odb/sqlite/binding.hxx | 1 - odb/sqlite/blob-stream.hxx | 1 - odb/sqlite/blob.hxx | 1 - odb/sqlite/buildfile | 1 - odb/sqlite/connection-factory.cxx | 1 - odb/sqlite/connection-factory.hxx | 1 - odb/sqlite/connection.cxx | 1 - odb/sqlite/connection.hxx | 1 - odb/sqlite/connection.ixx | 1 - odb/sqlite/container-statements.hxx | 1 - odb/sqlite/container-statements.txx | 1 - odb/sqlite/database.cxx | 1 - odb/sqlite/database.hxx | 1 - odb/sqlite/database.ixx | 1 - odb/sqlite/details/build2/config-stub.h | 1 - odb/sqlite/details/build2/config-vc-stub.h | 1 - odb/sqlite/details/build2/config-vc.h | 1 - odb/sqlite/details/build2/config.h | 1 - odb/sqlite/details/config-vc.h | 1 - odb/sqlite/details/config.h.in | 1 - odb/sqlite/details/config.hxx | 1 - odb/sqlite/details/conversion.hxx | 1 - odb/sqlite/details/export.hxx | 1 - odb/sqlite/details/options.cli | 1 - odb/sqlite/error.cxx | 1 - odb/sqlite/error.hxx | 1 - odb/sqlite/exceptions.cxx | 1 - odb/sqlite/exceptions.hxx | 1 - odb/sqlite/forward.hxx | 1 - odb/sqlite/makefile | 1 - odb/sqlite/no-id-object-result.hxx | 1 - odb/sqlite/no-id-object-result.txx | 1 - odb/sqlite/no-id-object-statements.hxx | 1 - odb/sqlite/no-id-object-statements.txx | 1 - odb/sqlite/polymorphic-object-result.hxx | 1 - odb/sqlite/polymorphic-object-result.txx | 1 - odb/sqlite/polymorphic-object-statements.hxx | 1 - odb/sqlite/polymorphic-object-statements.txx | 1 - odb/sqlite/prepared-query.cxx | 1 - odb/sqlite/prepared-query.hxx | 1 - odb/sqlite/query-const-expr.cxx | 1 - odb/sqlite/query-dynamic.cxx | 1 - odb/sqlite/query-dynamic.hxx | 1 - odb/sqlite/query-dynamic.ixx | 1 - odb/sqlite/query-dynamic.txx | 1 - odb/sqlite/query.cxx | 1 - odb/sqlite/query.hxx | 1 - odb/sqlite/query.ixx | 1 - odb/sqlite/query.txx | 1 - odb/sqlite/section-statements.hxx | 1 - odb/sqlite/section-statements.txx | 1 - odb/sqlite/simple-object-result.hxx | 1 - odb/sqlite/simple-object-result.txx | 1 - odb/sqlite/simple-object-statements.cxx | 1 - odb/sqlite/simple-object-statements.hxx | 1 - odb/sqlite/simple-object-statements.ixx | 1 - odb/sqlite/simple-object-statements.txx | 1 - odb/sqlite/sqlite-types.hxx | 1 - odb/sqlite/statement-cache.cxx | 1 - odb/sqlite/statement-cache.hxx | 1 - odb/sqlite/statement-cache.txx | 1 - odb/sqlite/statement.cxx | 1 - odb/sqlite/statement.hxx | 1 - odb/sqlite/statements-base.cxx | 1 - odb/sqlite/statements-base.hxx | 1 - odb/sqlite/stream.cxx | 1 - odb/sqlite/stream.hxx | 1 - odb/sqlite/text-stream.hxx | 1 - odb/sqlite/text.hxx | 1 - odb/sqlite/tracer.cxx | 1 - odb/sqlite/tracer.hxx | 1 - odb/sqlite/traits-calls.hxx | 1 - odb/sqlite/traits.cxx | 1 - odb/sqlite/traits.hxx | 1 - odb/sqlite/transaction-impl.cxx | 1 - odb/sqlite/transaction-impl.hxx | 1 - odb/sqlite/transaction-impl.ixx | 1 - odb/sqlite/transaction.cxx | 1 - odb/sqlite/transaction.hxx | 1 - odb/sqlite/transaction.ixx | 1 - odb/sqlite/version-build2-stub.hxx | 1 - odb/sqlite/version-build2.hxx.in | 1 - odb/sqlite/version.hxx | 1 - odb/sqlite/view-result.hxx | 1 - odb/sqlite/view-result.txx | 1 - odb/sqlite/view-statements.hxx | 1 - odb/sqlite/view-statements.txx | 1 - tests/basics/buildfile | 1 - tests/basics/driver.cxx | 1 - tests/build/bootstrap.build | 1 - tests/build/root.build | 1 - tests/buildfile | 1 - 126 files changed, 126 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5ae3d5a..963f3c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,4 @@ # file : Makefile.am -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) diff --git a/bootstrap b/bootstrap index 0e786df..85d1399 100755 --- a/bootstrap +++ b/bootstrap @@ -1,7 +1,6 @@ #! /bin/sh # file : bootstrap -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file # diff --git a/build/bootstrap.build b/build/bootstrap.build index a5a24ab..bb9c901 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -1,5 +1,4 @@ # file : build/bootstrap.build -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = libodb-sqlite diff --git a/build/bootstrap.make b/build/bootstrap.make index 82d2e63..c859827 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -1,5 +1,4 @@ # file : build/bootstrap.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project_name := libodb-sqlite diff --git a/build/export.build b/build/export.build index 7d740c5..8ce77d8 100644 --- a/build/export.build +++ b/build/export.build @@ -1,5 +1,4 @@ # file : build/export.build -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $out_root/ diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make index ed533c8..af9cfd4 100644 --- a/build/export/libodb-sqlite/stub.make +++ b/build/export/libodb-sqlite/stub.make @@ -1,5 +1,4 @@ # file : build/export/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make index 3d01453..9bdf238 100644 --- a/build/import/cli/cli-cxx.make +++ b/build/import/cli/cli-cxx.make @@ -1,5 +1,4 @@ # file : build/import/cli/cli-cxx.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file # Here we are operating in the importing project's space, not in diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make index f13d01b..6355000 100644 --- a/build/import/cli/configuration-rules.make +++ b/build/import/cli/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/cli/configuration-rules.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. diff --git a/build/import/cli/configure b/build/import/cli/configure index 944f48c..2a1fde4 100755 --- a/build/import/cli/configure +++ b/build/import/cli/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/cli/configure -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make index 047ba40..741b371 100644 --- a/build/import/cli/stub.make +++ b/build/import/cli/stub.make @@ -1,5 +1,4 @@ # file : build/import/cli/stub.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : MIT; see accompanying LICENSE file $(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make index 260dcb6..bf8dee4 100644 --- a/build/import/libodb-sqlite/configuration-rules.make +++ b/build/import/libodb-sqlite/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libodb-sqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure index 2d61e29..9f245f5 100755 --- a/build/import/libodb-sqlite/configure +++ b/build/import/libodb-sqlite/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libodb-sqlite/configure -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make index add7c39..417e65a 100644 --- a/build/import/libodb-sqlite/stub.make +++ b/build/import/libodb-sqlite/stub.make @@ -1,5 +1,4 @@ # file : build/import/libodb-sqlite/stub.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make index 872cbb3..340c418 100644 --- a/build/import/libodb/configuration-rules.make +++ b/build/import/libodb/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libodb/configuration-rules.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. diff --git a/build/import/libodb/configure b/build/import/libodb/configure index 0d57a5f..261a202 100755 --- a/build/import/libodb/configure +++ b/build/import/libodb/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libodb/configure -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make index 6b7088d..04dc786 100644 --- a/build/import/libodb/stub.make +++ b/build/import/libodb/stub.make @@ -1,5 +1,4 @@ # file : build/import/libodb/stub.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make index 52db522..c7fcbed 100644 --- a/build/import/libsqlite/configuration-rules.make +++ b/build/import/libsqlite/configuration-rules.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/configuration-rules.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure index 81cf42b..0ae364f 100755 --- a/build/import/libsqlite/configure +++ b/build/import/libsqlite/configure @@ -1,7 +1,6 @@ #! /usr/bin/env bash # file : build/import/libsqlite/configure -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make index 8cc81e3..7e346bd 100644 --- a/build/import/libsqlite/rules.make +++ b/build/import/libsqlite/rules.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/rules.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make index 2038625..2d9e519 100644 --- a/build/import/libsqlite/stub.make +++ b/build/import/libsqlite/stub.make @@ -1,5 +1,4 @@ # file : build/import/libsqlite/stub.make -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file $(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) diff --git a/build/root.build b/build/root.build index ece30fb..ba74c09 100644 --- a/build/root.build +++ b/build/root.build @@ -1,5 +1,4 @@ # file : build/root.build -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = latest diff --git a/buildfile b/buildfile index b74794a..7bd5ae3 100644 --- a/buildfile +++ b/buildfile @@ -1,5 +1,4 @@ # file : buildfile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README} manifest diff --git a/configure.ac b/configure.ac index 21b0b51..27a5537 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,4 @@ # file : configure.ac -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file AC_PREREQ(2.60) diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in index dc682a2..b53bc6f 100644 --- a/libodb-sqlite.pc.in +++ b/libodb-sqlite.pc.in @@ -1,5 +1,4 @@ # file : libodb-sqlite.pc.in -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file prefix=@prefix@ diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 index 7874d4b..0864209 100644 --- a/m4/disable-rpath.m4 +++ b/m4/disable-rpath.m4 @@ -1,5 +1,4 @@ dnl file : m4/disable-rpath.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([DISABLE_RPATH],[ diff --git a/m4/libodb.m4 b/m4/libodb.m4 index 5f140bd..0dba7c4 100644 --- a/m4/libodb.m4 +++ b/m4/libodb.m4 @@ -1,5 +1,4 @@ dnl file : m4/libodb.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 index 3985706..421e990 100644 --- a/m4/libsqlite.m4 +++ b/m4/libsqlite.m4 @@ -1,5 +1,4 @@ dnl file : m4/libsqlite.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 index 635793f..302639f 100644 --- a/m4/libtool-link.m4 +++ b/m4/libtool-link.m4 @@ -1,5 +1,4 @@ dnl file : m4/libtool-link.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 index d5aa2d0..c48ea56 100644 --- a/m4/pkgconfig.m4 +++ b/m4/pkgconfig.m4 @@ -1,5 +1,4 @@ dnl file : m4/pkgconfig.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([PKGCONFIG],[ diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 index 79b89cd..5fb1c11 100644 --- a/m4/static-lib.m4 +++ b/m4/static-lib.m4 @@ -1,5 +1,4 @@ dnl file : m4/static-lib.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl dnl STATIC_LIB(MACRO, DESCRIPTION) diff --git a/m4/threads.m4 b/m4/threads.m4 index 10bdfdd..6f2e25f 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,5 +1,4 @@ dnl file : m4/threads.m4 -dnl copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC dnl license : GNU GPL v2; see accompanying LICENSE file dnl AC_DEFUN([THREADS],[ diff --git a/makefile b/makefile index c107e17..3a42f20 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,4 @@ # file : makefile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am index f6be926..0f66fc3 100644 --- a/odb/sqlite/Makefile.am +++ b/odb/sqlite/Makefile.am @@ -1,5 +1,4 @@ # file : odb/sqlite/Makefile.am -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file lib_LTLIBRARIES = libodb-sqlite.la diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx index 22f0cf9..d25e919 100644 --- a/odb/sqlite/auto-handle.hxx +++ b/odb/sqlite/auto-handle.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/auto-handle.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx index 09d4927..3807130 100644 --- a/odb/sqlite/binding.hxx +++ b/odb/sqlite/binding.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/binding.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx index 1531fd1..caa7c24 100644 --- a/odb/sqlite/blob-stream.hxx +++ b/odb/sqlite/blob-stream.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/blob-stream.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx index 0c559df..a4892a2 100644 --- a/odb/sqlite/blob.hxx +++ b/odb/sqlite/blob.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/blob.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index d50aa37..73455f8 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,5 +1,4 @@ # file : odb/sqlite/buildfile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import int_libs = libodb%lib{odb} diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 579cb61..1269db3 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection-factory.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 616a940..b665625 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection-factory.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index ab17c7c..a807949 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::bad_alloc diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index a71f07e..5bc95c6 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 87b599f..c1bf77a 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/connection.ixx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx index 7edc2dc..b9cccf0 100644 --- a/odb/sqlite/container-statements.hxx +++ b/odb/sqlite/container-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/container-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx index 8f3844c..6db91f2 100644 --- a/odb/sqlite/container-statements.txx +++ b/odb/sqlite/container-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/container-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 79c8666..96fab8d 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef _WIN32 diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 024372c..e4c9e78 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index a62dad1..c72d2f9 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/database.ixx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // move() diff --git a/odb/sqlite/details/build2/config-stub.h b/odb/sqlite/details/build2/config-stub.h index c5f34dd..34ba8ff 100644 --- a/odb/sqlite/details/build2/config-stub.h +++ b/odb/sqlite/details/build2/config-stub.h @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/build2/config-stub.h - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc-stub.h b/odb/sqlite/details/build2/config-vc-stub.h index f24b0c0..70e3e93 100644 --- a/odb/sqlite/details/build2/config-vc-stub.h +++ b/odb/sqlite/details/build2/config-vc-stub.h @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/build2/config-vc-stub.h - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h index a3b0299..75ce442 100644 --- a/odb/sqlite/details/build2/config-vc.h +++ b/odb/sqlite/details/build2/config-vc.h @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/build2/config-vc.h - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h index f304825..b4a1a1f 100644 --- a/odb/sqlite/details/build2/config.h +++ b/odb/sqlite/details/build2/config.h @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/build2/config.h - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h index 1f1fc61..f42c2a0 100644 --- a/odb/sqlite/details/config-vc.h +++ b/odb/sqlite/details/config-vc.h @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/config-vc.h - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in index e819fda..a223ecb 100644 --- a/odb/sqlite/details/config.h.in +++ b/odb/sqlite/details/config.h.in @@ -1,5 +1,4 @@ /* file : odb/sqlite/details/config.h.in - * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC * license : GNU GPL v2; see accompanying LICENSE file */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index 25c976d..bbf32f6 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/details/config.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx index 687c9d0..04843b2 100644 --- a/odb/sqlite/details/conversion.hxx +++ b/odb/sqlite/details/conversion.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/details/conversion.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 3d838e7..515b891 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/details/export.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli index 901457f..d1955c3 100644 --- a/odb/sqlite/details/options.cli +++ b/odb/sqlite/details/options.cli @@ -1,5 +1,4 @@ // file : odb/sqlite/details/options.cli -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file include ; diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx index 49bdc96..ae6bbe3 100644 --- a/odb/sqlite/error.cxx +++ b/odb/sqlite/error.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/error.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx index 441e8ff..4646f85 100644 --- a/odb/sqlite/error.hxx +++ b/odb/sqlite/error.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/error.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx index be06891..0621189 100644 --- a/odb/sqlite/exceptions.cxx +++ b/odb/sqlite/exceptions.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/exceptions.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx index 4312c31..3adb433 100644 --- a/odb/sqlite/exceptions.hxx +++ b/odb/sqlite/exceptions.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/exceptions.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx index e31b156..1be05b4 100644 --- a/odb/sqlite/forward.hxx +++ b/odb/sqlite/forward.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/forward.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index b0baab1..13a3c40 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -1,5 +1,4 @@ # file : odb/sqlite/makefile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx index 4b6b3d5..b0edb09 100644 --- a/odb/sqlite/no-id-object-result.hxx +++ b/odb/sqlite/no-id-object-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/no-id-object-result.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx index 0d3cae8..bd26afc 100644 --- a/odb/sqlite/no-id-object-result.txx +++ b/odb/sqlite/no-id-object-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/no-id-object-result.txx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx index fb57967..7a0376a 100644 --- a/odb/sqlite/no-id-object-statements.hxx +++ b/odb/sqlite/no-id-object-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/no-id-object-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx index 1fe1db8..d0a62b2 100644 --- a/odb/sqlite/no-id-object-statements.txx +++ b/odb/sqlite/no-id-object-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/no-id-object-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx index a9d34da..3239471 100644 --- a/odb/sqlite/polymorphic-object-result.hxx +++ b/odb/sqlite/polymorphic-object-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/polymorphic-object-result.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 960c477..bd22f01 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/polymorphic-object-result.txx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx index ddee2f0..736686b 100644 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ b/odb/sqlite/polymorphic-object-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/polymorphic-object-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index 6757e4b..f2a1605 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/polymorphic-object-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index 6812b39..ed63191 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/prepared-query.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index d688b06..4938ff3 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/prepared-query.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx index 17ef809..c8eaec7 100644 --- a/odb/sqlite/query-const-expr.cxx +++ b/odb/sqlite/query-const-expr.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-const-expr.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx index 5a05011..8089aed 100644 --- a/odb/sqlite/query-dynamic.cxx +++ b/odb/sqlite/query-dynamic.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-dynamic.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx index ee14f32..f720a95 100644 --- a/odb/sqlite/query-dynamic.hxx +++ b/odb/sqlite/query-dynamic.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-dynamic.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx index 0a51893..7fafe3e 100644 --- a/odb/sqlite/query-dynamic.ixx +++ b/odb/sqlite/query-dynamic.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-dynamic.ixx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx index faebf25..48b7ec4 100644 --- a/odb/sqlite/query-dynamic.txx +++ b/odb/sqlite/query-dynamic.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/query-dynamic.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx index 5862f83..98eb1cd 100644 --- a/odb/sqlite/query.cxx +++ b/odb/sqlite/query.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 70e4aa1..c9cbfaa 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx index 2b4cd3f..00e9b66 100644 --- a/odb/sqlite/query.ixx +++ b/odb/sqlite/query.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.ixx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index 3ee8bdf..f381ff0 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/query.txx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx index 2ac489f..e6a5da6 100644 --- a/odb/sqlite/section-statements.hxx +++ b/odb/sqlite/section-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/section-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx index 1fdc7a2..ff588b3 100644 --- a/odb/sqlite/section-statements.txx +++ b/odb/sqlite/section-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/section-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx index 223257a..d68af8e 100644 --- a/odb/sqlite/simple-object-result.hxx +++ b/odb/sqlite/simple-object-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-result.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx index 542a006..f27b226 100644 --- a/odb/sqlite/simple-object-result.txx +++ b/odb/sqlite/simple-object-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-result.txx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx index bb93645..1eb07db 100644 --- a/odb/sqlite/simple-object-statements.cxx +++ b/odb/sqlite/simple-object-statements.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-statements.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx index 41bcba9..b60fe6c 100644 --- a/odb/sqlite/simple-object-statements.hxx +++ b/odb/sqlite/simple-object-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx index 0cd08e7..6756c06 100644 --- a/odb/sqlite/simple-object-statements.ixx +++ b/odb/sqlite/simple-object-statements.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-statements.ixx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx index 43efd28..b80944d 100644 --- a/odb/sqlite/simple-object-statements.txx +++ b/odb/sqlite/simple-object-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/simple-object-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::memset diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx index fa46b32..b9839bf 100644 --- a/odb/sqlite/sqlite-types.hxx +++ b/odb/sqlite/sqlite-types.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/sqlite-types.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx index 36d71ee..095dcad 100644 --- a/odb/sqlite/statement-cache.cxx +++ b/odb/sqlite/statement-cache.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement-cache.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index ffa7f34..b42bda4 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement-cache.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 1dedb58..c089e32 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/statement-cache.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement-cache.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index da72d38..8f93a9f 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index 4be1c5a..9eeea7b 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statement.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx index d0bd786..bde8c55 100644 --- a/odb/sqlite/statements-base.cxx +++ b/odb/sqlite/statements-base.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statements-base.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx index 60619df..5851d1b 100644 --- a/odb/sqlite/statements-base.hxx +++ b/odb/sqlite/statements-base.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/statements-base.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx index ff39a88..8420ba2 100644 --- a/odb/sqlite/stream.cxx +++ b/odb/sqlite/stream.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/stream.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx index 3569082..c2d45c0 100644 --- a/odb/sqlite/stream.hxx +++ b/odb/sqlite/stream.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/stream.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx index 851d82d..7a9b467 100644 --- a/odb/sqlite/text-stream.hxx +++ b/odb/sqlite/text-stream.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/text-stream.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx index b95f248..3f681fb 100644 --- a/odb/sqlite/text.hxx +++ b/odb/sqlite/text.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/text.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx index 4c3def8..49f6b00 100644 --- a/odb/sqlite/tracer.cxx +++ b/odb/sqlite/tracer.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/tracer.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx index 8f8ac8b..b12573b 100644 --- a/odb/sqlite/tracer.hxx +++ b/odb/sqlite/tracer.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/tracer.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx index dbc77a1..9d5b59f 100644 --- a/odb/sqlite/traits-calls.hxx +++ b/odb/sqlite/traits-calls.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/traits-calls.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index 73c5521..a47455d 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/traits.cxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx index 0c10e69..a8cf578 100644 --- a/odb/sqlite/traits.hxx +++ b/odb/sqlite/traits.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/traits.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index aabb900..315af70 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 263fa1a..818270a 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx index ae66cfa..c49fedb 100644 --- a/odb/sqlite/transaction-impl.ixx +++ b/odb/sqlite/transaction-impl.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction-impl.ixx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx index 3e98984..8b4ab23 100644 --- a/odb/sqlite/transaction.cxx +++ b/odb/sqlite/transaction.cxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index b41ed10..01df7d4 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index accf263..0528cec 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -1,5 +1,4 @@ // file : odb/sqlite/transaction.ixx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2-stub.hxx b/odb/sqlite/version-build2-stub.hxx index 697d375..a6bb4d0 100644 --- a/odb/sqlite/version-build2-stub.hxx +++ b/odb/sqlite/version-build2-stub.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/version-build2-stub.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in index 0e0d238..50fef2d 100644 --- a/odb/sqlite/version-build2.hxx.in +++ b/odb/sqlite/version-build2.hxx.in @@ -1,5 +1,4 @@ // file : odb/sqlite/version-build2.hxx.in -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index cf47bd4..b92f5c3 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/version.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifdef LIBODB_SQLITE_BUILD2 diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx index 5b300b8..ce3d747 100644 --- a/odb/sqlite/view-result.hxx +++ b/odb/sqlite/view-result.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-result.hxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index 9e5957c..60efb81 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-result.txx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx index 555884a..0bd79ee 100644 --- a/odb/sqlite/view-statements.hxx +++ b/odb/sqlite/view-statements.hxx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-statements.hxx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx index 0f06f1c..0531a92 100644 --- a/odb/sqlite/view-statements.txx +++ b/odb/sqlite/view-statements.txx @@ -1,5 +1,4 @@ // file : odb/sqlite/view-statements.txx -// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 9759243..5d671d3 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -1,5 +1,4 @@ # file : tests/basics/buildfile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file import libs = libodb-sqlite%lib{odb-sqlite} diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx index 053d76b..b998574 100644 --- a/tests/basics/driver.cxx +++ b/tests/basics/driver.cxx @@ -1,5 +1,4 @@ // file : tests/basics/driver.cxx -// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // Basic test to make sure the library is usable. Functionality testing diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build index c5c067b..6ee38db 100644 --- a/tests/build/bootstrap.build +++ b/tests/build/bootstrap.build @@ -1,5 +1,4 @@ # file : tests/build/bootstrap.build -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file project = # Unnamed subproject. diff --git a/tests/build/root.build b/tests/build/root.build index da6ff40..6c5a90b 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,5 +1,4 @@ # file : tests/build/root.build -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file cxx.std = latest diff --git a/tests/buildfile b/tests/buildfile index 3614001..57588a4 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -1,5 +1,4 @@ # file : tests/buildfile -# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file ./: {*/ -build/} -- cgit v1.1 From 7085d9781b960a77f71d4f16e246ed44ea30b9f7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Jul 2020 16:09:51 +0300 Subject: Canonicalize license in manifest --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index 2954072..42048a8 100644 --- a/manifest +++ b/manifest @@ -3,8 +3,8 @@ name: libodb-sqlite version: 2.5.0-b.18.z project: odb summary: SQLite ODB runtime library -license: GPLv2 -license: proprietary +license: GPL-2.0-only +license: other: proprietary ; Not free/open source. topics: C++, ORM, SQLite, SQL description-file: README changes-file: NEWS -- cgit v1.1 From 2908718f42f8cfad5264de71ea25b587957b1907 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 18 Jul 2020 14:32:25 +0200 Subject: Release version 2.5.0-b.19 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 42048a8..37090dc 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.18.z +version: 2.5.0-b.19 project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.12.0 depends: * bpkg >= 0.12.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.18.1 2.5.0-b.19) +depends: libodb == 2.5.0-b.19 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b92f5c3..952ed63 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20468 +#if ODB_VERSION != 20469 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049968 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.18" +#define LIBODB_SQLITE_VERSION 2049969 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.19" #include diff --git a/version b/version index a9b5191..ea83ada 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.18 +2.5.0-b.19 -- cgit v1.1 From f8c8491f24cb7d0de03c8ff3defa191f3a2481ba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Jul 2020 15:13:40 +0200 Subject: Change version to 2.5.0-b.20.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 37090dc..f5a3e9b 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.19 +version: 2.5.0-b.20.z project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.12.0 -depends: * bpkg >= 0.12.0 +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.19 +depends: libodb [2.5.0-b.20.1 2.5.0-b.21) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index 952ed63..b2ec3cd 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20469 +#if ODB_VERSION != 20470 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049969 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.19" +#define LIBODB_SQLITE_VERSION 2049970 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.20" #include diff --git a/version b/version index ea83ada..a60117f 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.19 +2.5.0-b.20 -- cgit v1.1 From bf04c01061bb40db4cb0b3625b55afcf8a633bf6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 1 Aug 2020 13:51:14 +0300 Subject: Disable success build emails --- manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest b/manifest index f5a3e9b..fadd9a6 100644 --- a/manifest +++ b/manifest @@ -12,7 +12,7 @@ url: https://www.codesynthesis.com/products/odb/ doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ email: odb-users@codesynthesis.com -build-email: odb-builds@codesynthesis.com +build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 depends: * build2 >= 0.13.0 -- cgit v1.1 From 204b55b97d107eb2d3a6d1bf94f49b74591b3416 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 1 Aug 2020 13:52:59 +0300 Subject: Use legal{} target type for legal documentation (LICENSE, AUTHORS, etc) --- buildfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildfile b/buildfile index 7bd5ae3..4a1b0a7 100644 --- a/buildfile +++ b/buildfile @@ -1,7 +1,9 @@ # file : buildfile # license : GNU GPL v2; see accompanying LICENSE file -./: {*/ -build/ -m4/ -etc/} doc{GPLv2 INSTALL LICENSE NEWS README} manifest +./: {*/ -build/ -m4/ -etc/} \ + doc{INSTALL NEWS README} legal{GPLv2 LICENSE} \ + manifest # Don't install tests or the INSTALL file. # -- cgit v1.1 From 55fd0fe24bb754b34381cf26fed1327cd37415fc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 09:59:39 +0200 Subject: Update copyright --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d106b92..9678900 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2020 Code Synthesis Tools CC. +Copyright (c) 2009-2021 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as -- cgit v1.1 From edaa6f79149a79d6b59efa711bbd5feeeb40513e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 30 Apr 2021 10:00:33 +0200 Subject: Add transaction::connection(database&) overload --- odb/sqlite/database.cxx | 4 +++- odb/sqlite/database.ixx | 2 +- odb/sqlite/polymorphic-object-statements.txx | 2 +- odb/sqlite/transaction-impl.hxx | 5 ----- odb/sqlite/transaction-impl.ixx | 14 -------------- odb/sqlite/transaction.hxx | 3 +++ odb/sqlite/transaction.ixx | 8 +++++++- 7 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 odb/sqlite/transaction-impl.ixx diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 96fab8d..c15c633 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -225,7 +225,9 @@ namespace odb cp = factory_->connect (); sqlite::connection& c ( - cp != 0 ? *cp : transaction::current ().connection ()); + cp != 0 + ? *cp + : transaction::current ().connection (const_cast (*this))); try { diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index c72d2f9..d5302a1 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -590,7 +590,7 @@ namespace odb { // Throws if not in transaction. // - sqlite::connection& c (transaction::current ().connection ()); + sqlite::connection& c (transaction::current ().connection (*this)); return c.prepare_query (n, q); } diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx index f2a1605..6a376d3 100644 --- a/odb/sqlite/polymorphic-object-statements.txx +++ b/odb/sqlite/polymorphic-object-statements.txx @@ -116,7 +116,7 @@ namespace odb root_type& robj, const schema_version_migration* svm) { - connection_type& conn (transaction::current ().connection ()); + connection_type& conn (transaction::current ().connection (db)); polymorphic_derived_object_statements& sts ( conn.statement_cache ().find_object ()); root_statements_type& rsts (sts.root_statements ()); diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 818270a..040bcd7 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -45,9 +45,6 @@ namespace odb virtual void rollback (); - connection_type& - connection (); - private: connection_ptr connection_; lock lock_; @@ -55,8 +52,6 @@ namespace odb } } -#include - #include #endif // ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction-impl.ixx b/odb/sqlite/transaction-impl.ixx deleted file mode 100644 index c49fedb..0000000 --- a/odb/sqlite/transaction-impl.ixx +++ /dev/null @@ -1,14 +0,0 @@ -// file : odb/sqlite/transaction-impl.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - inline transaction_impl::connection_type& transaction_impl:: - connection () - { - return *connection_; - } - } -} diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx index 01df7d4..5e8c141 100644 --- a/odb/sqlite/transaction.hxx +++ b/odb/sqlite/transaction.hxx @@ -40,6 +40,9 @@ namespace odb connection_type& connection (); + connection_type& + connection (odb::database&); + // Return current transaction or throw if there is no transaction // in effect. // diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx index 0528cec..de4bd3e 100644 --- a/odb/sqlite/transaction.ixx +++ b/odb/sqlite/transaction.ixx @@ -39,7 +39,13 @@ namespace odb inline transaction::connection_type& transaction:: connection () { - return implementation ().connection (); + return static_cast (odb::transaction::connection ()); + } + + inline transaction::connection_type& transaction:: + connection (odb::database& db) + { + return static_cast (odb::transaction::connection (db)); } inline void transaction:: -- cgit v1.1 From 79cb2f05559e1ed9e724efd4f5dbceca794e7162 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 12:37:09 +0200 Subject: Add serial_connection_factory This factory can be used when the database access is guaranteed to be serial. --- odb/sqlite/connection-factory.cxx | 34 ++++++++++++++++++++++++++++++++++ odb/sqlite/connection-factory.hxx | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 1269db3..1a1f85a 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -17,6 +17,40 @@ namespace odb namespace sqlite { // + // serial_connection_factory + // + + serial_connection_factory:: + ~serial_connection_factory () + { + // We should hold the last reference to the connection. + // + if (connection_ != 0) + assert (connection_.count () == 1); + } + + connection_ptr serial_connection_factory:: + create () + { + return connection_ptr (new (shared) connection (*this)); + } + + connection_ptr serial_connection_factory:: + connect () + { + return connection_; + } + + void serial_connection_factory:: + database (database_type& db) + { + connection_factory::database (db); + + if (!connection_) + connection_ = create (); + } + + // // single_connection_factory // diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index b665625..141fff6 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -23,7 +23,42 @@ namespace odb { namespace sqlite { - // Share a single connection. + // Share a single connection in a guaranteed serial database access. + // + // For example, a single-threaded application that executes all the + // operations via the database instance without messing with multiple + // connections/transactions would qualify. + // + class LIBODB_SQLITE_EXPORT serial_connection_factory: + public connection_factory + { + public: + serial_connection_factory () {} + + virtual connection_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~serial_connection_factory (); + + private: + serial_connection_factory (const serial_connection_factory&); + serial_connection_factory& operator= (const serial_connection_factory&); + + protected: + // This function is called when the factory needs to create the + // connection. + // + virtual connection_ptr + create (); + + connection_ptr connection_; + }; + + // Share a single connection potentially between multiple threads. // class LIBODB_SQLITE_EXPORT single_connection_factory: public connection_factory -- cgit v1.1 From 344fd3309516aaa7faa8d0b91511ed868a5d60a4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 09:13:01 +0200 Subject: Move call to connection::invalidate_results() to clear() --- odb/sqlite/connection.cxx | 2 ++ odb/sqlite/connection.hxx | 3 ++- odb/sqlite/transaction-impl.cxx | 24 +++++++----------------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index a807949..c9e5d75 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -185,6 +185,8 @@ namespace odb void connection:: clear () { + invalidate_results (); + // The current first active_object will remove itself from the list // and make the second object (if any) the new first. // diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 5bc95c6..783ef5b 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -156,7 +156,8 @@ namespace odb wait (); public: - // Reset active statements. + // Reset active statements. Also invalidates query results by first + // calling invalidate_results(). // void clear (); diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 315af70..b1b83c8 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -95,15 +95,12 @@ namespace odb void transaction_impl:: commit () { - // Invalidate query results. + // Invalidate query results and reset active statements. // - connection_->invalidate_results (); - - // Reset active statements. Active statements will prevent COMMIT - // from completing (write statements) or releasing the locks (read - // statements). Normally, a statement is automatically reset on - // completion, however, if an exception is thrown, that may not - // happen. + // Active statements will prevent COMMIT from completing (write + // statements) or releasing the locks (read statements). Normally, a + // statement is automatically reset on completion, however, if an + // exception is thrown, that may not happen. // connection_->clear (); @@ -121,15 +118,8 @@ namespace odb void transaction_impl:: rollback () { - // Invalidate query results. - // - connection_->invalidate_results (); - - // Reset active statements. Active statements will prevent ROLLBACK - // from completing (write statements) or releasing the locks (read - // statements). Normally, a statement is automatically reset on - // completion, however, if an exception is thrown, that may not - // happen. + // Invalidate query results and reset active statements (the same + // reasoning as in commit()). // connection_->clear (); -- cgit v1.1 From 2c15821eb8a9d6a7f79b7194b23d84dd8bb773c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 09:58:08 +0200 Subject: Allow active objects to remain on list after call to clear() --- odb/sqlite/connection.cxx | 16 ++++++++++++---- odb/sqlite/connection.hxx | 6 ++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index c9e5d75..cdd4c20 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -187,11 +187,19 @@ namespace odb { invalidate_results (); - // The current first active_object will remove itself from the list - // and make the second object (if any) the new first. + // The current first active_object may remove itself from the list and + // make the second object (if any) the new first. // - while (active_objects_ != 0) - active_objects_->clear (); + for (active_object** pp (&active_objects_); *pp != nullptr; ) + { + active_object* p (*pp); + p->clear (); + + // Move to the next object if this one decided to stay on the list. + // + if (*pp == p) + pp = &p->next_; + } } // connection_factory diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 783ef5b..254a002 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -41,8 +41,8 @@ namespace odb class LIBODB_SQLITE_EXPORT active_object { public: - // This function should remove the object from the list, since - // it shall no longer be "active". + // This function may remove the object from the list since it may no + // longer be "active". // virtual void clear () = 0; @@ -57,6 +57,8 @@ namespace odb list_remove (); protected: + friend class connection; + // prev_ == 0 means we are the first element. // next_ == 0 means we are the last element. // next_ == this means we are not on the list (prev_ should be 0). -- cgit v1.1 From fa3f14db14671b4c37c400880d097b17aa12b824 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 11:55:45 +0200 Subject: Move begin/commit/rollback statements to connection --- odb/sqlite/connection.cxx | 46 +++++++++++++++++++++++++++++++++++ odb/sqlite/connection.hxx | 27 +++++++++++++++++++++ odb/sqlite/connection.ixx | 2 +- odb/sqlite/statement-cache.cxx | 39 ----------------------------- odb/sqlite/statement-cache.hxx | 54 +++-------------------------------------- odb/sqlite/transaction-impl.cxx | 15 +++++------- 6 files changed, 83 insertions(+), 100 deletions(-) delete mode 100644 odb/sqlite/statement-cache.cxx diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index cdd4c20..57ce860 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -25,6 +25,8 @@ odb_sqlite_connection_unlock_callback (void**, int); namespace odb { + using namespace details; + namespace sqlite { connection:: @@ -105,6 +107,12 @@ namespace odb db.foreign_keys () ? 22 : 23); st.execute (); + // String lengths include '\0', as per the SQLite manual suggestion. + // + begin_.reset (new (shared) generic_statement (*this, "BEGIN", 6)); + commit_.reset (new (shared) generic_statement (*this, "COMMIT", 7)); + rollback_.reset (new (shared) generic_statement (*this, "ROLLBACK", 9)); + // Create statement cache. // statement_cache_.reset (new statement_cache_type (*this)); @@ -119,6 +127,44 @@ namespace odb clear_prepared_map (); } + generic_statement& connection:: + begin_statement () + { + return static_cast (*begin_); + } + + generic_statement& connection:: + begin_immediate_statement () + { + if (!begin_immediate_) + begin_immediate_.reset ( + new (shared) generic_statement (*this, "BEGIN IMMEDIATE", 16)); + + return static_cast (*begin_immediate_); + } + + generic_statement& connection:: + begin_exclusive_statement () + { + if (!begin_exclusive_) + begin_exclusive_.reset ( + new (shared) generic_statement (*this, "BEGIN EXCLUSIVE", 16)); + + return static_cast (*begin_exclusive_); + } + + generic_statement& connection:: + commit_statement () + { + return static_cast (*commit_); + } + + generic_statement& connection:: + rollback_statement () + { + return static_cast (*rollback_); + } + transaction_impl* connection:: begin () { diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 254a002..30bb467 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -8,6 +8,7 @@ #include +#include #include #include @@ -29,6 +30,7 @@ namespace odb namespace sqlite { class statement_cache; + class generic_statement; class connection_factory; class connection; @@ -164,6 +166,22 @@ namespace odb void clear (); + public: + generic_statement& + begin_statement (); + + generic_statement& + begin_immediate_statement (); + + generic_statement& + begin_exclusive_statement (); + + generic_statement& + commit_statement (); + + generic_statement& + rollback_statement (); + private: connection (const connection&); connection& operator= (const connection&); @@ -180,6 +198,15 @@ namespace odb // details::unique_ptr statement_cache_; + // Note: using odb::statement in order to break the connection-statement + // dependency cycle. + // + details::shared_ptr begin_; + details::shared_ptr begin_immediate_; + details::shared_ptr begin_exclusive_; + details::shared_ptr commit_; + details::shared_ptr rollback_; + // Unlock notification machinery. // private: diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index c1bf77a..69739b7 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -5,7 +5,7 @@ namespace odb { namespace sqlite { - // active_objects + // active_object // inline void active_object:: list_add () diff --git a/odb/sqlite/statement-cache.cxx b/odb/sqlite/statement-cache.cxx deleted file mode 100644 index 095dcad..0000000 --- a/odb/sqlite/statement-cache.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : odb/sqlite/statement-cache.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - using namespace details; - - namespace sqlite - { - statement_cache:: - statement_cache (connection& conn) - : conn_ (conn), - version_seq_ (conn.database ().schema_version_sequence ()), - // String lengths below include '\0', as per SQLite manual - // suggestions. - // - begin_ (new (shared) generic_statement (conn_, "BEGIN", 6)), - commit_ (new (shared) generic_statement (conn_, "COMMIT", 7)), - rollback_ (new (shared) generic_statement (conn_, "ROLLBACK", 9)) - { - } - - void statement_cache:: - begin_immediate_statement_ () const - { - begin_immediate_.reset ( - new (shared) generic_statement (conn_, "BEGIN IMMEDIATE", 16)); - } - - void statement_cache:: - begin_exclusive_statement_ () const - { - begin_exclusive_.reset ( - new (shared) generic_statement (conn_, "BEGIN EXCLUSIVE", 16)); - } - } -} diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index b42bda4..923b428 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -29,43 +29,9 @@ namespace odb class LIBODB_SQLITE_EXPORT statement_cache { public: - statement_cache (connection&); - - generic_statement& - begin_statement () const - { - return *begin_; - } - - generic_statement& - begin_immediate_statement () const - { - if (!begin_immediate_) - begin_immediate_statement_ (); - - return *begin_immediate_; - } - - generic_statement& - begin_exclusive_statement () const - { - if (!begin_exclusive_) - begin_exclusive_statement_ (); - - return *begin_exclusive_; - } - - generic_statement& - commit_statement () const - { - return *commit_; - } - - generic_statement& - rollback_statement () const - { - return *rollback_; - } + statement_cache (connection& conn) + : conn_ (conn), + version_seq_ (conn.database ().schema_version_sequence ()) {} template typename object_traits_impl::statements_type& @@ -76,26 +42,12 @@ namespace odb find_view (); private: - void - begin_immediate_statement_ () const; - - void - begin_exclusive_statement_ () const; - - private: typedef std::map, details::type_info_comparator> map; connection& conn_; unsigned int version_seq_; - - details::shared_ptr begin_; - mutable details::shared_ptr begin_immediate_; - mutable details::shared_ptr begin_exclusive_; - details::shared_ptr commit_; - details::shared_ptr rollback_; - map map_; }; } diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index b1b83c8..721b3fe 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -6,7 +6,6 @@ #include #include #include -#include #include namespace odb @@ -43,23 +42,21 @@ namespace odb odb::transaction_impl::connection_ = connection_.get (); } - statement_cache& sc (connection_->statement_cache ()); - switch (lock_) { case deferred: { - sc.begin_statement ().execute (); + connection_->begin_statement ().execute (); break; } case immediate: { - sc.begin_immediate_statement ().execute (); + connection_->begin_immediate_statement ().execute (); break; } case exclusive: { - sc.begin_exclusive_statement ().execute (); + connection_->begin_exclusive_statement ().execute (); break; } } @@ -82,7 +79,7 @@ namespace odb // try { - c_->statement_cache ().rollback_statement ().execute (); + c_->rollback_statement ().execute (); } catch (...) {} } @@ -106,7 +103,7 @@ namespace odb { commit_guard cg (*connection_); - connection_->statement_cache ().commit_statement ().execute (); + connection_->commit_statement ().execute (); cg.release (); } @@ -123,7 +120,7 @@ namespace odb // connection_->clear (); - connection_->statement_cache ().rollback_statement ().execute (); + connection_->rollback_statement ().execute (); // Release the connection. // -- cgit v1.1 From 64f60cfa94d730ea5d6a9e7bc22a8d706f73d53c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Apr 2021 09:05:42 +0200 Subject: Add support for SQLite ATTACH DATABASE functionality --- odb/sqlite/connection-factory.cxx | 118 ++++++++++++++++++++++++++++++++++++++ odb/sqlite/connection-factory.hxx | 32 +++++++++++ odb/sqlite/connection.cxx | 45 ++++++++++++++- odb/sqlite/connection.hxx | 109 ++++++++++++++++++++++++++++++++--- odb/sqlite/connection.ixx | 30 ++++++++++ odb/sqlite/database.cxx | 31 +++++++++- odb/sqlite/database.hxx | 79 +++++++++++++++++++++++++ odb/sqlite/database.ixx | 16 ++++++ odb/sqlite/makefile | 1 - odb/sqlite/prepared-query.cxx | 12 ++++ odb/sqlite/prepared-query.hxx | 3 + odb/sqlite/statement.cxx | 38 +++++++----- odb/sqlite/transaction-impl.cxx | 58 ++++++++++++++++--- odb/sqlite/transaction-impl.hxx | 9 +++ 14 files changed, 547 insertions(+), 34 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 1a1f85a..0bbf617 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -1,6 +1,8 @@ // file : odb/sqlite/connection-factory.cxx // license : GNU GPL v2; see accompanying LICENSE file +#include + #include #include @@ -295,5 +297,121 @@ namespace odb pooled_connection* c (static_cast (arg)); return static_cast (c->factory_).release (c); } + + // + // default_attached_connection_factory + // + + void default_attached_connection_factory:: + detach () + { + // Note that this function may be called several times, for example, in + // case of detach_database() failure. + // + if (attached_connection_ != 0) + { + // We should hold the last reference to the attached connection. + // + assert (attached_connection_.count () == 1); + + // While it may seem like a good idea to also invalidate query results + // and reset active statements, if any such result/statement is still + // alive, then there would be bigger problems since it would have a + // dangling reference to the connection. In a way, this's the same + // reason we don't do it in the connection destructor. + + // Remove ourselves from the active object list of the main + // connection. + // + if (next_ != this) // Might have already been done. + list_remove (); + + const string& s (database ().schema ()); + + if (s != "main" && s != "temp") + main_factory ().detach_database (main_connection_, s); + + // Explicitly free the attached connection so that we don't try to + // redo this. + // + attached_connection_.reset (); + } + } + + default_attached_connection_factory:: + ~default_attached_connection_factory () + { + if (attached_connection_ != 0) + { + // This can throw. Ignoring the failure to detach seems like the most + // sensible thing to do here. + // + try{ detach (); } catch (...) {} + } + } + + connection_ptr default_attached_connection_factory:: + connect () + { + return attached_connection_; + } + + void default_attached_connection_factory:: + database (database_type& db) + { + attached_connection_factory::database (db); + + if (!attached_connection_) + { + const string& s (db.schema ()); + + if (s != "main" && s != "temp") + main_factory ().attach_database (main_connection_, db.name (), s); + + attached_connection_.reset ( + new (shared) connection (*this, + s != "main" ? &translate_statement : 0)); + + // Add ourselves to the active object list of the main connection. + // + list_add (); + } + } + + void default_attached_connection_factory:: + clear () + { + attached_connection_->clear (); + } + + void default_attached_connection_factory:: + translate_statement (string& r, + const char* text, + size_t text_size, + connection& conn) + { + r.assign (text, text_size); + + // Things will fall apart if any of the statements we translate use + // "main" as a table alias. So we have this crude check even though it + // means we cannot use "main" for other aliases (e.g., column). + // + assert (r.find ("AS \"main\"") == string::npos); + + const string& s (conn.database ().schema ()); + for (size_t p (0); (p = r.find ("\"main\".", p, 7)) != string::npos; ) + { + // Verify the preceding character. + // + if (p != 0 && r[p - 1] == '.') + { + p += 7; + continue; + } + + r.replace (p + 1, 4, s); + p += s.size () + 3; + } + } } } diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 141fff6..0d01b85 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -233,6 +233,38 @@ namespace odb details::mutex mutex_; details::condition cond_; }; + + class LIBODB_SQLITE_EXPORT default_attached_connection_factory: + public attached_connection_factory + { + public: + explicit + default_attached_connection_factory (const connection_ptr& main) + : attached_connection_factory (main) {} + + using attached_connection_factory::database; // Accessor. + + virtual void + database (database_type&); + + virtual connection_ptr + connect (); + + // Active object interface. + // + virtual void + clear (); + + virtual void + detach (); + + virtual + ~default_attached_connection_factory (); + + protected: + static void + translate_statement (std::string&, const char*, std::size_t, connection&); + }; } } diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 57ce860..bb71274 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -30,8 +30,11 @@ namespace odb namespace sqlite { connection:: - connection (connection_factory& cf, int extra_flags) + connection (connection_factory& cf, + int extra_flags, + statement_translator* st) : odb::connection (cf), + statement_translator_ (st), unlock_cond_ (unlock_mutex_), active_objects_ (0) { @@ -83,9 +86,12 @@ namespace odb } connection:: - connection (connection_factory& cf, sqlite3* handle) + connection (connection_factory& cf, + sqlite3* handle, + statement_translator* st) : odb::connection (cf), handle_ (handle), + statement_translator_ (st), unlock_cond_ (unlock_mutex_), active_objects_ (0) { @@ -119,6 +125,25 @@ namespace odb } connection:: + connection (attached_connection_factory& cf, statement_translator* st) + : odb::connection (cf), + handle_ (0), + statement_translator_ (st), + unlock_cond_ (unlock_mutex_), + active_objects_ (0) + { + // Copy some things over from the main connection. + // + connection& main (*cf.main_connection_); + + tracer_ = main.tracer_; + + // Create statement cache. + // + statement_cache_.reset (new statement_cache_type (*this)); + } + + connection:: ~connection () { // Destroy prepared query statements before freeing the connections. @@ -213,7 +238,7 @@ namespace odb // unlock_notify() returns SQLITE_OK or SQLITE_LOCKED (deadlock). // - int e (sqlite3_unlock_notify (handle_, + int e (sqlite3_unlock_notify (handle (), &odb_sqlite_connection_unlock_callback, this)); if (e == SQLITE_LOCKED) @@ -261,6 +286,20 @@ namespace odb odb::connection_factory::db_ = &db; db_ = &db; } + + void connection_factory:: + attach_database (const connection_ptr& conn, + const std::string& name, + const std::string& schema) + { + conn->execute ("ATTACH DATABASE '" + name + "' AS \"" + schema + '"'); + } + + void connection_factory:: + detach_database (const connection_ptr& conn, const std::string& schema) + { + conn->execute ("DETACH DATABASE \"" + schema + '"'); + } } } diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 30bb467..f8df9d0 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -32,13 +32,14 @@ namespace odb class statement_cache; class generic_statement; class connection_factory; + class attached_connection_factory; class connection; typedef details::shared_ptr connection_ptr; // SQLite "active object", i.e., an object that needs to be // "cleared" before the transaction can be committed and the - // connection release. These form a doubly-linked list. + // connection released. These form a doubly-linked list. // class LIBODB_SQLITE_EXPORT active_object { @@ -77,15 +78,42 @@ namespace odb typedef sqlite::statement_cache statement_cache_type; typedef sqlite::database database_type; + // Translate the database schema in statement text (used to implement + // attached databases). If the result is empty, then no translation is + // required and the original text should be used as is. + // + typedef void (statement_translator) (std::string& result, + const char* text, + std::size_t text_size, + connection&); virtual ~connection (); - connection (connection_factory&, int extra_flags = 0); - connection (connection_factory&, sqlite3* handle); + connection (connection_factory&, + int extra_flags = 0, + statement_translator* = 0); + + connection (connection_factory&, + sqlite3* handle, + statement_translator* = 0); + + // Create an attached connection (see the attached database constructor + // for details). + // + connection (attached_connection_factory&, statement_translator*); database_type& database (); + // Return the main connection of an attached connection. If this + // connection is main, return itself. + // + connection& + main_connection (); + + static connection_ptr + main_connection (const connection_ptr&); + public: virtual transaction_impl* begin (); @@ -142,10 +170,7 @@ namespace odb public: sqlite3* - handle () - { - return handle_; - } + handle (); statement_cache_type& statement_cache () @@ -167,6 +192,8 @@ namespace odb clear (); public: + // Note: only available on main connection. + // generic_statement& begin_statement (); @@ -182,6 +209,12 @@ namespace odb generic_statement& rollback_statement (); + protected: + friend class attached_connection_factory; + + connection_factory& + factory (); + private: connection (const connection&); connection& operator= (const connection&); @@ -191,8 +224,13 @@ namespace odb init (); private: + // Note that we use NULL handle as an indication of an attached + // connection. + // auto_handle handle_; + statement_translator* statement_translator_; + // Keep statement_cache_ after handle_ so that it is destroyed before // the connection is closed. // @@ -218,6 +256,7 @@ namespace odb connection_unlock_callback (void**, int); private: + friend class statement; // statement_translator_ friend class transaction_impl; // invalidate_results() // Linked list of active objects currently associated @@ -248,12 +287,68 @@ namespace odb connection_factory (): db_ (0) {} + // Attach/detach additional databases. Connection is one of the main + // connections created by this factory. Note: not called for "main" and + // "temp" schemas. + // + // The default implementations simply execute the ATTACH DATABASE and + // DETACH DATABASE SQLite statements. + // + virtual void + attach_database (const connection_ptr&, + const std::string& name, + const std::string& schema); + + virtual void + detach_database (const connection_ptr&, const std::string& schema); + // Needed to break the circular connection_factory-database dependency // (odb::connection_factory has the odb::database member). // protected: database_type* db_; }; + + // The call to database() should cause ATTACH DATABASE (or otherwise make + // sure the database is attached). Destruction of the factory should cause + // DETACH DATABASE (or otherwise notice that this factory no longer needs + // the database attached). + // + // Note that attached_connection_factory is an active object that + // registers itself with the main connection in order to get notified on + // transaction finalization. + // + class LIBODB_SQLITE_EXPORT attached_connection_factory: + public connection_factory, + public active_object + { + public: + explicit + attached_connection_factory (const connection_ptr& main) + : active_object (*main), main_connection_ (main) {} + + virtual void + detach () = 0; + + protected: + friend class database; + friend class connection; + friend class transaction_impl; + + connection_factory& + main_factory () + { + return main_connection_->factory (); + } + + // Note that this essentially establishes a "protocol" for all the + // attached connection factory implementations: they hold a counted + // reference to the main connection and they maintain a single shared + // attached connection. + // + connection_ptr main_connection_; + connection_ptr attached_connection_; + }; } } diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index 69739b7..c0e49b9 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -37,6 +37,36 @@ namespace odb return static_cast (factory_).database (); } + inline connection& connection:: + main_connection () + { + return handle_ != 0 + ? *this + : *static_cast (factory_).main_connection_; + } + + inline connection_ptr connection:: + main_connection (const connection_ptr& c) + { + return c->handle_ != 0 + ? c + : static_cast (c->factory_).main_connection_; + } + + inline sqlite3* connection:: + handle () + { + return handle_ != 0 + ? handle_ + : static_cast (factory_).main_connection_->handle_; + } + + inline connection_factory& connection:: + factory () + { + return static_cast (factory_); + } + template inline prepared_query connection:: prepare_query (const char* n, const char* q) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index c15c633..a7cf098 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -151,8 +151,35 @@ namespace odb factory_->database (*this); } + database:: + database (const connection_ptr& conn, + const string& name, + const string& schema, + transfer_ptr factory) + : odb::database (id_sqlite), + name_ (name), + schema_ (schema), + flags_ (0), + factory_ (factory.transfer ()) + { + assert (!schema_.empty ()); + + // Copy some things over from the connection's database. + // + database& db (conn->database ()); + + tracer_ = db.tracer_; + foreign_keys_ = db.foreign_keys_; + + if (!factory_) + factory_.reset (new default_attached_connection_factory ( + connection::main_connection (conn))); + + factory_->database (*this); + } + void database:: - print_usage (std::ostream& os) + print_usage (ostream& os) { details::options::print_usage (os); } @@ -196,7 +223,7 @@ namespace odb else if (!schema_version_table_.empty ()) text += schema_version_table_; // Already quoted. else - text += "\"schema_version\""; + text += "\"main\".\"schema_version\""; text += " WHERE \"name\" = ?"; diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index e4c9e78..478fbdb 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -83,6 +83,69 @@ namespace odb details::transfer_ptr = details::transfer_ptr ()); + // Attach to the specified connection a database with the specified name + // as the specified schema. Good understanding of SQLite ATTACH/DETACH + // DATABASE semantics and ODB connection management is recommended when + // using this mechanism. + // + // The resulting database instance is referred to as an "attached + // database" and the connection it returns as an "attached connection" + // (which is just a proxy for the main connection). Database operations + // executed on the attached database or attached connection are + // automatically translated to refer to the specified schema rather than + // "main". For uniformity attached databases can also be created for the + // pre-attached "main" and "temp" schemas (in this case name can be + // anything). + // + // The main connection and attached to it databases and connections are + // all meant to be used withing the same thread. In particular, the + // attached database holds a counted reference to the main connection + // which means the connection will not be released until all the + // attached to this connection databases are destroyed. + // + // Note that in this model the attached databases are attached to the + // main connection, not to the (main) database, which mimics the + // underlying semantics of SQLite. An alternative model would have been + // to notionally attach the databases to the main database and under the + // hood automatically attach them to each returned connecton. While this + // may seem like a more convenient model in some cases, it is also less + // flexible: the current model allows attaching a different set of + // databases to different connections, attaching them on demand as the + // transaction progresses, etc. Also, the more convenient model can be + // implemented on top this model by deriving an aplication-specific + // database class and/or providing custom connection factories. + // + // Note also that unless the name is a URI with appropriate mode, it is + // opened with the SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE flags. So if + // you want just SQLITE_OPEN_READWRITE, then you will need to verify its + // existence manually prior to calling this constructor. + // + // The automatic translation of the statements relies on all the + // statements text having references to top-level database entities + // (tables, indexes, etc) qualified with the "main" schema. To achieve + // this, compile your headers with `--schema main` and, if using schema + // migration, with `--schema-version-table main.schema_version`. You + // must also not use "main" as a table alias. + // + database (const connection_ptr&, + const std::string& name, + const std::string& schema, + details::transfer_ptr = + details::transfer_ptr ()); + + // The database is automatically detached on destruction but a failure + // to detach is ignored. To detect such a failure perform explicit + // detach. For uniformity detaching a main database is a no-op. + // + void + detach (); + + // Return the main database of an attached database. If this database + // is main, return itself. + // + database& + main_database (); + // Move-constructible but not move-assignable. // #ifdef ODB_CXX11 @@ -99,6 +162,15 @@ namespace odb return name_; } + // Schema name under which this database was attached or empty for the + // main database. + // + const std::string& + schema () const + { + return schema_; + } + int flags () const { @@ -463,12 +535,19 @@ namespace odb connection_ (); private: + friend class transaction_impl; // factory_ + // Note: remember to update move ctor if adding any new members. // std::string name_; + std::string schema_; int flags_; bool foreign_keys_; std::string vfs_; + + // Note: keep last so that all other database members are still valid + // during factory's destruction. + // details::unique_ptr factory_; }; } diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index d5302a1..e906a39 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -14,6 +14,7 @@ namespace odb database (database&& db) // Has to be inline. : odb::database (std::move (db)), name_ (std::move (db.name_)), + schema_ (std::move (db.schema_)), flags_ (db.flags_), foreign_keys_ (db.foreign_keys_), vfs_ (std::move (db.vfs_)), @@ -23,6 +24,21 @@ namespace odb } #endif + inline void database:: + detach () + { + if (!schema_.empty ()) + static_cast (*factory_).detach (); + } + + inline database& database:: + main_database () + { + return schema_.empty () + ? *this + : static_cast (*factory_).main_connection_->database (); + } + inline connection_ptr database:: connection () { diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index 13a3c40..cead138 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -16,7 +16,6 @@ query-const-expr.cxx \ simple-object-statements.cxx \ statement.cxx \ statements-base.cxx \ -statement-cache.cxx \ stream.cxx \ tracer.cxx \ traits.cxx \ diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx index ed63191..79df0f2 100644 --- a/odb/sqlite/prepared-query.cxx +++ b/odb/sqlite/prepared-query.cxx @@ -3,6 +3,8 @@ #include +#include + namespace odb { namespace sqlite @@ -11,5 +13,15 @@ namespace odb ~prepared_query_impl () { } + + bool prepared_query_impl:: + verify_connection (odb::transaction& t) + { + // The transaction can be started using the main database of any of the + // attached databases. So we verify the main connections match. + // + return &static_cast (t.connection ()).main_connection () == + &static_cast (stmt->connection ()).main_connection (); + } } } diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx index 4938ff3..a8873a5 100644 --- a/odb/sqlite/prepared-query.hxx +++ b/odb/sqlite/prepared-query.hxx @@ -24,6 +24,9 @@ namespace odb prepared_query_impl (odb::connection& c): odb::prepared_query_impl (c) {} + virtual bool + verify_connection (odb::transaction&); + sqlite::query_base query; }; } diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 8f93a9f..b1b0f58 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -27,7 +27,7 @@ namespace odb { { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->deallocate (conn_, *this); @@ -55,27 +55,27 @@ namespace odb { active_ = false; - string tmp; + string tmp1; if (proc != 0) { switch (sk) { case statement_select: - process_select (tmp, + process_select (tmp1, text, &proc->bind->buffer, proc->count, sizeof (bind), '"', '"', optimize); break; case statement_insert: - process_insert (tmp, + process_insert (tmp1, text, &proc->bind->buffer, proc->count, sizeof (bind), '?', '$'); break; case statement_update: - process_update (tmp, + process_update (tmp1, text, &proc->bind->buffer, proc->count, sizeof (bind), '?', @@ -86,8 +86,20 @@ namespace odb assert (false); } - text = tmp.c_str (); - text_size = tmp.size (); + text = tmp1.c_str (); + text_size = tmp1.size (); + } + + string tmp2; + if (conn_.statement_translator_ != 0) + { + conn_.statement_translator_ (tmp2, text, text_size, conn_); + + if (!tmp2.empty ()) + { + text = tmp2.c_str (); + text_size = tmp2.size (); + } } #if SQLITE_VERSION_NUMBER < 3005003 @@ -101,7 +113,7 @@ namespace odb { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) { @@ -477,7 +489,7 @@ namespace odb { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->execute (conn_, *this); @@ -618,7 +630,7 @@ namespace odb { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->execute (conn_, *this); @@ -738,7 +750,7 @@ namespace odb { { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->execute (conn_, *this); @@ -845,7 +857,7 @@ namespace odb { { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->execute (conn_, *this); @@ -931,7 +943,7 @@ namespace odb { { odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || + if ((t = conn_.main_connection ().transaction_tracer ()) || (t = conn_.tracer ()) || (t = conn_.database ().tracer ())) t->execute (conn_, *this); diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 721b3fe..106270d 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -42,21 +42,23 @@ namespace odb odb::transaction_impl::connection_ = connection_.get (); } + connection_type& mc (connection_->main_connection ()); + switch (lock_) { case deferred: { - connection_->begin_statement ().execute (); + mc.begin_statement ().execute (); break; } case immediate: { - connection_->begin_immediate_statement ().execute (); + mc.begin_immediate_statement ().execute (); break; } case exclusive: { - connection_->begin_exclusive_statement ().execute (); + mc.begin_exclusive_statement ().execute (); break; } } @@ -92,6 +94,8 @@ namespace odb void transaction_impl:: commit () { + connection_type& mc (connection_->main_connection ()); + // Invalidate query results and reset active statements. // // Active statements will prevent COMMIT from completing (write @@ -99,11 +103,13 @@ namespace odb // statement is automatically reset on completion, however, if an // exception is thrown, that may not happen. // - connection_->clear (); + // Note: must be done via the main connection. + // + mc.clear (); { - commit_guard cg (*connection_); - connection_->commit_statement ().execute (); + commit_guard cg (mc); + mc.commit_statement ().execute (); cg.release (); } @@ -115,16 +121,52 @@ namespace odb void transaction_impl:: rollback () { + connection_type& mc (connection_->main_connection ()); + // Invalidate query results and reset active statements (the same // reasoning as in commit()). // - connection_->clear (); + // Note: must be done via the main connection. + // + mc.clear (); - connection_->rollback_statement ().execute (); + mc.rollback_statement ().execute (); // Release the connection. // connection_.reset (); } + + odb::connection& transaction_impl:: + connection (odb::database* pdb) + { + if (pdb == 0) + return *connection_; + + // Pick the corresponding connection for main/attached database. + // + database_type& db (static_cast (*pdb)); + + assert (&db.main_database () == + &static_cast (database_).main_database ()); + + return db.schema ().empty () + ? connection_->main_connection () + : *static_cast (*db.factory_).attached_connection_; + } + + // Store transaction tracer in the main database. + // + void transaction_impl:: + tracer (odb::tracer* t) + { + connection_->main_connection ().transaction_tracer_ = t; + } + + odb::tracer* transaction_impl:: + tracer () const + { + return connection_->main_connection ().transaction_tracer_; + } } } diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx index 040bcd7..d1a310b 100644 --- a/odb/sqlite/transaction-impl.hxx +++ b/odb/sqlite/transaction-impl.hxx @@ -45,6 +45,15 @@ namespace odb virtual void rollback (); + virtual odb::connection& + connection (odb::database*); + + virtual void + tracer (odb::tracer*); + + virtual odb::tracer* + tracer () const; + private: connection_ptr connection_; lock lock_; -- cgit v1.1 From c22cc575cfd2e89771093b15aa337d563f1eba5b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 May 2021 11:34:26 +0200 Subject: Cosmetic changes to the ATTACH DATABASE code --- odb/sqlite/connection-factory.cxx | 2 +- odb/sqlite/connection-factory.hxx | 6 +++--- odb/sqlite/connection.hxx | 8 ++++---- odb/sqlite/database.hxx | 30 +++++++++++++++++------------- odb/sqlite/stream.hxx | 4 ++++ odb/sqlite/transaction-impl.cxx | 2 +- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx index 0bbf617..794c6dd 100644 --- a/odb/sqlite/connection-factory.cxx +++ b/odb/sqlite/connection-factory.cxx @@ -317,7 +317,7 @@ namespace odb // While it may seem like a good idea to also invalidate query results // and reset active statements, if any such result/statement is still // alive, then there would be bigger problems since it would have a - // dangling reference to the connection. In a way, this's the same + // dangling reference to the connection. In a way, that's the same // reason we don't do it in the connection destructor. // Remove ourselves from the active object list of the main diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx index 0d01b85..b410997 100644 --- a/odb/sqlite/connection-factory.hxx +++ b/odb/sqlite/connection-factory.hxx @@ -250,14 +250,14 @@ namespace odb virtual connection_ptr connect (); + virtual void + detach (); + // Active object interface. // virtual void clear (); - virtual void - detach (); - virtual ~default_attached_connection_factory (); diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index f8df9d0..366239f 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -78,9 +78,9 @@ namespace odb typedef sqlite::statement_cache statement_cache_type; typedef sqlite::database database_type; - // Translate the database schema in statement text (used to implement - // attached databases). If the result is empty, then no translation is - // required and the original text should be used as is. + // Translate the database schema in the statement text (used to + // implement attached databases). If the result is empty, then no + // translation is required and the original text should be used as is. // typedef void (statement_translator) (std::string& result, const char* text, @@ -341,7 +341,7 @@ namespace odb return main_connection_->factory (); } - // Note that this essentially establishes a "protocol" for all the + // Note that this essentially establishes a "framework" for all the // attached connection factory implementations: they hold a counted // reference to the main connection and they maintain a single shared // attached connection. diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 478fbdb..614ed63 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -85,8 +85,8 @@ namespace odb // Attach to the specified connection a database with the specified name // as the specified schema. Good understanding of SQLite ATTACH/DETACH - // DATABASE semantics and ODB connection management is recommended when - // using this mechanism. + // DATABASE statements semantics and ODB connection management is + // strongly recommended when using this mechanism. // // The resulting database instance is referred to as an "attached // database" and the connection it returns as an "attached connection" @@ -97,6 +97,14 @@ namespace odb // pre-attached "main" and "temp" schemas (in this case name can be // anything). // + // The automatic translation of the statements relies on their text + // having references to top-level database entities (tables, indexes, + // etc) qualified with the "main" schema. To achieve this, compile your + // headers with `--schema main` and, if using schema migration, with + // `--schema-version-table main.schema_version`. You must also not use + // "main" as an object/table alias in views of native statements. For + // optimal translation performance use 4-character schema names. + // // The main connection and attached to it databases and connections are // all meant to be used withing the same thread. In particular, the // attached database holds a counted reference to the main connection @@ -107,25 +115,21 @@ namespace odb // main connection, not to the (main) database, which mimics the // underlying semantics of SQLite. An alternative model would have been // to notionally attach the databases to the main database and under the - // hood automatically attach them to each returned connecton. While this - // may seem like a more convenient model in some cases, it is also less - // flexible: the current model allows attaching a different set of + // hood automatically attach them to each returned connection. While + // this may seem like a more convenient model in some cases, it is also + // less flexible: the current model allows attaching a different set of // databases to different connections, attaching them on demand as the // transaction progresses, etc. Also, the more convenient model can be - // implemented on top this model by deriving an aplication-specific + // implemented on top this model by deriving an application-specific // database class and/or providing custom connection factories. // - // Note also that unless the name is a URI with appropriate mode, it is + // Note that unless the name is a URI with appropriate mode, it is // opened with the SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE flags. So if // you want just SQLITE_OPEN_READWRITE, then you will need to verify its // existence manually prior to calling this constructor. // - // The automatic translation of the statements relies on all the - // statements text having references to top-level database entities - // (tables, indexes, etc) qualified with the "main" schema. To achieve - // this, compile your headers with `--schema main` and, if using schema - // migration, with `--schema-version-table main.schema_version`. You - // must also not use "main" as a table alias. + // Note that attaching/detaching databases withing a transaction is only + // supported since SQLite 3.21.0. // database (const connection_ptr&, const std::string& name, diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx index c2d45c0..6ee76cb 100644 --- a/odb/sqlite/stream.hxx +++ b/odb/sqlite/stream.hxx @@ -23,6 +23,10 @@ namespace odb class LIBODB_SQLITE_EXPORT stream: public active_object { public: + // @@ TODO: db is actually what we now (and SQLite in other places) + // call schema (see database::schema(), ATTACH DATABASE). So we + // should probably rename this at some point for consistency. + // stream (const char* db, const char* table, const char* column, diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx index 106270d..6485f7e 100644 --- a/odb/sqlite/transaction-impl.cxx +++ b/odb/sqlite/transaction-impl.cxx @@ -155,7 +155,7 @@ namespace odb : *static_cast (*db.factory_).attached_connection_; } - // Store transaction tracer in the main database. + // Store transaction tracer in the main connection. // void transaction_impl:: tracer (odb::tracer* t) -- cgit v1.1 From 2ac3e83cdb046e2863c9aaff56e8e1a9328a6f57 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 May 2021 11:44:06 +0200 Subject: Remove stray use of nullptr --- odb/sqlite/connection.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index bb71274..0445163 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -261,7 +261,7 @@ namespace odb // The current first active_object may remove itself from the list and // make the second object (if any) the new first. // - for (active_object** pp (&active_objects_); *pp != nullptr; ) + for (active_object** pp (&active_objects_); *pp != 0; ) { active_object* p (*pp); p->clear (); -- cgit v1.1 From f1716624e7ed6ad06944103c8e0d40ed40e0bf92 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 24 May 2021 18:54:36 +0300 Subject: Fix MinGW GCC's 'redeclared without dllimport attribute' warning --- odb/sqlite/connection.hxx | 5 +---- odb/sqlite/connection.ixx | 8 ++++++++ odb/sqlite/database.hxx | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 366239f..dbe4494 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -336,10 +336,7 @@ namespace odb friend class transaction_impl; connection_factory& - main_factory () - { - return main_connection_->factory (); - } + main_factory (); // Note that this essentially establishes a "framework" for all the // attached connection factory implementations: they hold a counted diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx index c0e49b9..094fd52 100644 --- a/odb/sqlite/connection.ixx +++ b/odb/sqlite/connection.ixx @@ -96,5 +96,13 @@ namespace odb // return prepare_query (n, sqlite::query_base (q)); } + + // attached_connection_factory + // + inline connection_factory& attached_connection_factory:: + main_factory () + { + return main_connection_->factory (); + } } } diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 614ed63..e7579d6 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -106,7 +106,7 @@ namespace odb // optimal translation performance use 4-character schema names. // // The main connection and attached to it databases and connections are - // all meant to be used withing the same thread. In particular, the + // all meant to be used within the same thread. In particular, the // attached database holds a counted reference to the main connection // which means the connection will not be released until all the // attached to this connection databases are destroyed. @@ -120,7 +120,7 @@ namespace odb // less flexible: the current model allows attaching a different set of // databases to different connections, attaching them on demand as the // transaction progresses, etc. Also, the more convenient model can be - // implemented on top this model by deriving an application-specific + // implemented on top of this model by deriving an application-specific // database class and/or providing custom connection factories. // // Note that unless the name is a URI with appropriate mode, it is -- cgit v1.1 From dfeb43d6ee14be83281945e82ebb484eeb072fe8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Jun 2021 11:01:06 +0200 Subject: Work around bogus Clang warning --- odb/sqlite/statement-cache.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx index 923b428..31ca685 100644 --- a/odb/sqlite/statement-cache.hxx +++ b/odb/sqlite/statement-cache.hxx @@ -31,7 +31,7 @@ namespace odb public: statement_cache (connection& conn) : conn_ (conn), - version_seq_ (conn.database ().schema_version_sequence ()) {} + version_seq_ (conn_.database ().schema_version_sequence ()) {} template typename object_traits_impl::statements_type& -- cgit v1.1 From 2894165a408b43aaa8c495342b07414bf860ffd9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 16 Oct 2021 11:12:51 +0200 Subject: Release version 2.5.0-b.21 --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index fadd9a6..3d1217e 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.20.z +version: 2.5.0-b.21 project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.13.0 depends: * bpkg >= 0.13.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.20.1 2.5.0-b.21) +depends: libodb == 2.5.0-b.21 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b2ec3cd..cd06839 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20470 +#if ODB_VERSION != 20471 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049970 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.20" +#define LIBODB_SQLITE_VERSION 2049971 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.21" #include diff --git a/version b/version index a60117f..412a335 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.20 +2.5.0-b.21 -- cgit v1.1 From dd14657fc8c94ab8a224bf8cff9d75314ef54bb2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Oct 2021 09:01:10 +0200 Subject: Change version to 2.5.0-b.22.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3d1217e..2783dd2 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.21 +version: 2.5.0-b.22.z project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.13.0 -depends: * bpkg >= 0.13.0 +depends: * build2 >= 0.14.0 +depends: * bpkg >= 0.14.0 depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.21 +depends: libodb [2.5.0-b.22.1 2.5.0-b.23) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index cd06839..ee7f0af 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20471 +#if ODB_VERSION != 20472 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049971 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.21" +#define LIBODB_SQLITE_VERSION 2049972 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.22" #include diff --git a/version b/version index 412a335..6d2beda 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.21 +2.5.0-b.22 -- cgit v1.1 From 6eb4a1646da26848cc0e1a135b5bea859623e4ec Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Oct 2021 09:09:14 +0200 Subject: Lower build2 version requirement to 0.14.0- to ease upgrades --- manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest b/manifest index 2783dd2..4ea3db9 100644 --- a/manifest +++ b/manifest @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.14.0 -depends: * bpkg >= 0.14.0 +depends: * build2 >= 0.14.0- +depends: * bpkg >= 0.14.0- depends: libsqlite3 ^3.6.18 depends: libodb [2.5.0-b.22.1 2.5.0-b.23) -- cgit v1.1 From 94d7ddf7646400d87705866a84318d90f565b4a1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 26 Jul 2022 08:47:24 +0200 Subject: Release version 2.5.0-b.23 --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4ea3db9..066f104 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.22.z +version: 2.5.0-b.23 project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -15,7 +15,7 @@ email: odb-users@codesynthesis.com build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.14.0- -depends: * bpkg >= 0.14.0- +depends: * build2 >= 0.15.0- +depends: * bpkg >= 0.15.0- depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.22.1 2.5.0-b.23) +depends: libodb == 2.5.0-b.23 diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index ee7f0af..d8615d1 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20472 +#if ODB_VERSION != 20473 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049972 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.22" +#define LIBODB_SQLITE_VERSION 2049973 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.23" #include diff --git a/version b/version index 6d2beda..0a10d59 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.22 +2.5.0-b.23 -- cgit v1.1 From 7ec5657a4c8f27d3a63d46f5fbad567ca786a6fb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 29 Jul 2022 09:50:26 +0200 Subject: Change version to 2.5.0-b.24.z --- manifest | 4 ++-- odb/sqlite/version.hxx | 6 +++--- version | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 066f104..7fa3489 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.23 +version: 2.5.0-b.24.z project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -18,4 +18,4 @@ requires: c++11 depends: * build2 >= 0.15.0- depends: * bpkg >= 0.15.0- depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.23 +depends: libodb [2.5.0-b.24.1 2.5.0-b.25) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d8615d1..d613340 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20473 +#if ODB_VERSION != 20474 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049973 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.23" +#define LIBODB_SQLITE_VERSION 2049974 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.24" #include diff --git a/version b/version index 0a10d59..cd2d927 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.5.0-b.23 +2.5.0-b.24 -- cgit v1.1 From 51545ab70cb1af3dc72abc11a002c7a3b15bacc7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Sep 2022 20:01:40 +0300 Subject: Update copyright --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9678900..0cffa09 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2021 Code Synthesis Tools CC. +Copyright (c) 2009-2022 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as -- cgit v1.1 From 0700ddb5cbe6b1ea2f5abe765ce498445f359e30 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 9 Sep 2022 16:10:14 +0300 Subject: Rename version file to version.txt --- makefile | 4 ++-- odb/sqlite/makefile | 2 +- version | 1 - version.txt | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 version create mode 100644 version.txt diff --git a/makefile b/makefile index 3a42f20..f28752a 100644 --- a/makefile +++ b/makefile @@ -12,13 +12,13 @@ clean := $(out_base)/.clean $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) -$(dist): export docs := GPLv2 LICENSE README NEWS version +$(dist): export docs := GPLv2 LICENSE README NEWS version.txt $(dist): data_dist := INSTALL libodb-sqlite-vc8.sln libodb-sqlite-vc9.sln \ libodb-sqlite-vc10.sln libodb-sqlite-vc11.sln libodb-sqlite-vc12.sln \ $(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) -$(dist): export version = $(shell cat $(src_root)/version) +$(dist): export version = $(shell cat $(src_root)/version.txt) $(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs))) $(call dist-data,$(docs) $(data_dist) libodb-sqlite.pc.in) diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile index cead138..485b9ec 100644 --- a/odb/sqlite/makefile +++ b/odb/sqlite/makefile @@ -111,7 +111,7 @@ libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters \ libodb-sqlite-vc12.vcxproj libodb-sqlite-vc12.vcxproj.filters $(dist): export interface_version = $(shell sed -e \ -'s/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) +'s/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version.txt) $(dist): $(gen) $(call dist-data,$(sources_dist) $(headers_dist) $(data_dist)) diff --git a/version b/version deleted file mode 100644 index cd2d927..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -2.5.0-b.24 diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..cd2d927 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +2.5.0-b.24 -- cgit v1.1 From e022a925a6b3ccd98ec97e33c3dac8d0b25773ea Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Sep 2022 20:00:44 +0300 Subject: Use ad hoc recipe to compile options.cli file --- build/root.build | 10 +- manifest | 1 + odb/sqlite/buildfile | 102 ++- odb/sqlite/details/.gitignore | 2 +- .../pregenerated/odb/sqlite/details/options.cxx | 980 +++++++++++++++++++++ .../pregenerated/odb/sqlite/details/options.hxx | 530 +++++++++++ .../pregenerated/odb/sqlite/details/options.ixx | 324 +++++++ repositories.manifest | 4 + 8 files changed, 1915 insertions(+), 38 deletions(-) create mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx create mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx create mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx diff --git a/build/root.build b/build/root.build index ba74c09..a1975db 100644 --- a/build/root.build +++ b/build/root.build @@ -1,6 +1,8 @@ # file : build/root.build # license : GNU GPL v2; see accompanying LICENSE file +config [bool] config.libodb_sqlite.develop ?= false + cxx.std = latest using cxx @@ -15,11 +17,3 @@ if ($cxx.target.system == 'win32-msvc') if ($cxx.class == 'msvc') cxx.coptions += /wd4251 /wd4275 /wd4800 - -# Load the cli module but only if it's available. This way a distribution -# that includes pre-generated files can be built without installing cli. -# This is also the reason why we need to explicitly spell out individual -# source file prerequisites instead of using the cli.cxx{} group (it won't -# be there unless the module is configured). -# -using? cli diff --git a/manifest b/manifest index 7fa3489..8aed6a0 100644 --- a/manifest +++ b/manifest @@ -19,3 +19,4 @@ depends: * build2 >= 0.15.0- depends: * bpkg >= 0.15.0- depends: libsqlite3 ^3.6.18 depends: libodb [2.5.0-b.24.1 2.5.0-b.25) +depends: * cli ^1.2.0- ? ($config.libodb_sqlite.develop) diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile index 73455f8..d2da43f 100644 --- a/odb/sqlite/buildfile +++ b/odb/sqlite/buildfile @@ -1,12 +1,15 @@ # file : odb/sqlite/buildfile # license : GNU GPL v2; see accompanying LICENSE file +define cli: file +cli{*}: extension = cli + import int_libs = libodb%lib{odb} import int_libs += libsqlite3%lib{sqlite3} -lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ - details/{hxx ixx txx cxx}{* -options} details/{hxx ixx cxx}{options} \ - details/build2/{h}{*} \ +lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ + details/{hxx ixx txx cxx}{* -options} \ + details/build2/{h}{*} \ $int_libs # Include the generated version header into the distribution (so that we don't @@ -47,35 +50,76 @@ if $version.pre_release else lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" -# Generated options parser. +develop = $config.libodb_sqlite.develop + +## Consumption build ($develop == false). +# + +# Use pregenerated versions in the consumption build. +# +lib{odb-sqlite}: details/pregenerated/{hxx ixx cxx}{**}: include = (!$develop) + +if! $develop + cxx.poptions =+ "-I($src_base/details/pregenerated)" # Note: must come first. + +# Don't install pregenerated headers since they are only used internally in +# the database implementation (also below). +# +details/pregenerated/{hxx ixx}{*}: install = false + +# Distribute pregenerated versions only in the consumption build. +# +details/pregenerated/{hxx ixx cxx}{*}: dist = (!$develop) + # -details/ +## + +## Development build ($develop == true). +# + +lib{odb-sqlite}: details/{hxx ixx cxx}{options}: include = $develop + +if $develop + import! [metadata] cli = cli%exe{cli} + +# In the development build distribute regenerated {hxx ixx cxx}{options}, +# remapping their locations to the paths of the pregenerated versions (which +# are only distributed in the consumption build; see above). This way we make +# sure that the distributed files are always up-to-date. +# +
: details/cli{options} $cli { - if $cli.configured - { - cli.cxx{options}: cli{options} - - cli.options += --include-with-brackets --include-prefix odb/sqlite/details \ ---guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ ---cli-namespace odb::sqlite::details::cli --long-usage --no-combined-flags - - # Include generated cli files into the distribution and don't remove them - # when cleaning in src (so that clean results in a state identical to - # distributed). But don't install their headers since they are only used - # internally in the database implementation. - # - cli.cxx{*}: - { - dist = true - clean = ($src_root != $out_root) - install = false - } - } - else - # No install for the pre-generated case. - # - hxx{options}@./ ixx{options}@./: install = false + install = false + dist = ($develop ? details/pregenerated/odb/sqlite/details/ : false) + + # Symlink the generated code in src for convenience of development. + # + backlink = true } +% +if $develop +{{ + options = --include-with-brackets --include-prefix odb/sqlite/details \ + --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ + --cli-namespace odb::sqlite::details::cli --long-usage \ + --no-combined-flags + + $cli $options -o $out_base/details/ $path($<[0]) + + # If the result differs from the pregenerated version, copy it over. + # + d = [dir_path] $src_base/details/pregenerated/odb/sqlite/details/ + + if diff $d/options.hxx $path($>[0]) >- && \ + diff $d/options.ixx $path($>[1]) >- && \ + diff $d/options.cxx $path($>[2]) >- + exit + end + + cp $path($>[0]) $d/options.hxx + cp $path($>[1]) $d/options.ixx + cp $path($>[2]) $d/options.cxx +}} # Install into the odb/sqlite/ subdirectory of, say, /usr/include/ # recreating subdirectories. diff --git a/odb/sqlite/details/.gitignore b/odb/sqlite/details/.gitignore index c6e608b..b298f89 100644 --- a/odb/sqlite/details/.gitignore +++ b/odb/sqlite/details/.gitignore @@ -1 +1 @@ -options.?xx +/options.?xx diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx new file mode 100644 index 0000000..a3a2c3e --- /dev/null +++ b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx @@ -0,0 +1,980 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + // unknown_option + // + unknown_option:: + ~unknown_option () throw () + { + } + + void unknown_option:: + print (::std::ostream& os) const + { + os << "unknown option '" << option ().c_str () << "'"; + } + + const char* unknown_option:: + what () const throw () + { + return "unknown option"; + } + + // unknown_argument + // + unknown_argument:: + ~unknown_argument () throw () + { + } + + void unknown_argument:: + print (::std::ostream& os) const + { + os << "unknown argument '" << argument ().c_str () << "'"; + } + + const char* unknown_argument:: + what () const throw () + { + return "unknown argument"; + } + + // missing_value + // + missing_value:: + ~missing_value () throw () + { + } + + void missing_value:: + print (::std::ostream& os) const + { + os << "missing value for option '" << option ().c_str () << "'"; + } + + const char* missing_value:: + what () const throw () + { + return "missing option value"; + } + + // invalid_value + // + invalid_value:: + ~invalid_value () throw () + { + } + + void invalid_value:: + print (::std::ostream& os) const + { + os << "invalid value '" << value ().c_str () << "' for option '" + << option ().c_str () << "'"; + + if (!message ().empty ()) + os << ": " << message ().c_str (); + } + + const char* invalid_value:: + what () const throw () + { + return "invalid option value"; + } + + // eos_reached + // + void eos_reached:: + print (::std::ostream& os) const + { + os << what (); + } + + const char* eos_reached:: + what () const throw () + { + return "end of argument stream reached"; + } + + // file_io_failure + // + file_io_failure:: + ~file_io_failure () throw () + { + } + + void file_io_failure:: + print (::std::ostream& os) const + { + os << "unable to open file '" << file ().c_str () << "' or read failure"; + } + + const char* file_io_failure:: + what () const throw () + { + return "unable to open file or read failure"; + } + + // unmatched_quote + // + unmatched_quote:: + ~unmatched_quote () throw () + { + } + + void unmatched_quote:: + print (::std::ostream& os) const + { + os << "unmatched quote in argument '" << argument ().c_str () << "'"; + } + + const char* unmatched_quote:: + what () const throw () + { + return "unmatched quote"; + } + + // scanner + // + scanner:: + ~scanner () + { + } + + // argv_scanner + // + bool argv_scanner:: + more () + { + return i_ < argc_; + } + + const char* argv_scanner:: + peek () + { + if (i_ < argc_) + return argv_[i_]; + else + throw eos_reached (); + } + + const char* argv_scanner:: + next () + { + if (i_ < argc_) + { + const char* r (argv_[i_]); + + if (erase_) + { + for (int i (i_ + 1); i < argc_; ++i) + argv_[i - 1] = argv_[i]; + + --argc_; + argv_[argc_] = 0; + } + else + ++i_; + + ++start_position_; + return r; + } + else + throw eos_reached (); + } + + void argv_scanner:: + skip () + { + if (i_ < argc_) + { + ++i_; + ++start_position_; + } + else + throw eos_reached (); + } + + std::size_t argv_scanner:: + position () + { + return start_position_; + } + + // argv_file_scanner + // + int argv_file_scanner::zero_argc_ = 0; + std::string argv_file_scanner::empty_string_; + + bool argv_file_scanner:: + more () + { + if (!args_.empty ()) + return true; + + while (base::more ()) + { + // See if the next argument is the file option. + // + const char* a (base::peek ()); + const option_info* oi = 0; + const char* ov = 0; + + if (!skip_) + { + if ((oi = find (a)) != 0) + { + base::next (); + + if (!base::more ()) + throw missing_value (a); + + ov = base::next (); + } + else if (std::strncmp (a, "-", 1) == 0) + { + if ((ov = std::strchr (a, '=')) != 0) + { + std::string o (a, 0, ov - a); + if ((oi = find (o.c_str ())) != 0) + { + base::next (); + ++ov; + } + } + } + } + + if (oi != 0) + { + if (oi->search_func != 0) + { + std::string f (oi->search_func (ov, oi->arg)); + + if (!f.empty ()) + load (f); + } + else + load (ov); + + if (!args_.empty ()) + return true; + } + else + { + if (!skip_) + skip_ = (std::strcmp (a, "--") == 0); + + return true; + } + } + + return false; + } + + const char* argv_file_scanner:: + peek () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? base::peek () : args_.front ().value.c_str (); + } + + const std::string& argv_file_scanner:: + peek_file () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? empty_string_ : *args_.front ().file; + } + + std::size_t argv_file_scanner:: + peek_line () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? 0 : args_.front ().line; + } + + const char* argv_file_scanner:: + next () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::next (); + else + { + hold_[i_ == 0 ? ++i_ : --i_].swap (args_.front ().value); + args_.pop_front (); + ++start_position_; + return hold_[i_].c_str (); + } + } + + void argv_file_scanner:: + skip () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::skip (); + else + { + args_.pop_front (); + ++start_position_; + } + } + + const argv_file_scanner::option_info* argv_file_scanner:: + find (const char* a) const + { + for (std::size_t i (0); i < options_count_; ++i) + if (std::strcmp (a, options_[i].option) == 0) + return &options_[i]; + + return 0; + } + + std::size_t argv_file_scanner:: + position () + { + return start_position_; + } + + void argv_file_scanner:: + load (const std::string& file) + { + using namespace std; + + ifstream is (file.c_str ()); + + if (!is.is_open ()) + throw file_io_failure (file); + + files_.push_back (file); + + arg a; + a.file = &*files_.rbegin (); + + for (a.line = 1; !is.eof (); ++a.line) + { + string line; + getline (is, line); + + if (is.fail () && !is.eof ()) + throw file_io_failure (file); + + string::size_type n (line.size ()); + + // Trim the line from leading and trailing whitespaces. + // + if (n != 0) + { + const char* f (line.c_str ()); + const char* l (f + n); + + const char* of (f); + while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) + ++f; + + --l; + + const char* ol (l); + while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) + --l; + + if (f != of || l != ol) + line = f <= l ? string (f, l - f + 1) : string (); + } + + // Ignore empty lines, those that start with #. + // + if (line.empty () || line[0] == '#') + continue; + + string::size_type p (string::npos); + if (line.compare (0, 1, "-") == 0) + { + p = line.find (' '); + + string::size_type q (line.find ('=')); + if (q != string::npos && q < p) + p = q; + } + + string s1; + if (p != string::npos) + { + s1.assign (line, 0, p); + + // Skip leading whitespaces in the argument. + // + if (line[p] == '=') + ++p; + else + { + n = line.size (); + for (++p; p < n; ++p) + { + char c (line[p]); + if (c != ' ' && c != '\t' && c != '\r') + break; + } + } + } + else if (!skip_) + skip_ = (line == "--"); + + string s2 (line, p != string::npos ? p : 0); + + // If the string (which is an option value or argument) is + // wrapped in quotes, remove them. + // + n = s2.size (); + char cf (s2[0]), cl (s2[n - 1]); + + if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') + { + if (n == 1 || cf != cl) + throw unmatched_quote (s2); + + s2 = string (s2, 1, n - 2); + } + + if (!s1.empty ()) + { + // See if this is another file option. + // + const option_info* oi; + if (!skip_ && (oi = find (s1.c_str ()))) + { + if (s2.empty ()) + throw missing_value (oi->option); + + if (oi->search_func != 0) + { + string f (oi->search_func (s2.c_str (), oi->arg)); + if (!f.empty ()) + load (f); + } + else + { + // If the path of the file being parsed is not simple and the + // path of the file that needs to be loaded is relative, then + // complete the latter using the former as a base. + // +#ifndef _WIN32 + string::size_type p (file.find_last_of ('/')); + bool c (p != string::npos && s2[0] != '/'); +#else + string::size_type p (file.find_last_of ("/\\")); + bool c (p != string::npos && s2[1] != ':'); +#endif + if (c) + s2.insert (0, file, 0, p + 1); + + load (s2); + } + + continue; + } + + a.value = s1; + args_.push_back (a); + } + + a.value = s2; + args_.push_back (a); + } + } + + template + struct parser + { + static void + parse (X& x, scanner& s) + { + using namespace std; + + const char* o (s.next ()); + if (s.more ()) + { + string v (s.next ()); + istringstream is (v); + if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + const char* v (s.next ()); + + if (std::strcmp (v, "1") == 0 || + std::strcmp (v, "true") == 0 || + std::strcmp (v, "TRUE") == 0 || + std::strcmp (v, "True") == 0) + x = true; + else if (std::strcmp (v, "0") == 0 || + std::strcmp (v, "false") == 0 || + std::strcmp (v, "FALSE") == 0 || + std::strcmp (v, "False") == 0) + x = false; + else + throw invalid_value (o, v); + } + else + throw missing_value (o); + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + } + }; + + template + struct parser > + { + static void + parse (std::pair& x, scanner& s) + { + x.second = s.position (); + parser::parse (x.first, s); + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, scanner& s) + { + X x; + parser::parse (x, s); + c.push_back (x); + } + }; + + template + struct parser > + { + static void + parse (std::set& c, scanner& s) + { + X x; + parser::parse (x, s); + c.insert (x); + } + }; + + template + struct parser > + { + static void + parse (std::map& m, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::size_t pos (s.position ()); + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); + + int ac (2); + char* av[] = + { + const_cast (o), + 0 + }; + + if (!kstr.empty ()) + { + av[1] = const_cast (kstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (k, s); + } + + if (!vstr.empty ()) + { + av[1] = const_cast (vstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (v, s); + } + + m[k] = v; + } + else + throw missing_value (o); + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + s.next (); + x.*M = true; + } + } + } + } +} + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + // options + // + + options:: + options () + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + } + + options:: + options (int& argc, + char** argv, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int start, + int& argc, + char** argv, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int& argc, + char** argv, + int& end, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (int start, + int& argc, + char** argv, + int& end, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (::odb::sqlite::details::cli::scanner& s, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + _parse (s, opt, arg); + } + + ::odb::sqlite::details::cli::usage_para options:: + print_usage (::std::ostream& os, ::odb::sqlite::details::cli::usage_para p) + { + CLI_POTENTIALLY_UNUSED (os); + + if (p != ::odb::sqlite::details::cli::usage_para::none) + os << ::std::endl; + + os << "--database SQLite database file name. If the database file is not" << ::std::endl + << " specified then a private, temporary on-disk database will" << ::std::endl + << " be created. Use the :memory: special name to create a" << ::std::endl + << " private, temporary in-memory database." << ::std::endl; + + os << std::endl + << "--create Create the SQLite database if it does not already exist." << ::std::endl + << " By default opening the database fails if it does not" << ::std::endl + << " already exist." << ::std::endl; + + os << std::endl + << "--read-only Open the SQLite database in read-only mode. By default" << ::std::endl + << " the database is opened for reading and writing if" << ::std::endl + << " possible, or reading only if the file is write-protected" << ::std::endl + << " by the operating system." << ::std::endl; + + os << std::endl + << "--options-file Read additional options from . Each option should" << ::std::endl + << " appear on a separate line optionally followed by space or" << ::std::endl + << " equal sign (=) and an option value. Empty lines and lines" << ::std::endl + << " starting with # are ignored." << ::std::endl; + + p = ::odb::sqlite::details::cli::usage_para::option; + + return p; + } + + typedef + std::map + _cli_options_map; + + static _cli_options_map _cli_options_map_; + + struct _cli_options_map_init + { + _cli_options_map_init () + { + _cli_options_map_["--database"] = + &::odb::sqlite::details::cli::thunk< options, std::string, &options::database_ >; + _cli_options_map_["--create"] = + &::odb::sqlite::details::cli::thunk< options, &options::create_ >; + _cli_options_map_["--read-only"] = + &::odb::sqlite::details::cli::thunk< options, &options::read_only_ >; + _cli_options_map_["--options-file"] = + &::odb::sqlite::details::cli::thunk< options, std::string, &options::options_file_ >; + } + }; + + static _cli_options_map_init _cli_options_map_init_; + + bool options:: + _parse (const char* o, ::odb::sqlite::details::cli::scanner& s) + { + _cli_options_map::const_iterator i (_cli_options_map_.find (o)); + + if (i != _cli_options_map_.end ()) + { + (*(i->second)) (*this, s); + return true; + } + + return false; + } + + bool options:: + _parse (::odb::sqlite::details::cli::scanner& s, + ::odb::sqlite::details::cli::unknown_mode opt_mode, + ::odb::sqlite::details::cli::unknown_mode arg_mode) + { + bool r = false; + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + opt = false; + s.skip (); + r = true; + continue; + } + + if (opt) + { + if (_parse (o, s)) + { + r = true; + continue; + } + + if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + // Handle combined option values. + // + std::string co; + if (const char* v = std::strchr (o, '=')) + { + co.assign (o, 0, v - o); + ++v; + + int ac (2); + char* av[] = + { + const_cast (co.c_str ()), + const_cast (v) + }; + + ::odb::sqlite::details::cli::argv_scanner ns (0, ac, av); + + if (_parse (co.c_str (), ns)) + { + // Parsed the option but not its value? + // + if (ns.end () != 2) + throw ::odb::sqlite::details::cli::invalid_value (co, v); + + s.next (); + r = true; + continue; + } + else + { + // Set the unknown option and fall through. + // + o = co.c_str (); + } + } + + switch (opt_mode) + { + case ::odb::sqlite::details::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::odb::sqlite::details::cli::unknown_mode::stop: + { + break; + } + case ::odb::sqlite::details::cli::unknown_mode::fail: + { + throw ::odb::sqlite::details::cli::unknown_option (o); + } + } + + break; + } + } + + switch (arg_mode) + { + case ::odb::sqlite::details::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::odb::sqlite::details::cli::unknown_mode::stop: + { + break; + } + case ::odb::sqlite::details::cli::unknown_mode::fail: + { + throw ::odb::sqlite::details::cli::unknown_argument (o); + } + } + + break; + } + + return r; + } + } + } +} + +// Begin epilogue. +// +// +// End epilogue. + diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx new file mode 100644 index 0000000..abc4b3f --- /dev/null +++ b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx @@ -0,0 +1,530 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef LIBODB_SQLITE_DETAILS_OPTIONS_HXX +#define LIBODB_SQLITE_DETAILS_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include +#include +#include +#include +#include +#include + +#ifndef CLI_POTENTIALLY_UNUSED +# if defined(_MSC_VER) || defined(__xlC__) +# define CLI_POTENTIALLY_UNUSED(x) (void*)&x +# else +# define CLI_POTENTIALLY_UNUSED(x) (void)x +# endif +#endif + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + class usage_para + { + public: + enum value + { + none, + text, + option + }; + + usage_para (value); + + operator value () const + { + return v_; + } + + private: + value v_; + }; + + class unknown_mode + { + public: + enum value + { + skip, + stop, + fail + }; + + unknown_mode (value); + + operator value () const + { + return v_; + } + + private: + value v_; + }; + + // Exceptions. + // + + class exception: public std::exception + { + public: + virtual void + print (::std::ostream&) const = 0; + }; + + ::std::ostream& + operator<< (::std::ostream&, const exception&); + + class unknown_option: public exception + { + public: + virtual + ~unknown_option () throw (); + + unknown_option (const std::string& option); + + const std::string& + option () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class unknown_argument: public exception + { + public: + virtual + ~unknown_argument () throw (); + + unknown_argument (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + class missing_value: public exception + { + public: + virtual + ~missing_value () throw (); + + missing_value (const std::string& option); + + const std::string& + option () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class invalid_value: public exception + { + public: + virtual + ~invalid_value () throw (); + + invalid_value (const std::string& option, + const std::string& value, + const std::string& message = std::string ()); + + const std::string& + option () const; + + const std::string& + value () const; + + const std::string& + message () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + std::string value_; + std::string message_; + }; + + class eos_reached: public exception + { + public: + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + }; + + class file_io_failure: public exception + { + public: + virtual + ~file_io_failure () throw (); + + file_io_failure (const std::string& file); + + const std::string& + file () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string file_; + }; + + class unmatched_quote: public exception + { + public: + virtual + ~unmatched_quote () throw (); + + unmatched_quote (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + // Command line argument scanner interface. + // + // The values returned by next() are guaranteed to be valid + // for the two previous arguments up until a call to a third + // peek() or next(). + // + // The position() function returns a monotonically-increasing + // number which, if stored, can later be used to determine the + // relative position of the argument returned by the following + // call to next(). Note that if multiple scanners are used to + // extract arguments from multiple sources, then the end + // position of the previous scanner should be used as the + // start position of the next. + // + class scanner + { + public: + virtual + ~scanner (); + + virtual bool + more () = 0; + + virtual const char* + peek () = 0; + + virtual const char* + next () = 0; + + virtual void + skip () = 0; + + virtual std::size_t + position () = 0; + }; + + class argv_scanner: public scanner + { + public: + argv_scanner (int& argc, + char** argv, + bool erase = false, + std::size_t start_position = 0); + + argv_scanner (int start, + int& argc, + char** argv, + bool erase = false, + std::size_t start_position = 0); + + int + end () const; + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + virtual std::size_t + position (); + + protected: + std::size_t start_position_; + int i_; + int& argc_; + char** argv_; + bool erase_; + }; + + class argv_file_scanner: public argv_scanner + { + public: + argv_file_scanner (int& argc, + char** argv, + const std::string& option, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& option, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (const std::string& file, + const std::string& option, + std::size_t start_position = 0); + + struct option_info + { + // If search_func is not NULL, it is called, with the arg + // value as the second argument, to locate the options file. + // If it returns an empty string, then the file is ignored. + // + const char* option; + std::string (*search_func) (const char*, void* arg); + void* arg; + }; + + argv_file_scanner (int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (int start, + int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (const std::string& file, + const option_info* options = 0, + std::size_t options_count = 0, + std::size_t start_position = 0); + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + virtual std::size_t + position (); + + // Return the file path if the peeked at argument came from a file and + // the empty string otherwise. The reference is guaranteed to be valid + // till the end of the scanner lifetime. + // + const std::string& + peek_file (); + + // Return the 1-based line number if the peeked at argument came from + // a file and zero otherwise. + // + std::size_t + peek_line (); + + private: + const option_info* + find (const char*) const; + + void + load (const std::string& file); + + typedef argv_scanner base; + + const std::string option_; + option_info option_info_; + const option_info* options_; + std::size_t options_count_; + + struct arg + { + std::string value; + const std::string* file; + std::size_t line; + }; + + std::deque args_; + std::list files_; + + // Circular buffer of two arguments. + // + std::string hold_[2]; + std::size_t i_; + + bool skip_; + + static int zero_argc_; + static std::string empty_string_; + }; + + template + struct parser; + } + } + } +} + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + class options + { + public: + options (); + + options (int& argc, + char** argv, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int& argc, + char** argv, + int& end, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (::odb::sqlite::details::cli::scanner&, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + // Option accessors. + // + const std::string& + database () const; + + const bool& + create () const; + + const bool& + read_only () const; + + const std::string& + options_file () const; + + // Print usage information. + // + static ::odb::sqlite::details::cli::usage_para + print_usage (::std::ostream&, + ::odb::sqlite::details::cli::usage_para = ::odb::sqlite::details::cli::usage_para::none); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::odb::sqlite::details::cli::scanner&); + + private: + bool + _parse (::odb::sqlite::details::cli::scanner&, + ::odb::sqlite::details::cli::unknown_mode option, + ::odb::sqlite::details::cli::unknown_mode argument); + + public: + std::string database_; + bool create_; + bool read_only_; + std::string options_file_; + }; + } + } +} + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // LIBODB_SQLITE_DETAILS_OPTIONS_HXX diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx new file mode 100644 index 0000000..54092aa --- /dev/null +++ b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx @@ -0,0 +1,324 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + // usage_para + // + inline usage_para:: + usage_para (value v) + : v_ (v) + { + } + + // unknown_mode + // + inline unknown_mode:: + unknown_mode (value v) + : v_ (v) + { + } + + // exception + // + inline ::std::ostream& + operator<< (::std::ostream& os, const exception& e) + { + e.print (os); + return os; + } + + // unknown_option + // + inline unknown_option:: + unknown_option (const std::string& option) + : option_ (option) + { + } + + inline const std::string& unknown_option:: + option () const + { + return option_; + } + + // unknown_argument + // + inline unknown_argument:: + unknown_argument (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unknown_argument:: + argument () const + { + return argument_; + } + + // missing_value + // + inline missing_value:: + missing_value (const std::string& option) + : option_ (option) + { + } + + inline const std::string& missing_value:: + option () const + { + return option_; + } + + // invalid_value + // + inline invalid_value:: + invalid_value (const std::string& option, + const std::string& value, + const std::string& message) + : option_ (option), + value_ (value), + message_ (message) + { + } + + inline const std::string& invalid_value:: + option () const + { + return option_; + } + + inline const std::string& invalid_value:: + value () const + { + return value_; + } + + inline const std::string& invalid_value:: + message () const + { + return message_; + } + + // file_io_failure + // + inline file_io_failure:: + file_io_failure (const std::string& file) + : file_ (file) + { + } + + inline const std::string& file_io_failure:: + file () const + { + return file_; + } + + // unmatched_quote + // + inline unmatched_quote:: + unmatched_quote (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unmatched_quote:: + argument () const + { + return argument_; + } + + // argv_scanner + // + inline argv_scanner:: + argv_scanner (int& argc, + char** argv, + bool erase, + std::size_t sp) + : start_position_ (sp + 1), + i_ (1), + argc_ (argc), + argv_ (argv), + erase_ (erase) + { + } + + inline argv_scanner:: + argv_scanner (int start, + int& argc, + char** argv, + bool erase, + std::size_t sp) + : start_position_ (sp + static_cast (start)), + i_ (start), + argc_ (argc), + argv_ (argv), + erase_ (erase) + { + } + + inline int argv_scanner:: + end () const + { + return i_; + } + + // argv_file_scanner + // + inline argv_file_scanner:: + argv_file_scanner (int& argc, + char** argv, + const std::string& option, + bool erase, + std::size_t sp) + : argv_scanner (argc, argv, erase, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + } + + inline argv_file_scanner:: + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& option, + bool erase, + std::size_t sp) + : argv_scanner (start, argc, argv, erase, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + } + + inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const std::string& option, + std::size_t sp) + : argv_scanner (0, zero_argc_, 0, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + + load (file); + } + + inline argv_file_scanner:: + argv_file_scanner (int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase, + std::size_t sp) + : argv_scanner (argc, argv, erase, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + } + + inline argv_file_scanner:: + argv_file_scanner (int start, + int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase, + std::size_t sp) + : argv_scanner (start, argc, argv, erase, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + } + + inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const option_info* options, + std::size_t options_count, + std::size_t sp) + : argv_scanner (0, zero_argc_, 0, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + load (file); + } + } + } + } +} + +namespace odb +{ + namespace sqlite + { + namespace details + { + // options + // + + inline const std::string& options:: + database () const + { + return this->database_; + } + + inline const bool& options:: + create () const + { + return this->create_; + } + + inline const bool& options:: + read_only () const + { + return this->read_only_; + } + + inline const std::string& options:: + options_file () const + { + return this->options_file_; + } + } + } +} + +// Begin epilogue. +// +// +// End epilogue. diff --git a/repositories.manifest b/repositories.manifest index b45f391..fe2f8c0 100644 --- a/repositories.manifest +++ b/repositories.manifest @@ -8,3 +8,7 @@ location: https://git.build2.org/packaging/sqlite/sqlite.git##HEAD : role: prerequisite location: ../libodb.git##HEAD + +: +role: prerequisite +location: https://git.codesynthesis.com/cli/cli.git##HEAD -- cgit v1.1 From e09f0f48b15106ac4048a28eb699e3d4cf43020c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Dec 2022 20:47:16 +0300 Subject: Add noexcept to move constructors and move assignment operators --- odb/sqlite/database.hxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index e7579d6..e1e62cc 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -152,6 +152,9 @@ namespace odb // Move-constructible but not move-assignable. // + // Note: noexcept is not specified since odb::database(odb::database&&) + // can throw. + // #ifdef ODB_CXX11 database (database&&); #endif -- cgit v1.1 From cf49a3da69d4b46bd93e4454451787de1e43bad4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 20 Mar 2023 16:51:13 +0300 Subject: Regenerate options parsing files --- .../pregenerated/odb/sqlite/details/options.cxx | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx index a3a2c3e..12f4193 100644 --- a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx +++ b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx @@ -669,6 +669,53 @@ namespace odb } }; + template + struct parser > + { + static void + parse (std::multimap& m, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::size_t pos (s.position ()); + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); + + int ac (2); + char* av[] = + { + const_cast (o), + 0 + }; + + if (!kstr.empty ()) + { + av[1] = const_cast (kstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (k, s); + } + + if (!vstr.empty ()) + { + av[1] = const_cast (vstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (v, s); + } + + m.insert (typename std::multimap::value_type (k, v)); + } + else + throw missing_value (o); + } + }; + template void thunk (X& x, scanner& s) -- cgit v1.1 From 1daf7857fce77e7c48e204b3e102ade302c92c97 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 20 Mar 2023 16:51:27 +0300 Subject: Update copyright --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 0cffa09..fad395c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2022 Code Synthesis Tools CC. +Copyright (c) 2009-2023 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as -- cgit v1.1 From ea439a6e0cc920ce78c5bfc1e3b1b35d2e5a3cbb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 30 Jun 2023 13:05:40 +0200 Subject: Release version 2.5.0-b.25 --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version.txt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8aed6a0..7dce846 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.24.z +version: 2.5.0-b.25 project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -15,8 +15,8 @@ email: odb-users@codesynthesis.com build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.15.0- -depends: * bpkg >= 0.15.0- +depends: * build2 >= 0.15.0 +depends: * bpkg >= 0.15.0 depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.24.1 2.5.0-b.25) +depends: libodb == 2.5.0-b.25 depends: * cli ^1.2.0- ? ($config.libodb_sqlite.develop) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index d613340..b12c1ff 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20474 +#if ODB_VERSION != 20475 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049974 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.24" +#define LIBODB_SQLITE_VERSION 2049975 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.25" #include diff --git a/version.txt b/version.txt index cd2d927..2636902 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.5.0-b.24 +2.5.0-b.25 -- cgit v1.1 From b8fd47d8421dd90a010a2f12d9282f68560840bb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 Jul 2023 10:10:47 +0200 Subject: Change version to 2.5.0-b.26.z --- manifest | 8 ++++---- odb/sqlite/version.hxx | 6 +++--- version.txt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7dce846..fef85a0 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ : 1 name: libodb-sqlite -version: 2.5.0-b.25 +version: 2.5.0-b.26.z project: odb summary: SQLite ODB runtime library license: GPL-2.0-only @@ -15,8 +15,8 @@ email: odb-users@codesynthesis.com build-warning-email: odb-builds@codesynthesis.com builds: all requires: c++11 -depends: * build2 >= 0.15.0 -depends: * bpkg >= 0.15.0 +depends: * build2 >= 0.16.0- +depends: * bpkg >= 0.16.0- depends: libsqlite3 ^3.6.18 -depends: libodb == 2.5.0-b.25 +depends: libodb [2.5.0-b.26.1 2.5.0-b.27) depends: * cli ^1.2.0- ? ($config.libodb_sqlite.develop) diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx index b12c1ff..ad468de 100644 --- a/odb/sqlite/version.hxx +++ b/odb/sqlite/version.hxx @@ -31,15 +31,15 @@ // Check that we have compatible ODB version. // -#if ODB_VERSION != 20475 +#if ODB_VERSION != 20476 # error incompatible odb interface version detected #endif // libodb-sqlite version: odb interface version plus the bugfix // version. // -#define LIBODB_SQLITE_VERSION 2049975 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.25" +#define LIBODB_SQLITE_VERSION 2049976 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.26" #include diff --git a/version.txt b/version.txt index 2636902..6bc2f39 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.5.0-b.25 +2.5.0-b.26 -- cgit v1.1 From e330d6ead75dc3f86018b936552eef5abd80d9ac Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 15 Jan 2024 19:48:32 +0300 Subject: Update copyright --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index fad395c..9d92da1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2023 Code Synthesis Tools CC. +Copyright (c) 2009-2024 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as -- cgit v1.1 From c53136bd7d266fccaca679d0471dd8ac0ce91373 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 15 Jan 2024 19:47:27 +0300 Subject: Fix odb/sqlite/details/config.hxx for build2 build --- odb/sqlite/details/config.hxx | 12 ++++++++++++ odb/sqlite/details/export.hxx | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx index bbf32f6..4f1c5ce 100644 --- a/odb/sqlite/details/config.hxx +++ b/odb/sqlite/details/config.hxx @@ -16,6 +16,18 @@ # endif #endif +// LIBODB_SQLITE_BUILD2 macro can be defined either by the buildfile or by the +// included odb/sqlite/details/config*.h (see above). +// +#ifdef LIBODB_SQLITE_BUILD2 +# include + +# if SQLITE_VERSION_NUMBER >= 3006012 +# define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1 +# endif +# define LIBODB_SQLITE_HAVE_COLUMN_METADATA 1 +#endif + // no post #endif // ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx index 515b891..c0903ae 100644 --- a/odb/sqlite/details/export.hxx +++ b/odb/sqlite/details/export.hxx @@ -6,7 +6,15 @@ #include -#include +#ifdef ODB_COMPILER +# error libodb-sqlite header included in odb-compiled header +#elif !defined(LIBODB_SQLITE_BUILD2) +# ifdef _MSC_VER +# include +# else +# include +# endif +#endif // Normally we don't export class templates (but do complete specializations), // inline functions, and classes with only inline member functions. Exporting -- cgit v1.1 From e5d0186db99492a139237067bab841a5b83463af Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 24 Jan 2024 19:01:19 +0300 Subject: Turn libodb-sqlite repository into package for muti-package repository --- .gitignore | 37 - GPLv2 | 340 ---- INSTALL | 120 -- INSTALL-GIT | 78 - LICENSE | 20 - Makefile.am | 10 - NEWS | 1 - README | 20 - README-GIT | 5 - bootstrap | 16 - build/.gitignore | 3 - build/bootstrap.build | 10 - build/bootstrap.make | 70 - build/export.build | 9 - build/export/libodb-sqlite/stub.make | 8 - build/import/cli/cli-cxx.make | 47 - build/import/cli/configuration-rules.make | 13 - build/import/cli/configure | 53 - build/import/cli/stub.make | 28 - .../import/libodb-sqlite/configuration-rules.make | 13 - build/import/libodb-sqlite/configure | 53 - build/import/libodb-sqlite/stub.make | 28 - build/import/libodb/configuration-rules.make | 13 - build/import/libodb/configure | 53 - build/import/libodb/stub.make | 28 - build/import/libsqlite/configuration-rules.make | 13 - build/import/libsqlite/configure | 53 - build/import/libsqlite/rules.make | 27 - build/import/libsqlite/stub.make | 30 - build/import/libsqlite/version | 1 - build/root.build | 19 - buildfile | 11 - configure.ac | 66 - etc/sqlite/README | 30 - etc/sqlite/sqlite3-vc10.sln | 26 - etc/sqlite/sqlite3-vc10.vcxproj | 170 -- etc/sqlite/sqlite3-vc10.vcxproj.filters | 23 - etc/sqlite/sqlite3-vc11.sln | 26 - etc/sqlite/sqlite3-vc11.vcxproj | 174 -- etc/sqlite/sqlite3-vc11.vcxproj.filters | 23 - etc/sqlite/sqlite3-vc12.sln | 28 - etc/sqlite/sqlite3-vc12.vcxproj | 170 -- etc/sqlite/sqlite3-vc12.vcxproj.filters | 23 - etc/sqlite/sqlite3-vc8.sln | 26 - etc/sqlite/sqlite3-vc8.vcproj | 360 ---- etc/sqlite/sqlite3-vc9.sln | 26 - etc/sqlite/sqlite3-vc9.vcproj | 367 ----- libodb-sqlite-vc10.sln | 26 - libodb-sqlite-vc11.sln | 26 - libodb-sqlite-vc12.sln | 28 - libodb-sqlite-vc8.sln | 26 - libodb-sqlite-vc9.sln | 26 - libodb-sqlite.pc.in | 14 - libodb-sqlite/.gitignore | 25 + libodb-sqlite/GPLv2 | 340 ++++ libodb-sqlite/INSTALL | 6 + libodb-sqlite/LICENSE | 20 + libodb-sqlite/README | 20 + libodb-sqlite/build/.gitignore | 3 + libodb-sqlite/build/bootstrap.build | 10 + libodb-sqlite/build/export.build | 9 + libodb-sqlite/build/root.build | 19 + libodb-sqlite/buildfile | 9 + libodb-sqlite/manifest | 22 + libodb-sqlite/odb/sqlite/auto-handle.hxx | 101 ++ libodb-sqlite/odb/sqlite/binding.hxx | 44 + libodb-sqlite/odb/sqlite/blob-stream.hxx | 31 + libodb-sqlite/odb/sqlite/blob.hxx | 68 + libodb-sqlite/odb/sqlite/buildfile | 155 ++ libodb-sqlite/odb/sqlite/connection-factory.cxx | 417 +++++ libodb-sqlite/odb/sqlite/connection-factory.hxx | 273 ++++ libodb-sqlite/odb/sqlite/connection.cxx | 310 ++++ libodb-sqlite/odb/sqlite/connection.hxx | 356 ++++ libodb-sqlite/odb/sqlite/connection.ixx | 108 ++ libodb-sqlite/odb/sqlite/container-statements.hxx | 355 ++++ libodb-sqlite/odb/sqlite/container-statements.txx | 107 ++ libodb-sqlite/odb/sqlite/database.cxx | 306 ++++ libodb-sqlite/odb/sqlite/database.hxx | 567 +++++++ libodb-sqlite/odb/sqlite/database.ixx | 622 +++++++ libodb-sqlite/odb/sqlite/details/.gitignore | 1 + .../odb/sqlite/details/build2/config-stub.h | 5 + .../odb/sqlite/details/build2/config-vc-stub.h | 5 + .../odb/sqlite/details/build2/config-vc.h | 15 + libodb-sqlite/odb/sqlite/details/build2/config.h | 17 + libodb-sqlite/odb/sqlite/details/config-vc.h | 5 + libodb-sqlite/odb/sqlite/details/config.h.in | 14 + libodb-sqlite/odb/sqlite/details/config.hxx | 33 + libodb-sqlite/odb/sqlite/details/conversion.hxx | 58 + libodb-sqlite/odb/sqlite/details/export.hxx | 86 + libodb-sqlite/odb/sqlite/details/options.cli | 47 + .../pregenerated/odb/sqlite/details/options.cxx | 1027 ++++++++++++ .../pregenerated/odb/sqlite/details/options.hxx | 530 ++++++ .../pregenerated/odb/sqlite/details/options.ixx | 324 ++++ libodb-sqlite/odb/sqlite/error.cxx | 94 ++ libodb-sqlite/odb/sqlite/error.hxx | 27 + libodb-sqlite/odb/sqlite/exceptions.cxx | 92 ++ libodb-sqlite/odb/sqlite/exceptions.hxx | 101 ++ libodb-sqlite/odb/sqlite/forward.hxx | 112 ++ libodb-sqlite/odb/sqlite/no-id-object-result.hxx | 80 + libodb-sqlite/odb/sqlite/no-id-object-result.txx | 114 ++ .../odb/sqlite/no-id-object-statements.hxx | 136 ++ .../odb/sqlite/no-id-object-statements.txx | 36 + .../odb/sqlite/polymorphic-object-result.hxx | 98 ++ .../odb/sqlite/polymorphic-object-result.txx | 287 ++++ .../odb/sqlite/polymorphic-object-statements.hxx | 479 ++++++ .../odb/sqlite/polymorphic-object-statements.txx | 145 ++ libodb-sqlite/odb/sqlite/prepared-query.cxx | 27 + libodb-sqlite/odb/sqlite/prepared-query.hxx | 37 + libodb-sqlite/odb/sqlite/query-const-expr.cxx | 14 + libodb-sqlite/odb/sqlite/query-dynamic.cxx | 157 ++ libodb-sqlite/odb/sqlite/query-dynamic.hxx | 32 + libodb-sqlite/odb/sqlite/query-dynamic.ixx | 26 + libodb-sqlite/odb/sqlite/query-dynamic.txx | 20 + libodb-sqlite/odb/sqlite/query.cxx | 378 +++++ libodb-sqlite/odb/sqlite/query.hxx | 1728 ++++++++++++++++++++ libodb-sqlite/odb/sqlite/query.ixx | 46 + libodb-sqlite/odb/sqlite/query.txx | 168 ++ libodb-sqlite/odb/sqlite/section-statements.hxx | 198 +++ libodb-sqlite/odb/sqlite/section-statements.txx | 40 + libodb-sqlite/odb/sqlite/simple-object-result.hxx | 88 + libodb-sqlite/odb/sqlite/simple-object-result.txx | 158 ++ .../odb/sqlite/simple-object-statements.cxx | 15 + .../odb/sqlite/simple-object-statements.hxx | 591 +++++++ .../odb/sqlite/simple-object-statements.ixx | 68 + .../odb/sqlite/simple-object-statements.txx | 146 ++ libodb-sqlite/odb/sqlite/sqlite-types.hxx | 57 + libodb-sqlite/odb/sqlite/statement-cache.hxx | 60 + libodb-sqlite/odb/sqlite/statement-cache.txx | 60 + libodb-sqlite/odb/sqlite/statement.cxx | 988 +++++++++++ libodb-sqlite/odb/sqlite/statement.hxx | 392 +++++ libodb-sqlite/odb/sqlite/statements-base.cxx | 15 + libodb-sqlite/odb/sqlite/statements-base.hxx | 63 + libodb-sqlite/odb/sqlite/stream.cxx | 120 ++ libodb-sqlite/odb/sqlite/stream.hxx | 85 + libodb-sqlite/odb/sqlite/text-stream.hxx | 31 + libodb-sqlite/odb/sqlite/text.hxx | 69 + libodb-sqlite/odb/sqlite/tracer.cxx | 60 + libodb-sqlite/odb/sqlite/tracer.hxx | 61 + libodb-sqlite/odb/sqlite/traits-calls.hxx | 214 +++ libodb-sqlite/odb/sqlite/traits.cxx | 219 +++ libodb-sqlite/odb/sqlite/traits.hxx | 1099 +++++++++++++ libodb-sqlite/odb/sqlite/transaction-impl.cxx | 172 ++ libodb-sqlite/odb/sqlite/transaction-impl.hxx | 66 + libodb-sqlite/odb/sqlite/transaction.cxx | 26 + libodb-sqlite/odb/sqlite/transaction.hxx | 87 + libodb-sqlite/odb/sqlite/transaction.ixx | 57 + libodb-sqlite/odb/sqlite/version-build2-stub.hxx | 4 + libodb-sqlite/odb/sqlite/version-build2.hxx | 0 libodb-sqlite/odb/sqlite/version-build2.hxx.in | 42 + libodb-sqlite/odb/sqlite/version.hxx | 47 + libodb-sqlite/odb/sqlite/view-result.hxx | 80 + libodb-sqlite/odb/sqlite/view-result.txx | 114 ++ libodb-sqlite/odb/sqlite/view-statements.hxx | 88 + libodb-sqlite/odb/sqlite/view-statements.txx | 33 + libodb-sqlite/tests/.gitignore | 1 + libodb-sqlite/tests/basics/buildfile | 6 + libodb-sqlite/tests/basics/driver.cxx | 52 + libodb-sqlite/tests/build/.gitignore | 3 + libodb-sqlite/tests/build/bootstrap.build | 8 + libodb-sqlite/tests/build/root.build | 23 + libodb-sqlite/tests/buildfile | 4 + m4/acx-pthread.m4 | 259 --- m4/disable-rpath.m4 | 24 - m4/libodb.m4 | 81 - m4/libsqlite.m4 | 92 -- m4/libtool-link.m4 | 45 - m4/pkgconfig.m4 | 11 - m4/static-lib.m4 | 17 - m4/threads.m4 | 68 - makefile | 36 - manifest | 22 - odb/sqlite/Makefile.am | 14 - odb/sqlite/auto-handle.hxx | 101 -- odb/sqlite/binding.hxx | 44 - odb/sqlite/blob-stream.hxx | 31 - odb/sqlite/blob.hxx | 68 - odb/sqlite/buildfile | 155 -- odb/sqlite/connection-factory.cxx | 417 ----- odb/sqlite/connection-factory.hxx | 273 ---- odb/sqlite/connection.cxx | 310 ---- odb/sqlite/connection.hxx | 356 ---- odb/sqlite/connection.ixx | 108 -- odb/sqlite/container-statements.hxx | 355 ---- odb/sqlite/container-statements.txx | 107 -- odb/sqlite/database.cxx | 306 ---- odb/sqlite/database.hxx | 567 ------- odb/sqlite/database.ixx | 622 ------- odb/sqlite/details/.gitignore | 1 - odb/sqlite/details/build2/config-stub.h | 5 - odb/sqlite/details/build2/config-vc-stub.h | 5 - odb/sqlite/details/build2/config-vc.h | 15 - odb/sqlite/details/build2/config.h | 17 - odb/sqlite/details/config-vc.h | 5 - odb/sqlite/details/config.h.in | 14 - odb/sqlite/details/config.hxx | 33 - odb/sqlite/details/conversion.hxx | 58 - odb/sqlite/details/export.hxx | 86 - odb/sqlite/details/options.cli | 47 - .../pregenerated/odb/sqlite/details/options.cxx | 1027 ------------ .../pregenerated/odb/sqlite/details/options.hxx | 530 ------ .../pregenerated/odb/sqlite/details/options.ixx | 324 ---- odb/sqlite/error.cxx | 94 -- odb/sqlite/error.hxx | 27 - odb/sqlite/exceptions.cxx | 92 -- odb/sqlite/exceptions.hxx | 101 -- odb/sqlite/forward.hxx | 112 -- odb/sqlite/libodb-sqlite-vc10.vcxproj | 174 -- odb/sqlite/libodb-sqlite-vc10.vcxproj.filters | 19 - odb/sqlite/libodb-sqlite-vc11.vcxproj | 178 -- odb/sqlite/libodb-sqlite-vc11.vcxproj.filters | 19 - odb/sqlite/libodb-sqlite-vc12.vcxproj | 182 --- odb/sqlite/libodb-sqlite-vc12.vcxproj.filters | 19 - odb/sqlite/libodb-sqlite-vc8.vcproj | 352 ---- odb/sqlite/libodb-sqlite-vc9.vcproj | 359 ---- odb/sqlite/makefile | 159 -- odb/sqlite/no-id-object-result.hxx | 80 - odb/sqlite/no-id-object-result.txx | 114 -- odb/sqlite/no-id-object-statements.hxx | 136 -- odb/sqlite/no-id-object-statements.txx | 36 - odb/sqlite/polymorphic-object-result.hxx | 98 -- odb/sqlite/polymorphic-object-result.txx | 287 ---- odb/sqlite/polymorphic-object-statements.hxx | 479 ------ odb/sqlite/polymorphic-object-statements.txx | 145 -- odb/sqlite/prepared-query.cxx | 27 - odb/sqlite/prepared-query.hxx | 37 - odb/sqlite/query-const-expr.cxx | 14 - odb/sqlite/query-dynamic.cxx | 157 -- odb/sqlite/query-dynamic.hxx | 32 - odb/sqlite/query-dynamic.ixx | 26 - odb/sqlite/query-dynamic.txx | 20 - odb/sqlite/query.cxx | 378 ----- odb/sqlite/query.hxx | 1728 -------------------- odb/sqlite/query.ixx | 46 - odb/sqlite/query.txx | 168 -- odb/sqlite/section-statements.hxx | 198 --- odb/sqlite/section-statements.txx | 40 - odb/sqlite/simple-object-result.hxx | 88 - odb/sqlite/simple-object-result.txx | 158 -- odb/sqlite/simple-object-statements.cxx | 15 - odb/sqlite/simple-object-statements.hxx | 591 ------- odb/sqlite/simple-object-statements.ixx | 68 - odb/sqlite/simple-object-statements.txx | 146 -- odb/sqlite/sqlite-types.hxx | 57 - odb/sqlite/statement-cache.hxx | 60 - odb/sqlite/statement-cache.txx | 60 - odb/sqlite/statement.cxx | 988 ----------- odb/sqlite/statement.hxx | 392 ----- odb/sqlite/statements-base.cxx | 15 - odb/sqlite/statements-base.hxx | 63 - odb/sqlite/stream.cxx | 120 -- odb/sqlite/stream.hxx | 85 - odb/sqlite/text-stream.hxx | 31 - odb/sqlite/text.hxx | 69 - odb/sqlite/tracer.cxx | 60 - odb/sqlite/tracer.hxx | 61 - odb/sqlite/traits-calls.hxx | 214 --- odb/sqlite/traits.cxx | 219 --- odb/sqlite/traits.hxx | 1099 ------------- odb/sqlite/transaction-impl.cxx | 172 -- odb/sqlite/transaction-impl.hxx | 66 - odb/sqlite/transaction.cxx | 26 - odb/sqlite/transaction.hxx | 87 - odb/sqlite/transaction.ixx | 57 - odb/sqlite/version-build2-stub.hxx | 4 - odb/sqlite/version-build2.hxx | 0 odb/sqlite/version-build2.hxx.in | 42 - odb/sqlite/version.hxx | 47 - odb/sqlite/view-result.hxx | 80 - odb/sqlite/view-result.txx | 114 -- odb/sqlite/view-statements.hxx | 88 - odb/sqlite/view-statements.txx | 33 - repositories.manifest | 14 - tests/.gitignore | 1 - tests/basics/buildfile | 6 - tests/basics/driver.cxx | 52 - tests/build/.gitignore | 3 - tests/build/bootstrap.build | 8 - tests/build/root.build | 23 - tests/buildfile | 4 - version.txt | 1 - 280 files changed, 16714 insertions(+), 21290 deletions(-) delete mode 100644 .gitignore delete mode 100644 GPLv2 delete mode 100644 INSTALL delete mode 100644 INSTALL-GIT delete mode 100644 LICENSE delete mode 100644 Makefile.am delete mode 100644 NEWS delete mode 100644 README delete mode 100644 README-GIT delete mode 100755 bootstrap delete mode 100644 build/.gitignore delete mode 100644 build/bootstrap.build delete mode 100644 build/bootstrap.make delete mode 100644 build/export.build delete mode 100644 build/export/libodb-sqlite/stub.make delete mode 100644 build/import/cli/cli-cxx.make delete mode 100644 build/import/cli/configuration-rules.make delete mode 100755 build/import/cli/configure delete mode 100644 build/import/cli/stub.make delete mode 100644 build/import/libodb-sqlite/configuration-rules.make delete mode 100755 build/import/libodb-sqlite/configure delete mode 100644 build/import/libodb-sqlite/stub.make delete mode 100644 build/import/libodb/configuration-rules.make delete mode 100755 build/import/libodb/configure delete mode 100644 build/import/libodb/stub.make delete mode 100644 build/import/libsqlite/configuration-rules.make delete mode 100755 build/import/libsqlite/configure delete mode 100644 build/import/libsqlite/rules.make delete mode 100644 build/import/libsqlite/stub.make delete mode 100644 build/import/libsqlite/version delete mode 100644 build/root.build delete mode 100644 buildfile delete mode 100644 configure.ac delete mode 100644 etc/sqlite/README delete mode 100644 etc/sqlite/sqlite3-vc10.sln delete mode 100644 etc/sqlite/sqlite3-vc10.vcxproj delete mode 100644 etc/sqlite/sqlite3-vc10.vcxproj.filters delete mode 100644 etc/sqlite/sqlite3-vc11.sln delete mode 100644 etc/sqlite/sqlite3-vc11.vcxproj delete mode 100644 etc/sqlite/sqlite3-vc11.vcxproj.filters delete mode 100644 etc/sqlite/sqlite3-vc12.sln delete mode 100644 etc/sqlite/sqlite3-vc12.vcxproj delete mode 100644 etc/sqlite/sqlite3-vc12.vcxproj.filters delete mode 100644 etc/sqlite/sqlite3-vc8.sln delete mode 100644 etc/sqlite/sqlite3-vc8.vcproj delete mode 100644 etc/sqlite/sqlite3-vc9.sln delete mode 100644 etc/sqlite/sqlite3-vc9.vcproj delete mode 100644 libodb-sqlite-vc10.sln delete mode 100644 libodb-sqlite-vc11.sln delete mode 100644 libodb-sqlite-vc12.sln delete mode 100644 libodb-sqlite-vc8.sln delete mode 100644 libodb-sqlite-vc9.sln delete mode 100644 libodb-sqlite.pc.in create mode 100644 libodb-sqlite/.gitignore create mode 100644 libodb-sqlite/GPLv2 create mode 100644 libodb-sqlite/INSTALL create mode 100644 libodb-sqlite/LICENSE create mode 100644 libodb-sqlite/README create mode 100644 libodb-sqlite/build/.gitignore create mode 100644 libodb-sqlite/build/bootstrap.build create mode 100644 libodb-sqlite/build/export.build create mode 100644 libodb-sqlite/build/root.build create mode 100644 libodb-sqlite/buildfile create mode 100644 libodb-sqlite/manifest create mode 100644 libodb-sqlite/odb/sqlite/auto-handle.hxx create mode 100644 libodb-sqlite/odb/sqlite/binding.hxx create mode 100644 libodb-sqlite/odb/sqlite/blob-stream.hxx create mode 100644 libodb-sqlite/odb/sqlite/blob.hxx create mode 100644 libodb-sqlite/odb/sqlite/buildfile create mode 100644 libodb-sqlite/odb/sqlite/connection-factory.cxx create mode 100644 libodb-sqlite/odb/sqlite/connection-factory.hxx create mode 100644 libodb-sqlite/odb/sqlite/connection.cxx create mode 100644 libodb-sqlite/odb/sqlite/connection.hxx create mode 100644 libodb-sqlite/odb/sqlite/connection.ixx create mode 100644 libodb-sqlite/odb/sqlite/container-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/container-statements.txx create mode 100644 libodb-sqlite/odb/sqlite/database.cxx create mode 100644 libodb-sqlite/odb/sqlite/database.hxx create mode 100644 libodb-sqlite/odb/sqlite/database.ixx create mode 100644 libodb-sqlite/odb/sqlite/details/.gitignore create mode 100644 libodb-sqlite/odb/sqlite/details/build2/config-stub.h create mode 100644 libodb-sqlite/odb/sqlite/details/build2/config-vc-stub.h create mode 100644 libodb-sqlite/odb/sqlite/details/build2/config-vc.h create mode 100644 libodb-sqlite/odb/sqlite/details/build2/config.h create mode 100644 libodb-sqlite/odb/sqlite/details/config-vc.h create mode 100644 libodb-sqlite/odb/sqlite/details/config.h.in create mode 100644 libodb-sqlite/odb/sqlite/details/config.hxx create mode 100644 libodb-sqlite/odb/sqlite/details/conversion.hxx create mode 100644 libodb-sqlite/odb/sqlite/details/export.hxx create mode 100644 libodb-sqlite/odb/sqlite/details/options.cli create mode 100644 libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx create mode 100644 libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx create mode 100644 libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx create mode 100644 libodb-sqlite/odb/sqlite/error.cxx create mode 100644 libodb-sqlite/odb/sqlite/error.hxx create mode 100644 libodb-sqlite/odb/sqlite/exceptions.cxx create mode 100644 libodb-sqlite/odb/sqlite/exceptions.hxx create mode 100644 libodb-sqlite/odb/sqlite/forward.hxx create mode 100644 libodb-sqlite/odb/sqlite/no-id-object-result.hxx create mode 100644 libodb-sqlite/odb/sqlite/no-id-object-result.txx create mode 100644 libodb-sqlite/odb/sqlite/no-id-object-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/no-id-object-statements.txx create mode 100644 libodb-sqlite/odb/sqlite/polymorphic-object-result.hxx create mode 100644 libodb-sqlite/odb/sqlite/polymorphic-object-result.txx create mode 100644 libodb-sqlite/odb/sqlite/polymorphic-object-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/polymorphic-object-statements.txx create mode 100644 libodb-sqlite/odb/sqlite/prepared-query.cxx create mode 100644 libodb-sqlite/odb/sqlite/prepared-query.hxx create mode 100644 libodb-sqlite/odb/sqlite/query-const-expr.cxx create mode 100644 libodb-sqlite/odb/sqlite/query-dynamic.cxx create mode 100644 libodb-sqlite/odb/sqlite/query-dynamic.hxx create mode 100644 libodb-sqlite/odb/sqlite/query-dynamic.ixx create mode 100644 libodb-sqlite/odb/sqlite/query-dynamic.txx create mode 100644 libodb-sqlite/odb/sqlite/query.cxx create mode 100644 libodb-sqlite/odb/sqlite/query.hxx create mode 100644 libodb-sqlite/odb/sqlite/query.ixx create mode 100644 libodb-sqlite/odb/sqlite/query.txx create mode 100644 libodb-sqlite/odb/sqlite/section-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/section-statements.txx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-result.hxx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-result.txx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-statements.cxx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-statements.ixx create mode 100644 libodb-sqlite/odb/sqlite/simple-object-statements.txx create mode 100644 libodb-sqlite/odb/sqlite/sqlite-types.hxx create mode 100644 libodb-sqlite/odb/sqlite/statement-cache.hxx create mode 100644 libodb-sqlite/odb/sqlite/statement-cache.txx create mode 100644 libodb-sqlite/odb/sqlite/statement.cxx create mode 100644 libodb-sqlite/odb/sqlite/statement.hxx create mode 100644 libodb-sqlite/odb/sqlite/statements-base.cxx create mode 100644 libodb-sqlite/odb/sqlite/statements-base.hxx create mode 100644 libodb-sqlite/odb/sqlite/stream.cxx create mode 100644 libodb-sqlite/odb/sqlite/stream.hxx create mode 100644 libodb-sqlite/odb/sqlite/text-stream.hxx create mode 100644 libodb-sqlite/odb/sqlite/text.hxx create mode 100644 libodb-sqlite/odb/sqlite/tracer.cxx create mode 100644 libodb-sqlite/odb/sqlite/tracer.hxx create mode 100644 libodb-sqlite/odb/sqlite/traits-calls.hxx create mode 100644 libodb-sqlite/odb/sqlite/traits.cxx create mode 100644 libodb-sqlite/odb/sqlite/traits.hxx create mode 100644 libodb-sqlite/odb/sqlite/transaction-impl.cxx create mode 100644 libodb-sqlite/odb/sqlite/transaction-impl.hxx create mode 100644 libodb-sqlite/odb/sqlite/transaction.cxx create mode 100644 libodb-sqlite/odb/sqlite/transaction.hxx create mode 100644 libodb-sqlite/odb/sqlite/transaction.ixx create mode 100644 libodb-sqlite/odb/sqlite/version-build2-stub.hxx create mode 100644 libodb-sqlite/odb/sqlite/version-build2.hxx create mode 100644 libodb-sqlite/odb/sqlite/version-build2.hxx.in create mode 100644 libodb-sqlite/odb/sqlite/version.hxx create mode 100644 libodb-sqlite/odb/sqlite/view-result.hxx create mode 100644 libodb-sqlite/odb/sqlite/view-result.txx create mode 100644 libodb-sqlite/odb/sqlite/view-statements.hxx create mode 100644 libodb-sqlite/odb/sqlite/view-statements.txx create mode 100644 libodb-sqlite/tests/.gitignore create mode 100644 libodb-sqlite/tests/basics/buildfile create mode 100644 libodb-sqlite/tests/basics/driver.cxx create mode 100644 libodb-sqlite/tests/build/.gitignore create mode 100644 libodb-sqlite/tests/build/bootstrap.build create mode 100644 libodb-sqlite/tests/build/root.build create mode 100644 libodb-sqlite/tests/buildfile delete mode 100644 m4/acx-pthread.m4 delete mode 100644 m4/disable-rpath.m4 delete mode 100644 m4/libodb.m4 delete mode 100644 m4/libsqlite.m4 delete mode 100644 m4/libtool-link.m4 delete mode 100644 m4/pkgconfig.m4 delete mode 100644 m4/static-lib.m4 delete mode 100644 m4/threads.m4 delete mode 100644 makefile delete mode 100644 manifest delete mode 100644 odb/sqlite/Makefile.am delete mode 100644 odb/sqlite/auto-handle.hxx delete mode 100644 odb/sqlite/binding.hxx delete mode 100644 odb/sqlite/blob-stream.hxx delete mode 100644 odb/sqlite/blob.hxx delete mode 100644 odb/sqlite/buildfile delete mode 100644 odb/sqlite/connection-factory.cxx delete mode 100644 odb/sqlite/connection-factory.hxx delete mode 100644 odb/sqlite/connection.cxx delete mode 100644 odb/sqlite/connection.hxx delete mode 100644 odb/sqlite/connection.ixx delete mode 100644 odb/sqlite/container-statements.hxx delete mode 100644 odb/sqlite/container-statements.txx delete mode 100644 odb/sqlite/database.cxx delete mode 100644 odb/sqlite/database.hxx delete mode 100644 odb/sqlite/database.ixx delete mode 100644 odb/sqlite/details/.gitignore delete mode 100644 odb/sqlite/details/build2/config-stub.h delete mode 100644 odb/sqlite/details/build2/config-vc-stub.h delete mode 100644 odb/sqlite/details/build2/config-vc.h delete mode 100644 odb/sqlite/details/build2/config.h delete mode 100644 odb/sqlite/details/config-vc.h delete mode 100644 odb/sqlite/details/config.h.in delete mode 100644 odb/sqlite/details/config.hxx delete mode 100644 odb/sqlite/details/conversion.hxx delete mode 100644 odb/sqlite/details/export.hxx delete mode 100644 odb/sqlite/details/options.cli delete mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx delete mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx delete mode 100644 odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx delete mode 100644 odb/sqlite/error.cxx delete mode 100644 odb/sqlite/error.hxx delete mode 100644 odb/sqlite/exceptions.cxx delete mode 100644 odb/sqlite/exceptions.hxx delete mode 100644 odb/sqlite/forward.hxx delete mode 100644 odb/sqlite/libodb-sqlite-vc10.vcxproj delete mode 100644 odb/sqlite/libodb-sqlite-vc10.vcxproj.filters delete mode 100644 odb/sqlite/libodb-sqlite-vc11.vcxproj delete mode 100644 odb/sqlite/libodb-sqlite-vc11.vcxproj.filters delete mode 100644 odb/sqlite/libodb-sqlite-vc12.vcxproj delete mode 100644 odb/sqlite/libodb-sqlite-vc12.vcxproj.filters delete mode 100644 odb/sqlite/libodb-sqlite-vc8.vcproj delete mode 100644 odb/sqlite/libodb-sqlite-vc9.vcproj delete mode 100644 odb/sqlite/makefile delete mode 100644 odb/sqlite/no-id-object-result.hxx delete mode 100644 odb/sqlite/no-id-object-result.txx delete mode 100644 odb/sqlite/no-id-object-statements.hxx delete mode 100644 odb/sqlite/no-id-object-statements.txx delete mode 100644 odb/sqlite/polymorphic-object-result.hxx delete mode 100644 odb/sqlite/polymorphic-object-result.txx delete mode 100644 odb/sqlite/polymorphic-object-statements.hxx delete mode 100644 odb/sqlite/polymorphic-object-statements.txx delete mode 100644 odb/sqlite/prepared-query.cxx delete mode 100644 odb/sqlite/prepared-query.hxx delete mode 100644 odb/sqlite/query-const-expr.cxx delete mode 100644 odb/sqlite/query-dynamic.cxx delete mode 100644 odb/sqlite/query-dynamic.hxx delete mode 100644 odb/sqlite/query-dynamic.ixx delete mode 100644 odb/sqlite/query-dynamic.txx delete mode 100644 odb/sqlite/query.cxx delete mode 100644 odb/sqlite/query.hxx delete mode 100644 odb/sqlite/query.ixx delete mode 100644 odb/sqlite/query.txx delete mode 100644 odb/sqlite/section-statements.hxx delete mode 100644 odb/sqlite/section-statements.txx delete mode 100644 odb/sqlite/simple-object-result.hxx delete mode 100644 odb/sqlite/simple-object-result.txx delete mode 100644 odb/sqlite/simple-object-statements.cxx delete mode 100644 odb/sqlite/simple-object-statements.hxx delete mode 100644 odb/sqlite/simple-object-statements.ixx delete mode 100644 odb/sqlite/simple-object-statements.txx delete mode 100644 odb/sqlite/sqlite-types.hxx delete mode 100644 odb/sqlite/statement-cache.hxx delete mode 100644 odb/sqlite/statement-cache.txx delete mode 100644 odb/sqlite/statement.cxx delete mode 100644 odb/sqlite/statement.hxx delete mode 100644 odb/sqlite/statements-base.cxx delete mode 100644 odb/sqlite/statements-base.hxx delete mode 100644 odb/sqlite/stream.cxx delete mode 100644 odb/sqlite/stream.hxx delete mode 100644 odb/sqlite/text-stream.hxx delete mode 100644 odb/sqlite/text.hxx delete mode 100644 odb/sqlite/tracer.cxx delete mode 100644 odb/sqlite/tracer.hxx delete mode 100644 odb/sqlite/traits-calls.hxx delete mode 100644 odb/sqlite/traits.cxx delete mode 100644 odb/sqlite/traits.hxx delete mode 100644 odb/sqlite/transaction-impl.cxx delete mode 100644 odb/sqlite/transaction-impl.hxx delete mode 100644 odb/sqlite/transaction.cxx delete mode 100644 odb/sqlite/transaction.hxx delete mode 100644 odb/sqlite/transaction.ixx delete mode 100644 odb/sqlite/version-build2-stub.hxx delete mode 100644 odb/sqlite/version-build2.hxx delete mode 100644 odb/sqlite/version-build2.hxx.in delete mode 100644 odb/sqlite/version.hxx delete mode 100644 odb/sqlite/view-result.hxx delete mode 100644 odb/sqlite/view-result.txx delete mode 100644 odb/sqlite/view-statements.hxx delete mode 100644 odb/sqlite/view-statements.txx delete mode 100644 repositories.manifest delete mode 100644 tests/.gitignore delete mode 100644 tests/basics/buildfile delete mode 100644 tests/basics/driver.cxx delete mode 100644 tests/build/.gitignore delete mode 100644 tests/build/bootstrap.build delete mode 100644 tests/build/root.build delete mode 100644 tests/buildfile delete mode 100644 version.txt diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3004ad1..0000000 --- a/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -.bdep/ - -# Compiler/linker output. -# -*.d -*.t -*.i -*.ii -*.o -*.obj -*.so -*.dll -*.a -*.lib -*.exp -*.pdb -*.ilk -*.exe -*.exe.dlls/ -*.exe.manifest -*.pc - -*.l -*.l.cpp-options - -# Generated documentation. -# -*.pdf -*.ps - -# Generated build system files. -# -*-dynamic.make - -# Generated .gitignore files. -# -.gitignore diff --git a/GPLv2 b/GPLv2 deleted file mode 100644 index 3912109..0000000 --- a/GPLv2 +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 63fae36..0000000 --- a/INSTALL +++ /dev/null @@ -1,120 +0,0 @@ -Prerequisites -============= - - - libodb http://www.codesynthesis.com/products/odb/ - - libsqlite3 http://www.sqlite.org - -If you plan to access an SQLite database from multiple threads, then you will -need SQLite version 3.5.0 or later built with the unlock notify feature -(SQLITE_ENABLE_UNLOCK_NOTIFY) enabled. - -If you plant to use SQLite incremental BLOB/TEXT I/O support, then you will -need SQLite version 3.4.0 or later built with the column metadata functions -(SQLITE_ENABLE_COLUMN_METADATA) enabled. - - -Building on UNIX -================ - -The following build instructions are for the Linux/UNIX/Mac OS X -operating systems as well as for Cygwin and MinGW on Windows. - -The standard autotools-based build system is used on these platforms. -After unpacking the source code archive, change to the libodb-sqlite -package directory (referred to as libodb-sqlite/ from now on) and run -the configure script: - -./configure - -To see the available configuration options run configure with --help: - -./configure --help - -The configure script expects the libodb and libsqlite3 headers and -libraries to be installed in a directory where the C++ compiler -and linker will search for them by default (normally /usr and -/usr/local). If these libraries are installed in other directories, -you can use the CPPFLAGS and LDFLAGS configure variables to specify -their locations, for example: - -./configure CPPFLAGS=-I/opt/libodb/include LDFLAGS=-L/opt/libodb/lib - -If libodb is not installed and you would like to use its build -directory instead, you can use the --with-libodb configure option -to specify its location, for example: - -./configure --with-libodb=/tmp/libodb - -As another example, the following configure command only builds shared -libraries, uses the specified C++ compiler, and compiles with optimization -and without debug information: - -./configure --disable-static CXX=g++-4.5 CXXFLAGS=-O3 - -Once configuration is complete, run make to build libodb-sqlite: - -make - -Once the build is completed successfully, you can install the libodb-sqlite -headers and libraries using the install target (you may need to do this -step as root depending on the installation directory): - -make install - - -Building on Windows -=================== - -The following build instructions are for Windows using Microsoft Visual -Studio. If you would like to build libodb-sqlite with GCC either using -Cygwin or MinGW, refer to the "Building on UNIX" section above. - -The standard Visual Studio project and solution files are used on this -platform. The provided project files expect the libodb and sqlite -header and import library directories to be in the VC++ Directories -Include and Library search lists. For libodb, see the INSTALL file in -the package directory for more information on how to setup the VC++ -Directories. - -The SQLite binary distribution for Windows contains only a 32-bit DLL -and it is built without unlock notify support. The provided libodb- -sqlite project files assume the unlock notify feature is available (you -can change this by manually removing the LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY -macro from the project's "Preprocessor Definitions" settings). The SQLite -source distribution for Windows lacks Visual Studio project/solution files. - -To rectify this situation, the libodb-sqlite distribution includes, in the -etc\sqlite\ directory, Visual Studio 8, 9, 10, and 11 project/solution files -for building 32 and 64-bit SQLite libraries with unlock notify support. -Refer to the accompanying README file for information on how to build the -libraries and configure VC++ Directories to automatically locate them. - -To build libodb-sqlite, unpack the source code archive and open the -libodb-sqlite-vc.sln file located in the libodb-sqlite package -directory (referred to as libodb-sqlite\ from now on). Here is the -version of Visual Studio that you are using. Once the solution is open, -select the desired build configuration (Debug or Release) and platform -(Win32 or x64) and build the solution. - -The resulting 32-bit DLLs and import libraries are placed into the -libodb-sqlite\bin\ and libodb-sqlite\lib\ directories, respectively. -Similarly, the 64-bit DLLs and import libraries are placed into -libodb-sqlite\bin64\ and libodb-sqlite\lib64\. The Release versions of -the import libraries are named odb-sqlite.lib and the Debug versions -are named odb-sqlite-d.lib. - -To configure Visual Studio to automatically locate the libodb-sqlite -headers, DLLs, and import libraries, add the following paths to your -VC++ Directories: - -Win32: - - Include: ...\libodb-sqlite - Library: ...\libodb-sqlite\lib - Executable: ...\libodb-sqlite\bin - -x64: - - Include: ...\libodb-sqlite - Library: ...\libodb-sqlite\lib64 - Executable: ...\libodb-sqlite\bin64 diff --git a/INSTALL-GIT b/INSTALL-GIT deleted file mode 100644 index f917af5..0000000 --- a/INSTALL-GIT +++ /dev/null @@ -1,78 +0,0 @@ -The following instructions describe how to work with the source code that was -checked out from the git repository. - -The major difference between using a released source code package and source -code from the repository is that the former does not contain autotools-based -makefiles or Visual Studio project files. Instead, it contains templates for -these files as well as its own, custom build system. This build system is -used for development as well as to automatically generate the autotools and -Visual Studio files. - -This file describes how to use this build system to build the package as well -as to create a release-ready source distribution which contains the autotools -build system and Visual Studio project files. - - -Prerequisites -============= - -Besides the prerequisites listed in the INSTALL file, you will need the -following additional packages: - - - GNU bash >= 2.0.0 http://www.gnu.org/software/bash/ - - GNU make >= 3.81 http://www.gnu.org/software/make/ - - build >= latest http://www.codesynthesis.com/projects/build/ - -If you are planning to create the source code distributions, then you will -also need the following packages: - - - GNU m4 >= 1.4.0 http://www.gnu.org/software/m4/ - - GNU sed >= 4.0.0 http://www.gnu.org/software/sed/ - - tofrodos >= 1.7.0 http://www.thefreecountry.com/tofrodos/ - -As we as the GNU autotools: - - - GNU libtool >= 2.2.6b http://www.gnu.org/software/libtool/ - - GNU autoconf >= 2.67 http://www.gnu.org/software/autoconf/ - - GNU automake >= 1.11.1 http://www.gnu.org/software/automake/ - -Any reasonably up to date GNU/Linux installation would normally have all of -the above packages already present, except for build and maybe tofrodos. - - -Configuring and Building -======================== - -To build the source code simply run make in the root directory of the package. -The first time you run make, the build process will also configure the -package by asking you several questions. On the subsequent runs, make will -only rebuild what has changed. - -To run the automated test suite (if any), run 'make test'. To clean the object -files, executables, etc., run 'make clean'. To de-configure the package (that -is, to remove configuration files in addition to objects, executables, etc.), -run 'make disfigure'. - - -Creating Distribution -===================== - -To create the source code distribution, use the dist make target as well as -the dist_prefix variable to specify the directory where the distribution files -should be placed. For example: - -make dist dist_prefix=/tmp/package-1.1.0 - -Once the distribution files are ready, change to the distribution directory -and run the bootstrap script to bootstrap the autotools build system, for -example: - -cd /tmp/package-1.1.0 -./bootsrap - -To create the source code archives, use the autotools build system. First -configuring the package (see the INSTALL file for more information on this -step) and then use the dist target to make the archives, for example: - -./configure -make dist diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9d92da1..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009-2024 Code Synthesis Tools CC. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -For more information on ODB licensing as well as for answers to -some of the common licensing questions, visit the ODB License -page: - -http://www.codesynthesis.com/products/odb/license.xhtml - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 963f3c8..0000000 --- a/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# file : Makefile.am -# license : GNU GPL v2; see accompanying LICENSE file - -SUBDIRS = __path__(dirs) -dist_doc_DATA = __file__(docs) -EXTRA_DIST = __file__(extra_dist) -ACLOCAL_AMFLAGS = -I m4 - -pkgconfigdir = @pkgconfigdir@ -pkgconfig_DATA= libodb-sqlite.pc diff --git a/NEWS b/NEWS deleted file mode 100644 index 72d0f8b..0000000 --- a/NEWS +++ /dev/null @@ -1 +0,0 @@ -See the common NEWS file in the ODB compiler package. diff --git a/README b/README deleted file mode 100644 index ffd4049..0000000 --- a/README +++ /dev/null @@ -1,20 +0,0 @@ -ODB is an object-relational mapping (ORM) system for C++. It provides -tools, APIs, and library support that allow you to persist C++ objects -to a relational database (RDBMS) without having to deal with tables, -columns, or SQL and without manually writing any of the mapping code. -For more information see: - -http://www.codesynthesis.com/products/odb/ - -This package contains the SQLite ODB runtime library. Every application -that includes code generated for the SQLite database will need to link -to this library. - -See the NEWS file for the user-visible changes from the previous release. - -See the LICENSE file for distribution conditions. - -See the INSTALL file for prerequisites and installation instructions. - -Send questions, bug reports, or any other feedback to the -odb-users@codesynthesis.com mailing list. diff --git a/README-GIT b/README-GIT deleted file mode 100644 index be3ee92..0000000 --- a/README-GIT +++ /dev/null @@ -1,5 +0,0 @@ -The checked out odb/sqlite/version-build2.hxx will be overwritten during the -build process but these changes should be ignored. To do this automatically, -run: - -git update-index --assume-unchanged odb/sqlite/version-build2.hxx diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 85d1399..0000000 --- a/bootstrap +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - -# file : bootstrap -# license : GNU GPL v2; see accompanying LICENSE file - -# -# Bootstrap the automake build system. -# - -rm -f config.cache - -if test ! -d m4; then - mkdir m4 -fi - -autoreconf --install diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 4a730a3..0000000 --- a/build/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -config.build -root/ -bootstrap/ diff --git a/build/bootstrap.build b/build/bootstrap.build deleted file mode 100644 index bb9c901..0000000 --- a/build/bootstrap.build +++ /dev/null @@ -1,10 +0,0 @@ -# file : build/bootstrap.build -# license : GNU GPL v2; see accompanying LICENSE file - -project = libodb-sqlite - -using version -using config -using dist -using test -using install diff --git a/build/bootstrap.make b/build/bootstrap.make deleted file mode 100644 index c859827..0000000 --- a/build/bootstrap.make +++ /dev/null @@ -1,70 +0,0 @@ -# file : build/bootstrap.make -# license : GNU GPL v2; see accompanying LICENSE file - -project_name := libodb-sqlite - -# First try to include the bundled bootstrap.make if it exist. If that -# fails, let make search for the external bootstrap.make. -# -build := build-0.3 - --include $(dir $(lastword $(MAKEFILE_LIST)))../../$(build)/bootstrap.make - -ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),) -include $(build)/bootstrap.make -endif - - -# Aliases -# -.PHONY: $(out_base)/ \ - $(out_base)/.test \ - $(out_base)/.dist \ - $(out_base)/.clean - -ifdef %interactive% - -.PHONY: test dist clean - -test: $(out_base)/.test -dist: $(out_base)/.dist -clean: $(out_base)/.clean - -ifneq ($(filter $(.DEFAULT_GOAL),test dist clean),) -.DEFAULT_GOAL := -endif - -endif - -# Make sure the distribution prefix is set if the goal is dist. -# -ifneq ($(filter $(MAKECMDGOALS),dist),) -ifeq ($(dist_prefix),) -$(error dist_prefix is not set) -endif -endif - -# If we don't have dependency auto-generation then we need to manually -# make sure that generated files are generated before C++ file are -# compiler. To do this we make the object files ($2) depend in order- -# only on generated files ($3). -# -ifeq ($(cxx_id),generic) - -define include-dep -$(if $2,$(eval $2: | $3)) -endef - -else - -define include-dep -$(call -include,$1) -endef - -endif - -# Don't include dependency info for certain targets. -# -ifneq ($(filter $(MAKECMDGOALS),clean disfigure dist),) -include-dep = -endif diff --git a/build/export.build b/build/export.build deleted file mode 100644 index 8ce77d8..0000000 --- a/build/export.build +++ /dev/null @@ -1,9 +0,0 @@ -# file : build/export.build -# license : GNU GPL v2; see accompanying LICENSE file - -$out_root/ -{ - include odb/sqlite/ -} - -export $out_root/odb/sqlite/lib{odb-sqlite} diff --git a/build/export/libodb-sqlite/stub.make b/build/export/libodb-sqlite/stub.make deleted file mode 100644 index af9cfd4..0000000 --- a/build/export/libodb-sqlite/stub.make +++ /dev/null @@ -1,8 +0,0 @@ -# file : build/export/libodb-sqlite/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(src_root)/odb/sqlite/makefile,$(out_root)) - -$(call export,\ - l: $(out_root)/odb/sqlite/odb-sqlite.l,\ - cpp-options: $(out_root)/odb/sqlite/odb-sqlite.l.cpp-options) diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make deleted file mode 100644 index 9bdf238..0000000 --- a/build/import/cli/cli-cxx.make +++ /dev/null @@ -1,47 +0,0 @@ -# file : build/import/cli/cli-cxx.make -# license : MIT; see accompanying LICENSE file - -# Here we are operating in the importing project's space, not in -# cli's. -# - -# Get the C++ file extensions. -# -$(call include,$(bld_root)/cxx/configuration-static.make) - -cli_pattern := \ -$(out_base)/%.$(cxx_s_suffix) \ -$(out_base)/%.$(cxx_h_suffix) \ -$(out_base)/%.$(cxx_i_suffix) - -$(cli_pattern): cli_options := \ ---hxx-suffix .$(cxx_h_suffix) \ ---ixx-suffix .$(cxx_i_suffix) \ ---cxx-suffix .$(cxx_s_suffix) - -.PRECIOUS: $(cli_pattern) - -ifeq ($(out_base),$(src_base)) - -$(cli_pattern): $(src_base)/%.cli - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) - -else - -$(cli_pattern): $(src_base)/%.cli | $$(dir $$@). - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) - -$(cli_pattern): $(out_base)/%.cli | $$(dir $$@). - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) -endif - -.PHONY: $(out_base)/%.cxx.cli.clean - -$(out_base)/%.cxx.cli.clean: cxx_s_suffix := $(cxx_s_suffix) -$(out_base)/%.cxx.cli.clean: cxx_h_suffix := $(cxx_h_suffix) -$(out_base)/%.cxx.cli.clean: cxx_i_suffix := $(cxx_i_suffix) - -$(out_base)/%.cxx.cli.clean: - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_s_suffix))) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_h_suffix))) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_i_suffix))) diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make deleted file mode 100644 index 6355000..0000000 --- a/build/import/cli/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/cli/configuration-rules.make -# license : MIT; see accompanying LICENSE file - -$(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. - $(call message,,$(scf_root)/import/cli/configure $@) - -ifndef %foreign% - -$(dcf_root)/.disfigure:: - $(call message,rm $(dcf_root)/import/cli/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/cli/configuration-dynamic.make) - -endif diff --git a/build/import/cli/configure b/build/import/cli/configure deleted file mode 100755 index 2a1fde4..0000000 --- a/build/import/cli/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/cli/configure -# license : MIT; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'cli' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed " -$echo "version of 'cli' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'cli'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'cli'." -$eche - -out_root=`read_path --directory $src_root` - -fi - -echo cli_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make deleted file mode 100644 index 741b371..0000000 --- a/build/import/cli/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/cli/stub.make -# license : MIT; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) - -cli_installed := - -$(call -include,$(dcf_root)/import/cli/configuration-dynamic.make) - -ifdef cli_installed - -ifeq ($(cli_installed),y) - -$(call export,cli: cli,cli-rules: $(scf_root)/import/cli/cli-cxx.make) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/cli/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libodb-sqlite/configuration-rules.make b/build/import/libodb-sqlite/configuration-rules.make deleted file mode 100644 index bf8dee4..0000000 --- a/build/import/libodb-sqlite/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libodb-sqlite/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libodb-sqlite/configuration-dynamic.make: | $(dcf_root)/import/libodb-sqlite/. - $(call message,,$(scf_root)/import/libodb-sqlite/configure $@) - -ifndef %foreign% - -$(dcf_root)/.disfigure:: - $(call message,rm $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libodb-sqlite/configuration-dynamic.make) - -endif diff --git a/build/import/libodb-sqlite/configure b/build/import/libodb-sqlite/configure deleted file mode 100755 index 9f245f5..0000000 --- a/build/import/libodb-sqlite/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libodb-sqlite/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libodb-sqlite' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'libodb-sqlite' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'libodb-sqlite'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'libodb-sqlite'." -$echo - -out_root=`read_path --directory $src_root` - -fi - -echo libodb_sqlite_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/libodb-sqlite/stub.make b/build/import/libodb-sqlite/stub.make deleted file mode 100644 index 417e65a..0000000 --- a/build/import/libodb-sqlite/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/libodb-sqlite/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libodb-sqlite/configuration-rules.make,$(dcf_root)) - -libodb_sqlite_installed := - -$(call -include,$(dcf_root)/import/libodb-sqlite/configuration-dynamic.make) - -ifdef libodb_sqlite_installed - -ifeq ($(libodb_sqlite_installed),y) - -$(call export,l: -lodb-sqlite -lodb -lsqlite3,cpp-options: ) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/libodb-sqlite/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make deleted file mode 100644 index 340c418..0000000 --- a/build/import/libodb/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libodb/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/. - $(call message,,$(scf_root)/import/libodb/configure $@) - -ifndef %foreign% - -$(dcf_root)/.disfigure:: - $(call message,rm $(dcf_root)/import/libodb/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libodb/configuration-dynamic.make) - -endif diff --git a/build/import/libodb/configure b/build/import/libodb/configure deleted file mode 100755 index 261a202..0000000 --- a/build/import/libodb/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libodb/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libodb' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed " -$echo "version of 'libodb' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'libodb'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'libodb'." -$echo - -out_root=`read_path --directory $src_root` - -fi - -echo libodb_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make deleted file mode 100644 index 04dc786..0000000 --- a/build/import/libodb/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/libodb/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root)) - -libodb_installed := - -$(call -include,$(dcf_root)/import/libodb/configuration-dynamic.make) - -ifdef libodb_installed - -ifeq ($(libodb_installed),y) - -$(call export,l: -lodb,cpp-options: ) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/libodb/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libsqlite/configuration-rules.make b/build/import/libsqlite/configuration-rules.make deleted file mode 100644 index c7fcbed..0000000 --- a/build/import/libsqlite/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libsqlite/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libsqlite/configuration-dynamic.make: | $(dcf_root)/import/libsqlite/. - $(call message,,$(scf_root)/import/libsqlite/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libsqlite/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libsqlite/configuration-dynamic.make) - -endif diff --git a/build/import/libsqlite/configure b/build/import/libsqlite/configure deleted file mode 100755 index 0ae364f..0000000 --- a/build/import/libsqlite/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libsqlite/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'SQLite library' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'SQLite library' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= -type= - -if [ "$installed" = "n" ]; then - - $echo - $echo "Please enter the 'SQLite library' root directory." - $echo - - root=`read_path --directory --exist` - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` -fi - -echo libsqlite_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - echo libsqlite_root := $root >>$1 - echo libsqlite_type := $type >>$1 -fi diff --git a/build/import/libsqlite/rules.make b/build/import/libsqlite/rules.make deleted file mode 100644 index 7e346bd..0000000 --- a/build/import/libsqlite/rules.make +++ /dev/null @@ -1,27 +0,0 @@ -# file : build/import/libsqlite/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libsqlite/%: root := $(libsqlite_root) - -ifeq ($(libsqlite_type),archive) - -$(dcf_root)/import/libsqlite/sqlite.l: $(libsqlite_root)/.libs/libsqlite3.a - @echo $< >$@ -else - -$(dcf_root)/import/libsqlite/sqlite.l: $(libsqlite_root)/.libs/libsqlite3.so - @echo $< >$@ - @echo rpath:$(root)/.libs >>$@ -endif - -$(dcf_root)/import/libsqlite/sqlite.l.cpp-options: - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libsqlite/sqlite.l,\ -rm -f $(dcf_root)/import/libsqlite/sqlite.l) - $(call message,,rm -f $(dcf_root)/import/libsqlite/sqlite.l.cpp-options) - -endif diff --git a/build/import/libsqlite/stub.make b/build/import/libsqlite/stub.make deleted file mode 100644 index 2d9e519..0000000 --- a/build/import/libsqlite/stub.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/import/libsqlite/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libsqlite/configuration-rules.make,$(dcf_root)) - -libsqlite_installed := - -$(call -include,$(dcf_root)/import/libsqlite/configuration-dynamic.make) - -ifdef libsqlite_installed - -ifeq ($(libsqlite_installed),y) - -$(call export,l: -lsqlite3,cpp-options: ) - -else - -$(call include-once,$(scf_root)/import/libsqlite/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libsqlite/sqlite.l,\ - cpp-options: $(dcf_root)/import/libsqlite/sqlite.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libsqlite/version b/build/import/libsqlite/version deleted file mode 100644 index 6e8bf73..0000000 --- a/build/import/libsqlite/version +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/build/root.build b/build/root.build deleted file mode 100644 index a1975db..0000000 --- a/build/root.build +++ /dev/null @@ -1,19 +0,0 @@ -# file : build/root.build -# license : GNU GPL v2; see accompanying LICENSE file - -config [bool] config.libodb_sqlite.develop ?= false - -cxx.std = latest - -using cxx - -hxx{*}: extension = hxx -ixx{*}: extension = ixx -txx{*}: extension = txx -cxx{*}: extension = cxx - -if ($cxx.target.system == 'win32-msvc') - cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS - -if ($cxx.class == 'msvc') - cxx.coptions += /wd4251 /wd4275 /wd4800 diff --git a/buildfile b/buildfile deleted file mode 100644 index 4a1b0a7..0000000 --- a/buildfile +++ /dev/null @@ -1,11 +0,0 @@ -# file : buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -./: {*/ -build/ -m4/ -etc/} \ - doc{INSTALL NEWS README} legal{GPLv2 LICENSE} \ - manifest - -# Don't install tests or the INSTALL file. -# -tests/: install = false -doc{INSTALL}@./: install = false diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 27a5537..0000000 --- a/configure.ac +++ /dev/null @@ -1,66 +0,0 @@ -# file : configure.ac -# license : GNU GPL v2; see accompanying LICENSE file - -AC_PREREQ(2.60) -AC_INIT([libodb-sqlite], [__value__(version)], [odb-users@codesynthesis.com]) -AC_CONFIG_AUX_DIR([config]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_SRCDIR([odb/sqlite/version.hxx]) - -AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc subdir-objects dist-bzip2 dist-zip tar-ustar]) -m4_equote()[m4_ifdef]m4_dquote()([AM_PROG_AR], [AM_PROG_AR]) # Required by automake 1.12. - -LT_INIT([win32-dll]) - -AC_CANONICAL_HOST - -# Check for C++ compiler and use it to compile the tests. -# -AC_PROG_CXX -AC_LANG(C++) - -# Create the libtool executable so that we can use it in further tests. -# -LT_OUTPUT - -# Check for threads. -# -THREADS - -# Check for libsqlite. -# -LIBSQLITE( - [], - [AC_MSG_ERROR([libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to specify its location])]) - -AS_IF([test x$libsqlite_unlock_notify = xyes], -AC_DEFINE([LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY], [1], [Have sqlite3_unlock_notify.])) - -AS_IF([test x$libsqlite_column_metadata = xyes], -AC_DEFINE([LIBODB_SQLITE_HAVE_COLUMN_METADATA], [1], [Have column metadata functions.])) - -AS_IF([test x$threads != xnone -a x$libsqlite_unlock_notify = xno], -AC_MSG_WARN([libsqlite3 is built without sqlite3_unlock_notify support; multi-threaded support will be limited])) - -# Check for libodb. -# -LIBODB([],[AC_MSG_ERROR([libodb is not found; consider using --with-libodb=DIR])]) - -# Define LIBODB_SQLITE_STATIC_LIB if we are build static library on certain -# platforms. -# -STATIC_LIB([LIBODB_SQLITE_STATIC_LIB], [Static library interface.]) - -# Allow the user to specify the pkgconfig directory. -# -PKGCONFIG - -# Check if we should disable rpath. -# -DISABLE_RPATH - -# Output. -# -AC_CONFIG_HEADERS([odb/sqlite/config.h odb/sqlite/details/config.h]) -AC_CONFIG_FILES([__path__(config_files)]) -AC_OUTPUT diff --git a/etc/sqlite/README b/etc/sqlite/README deleted file mode 100644 index 0d493f0..0000000 --- a/etc/sqlite/README +++ /dev/null @@ -1,30 +0,0 @@ -This directory contains project/solution files for building SQLite libraries -with Microsoft Visual Studio versions 8, 9, 10, 11, and 12. - -To build SQLite, you will need to download two SQLite packages: sqlite- -amalgamation and sqlite-dll. Copy the sqlite3.c and sqlite3.h files from the -first package and the sqlite3.def file from the second package into the -directory with the project/solution files. Then open the solution and build -the desired configurations (Debug/Release) and platforms (Win32/x64). - -The resulting 32-bit DLLs and import libraries are placed into the bin\ and -lib\ sub-directories, respectively. Similarly, the 64-bit DLLs and import -libraries are placed into bin64\ and lib64\. The Release versions of the -import libraries are named sqlite3.lib and the Debug versions are named -sqlite3-d.lib. - -To configure Visual Studio to automatically locate the SQLite header, DLLs, -and import libraries, add the following paths to your VC++ Directories (below -sqlite refers to the build directory): - -Win32: - - Include: ...\sqlite - Library: ...\sqlite\lib - Executable: ...\sqlite\bin - -x64: - - Include: ...\sqlite - Library: ...\sqlite\lib64 - Executable: ...\sqlite\bin64 diff --git a/etc/sqlite/sqlite3-vc10.sln b/etc/sqlite/sqlite3-vc10.sln deleted file mode 100644 index c9c0922..0000000 --- a/etc/sqlite/sqlite3-vc10.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc10.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/etc/sqlite/sqlite3-vc10.vcxproj b/etc/sqlite/sqlite3-vc10.vcxproj deleted file mode 100644 index 8d2ba96..0000000 --- a/etc/sqlite/sqlite3-vc10.vcxproj +++ /dev/null @@ -1,170 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3409C5BB-974C-44FC-A9DB-2176837E9035} - Win32Proj - sqlite3 - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - bin\ - sqlite3-d - - - true - bin64\ - sqlite3-d - - - false - bin\ - sqlite3 - - - false - bin64\ - sqlite3 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - $(TargetPath) - lib\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - $(TargetPath) - lib64\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - true - true - $(TargetPath) - lib\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - true - true - $(TargetPath) - lib64\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - - - - - - - - diff --git a/etc/sqlite/sqlite3-vc10.vcxproj.filters b/etc/sqlite/sqlite3-vc10.vcxproj.filters deleted file mode 100644 index 13685a4..0000000 --- a/etc/sqlite/sqlite3-vc10.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/etc/sqlite/sqlite3-vc11.sln b/etc/sqlite/sqlite3-vc11.sln deleted file mode 100644 index 89ed59f..0000000 --- a/etc/sqlite/sqlite3-vc11.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc11.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/etc/sqlite/sqlite3-vc11.vcxproj b/etc/sqlite/sqlite3-vc11.vcxproj deleted file mode 100644 index 9174372..0000000 --- a/etc/sqlite/sqlite3-vc11.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3409C5BB-974C-44FC-A9DB-2176837E9035} - Win32Proj - sqlite3 - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - bin\ - sqlite3-d - - - true - bin64\ - sqlite3-d - - - false - bin\ - sqlite3 - - - false - bin64\ - sqlite3 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - $(TargetPath) - lib\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - $(TargetPath) - lib64\sqlite3-d.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - true - true - $(TargetPath) - lib\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;%(PreprocessorDefinitions) - - - Windows - true - true - true - $(TargetPath) - lib64\sqlite3.lib - sqlite3.def - /EXPORT:sqlite3_unlock_notify %(AdditionalOptions) - - - - - - - - - - - - diff --git a/etc/sqlite/sqlite3-vc11.vcxproj.filters b/etc/sqlite/sqlite3-vc11.vcxproj.filters deleted file mode 100644 index 13685a4..0000000 --- a/etc/sqlite/sqlite3-vc11.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/etc/sqlite/sqlite3-vc12.sln b/etc/sqlite/sqlite3-vc12.sln deleted file mode 100644 index 6d901fb..0000000 --- a/etc/sqlite/sqlite3-vc12.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc12.vcxproj", "{3409C5BB-974C-44FC-A9DB-2176837E9035}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.ActiveCfg = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|Win32.Build.0 = Debug|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.ActiveCfg = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Debug|x64.Build.0 = Debug|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.ActiveCfg = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|Win32.Build.0 = Release|Win32 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.ActiveCfg = Release|x64 - {3409C5BB-974C-44FC-A9DB-2176837E9035}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/etc/sqlite/sqlite3-vc12.vcxproj b/etc/sqlite/sqlite3-vc12.vcxproj deleted file mode 100644 index 1b74865..0000000 --- a/etc/sqlite/sqlite3-vc12.vcxproj +++ /dev/null @@ -1,170 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3409C5BB-974C-44FC-A9DB-2176837E9035} - Win32Proj - sqlite3 - - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - bin\ - sqlite3-d - - - true - bin64\ - sqlite3-d - - - false - bin\ - sqlite3 - - - false - bin64\ - sqlite3 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) - true - - - Windows - true - $(TargetPath) - lib\sqlite3-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) - true - - - Windows - true - $(TargetPath) - lib64\sqlite3-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) - true - - - Windows - true - true - true - $(TargetPath) - lib\sqlite3.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_OS_WIN=1;SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_RTREE=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_UNLOCK_NOTIFY=1;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) - true - - - Windows - true - true - true - $(TargetPath) - lib64\sqlite3.lib - - - - - - - - - - - - diff --git a/etc/sqlite/sqlite3-vc12.vcxproj.filters b/etc/sqlite/sqlite3-vc12.vcxproj.filters deleted file mode 100644 index 13685a4..0000000 --- a/etc/sqlite/sqlite3-vc12.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/etc/sqlite/sqlite3-vc8.sln b/etc/sqlite/sqlite3-vc8.sln deleted file mode 100644 index e5ed1d0..0000000 --- a/etc/sqlite/sqlite3-vc8.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc8.vcproj", "{6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.ActiveCfg = Debug|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.Build.0 = Debug|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.ActiveCfg = Debug|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.Build.0 = Debug|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.ActiveCfg = Release|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.Build.0 = Release|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.ActiveCfg = Release|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/etc/sqlite/sqlite3-vc8.vcproj b/etc/sqlite/sqlite3-vc8.vcproj deleted file mode 100644 index 8e1e552..0000000 --- a/etc/sqlite/sqlite3-vc8.vcproj +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/etc/sqlite/sqlite3-vc9.sln b/etc/sqlite/sqlite3-vc9.sln deleted file mode 100644 index 4206336..0000000 --- a/etc/sqlite/sqlite3-vc9.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3-vc9.vcproj", "{6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.ActiveCfg = Debug|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|Win32.Build.0 = Debug|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.ActiveCfg = Debug|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Debug|x64.Build.0 = Debug|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.ActiveCfg = Release|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|Win32.Build.0 = Release|Win32 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.ActiveCfg = Release|x64 - {6AAE1E22-4BE0-4CB4-A94E-B908167D88C2}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/etc/sqlite/sqlite3-vc9.vcproj b/etc/sqlite/sqlite3-vc9.vcproj deleted file mode 100644 index 9a698b7..0000000 --- a/etc/sqlite/sqlite3-vc9.vcproj +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libodb-sqlite-vc10.sln b/libodb-sqlite-vc10.sln deleted file mode 100644 index cef2f8a..0000000 --- a/libodb-sqlite-vc10.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc10.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libodb-sqlite-vc11.sln b/libodb-sqlite-vc11.sln deleted file mode 100644 index 0ca7868..0000000 --- a/libodb-sqlite-vc11.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc11.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libodb-sqlite-vc12.sln b/libodb-sqlite-vc12.sln deleted file mode 100644 index 878e1e2..0000000 --- a/libodb-sqlite-vc12.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc12.vcxproj", "{BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.ActiveCfg = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|Win32.Build.0 = Debug|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.ActiveCfg = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Debug|x64.Build.0 = Debug|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.ActiveCfg = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|Win32.Build.0 = Release|Win32 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.ActiveCfg = Release|x64 - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libodb-sqlite-vc8.sln b/libodb-sqlite-vc8.sln deleted file mode 100644 index 94d3f87..0000000 --- a/libodb-sqlite-vc8.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc8.vcproj", "{E4055842-E6F1-4305-9FD2-EF70A92290C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.Build.0 = Debug|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.ActiveCfg = Debug|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.Build.0 = Debug|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.ActiveCfg = Release|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.Build.0 = Release|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.ActiveCfg = Release|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libodb-sqlite-vc9.sln b/libodb-sqlite-vc9.sln deleted file mode 100644 index 15f4ac0..0000000 --- a/libodb-sqlite-vc9.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb-sqlite", "odb\sqlite\libodb-sqlite-vc9.vcproj", "{E4055842-E6F1-4305-9FD2-EF70A92290C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|Win32.Build.0 = Debug|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.ActiveCfg = Debug|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Debug|x64.Build.0 = Debug|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.ActiveCfg = Release|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|Win32.Build.0 = Release|Win32 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.ActiveCfg = Release|x64 - {E4055842-E6F1-4305-9FD2-EF70A92290C9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libodb-sqlite.pc.in b/libodb-sqlite.pc.in deleted file mode 100644 index b53bc6f..0000000 --- a/libodb-sqlite.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# file : libodb-sqlite.pc.in -# license : GNU GPL v2; see accompanying LICENSE file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libodb-sqlite -Description: Object-relational mapping (ORM) system for C++, SQLite runtime library -URL: http://www.codesynthesis.com/products/odb/ -Version: @VERSION@ -Libs: -L${libdir} -lodb-sqlite -Cflags: -I${includedir} diff --git a/libodb-sqlite/.gitignore b/libodb-sqlite/.gitignore new file mode 100644 index 0000000..1c363a0 --- /dev/null +++ b/libodb-sqlite/.gitignore @@ -0,0 +1,25 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.i.* +*.ii +*.ii.* +*.o +*.obj +*.gcm +*.pcm +*.ifc +*.so +*.dylib +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/libodb-sqlite/GPLv2 b/libodb-sqlite/GPLv2 new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/libodb-sqlite/GPLv2 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libodb-sqlite/INSTALL b/libodb-sqlite/INSTALL new file mode 100644 index 0000000..3eb4c33 --- /dev/null +++ b/libodb-sqlite/INSTALL @@ -0,0 +1,6 @@ +The easiest way to build this package is with the bpkg package manager: + +$ bpkg build libodb-sqlite + +But if you don't want to use the package manager, then you can also build it +manually using the standard build2 build system. diff --git a/libodb-sqlite/LICENSE b/libodb-sqlite/LICENSE new file mode 100644 index 0000000..9d92da1 --- /dev/null +++ b/libodb-sqlite/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009-2024 Code Synthesis Tools CC. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +For more information on ODB licensing as well as for answers to +some of the common licensing questions, visit the ODB License +page: + +http://www.codesynthesis.com/products/odb/license.xhtml + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/libodb-sqlite/README b/libodb-sqlite/README new file mode 100644 index 0000000..ffd4049 --- /dev/null +++ b/libodb-sqlite/README @@ -0,0 +1,20 @@ +ODB is an object-relational mapping (ORM) system for C++. It provides +tools, APIs, and library support that allow you to persist C++ objects +to a relational database (RDBMS) without having to deal with tables, +columns, or SQL and without manually writing any of the mapping code. +For more information see: + +http://www.codesynthesis.com/products/odb/ + +This package contains the SQLite ODB runtime library. Every application +that includes code generated for the SQLite database will need to link +to this library. + +See the NEWS file for the user-visible changes from the previous release. + +See the LICENSE file for distribution conditions. + +See the INSTALL file for prerequisites and installation instructions. + +Send questions, bug reports, or any other feedback to the +odb-users@codesynthesis.com mailing list. diff --git a/libodb-sqlite/build/.gitignore b/libodb-sqlite/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libodb-sqlite/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libodb-sqlite/build/bootstrap.build b/libodb-sqlite/build/bootstrap.build new file mode 100644 index 0000000..bb9c901 --- /dev/null +++ b/libodb-sqlite/build/bootstrap.build @@ -0,0 +1,10 @@ +# file : build/bootstrap.build +# license : GNU GPL v2; see accompanying LICENSE file + +project = libodb-sqlite + +using version +using config +using dist +using test +using install diff --git a/libodb-sqlite/build/export.build b/libodb-sqlite/build/export.build new file mode 100644 index 0000000..8ce77d8 --- /dev/null +++ b/libodb-sqlite/build/export.build @@ -0,0 +1,9 @@ +# file : build/export.build +# license : GNU GPL v2; see accompanying LICENSE file + +$out_root/ +{ + include odb/sqlite/ +} + +export $out_root/odb/sqlite/lib{odb-sqlite} diff --git a/libodb-sqlite/build/root.build b/libodb-sqlite/build/root.build new file mode 100644 index 0000000..a1975db --- /dev/null +++ b/libodb-sqlite/build/root.build @@ -0,0 +1,19 @@ +# file : build/root.build +# license : GNU GPL v2; see accompanying LICENSE file + +config [bool] config.libodb_sqlite.develop ?= false + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 diff --git a/libodb-sqlite/buildfile b/libodb-sqlite/buildfile new file mode 100644 index 0000000..a04e206 --- /dev/null +++ b/libodb-sqlite/buildfile @@ -0,0 +1,9 @@ +# file : buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -build/} doc{INSTALL NEWS README} legal{GPLv2 LICENSE} manifest + +# Don't install tests or the INSTALL file. +# +tests/: install = false +doc{INSTALL}@./: install = false diff --git a/libodb-sqlite/manifest b/libodb-sqlite/manifest new file mode 100644 index 0000000..fef85a0 --- /dev/null +++ b/libodb-sqlite/manifest @@ -0,0 +1,22 @@ +: 1 +name: libodb-sqlite +version: 2.5.0-b.26.z +project: odb +summary: SQLite ODB runtime library +license: GPL-2.0-only +license: other: proprietary ; Not free/open source. +topics: C++, ORM, SQLite, SQL +description-file: README +changes-file: NEWS +url: https://www.codesynthesis.com/products/odb/ +doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml +src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ +email: odb-users@codesynthesis.com +build-warning-email: odb-builds@codesynthesis.com +builds: all +requires: c++11 +depends: * build2 >= 0.16.0- +depends: * bpkg >= 0.16.0- +depends: libsqlite3 ^3.6.18 +depends: libodb [2.5.0-b.26.1 2.5.0-b.27) +depends: * cli ^1.2.0- ? ($config.libodb_sqlite.develop) diff --git a/libodb-sqlite/odb/sqlite/auto-handle.hxx b/libodb-sqlite/odb/sqlite/auto-handle.hxx new file mode 100644 index 0000000..d25e919 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/auto-handle.hxx @@ -0,0 +1,101 @@ +// file : odb/sqlite/auto-handle.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_AUTO_HANDLE_HXX +#define ODB_SQLITE_AUTO_HANDLE_HXX + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + struct handle_traits; + + template <> + struct handle_traits + { + static void + release (sqlite3* h) + { + if (sqlite3_close (h) == SQLITE_BUSY) + { + // Connection has outstanding prepared statements. + // + assert (false); + } + } + }; + + template <> + struct handle_traits + { + static void + release (sqlite3_stmt* h) + { + sqlite3_finalize (h); + } + }; + + template + class auto_handle + { + public: + auto_handle (H* h = 0) + : h_ (h) + { + } + + ~auto_handle () + { + if (h_ != 0) + handle_traits::release (h_); + } + + H* + get () const + { + return h_; + } + + void + reset (H* h = 0) + { + if (h_ != 0) + handle_traits::release (h_); + + h_ = h; + } + + H* + release () + { + H* h (h_); + h_ = 0; + return h; + } + + operator H* () const + { + return h_; + } + + private: + auto_handle (const auto_handle&); + auto_handle& operator= (const auto_handle&); + + private: + H* h_; + }; + } +} + +#include + +#endif // ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/libodb-sqlite/odb/sqlite/binding.hxx b/libodb-sqlite/odb/sqlite/binding.hxx new file mode 100644 index 0000000..3807130 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/binding.hxx @@ -0,0 +1,44 @@ +// file : odb/sqlite/binding.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BINDING_HXX +#define ODB_SQLITE_BINDING_HXX + +#include + +#include // std::size_t + +#include + +#include + +namespace odb +{ + namespace sqlite + { + class binding + { + public: + typedef sqlite::bind bind_type; + + binding (): bind (0), count (0), version (0) {} + + binding (bind_type* b, std::size_t n) + : bind (b), count (n), version (0) + { + } + + bind_type* bind; + std::size_t count; + std::size_t version; + + private: + binding (const binding&); + binding& operator= (const binding&); + }; + } +} + +#include + +#endif // ODB_SQLITE_BINDING_HXX diff --git a/libodb-sqlite/odb/sqlite/blob-stream.hxx b/libodb-sqlite/odb/sqlite/blob-stream.hxx new file mode 100644 index 0000000..caa7c24 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/blob-stream.hxx @@ -0,0 +1,31 @@ +// file : odb/sqlite/blob-stream.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BLOB_STREAM_HXX +#define ODB_SQLITE_BLOB_STREAM_HXX + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + class blob_stream: public stream + { + public: + blob_stream (const blob& b, bool rw) + : stream (b.db ().c_str (), + b.table ().c_str (), + b.column ().c_str (), + b.rowid (), + rw) {} + }; + } +} + +#include + +#endif // ODB_SQLITE_BLOB_STREAM_HXX diff --git a/libodb-sqlite/odb/sqlite/blob.hxx b/libodb-sqlite/odb/sqlite/blob.hxx new file mode 100644 index 0000000..a4892a2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/blob.hxx @@ -0,0 +1,68 @@ +// file : odb/sqlite/blob.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_BLOB_HXX +#define ODB_SQLITE_BLOB_HXX + +#include + +#include +#include // std::size_t + +// Carefully allow this header to be included into the ODB compilation. +// +#ifndef ODB_COMPILER +# include +#endif + +namespace odb +{ + namespace sqlite + { +#ifdef ODB_COMPILER + #pragma db sqlite:type("BLOB STREAM") + class blob +#else + class blob +#endif + { + public: + // BLOB size to provision for. Set before calling persist() or update(). + // + explicit + blob (std::size_t size = 0): size_ (size) {} + + std::size_t size () const {return size_;} + void size (std::size_t s) {size_ = s;} + + const std::string& db () const {return db_;} + const std::string& table () const {return table_;} + const std::string& column () const {return column_;} + long long rowid () const {return rowid_;} + + void + clear () + { + size_ = 0; + db_.clear (); + table_.clear (); + column_.clear (); + rowid_ = 0; + } + + private: +#ifndef ODB_COMPILER + friend struct default_value_traits; +#endif + std::size_t size_; + mutable std::string db_; + mutable std::string table_; + mutable std::string column_; + mutable long long rowid_; + }; + } +} + +#include + +#endif // ODB_SQLITE_BLOB_HXX diff --git a/libodb-sqlite/odb/sqlite/buildfile b/libodb-sqlite/odb/sqlite/buildfile new file mode 100644 index 0000000..d2da43f --- /dev/null +++ b/libodb-sqlite/odb/sqlite/buildfile @@ -0,0 +1,155 @@ +# file : odb/sqlite/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +define cli: file +cli{*}: extension = cli + +import int_libs = libodb%lib{odb} +import int_libs += libsqlite3%lib{sqlite3} + +lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ + details/{hxx ixx txx cxx}{* -options} \ + details/build2/{h}{*} \ + $int_libs + +# Include the generated version header into the distribution (so that we don't +# pick up an installed one) and don't remove it when cleaning in src (so that +# clean results in a state identical to distributed). +# +hxx{version-build2}: in{version-build2} $src_root/manifest +hxx{version-build2}: +{ + dist = true + clean = ($src_root != $out_root) +} + +# Build options. +# +cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 + +obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD + +# Export options. +# +lib{odb-sqlite}: +{ + cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 + cxx.export.libs = $int_libs +} + +liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC +libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED + +# For pre-releases use the complete version to make sure they cannot be used +# in place of another pre-release or the final version. See the version module +# for details on the version.* variable values. +# +if $version.pre_release + lib{odb-sqlite}: bin.lib.version = @"-$version.project_id" +else + lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" + +develop = $config.libodb_sqlite.develop + +## Consumption build ($develop == false). +# + +# Use pregenerated versions in the consumption build. +# +lib{odb-sqlite}: details/pregenerated/{hxx ixx cxx}{**}: include = (!$develop) + +if! $develop + cxx.poptions =+ "-I($src_base/details/pregenerated)" # Note: must come first. + +# Don't install pregenerated headers since they are only used internally in +# the database implementation (also below). +# +details/pregenerated/{hxx ixx}{*}: install = false + +# Distribute pregenerated versions only in the consumption build. +# +details/pregenerated/{hxx ixx cxx}{*}: dist = (!$develop) + +# +## + +## Development build ($develop == true). +# + +lib{odb-sqlite}: details/{hxx ixx cxx}{options}: include = $develop + +if $develop + import! [metadata] cli = cli%exe{cli} + +# In the development build distribute regenerated {hxx ixx cxx}{options}, +# remapping their locations to the paths of the pregenerated versions (which +# are only distributed in the consumption build; see above). This way we make +# sure that the distributed files are always up-to-date. +# +
: details/cli{options} $cli +{ + install = false + dist = ($develop ? details/pregenerated/odb/sqlite/details/ : false) + + # Symlink the generated code in src for convenience of development. + # + backlink = true +} +% +if $develop +{{ + options = --include-with-brackets --include-prefix odb/sqlite/details \ + --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ + --cli-namespace odb::sqlite::details::cli --long-usage \ + --no-combined-flags + + $cli $options -o $out_base/details/ $path($<[0]) + + # If the result differs from the pregenerated version, copy it over. + # + d = [dir_path] $src_base/details/pregenerated/odb/sqlite/details/ + + if diff $d/options.hxx $path($>[0]) >- && \ + diff $d/options.ixx $path($>[1]) >- && \ + diff $d/options.cxx $path($>[2]) >- + exit + end + + cp $path($>[0]) $d/options.hxx + cp $path($>[1]) $d/options.ixx + cp $path($>[2]) $d/options.cxx +}} + +# Install into the odb/sqlite/ subdirectory of, say, /usr/include/ +# recreating subdirectories. +# +install_include = [dir_path] include/odb/sqlite/ + +{hxx ixx txx}{*}: +{ + install = $install_include + install.subdirs = true +} + +# We want these to be picked up whether LIBODB_SQLITE_BUILD2 is defined or not. +# +hxx{version}@./: install = false +hxx{version-build2}: install = $install_include/version.hxx +hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx + +details/build2/ +{ + h{*}: install = false + + if ($cxx.target.system == 'win32-msvc') + { + h{config-vc}@./: install = $install_include/details/ + h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h + } + else + { + h{config}@./: install = $install_include/details/ + h{config-stub}@./: install = $install_include/details/build2/config.h + } +} diff --git a/libodb-sqlite/odb/sqlite/connection-factory.cxx b/libodb-sqlite/odb/sqlite/connection-factory.cxx new file mode 100644 index 0000000..794c6dd --- /dev/null +++ b/libodb-sqlite/odb/sqlite/connection-factory.cxx @@ -0,0 +1,417 @@ +// file : odb/sqlite/connection-factory.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include + +#include +#include + +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + +using namespace std; + +namespace odb +{ + using namespace details; + + namespace sqlite + { + // + // serial_connection_factory + // + + serial_connection_factory:: + ~serial_connection_factory () + { + // We should hold the last reference to the connection. + // + if (connection_ != 0) + assert (connection_.count () == 1); + } + + connection_ptr serial_connection_factory:: + create () + { + return connection_ptr (new (shared) connection (*this)); + } + + connection_ptr serial_connection_factory:: + connect () + { + return connection_; + } + + void serial_connection_factory:: + database (database_type& db) + { + connection_factory::database (db); + + if (!connection_) + connection_ = create (); + } + + // + // single_connection_factory + // + + single_connection_factory:: + ~single_connection_factory () + { + // If the connection is currently in use, wait for it to return to + // the factory. + // + lock l (mutex_); + } + + single_connection_factory::single_connection_ptr + single_connection_factory:: + create () + { + return single_connection_ptr (new (shared) single_connection (*this)); + } + + connection_ptr single_connection_factory:: + connect () + { + mutex_.lock (); + connection_->callback_ = &connection_->cb_; + connection_ptr r (connection_); + connection_.reset (); + return r; + } + + void single_connection_factory:: + database (database_type& db) + { + connection_factory::database (db); + + if (!connection_) + connection_ = create (); + } + + bool single_connection_factory:: + release (single_connection* c) + { + c->callback_ = 0; + connection_.reset (inc_ref (c)); + connection_->recycle (); + mutex_.unlock (); + return false; + } + + // + // single_connection_factory::single_connection + // + + single_connection_factory::single_connection:: + single_connection (single_connection_factory& f, int extra_flags) + : connection (f, extra_flags) + { + cb_.arg = this; + cb_.zero_counter = &zero_counter; + } + + single_connection_factory::single_connection:: + single_connection (single_connection_factory& f, sqlite3* handle) + : connection (f, handle) + { + cb_.arg = this; + cb_.zero_counter = &zero_counter; + } + + bool single_connection_factory::single_connection:: + zero_counter (void* arg) + { + single_connection* c (static_cast (arg)); + return static_cast (c->factory_).release (c); + } + + // + // new_connection_factory + // + + connection_ptr new_connection_factory:: + connect () + { + return connection_ptr (new (shared) connection (*this, extra_flags_)); + } + + void new_connection_factory:: + database (database_type& db) + { + bool first (db_ == 0); + + connection_factory::database (db); + + if (!first) + return; + + // Unless explicitly disabled, enable shared cache. + // +#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) + if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) + extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; +#endif + } + + // + // connection_pool_factory + // + + connection_pool_factory::pooled_connection_ptr connection_pool_factory:: + create () + { + return pooled_connection_ptr ( + new (shared) pooled_connection (*this, extra_flags_)); + } + + connection_pool_factory:: + ~connection_pool_factory () + { + // Wait for all the connections currently in use to return to the pool. + // + lock l (mutex_); + while (in_use_ != 0) + { + waiters_++; + cond_.wait (l); + waiters_--; + } + } + + connection_ptr connection_pool_factory:: + connect () + { + lock l (mutex_); + + while (true) + { + // See if we have a spare connection. + // + if (connections_.size () != 0) + { + shared_ptr c (connections_.back ()); + connections_.pop_back (); + + c->callback_ = &c->cb_; + in_use_++; + return c; + } + + // See if we can create a new one. + // + if(max_ == 0 || in_use_ < max_) + { + shared_ptr c (create ()); + c->callback_ = &c->cb_; + in_use_++; + return c; + } + + // Wait until someone releases a connection. + // + waiters_++; + cond_.wait (l); + waiters_--; + } + } + + void connection_pool_factory:: + database (database_type& db) + { + bool first (db_ == 0); + + connection_factory::database (db); + + if (!first) + return; + + // Unless explicitly disabled, enable shared cache. + // +#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) + if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) + extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; +#endif + + if (min_ > 0) + { + connections_.reserve (min_); + + for(size_t i (0); i < min_; ++i) + connections_.push_back (create ()); + } + } + + bool connection_pool_factory:: + release (pooled_connection* c) + { + c->callback_ = 0; + + lock l (mutex_); + + // Determine if we need to keep or free this connection. + // + bool keep (waiters_ != 0 || + min_ == 0 || + (connections_.size () + in_use_ <= min_)); + + in_use_--; + + if (keep) + { + connections_.push_back (pooled_connection_ptr (inc_ref (c))); + connections_.back ()->recycle (); + } + + if (waiters_ != 0) + cond_.signal (); + + return !keep; + } + + // + // connection_pool_factory::pooled_connection + // + + connection_pool_factory::pooled_connection:: + pooled_connection (connection_pool_factory& f, int extra_flags) + : connection (f, extra_flags) + { + cb_.arg = this; + cb_.zero_counter = &zero_counter; + } + + connection_pool_factory::pooled_connection:: + pooled_connection (connection_pool_factory& f, sqlite3* handle) + : connection (f, handle) + { + cb_.arg = this; + cb_.zero_counter = &zero_counter; + } + + bool connection_pool_factory::pooled_connection:: + zero_counter (void* arg) + { + pooled_connection* c (static_cast (arg)); + return static_cast (c->factory_).release (c); + } + + // + // default_attached_connection_factory + // + + void default_attached_connection_factory:: + detach () + { + // Note that this function may be called several times, for example, in + // case of detach_database() failure. + // + if (attached_connection_ != 0) + { + // We should hold the last reference to the attached connection. + // + assert (attached_connection_.count () == 1); + + // While it may seem like a good idea to also invalidate query results + // and reset active statements, if any such result/statement is still + // alive, then there would be bigger problems since it would have a + // dangling reference to the connection. In a way, that's the same + // reason we don't do it in the connection destructor. + + // Remove ourselves from the active object list of the main + // connection. + // + if (next_ != this) // Might have already been done. + list_remove (); + + const string& s (database ().schema ()); + + if (s != "main" && s != "temp") + main_factory ().detach_database (main_connection_, s); + + // Explicitly free the attached connection so that we don't try to + // redo this. + // + attached_connection_.reset (); + } + } + + default_attached_connection_factory:: + ~default_attached_connection_factory () + { + if (attached_connection_ != 0) + { + // This can throw. Ignoring the failure to detach seems like the most + // sensible thing to do here. + // + try{ detach (); } catch (...) {} + } + } + + connection_ptr default_attached_connection_factory:: + connect () + { + return attached_connection_; + } + + void default_attached_connection_factory:: + database (database_type& db) + { + attached_connection_factory::database (db); + + if (!attached_connection_) + { + const string& s (db.schema ()); + + if (s != "main" && s != "temp") + main_factory ().attach_database (main_connection_, db.name (), s); + + attached_connection_.reset ( + new (shared) connection (*this, + s != "main" ? &translate_statement : 0)); + + // Add ourselves to the active object list of the main connection. + // + list_add (); + } + } + + void default_attached_connection_factory:: + clear () + { + attached_connection_->clear (); + } + + void default_attached_connection_factory:: + translate_statement (string& r, + const char* text, + size_t text_size, + connection& conn) + { + r.assign (text, text_size); + + // Things will fall apart if any of the statements we translate use + // "main" as a table alias. So we have this crude check even though it + // means we cannot use "main" for other aliases (e.g., column). + // + assert (r.find ("AS \"main\"") == string::npos); + + const string& s (conn.database ().schema ()); + for (size_t p (0); (p = r.find ("\"main\".", p, 7)) != string::npos; ) + { + // Verify the preceding character. + // + if (p != 0 && r[p - 1] == '.') + { + p += 7; + continue; + } + + r.replace (p + 1, 4, s); + p += s.size () + 3; + } + } + } +} diff --git a/libodb-sqlite/odb/sqlite/connection-factory.hxx b/libodb-sqlite/odb/sqlite/connection-factory.hxx new file mode 100644 index 0000000..b410997 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/connection-factory.hxx @@ -0,0 +1,273 @@ +// file : odb/sqlite/connection-factory.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX +#define ODB_SQLITE_CONNECTION_FACTORY_HXX + +#include + +#include +#include // std::size_t +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // Share a single connection in a guaranteed serial database access. + // + // For example, a single-threaded application that executes all the + // operations via the database instance without messing with multiple + // connections/transactions would qualify. + // + class LIBODB_SQLITE_EXPORT serial_connection_factory: + public connection_factory + { + public: + serial_connection_factory () {} + + virtual connection_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~serial_connection_factory (); + + private: + serial_connection_factory (const serial_connection_factory&); + serial_connection_factory& operator= (const serial_connection_factory&); + + protected: + // This function is called when the factory needs to create the + // connection. + // + virtual connection_ptr + create (); + + connection_ptr connection_; + }; + + // Share a single connection potentially between multiple threads. + // + class LIBODB_SQLITE_EXPORT single_connection_factory: + public connection_factory + { + public: + single_connection_factory () {} + + virtual connection_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~single_connection_factory (); + + private: + single_connection_factory (const single_connection_factory&); + single_connection_factory& operator= (const single_connection_factory&); + + protected: + class LIBODB_SQLITE_EXPORT single_connection: public connection + { + public: + single_connection (single_connection_factory&, int extra_flags = 0); + single_connection (single_connection_factory&, sqlite3*); + + private: + static bool + zero_counter (void*); + + private: + friend class single_connection_factory; + shared_base::refcount_callback cb_; + }; + + friend class single_connection; + + typedef details::shared_ptr single_connection_ptr; + + // This function is called when the factory needs to create the + // connection. + // + virtual single_connection_ptr + create (); + + protected: + // Return true if the connection should be deleted, false otherwise. + // + bool + release (single_connection*); + + protected: + details::mutex mutex_; + single_connection_ptr connection_; + }; + + // Create a new connection every time one is requested. + // + class LIBODB_SQLITE_EXPORT new_connection_factory: + public connection_factory + { + public: + new_connection_factory (): extra_flags_ (0) {} + + virtual connection_ptr + connect (); + + virtual void + database (database_type&); + + private: + new_connection_factory (const new_connection_factory&); + new_connection_factory& operator= (const new_connection_factory&); + + private: + int extra_flags_; + }; + + // Pool a number of connections. + // + class LIBODB_SQLITE_EXPORT connection_pool_factory: + public connection_factory + { + public: + // The max_connections argument specifies the maximum number of + // concurrent connections this pool will maintain. If this value + // is 0 then the pool will create a new connection every time all + // of the existing connections are in use. + // + // The min_connections argument specifies the minimum number of + // connections that should be maintained by the pool. If the + // number of connections maintained by the pool exceeds this + // number and there are no active waiters for a new connection, + // then the pool will release the excess connections. If this + // value is 0 then the pool will maintain all the connections + // that were ever created. + // + // The ping argument specifies whether to ping the connection to + // make sure it is still alive before returning it to the caller. + // + connection_pool_factory (std::size_t max_connections = 0, + std::size_t min_connections = 0) + : max_ (max_connections), + min_ (min_connections), + extra_flags_ (0), + in_use_ (0), + waiters_ (0), + cond_ (mutex_) + { + // max_connections == 0 means unlimited. + // + assert (max_connections == 0 || max_connections >= min_connections); + } + + virtual connection_ptr + connect (); + + virtual void + database (database_type&); + + virtual + ~connection_pool_factory (); + + private: + connection_pool_factory (const connection_pool_factory&); + connection_pool_factory& operator= (const connection_pool_factory&); + + protected: + class LIBODB_SQLITE_EXPORT pooled_connection: public connection + { + public: + pooled_connection (connection_pool_factory&, int extra_flags = 0); + pooled_connection (connection_pool_factory&, sqlite3*); + + private: + static bool + zero_counter (void*); + + private: + friend class connection_pool_factory; + shared_base::refcount_callback cb_; + }; + + friend class pooled_connection; + + typedef details::shared_ptr pooled_connection_ptr; + typedef std::vector connections; + + // This function is called whenever the pool needs to create a new + // connection. + // + virtual pooled_connection_ptr + create (); + + protected: + // Return true if the connection should be deleted, false otherwise. + // + bool + release (pooled_connection*); + + protected: + const std::size_t max_; + const std::size_t min_; + int extra_flags_; + + std::size_t in_use_; // Number of connections currently in use. + std::size_t waiters_; // Number of threads waiting for a connection. + + connections connections_; + + details::mutex mutex_; + details::condition cond_; + }; + + class LIBODB_SQLITE_EXPORT default_attached_connection_factory: + public attached_connection_factory + { + public: + explicit + default_attached_connection_factory (const connection_ptr& main) + : attached_connection_factory (main) {} + + using attached_connection_factory::database; // Accessor. + + virtual void + database (database_type&); + + virtual connection_ptr + connect (); + + virtual void + detach (); + + // Active object interface. + // + virtual void + clear (); + + virtual + ~default_attached_connection_factory (); + + protected: + static void + translate_statement (std::string&, const char*, std::size_t, connection&); + }; + } +} + +#include + +#endif // ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/libodb-sqlite/odb/sqlite/connection.cxx b/libodb-sqlite/odb/sqlite/connection.cxx new file mode 100644 index 0000000..0445163 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/connection.cxx @@ -0,0 +1,310 @@ +// file : odb/sqlite/connection.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::bad_alloc +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include // deadlock + +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + +using namespace std; + +extern "C" void +odb_sqlite_connection_unlock_callback (void**, int); + +namespace odb +{ + using namespace details; + + namespace sqlite + { + connection:: + connection (connection_factory& cf, + int extra_flags, + statement_translator* st) + : odb::connection (cf), + statement_translator_ (st), + unlock_cond_ (unlock_mutex_), + active_objects_ (0) + { + database_type& db (database ()); + + int f (db.flags () | extra_flags); + const string& n (db.name ()); + + // If we are opening a temporary database, then add the create flag. + // + if (n.empty () || n == ":memory:") + f |= SQLITE_OPEN_CREATE; + + // A connection can only be used by a single thread at a time. So + // disable locking in SQLite unless explicitly requested. + // +#if defined(SQLITE_OPEN_NOMUTEX) + if ((f & SQLITE_OPEN_FULLMUTEX) == 0) + f |= SQLITE_OPEN_NOMUTEX; +#endif + + sqlite3* h (0); + + // sqlite3_open_v2() was only addedin SQLite 3.5.0. + // +#if SQLITE_VERSION_NUMBER >= 3005000 + const string& vfs (db.vfs ()); + int e ( + sqlite3_open_v2 ( + n.c_str (), &h, f, (vfs.empty () ? 0 : vfs.c_str ()))); +#else + // Readonly opening not supported in SQLite earlier than 3.5.0. + // + assert ((f & SQLITE_OPEN_READONLY) == 0); + int e (sqlite3_open (n.c_str (), &h)); +#endif + + handle_.reset (h); + + if (e != SQLITE_OK) + { + if (handle_ == 0) + throw bad_alloc (); + + translate_error (e, *this); + } + + init (); + } + + connection:: + connection (connection_factory& cf, + sqlite3* handle, + statement_translator* st) + : odb::connection (cf), + handle_ (handle), + statement_translator_ (st), + unlock_cond_ (unlock_mutex_), + active_objects_ (0) + { + init (); + } + + void connection:: + init () + { + database_type& db (database ()); + + // Enable/disable foreign key constraints. + // + generic_statement st ( + *this, + db.foreign_keys () + ? "PRAGMA foreign_keys=ON" + : "PRAGMA foreign_keys=OFF", + db.foreign_keys () ? 22 : 23); + st.execute (); + + // String lengths include '\0', as per the SQLite manual suggestion. + // + begin_.reset (new (shared) generic_statement (*this, "BEGIN", 6)); + commit_.reset (new (shared) generic_statement (*this, "COMMIT", 7)); + rollback_.reset (new (shared) generic_statement (*this, "ROLLBACK", 9)); + + // Create statement cache. + // + statement_cache_.reset (new statement_cache_type (*this)); + } + + connection:: + connection (attached_connection_factory& cf, statement_translator* st) + : odb::connection (cf), + handle_ (0), + statement_translator_ (st), + unlock_cond_ (unlock_mutex_), + active_objects_ (0) + { + // Copy some things over from the main connection. + // + connection& main (*cf.main_connection_); + + tracer_ = main.tracer_; + + // Create statement cache. + // + statement_cache_.reset (new statement_cache_type (*this)); + } + + connection:: + ~connection () + { + // Destroy prepared query statements before freeing the connections. + // + recycle (); + clear_prepared_map (); + } + + generic_statement& connection:: + begin_statement () + { + return static_cast (*begin_); + } + + generic_statement& connection:: + begin_immediate_statement () + { + if (!begin_immediate_) + begin_immediate_.reset ( + new (shared) generic_statement (*this, "BEGIN IMMEDIATE", 16)); + + return static_cast (*begin_immediate_); + } + + generic_statement& connection:: + begin_exclusive_statement () + { + if (!begin_exclusive_) + begin_exclusive_.reset ( + new (shared) generic_statement (*this, "BEGIN EXCLUSIVE", 16)); + + return static_cast (*begin_exclusive_); + } + + generic_statement& connection:: + commit_statement () + { + return static_cast (*commit_); + } + + generic_statement& connection:: + rollback_statement () + { + return static_cast (*rollback_); + } + + transaction_impl* connection:: + begin () + { + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::deferred); + } + + transaction_impl* connection:: + begin_immediate () + { + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::immediate); + } + + transaction_impl* connection:: + begin_exclusive () + { + return new transaction_impl ( + connection_ptr (inc_ref (this)), transaction_impl::exclusive); + } + + unsigned long long connection:: + execute (const char* s, std::size_t n) + { + generic_statement st (*this, s, n); + return st.execute (); + } + + inline void + connection_unlock_callback (void** args, int n) + { + for (int i (0); i < n; ++i) + { + connection* c (static_cast (args[i])); + details::lock l (c->unlock_mutex_); + c->unlocked_ = true; + c->unlock_cond_.signal (); + } + } + + void connection:: + wait () + { +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + unlocked_ = false; + + // unlock_notify() returns SQLITE_OK or SQLITE_LOCKED (deadlock). + // + int e (sqlite3_unlock_notify (handle (), + &odb_sqlite_connection_unlock_callback, + this)); + if (e == SQLITE_LOCKED) + throw deadlock (); + + details::lock l (unlock_mutex_); + + while (!unlocked_) + unlock_cond_.wait (l); +#else + translate_error (SQLITE_LOCKED, *this); +#endif + } + + void connection:: + clear () + { + invalidate_results (); + + // The current first active_object may remove itself from the list and + // make the second object (if any) the new first. + // + for (active_object** pp (&active_objects_); *pp != 0; ) + { + active_object* p (*pp); + p->clear (); + + // Move to the next object if this one decided to stay on the list. + // + if (*pp == p) + pp = &p->next_; + } + } + + // connection_factory + // + connection_factory:: + ~connection_factory () + { + } + + void connection_factory:: + database (database_type& db) + { + odb::connection_factory::db_ = &db; + db_ = &db; + } + + void connection_factory:: + attach_database (const connection_ptr& conn, + const std::string& name, + const std::string& schema) + { + conn->execute ("ATTACH DATABASE '" + name + "' AS \"" + schema + '"'); + } + + void connection_factory:: + detach_database (const connection_ptr& conn, const std::string& schema) + { + conn->execute ("DETACH DATABASE \"" + schema + '"'); + } + } +} + +extern "C" void +odb_sqlite_connection_unlock_callback (void** args, int n) +{ + odb::sqlite::connection_unlock_callback (args, n); +} diff --git a/libodb-sqlite/odb/sqlite/connection.hxx b/libodb-sqlite/odb/sqlite/connection.hxx new file mode 100644 index 0000000..dbe4494 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/connection.hxx @@ -0,0 +1,356 @@ +// file : odb/sqlite/connection.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONNECTION_HXX +#define ODB_SQLITE_CONNECTION_HXX + +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class statement_cache; + class generic_statement; + class connection_factory; + class attached_connection_factory; + + class connection; + typedef details::shared_ptr connection_ptr; + + // SQLite "active object", i.e., an object that needs to be + // "cleared" before the transaction can be committed and the + // connection released. These form a doubly-linked list. + // + class LIBODB_SQLITE_EXPORT active_object + { + public: + // This function may remove the object from the list since it may no + // longer be "active". + // + virtual void + clear () = 0; + + protected: + active_object (connection& c): prev_ (0), next_ (this), conn_ (c) {} + + void + list_add (); + + void + list_remove (); + + protected: + friend class connection; + + // prev_ == 0 means we are the first element. + // next_ == 0 means we are the last element. + // next_ == this means we are not on the list (prev_ should be 0). + // + active_object* prev_; + active_object* next_; + + connection& conn_; + }; + + class LIBODB_SQLITE_EXPORT connection: public odb::connection + { + public: + typedef sqlite::statement_cache statement_cache_type; + typedef sqlite::database database_type; + + // Translate the database schema in the statement text (used to + // implement attached databases). If the result is empty, then no + // translation is required and the original text should be used as is. + // + typedef void (statement_translator) (std::string& result, + const char* text, + std::size_t text_size, + connection&); + virtual + ~connection (); + + connection (connection_factory&, + int extra_flags = 0, + statement_translator* = 0); + + connection (connection_factory&, + sqlite3* handle, + statement_translator* = 0); + + // Create an attached connection (see the attached database constructor + // for details). + // + connection (attached_connection_factory&, statement_translator*); + + database_type& + database (); + + // Return the main connection of an attached connection. If this + // connection is main, return itself. + // + connection& + main_connection (); + + static connection_ptr + main_connection (const connection_ptr&); + + public: + virtual transaction_impl* + begin (); + + transaction_impl* + begin_immediate (); + + transaction_impl* + begin_exclusive (); + + public: + using odb::connection::execute; + + virtual unsigned long long + execute (const char* statement, std::size_t length); + + // Query preparation. + // + public: + template + prepared_query + prepare_query (const char* name, const char*); + + template + prepared_query + prepare_query (const char* name, const std::string&); + + template + prepared_query + prepare_query (const char* name, const sqlite::query_base&); + + template + prepared_query + prepare_query (const char* name, const odb::query_base&); + + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::connection::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::connection::tracer (t); + } + + using odb::connection::tracer; + + public: + sqlite3* + handle (); + + statement_cache_type& + statement_cache () + { + return *statement_cache_; + } + + // Wait for the locks to be released via unlock notification. Can + // be called after getting SQLITE_LOCKED_SHAREDCACHE. + // + void + wait (); + + public: + // Reset active statements. Also invalidates query results by first + // calling invalidate_results(). + // + void + clear (); + + public: + // Note: only available on main connection. + // + generic_statement& + begin_statement (); + + generic_statement& + begin_immediate_statement (); + + generic_statement& + begin_exclusive_statement (); + + generic_statement& + commit_statement (); + + generic_statement& + rollback_statement (); + + protected: + friend class attached_connection_factory; + + connection_factory& + factory (); + + private: + connection (const connection&); + connection& operator= (const connection&); + + private: + void + init (); + + private: + // Note that we use NULL handle as an indication of an attached + // connection. + // + auto_handle handle_; + + statement_translator* statement_translator_; + + // Keep statement_cache_ after handle_ so that it is destroyed before + // the connection is closed. + // + details::unique_ptr statement_cache_; + + // Note: using odb::statement in order to break the connection-statement + // dependency cycle. + // + details::shared_ptr begin_; + details::shared_ptr begin_immediate_; + details::shared_ptr begin_exclusive_; + details::shared_ptr commit_; + details::shared_ptr rollback_; + + // Unlock notification machinery. + // + private: + bool unlocked_; + details::mutex unlock_mutex_; + details::condition unlock_cond_; + + friend void + connection_unlock_callback (void**, int); + + private: + friend class statement; // statement_translator_ + friend class transaction_impl; // invalidate_results() + + // Linked list of active objects currently associated + // with this connection. + // + private: + friend class active_object; + active_object* active_objects_; + }; + + class LIBODB_SQLITE_EXPORT connection_factory: + public odb::connection_factory + { + public: + typedef sqlite::database database_type; + + virtual void + database (database_type&); + + database_type& + database () {return *db_;} + + virtual connection_ptr + connect () = 0; + + virtual + ~connection_factory (); + + connection_factory (): db_ (0) {} + + // Attach/detach additional databases. Connection is one of the main + // connections created by this factory. Note: not called for "main" and + // "temp" schemas. + // + // The default implementations simply execute the ATTACH DATABASE and + // DETACH DATABASE SQLite statements. + // + virtual void + attach_database (const connection_ptr&, + const std::string& name, + const std::string& schema); + + virtual void + detach_database (const connection_ptr&, const std::string& schema); + + // Needed to break the circular connection_factory-database dependency + // (odb::connection_factory has the odb::database member). + // + protected: + database_type* db_; + }; + + // The call to database() should cause ATTACH DATABASE (or otherwise make + // sure the database is attached). Destruction of the factory should cause + // DETACH DATABASE (or otherwise notice that this factory no longer needs + // the database attached). + // + // Note that attached_connection_factory is an active object that + // registers itself with the main connection in order to get notified on + // transaction finalization. + // + class LIBODB_SQLITE_EXPORT attached_connection_factory: + public connection_factory, + public active_object + { + public: + explicit + attached_connection_factory (const connection_ptr& main) + : active_object (*main), main_connection_ (main) {} + + virtual void + detach () = 0; + + protected: + friend class database; + friend class connection; + friend class transaction_impl; + + connection_factory& + main_factory (); + + // Note that this essentially establishes a "framework" for all the + // attached connection factory implementations: they hold a counted + // reference to the main connection and they maintain a single shared + // attached connection. + // + connection_ptr main_connection_; + connection_ptr attached_connection_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_CONNECTION_HXX diff --git a/libodb-sqlite/odb/sqlite/connection.ixx b/libodb-sqlite/odb/sqlite/connection.ixx new file mode 100644 index 0000000..094fd52 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/connection.ixx @@ -0,0 +1,108 @@ +// file : odb/sqlite/connection.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // active_object + // + inline void active_object:: + list_add () + { + next_ = conn_.active_objects_; + conn_.active_objects_ = this; + + if (next_ != 0) + next_->prev_ = this; + } + + inline void active_object:: + list_remove () + { + (prev_ == 0 ? conn_.active_objects_ : prev_->next_) = next_; + + if (next_ != 0) + next_->prev_ = prev_; + + prev_ = 0; + next_ = this; + } + + // connection + // + inline database& connection:: + database () + { + return static_cast (factory_).database (); + } + + inline connection& connection:: + main_connection () + { + return handle_ != 0 + ? *this + : *static_cast (factory_).main_connection_; + } + + inline connection_ptr connection:: + main_connection (const connection_ptr& c) + { + return c->handle_ != 0 + ? c + : static_cast (c->factory_).main_connection_; + } + + inline sqlite3* connection:: + handle () + { + return handle_ != 0 + ? handle_ + : static_cast (factory_).main_connection_->handle_; + } + + inline connection_factory& connection:: + factory () + { + return static_cast (factory_); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const char* q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const std::string& q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const sqlite::query_base& q) + { + return query_::call (*this, n, q); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const odb::query_base& q) + { + // Translate to native query. + // + return prepare_query (n, sqlite::query_base (q)); + } + + // attached_connection_factory + // + inline connection_factory& attached_connection_factory:: + main_factory () + { + return main_connection_->factory (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/container-statements.hxx b/libodb-sqlite/odb/sqlite/container-statements.hxx new file mode 100644 index 0000000..b9cccf0 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/container-statements.hxx @@ -0,0 +1,355 @@ +// file : odb/sqlite/container-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX +#define ODB_SQLITE_CONTAINER_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Template argument is the generated abstract container traits type. + // That is, it doesn't need to provide column counts and statements. + // + template + class container_statements + { + public: + typedef T traits; + + typedef typename traits::data_image_type data_image_type; + typedef typename traits::functions_type functions_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef sqlite::connection connection_type; + + container_statements (connection_type&, binding& id_binding); + + connection_type& + connection () + { + return conn_; + } + + // Functions. + // + functions_type& + functions () + { + return functions_; + } + + // Schema version. + // + const schema_version_migration& + version_migration () const {return *svm_;} + + void + version_migration (const schema_version_migration& svm) {svm_ = &svm;} + + // Id image binding (external). + // + const binding& + id_binding () + { + return id_binding_; + } + + // Data image. The image is split into the id (that comes as a + // binding) and index/key plus value which are in data_image_type. + // The select binding is a subset of the full binding (no id). + // + data_image_type& + data_image () + { + return data_image_; + } + + bind* + data_bind () + { + return insert_image_binding_.bind; + } + + bool + data_binding_test_version () const + { + return data_id_binding_version_ != id_binding_.version || + data_image_version_ != data_image_.version || + insert_image_binding_.version == 0; + } + + void + data_binding_update_version () + { + data_id_binding_version_ = id_binding_.version; + data_image_version_ = data_image_.version; + insert_image_binding_.version++; + select_image_binding_.version++; + } + + bool* + select_image_truncated () + { + return select_image_truncated_; + } + + // + // Statements. + // + + insert_statement_type& + insert_statement () + { + if (insert_ == 0) + insert_.reset ( + new (details::shared) insert_statement_type ( + conn_, + insert_text_, + versioned_, // Process if versioned. + insert_image_binding_, + 0)); + + return *insert_; + } + + select_statement_type& + select_statement () + { + if (select_ == 0) + select_.reset ( + new (details::shared) select_statement_type ( + conn_, + select_text_, + versioned_, // Process if versioned. + false, // Don't optimize. + id_binding_, + select_image_binding_)); + + return *select_; + } + + delete_statement_type& + delete_statement () + { + if (delete_ == 0) + delete_.reset ( + new (details::shared) delete_statement_type ( + conn_, delete_text_, id_binding_)); + + return *delete_; + } + + private: + container_statements (const container_statements&); + container_statements& operator= (const container_statements&); + + protected: + connection_type& conn_; + binding& id_binding_; + + functions_type functions_; + + data_image_type data_image_; + std::size_t data_image_version_; + std::size_t data_id_binding_version_; + + binding insert_image_binding_; + + binding select_image_binding_; + bool* select_image_truncated_; + + const char* insert_text_; + const char* select_text_; + const char* delete_text_; + + bool versioned_; + const schema_version_migration* svm_; + + details::shared_ptr insert_; + details::shared_ptr select_; + details::shared_ptr delete_; + }; + + template + class smart_container_statements: public container_statements + { + public: + typedef T traits; + typedef typename traits::cond_image_type cond_image_type; + + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef sqlite::connection connection_type; + + smart_container_statements (connection_type&, binding& id_binding); + + // Condition image. The image is split into the id (that comes as + // a binding) and index/key/value which is in cond_image_type. + // + cond_image_type& + cond_image () + { + return cond_image_; + } + + bind* + cond_bind () + { + return cond_image_binding_.bind; + } + + bool + cond_binding_test_version () const + { + return cond_id_binding_version_ != this->id_binding_.version || + cond_image_version_ != cond_image_.version || + cond_image_binding_.version == 0; + } + + void + cond_binding_update_version () + { + cond_id_binding_version_ = this->id_binding_.version; + cond_image_version_ = cond_image_.version; + cond_image_binding_.version++; + } + + // Update image. The image is split as follows: value comes + // from the data image, id comes as binding, and index/key + // comes from the condition image. + // + bind* + update_bind () + { + return update_image_binding_.bind; + } + + bool + update_binding_test_version () const + { + return update_id_binding_version_ != this->id_binding_.version || + update_cond_image_version_ != cond_image_.version || + update_data_image_version_ != this->data_image_.version || + update_image_binding_.version == 0; + } + + void + update_binding_update_version () + { + update_id_binding_version_ = this->id_binding_.version; + update_cond_image_version_ = cond_image_.version; + update_data_image_version_ = this->data_image_.version; + update_image_binding_.version++; + } + + // + // Statements. + // + + delete_statement_type& + delete_statement () + { + if (this->delete_ == 0) + this->delete_.reset ( + new (details::shared) delete_statement_type ( + this->conn_, + this->delete_text_, + this->cond_image_binding_)); + + return *this->delete_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + update_.reset ( + new (details::shared) update_statement_type ( + this->conn_, + update_text_, + this->versioned_, // Process if versioned. + update_image_binding_)); + + return *update_; + } + + protected: + cond_image_type cond_image_; + std::size_t cond_image_version_; + std::size_t cond_id_binding_version_; + binding cond_image_binding_; + + std::size_t update_id_binding_version_; + std::size_t update_cond_image_version_; + std::size_t update_data_image_version_; + binding update_image_binding_; + + const char* update_text_; + + details::shared_ptr update_; + }; + + // Template argument is the generated concrete container traits type. + // + template + class container_statements_impl: public T::statements_type + { + public: + typedef T traits; + typedef typename T::statements_type base; + typedef sqlite::connection connection_type; + + container_statements_impl (connection_type&, binding&); + + private: + container_statements_impl (const container_statements_impl&); + container_statements_impl& operator= (const container_statements_impl&); + + private: + bind data_image_bind_[traits::data_column_count]; + bool select_image_truncated_array_[traits::data_column_count - + traits::id_column_count]; + }; + + template + class smart_container_statements_impl: public container_statements_impl + { + public: + typedef T traits; + typedef sqlite::connection connection_type; + + smart_container_statements_impl (connection_type&, binding&); + + private: + bind cond_image_bind_[traits::cond_column_count]; + bind update_image_bind_[traits::value_column_count + + traits::cond_column_count]; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/container-statements.txx b/libodb-sqlite/odb/sqlite/container-statements.txx new file mode 100644 index 0000000..6db91f2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/container-statements.txx @@ -0,0 +1,107 @@ +// file : odb/sqlite/container-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +namespace odb +{ + namespace sqlite + { + // container_statements + // + template + container_statements:: + container_statements (connection_type& conn, binding& id) + : conn_ (conn), + id_binding_ (id), + functions_ (this), + insert_image_binding_ (0, 0), // Initialized by impl. + select_image_binding_ (0, 0), // Initialized by impl. + svm_ (0) + { + functions_.insert_ = &traits::insert; + functions_.select_ = &traits::select; + functions_.delete__ = &traits::delete_; + + data_image_.version = 0; + data_image_version_ = 0; + data_id_binding_version_ = 0; + } + + // smart_container_statements + // + template + smart_container_statements:: + smart_container_statements (connection_type& conn, binding& id) + : container_statements (conn, id), + cond_image_binding_ (0, 0), // Initialized by impl. + update_image_binding_ (0, 0) // Initialized by impl. + { + this->functions_.update_ = &traits::update; + + cond_image_.version = 0; + cond_image_version_ = 0; + cond_id_binding_version_ = 0; + + update_id_binding_version_ = 0; + update_cond_image_version_ = 0; + update_data_image_version_ = 0; + } + + // container_statements_impl + // + template + container_statements_impl:: + container_statements_impl (connection_type& conn, binding& id) + : base (conn, id) + { + this->select_image_truncated_ = select_image_truncated_array_; + + this->insert_image_binding_.bind = data_image_bind_; + this->insert_image_binding_.count = traits::data_column_count; + + this->select_image_binding_.bind = data_image_bind_ + + traits::id_column_count; + this->select_image_binding_.count = traits::data_column_count - + traits::id_column_count; + + std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); + std::memset (select_image_truncated_array_, + 0, + sizeof (select_image_truncated_array_)); + + for (std::size_t i (0); + i < traits::data_column_count - traits::id_column_count; + ++i) + data_image_bind_[i + traits::id_column_count].truncated = + select_image_truncated_array_ + i; + + this->insert_text_ = traits::insert_statement; + this->select_text_ = traits::select_statement; + this->delete_text_ = traits::delete_statement; + + this->versioned_ = traits::versioned; + } + + // smart_container_statements_impl + // + template + smart_container_statements_impl:: + smart_container_statements_impl (connection_type& conn, binding& id) + : container_statements_impl (conn, id) + { + this->cond_image_binding_.bind = cond_image_bind_; + this->cond_image_binding_.count = traits::cond_column_count; + + this->update_image_binding_.bind = update_image_bind_; + this->update_image_binding_.count = traits::value_column_count + + traits::cond_column_count; + + std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + + this->update_text_ = traits::update_statement; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/database.cxx b/libodb-sqlite/odb/sqlite/database.cxx new file mode 100644 index 0000000..a7cf098 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/database.cxx @@ -0,0 +1,306 @@ +// file : odb/sqlite/database.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifdef _WIN32 +# include // WideCharToMultiByte +#endif + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + using odb::details::transfer_ptr; + + database:: + ~database () + { + } + + database:: + database (const string& name, + int flags, + bool foreign_keys, + const string& vfs, + transfer_ptr factory) + : odb::database (id_sqlite), + name_ (name), + flags_ (flags), + foreign_keys_ (foreign_keys), + vfs_ (vfs), + factory_ (factory.transfer ()) + { + if (!factory_) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } + +#ifdef _WIN32 + database:: + database (const wstring& name, + int flags, + bool foreign_keys, + const string& vfs, + transfer_ptr factory) + : odb::database (id_sqlite), + flags_ (flags), + foreign_keys_ (foreign_keys), + vfs_ (vfs), + factory_ (factory.transfer ()) + { + // Convert UTF-16 name to UTF-8 using the WideCharToMultiByte() Win32 + // function. + // + int n ( + WideCharToMultiByte ( + CP_UTF8, + 0, + name.c_str (), + static_cast (name.size ()), + 0, + 0, + 0, + 0)); + + if (n == 0) + throw database_exception ( + SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); + + // This string is not shared so we are going to modify the underlying + // buffer directly. + // + name_.resize (static_cast (n)); + + n = WideCharToMultiByte ( + CP_UTF8, + 0, + name.c_str (), + static_cast (name.size ()), + const_cast (name_.c_str ()), + n, + 0, + 0); + + if (n == 0) + throw database_exception ( + SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); + + if (!factory_) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } +#endif + + database:: + database (int& argc, + char* argv[], + bool erase, + int flags, + bool foreign_keys, + const string& vfs, + transfer_ptr factory) + : odb::database (id_sqlite), + flags_ (flags), + foreign_keys_ (foreign_keys), + vfs_ (vfs), + factory_ (factory.transfer ()) + { + using namespace details; + + try + { + cli::argv_file_scanner scan (argc, argv, "--options-file", erase); + options ops (scan, cli::unknown_mode::skip, cli::unknown_mode::skip); + + name_ = ops.database (); + + if (ops.create ()) + flags_ |= SQLITE_OPEN_CREATE; + + if (ops.read_only ()) + flags_ = (flags_ & ~SQLITE_OPEN_READWRITE) | SQLITE_OPEN_READONLY; + } + catch (const cli::exception& e) + { + ostringstream ostr; + ostr << e; + throw cli_exception (ostr.str ()); + } + + if (!factory_) + factory_.reset (new connection_pool_factory ()); + + factory_->database (*this); + } + + database:: + database (const connection_ptr& conn, + const string& name, + const string& schema, + transfer_ptr factory) + : odb::database (id_sqlite), + name_ (name), + schema_ (schema), + flags_ (0), + factory_ (factory.transfer ()) + { + assert (!schema_.empty ()); + + // Copy some things over from the connection's database. + // + database& db (conn->database ()); + + tracer_ = db.tracer_; + foreign_keys_ = db.foreign_keys_; + + if (!factory_) + factory_.reset (new default_attached_connection_factory ( + connection::main_connection (conn))); + + factory_->database (*this); + } + + void database:: + print_usage (ostream& os) + { + details::options::print_usage (os); + } + + transaction_impl* database:: + begin () + { + return new transaction_impl (*this, transaction_impl::deferred); + } + + transaction_impl* database:: + begin_immediate () + { + return new transaction_impl (*this, transaction_impl::immediate); + } + + transaction_impl* database:: + begin_exclusive () + { + return new transaction_impl (*this, transaction_impl::exclusive); + } + + odb::connection* database:: + connection_ () + { + connection_ptr c (factory_->connect ()); + return c.release (); + } + + const database::schema_version_info& database:: + load_schema_version (const string& name) const + { + schema_version_info& svi (schema_version_map_[name]); + + // Construct the SELECT statement text. + // + string text ("SELECT \"version\", \"migration\" FROM "); + + if (!svi.version_table.empty ()) + text += svi.version_table; // Already quoted. + else if (!schema_version_table_.empty ()) + text += schema_version_table_; // Already quoted. + else + text += "\"main\".\"schema_version\""; + + text += " WHERE \"name\" = ?"; + + // Bind parameters and results. + // + size_t psize[1] = {name.size ()}; + bind pbind[1] = {{bind::text, + const_cast (name.c_str ()), + &psize[0], + 0, 0, 0}}; + binding param (pbind, 1); + param.version++; + + long long migration; + bool rnull[2]; + bind rbind[2] = {{bind::integer, &svi.version, 0, 0, &rnull[0], 0}, + {bind::integer, &migration, 0, 0, &rnull[1], 0}}; + binding result (rbind, 2); + result.version++; + + // If we are not in transaction, SQLite will start an implicit one + // which suits us just fine. + // + connection_ptr cp; + if (!transaction::has_current ()) + cp = factory_->connect (); + + sqlite::connection& c ( + cp != 0 + ? *cp + : transaction::current ().connection (const_cast (*this))); + + try + { + select_statement st (c, + text, + false, // Don't process. + false, // Don't optimize. + param, + result); + st.execute (); + auto_result ar (st); + + switch (st.fetch ()) + { + case select_statement::success: + { + svi.migration = migration != 0; + assert (st.fetch () == select_statement::no_data); + break; + } + case select_statement::no_data: + { + svi.version = 0; // No schema. + break; + } + case select_statement::truncated: + { + assert (false); + break; + } + } + } + catch (const database_exception& e) + { + // Try to detect the case where there is no version table. SQLite + // doesn't have an extended error code for this so we have to use + // the error text. + // + if (e.error () == SQLITE_ERROR && + e.message ().compare (0, 14, "no such table:") == 0) + svi.version = 0; // No schema. + else + throw; + } + + return svi; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/database.hxx b/libodb-sqlite/odb/sqlite/database.hxx new file mode 100644 index 0000000..e1e62cc --- /dev/null +++ b/libodb-sqlite/odb/sqlite/database.hxx @@ -0,0 +1,567 @@ +// file : odb/sqlite/database.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DATABASE_HXX +#define ODB_SQLITE_DATABASE_HXX + +#include + +#include + +#include +#include // std::ostream + +#include +#include // ODB_CXX11 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// We use the sqlite3_open_v2() flags in our interface. Define them +// for SQLite earlier that 3.5.0. +// +#if SQLITE_VERSION_NUMBER < 3005000 +# define SQLITE_OPEN_READONLY 0x00000001 +# define SQLITE_OPEN_READWRITE 0x00000002 +# define SQLITE_OPEN_CREATE 0x00000004 +#endif + +namespace odb +{ + namespace sqlite + { + class transaction_impl; + + class LIBODB_SQLITE_EXPORT database: public odb::database + { + public: + database (const std::string& name, + int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, + const std::string& vfs = "", + details::transfer_ptr = + details::transfer_ptr ()); + +#ifdef _WIN32 + database (const std::wstring& name, + int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, + const std::string& vfs = "", + details::transfer_ptr = + details::transfer_ptr ()); +#endif + + // Extract the database parameters from the command line. The + // following options are recognized: + // + // --database + // --create + // --read-only + // --options-file + // + // For more information, see the output of the print_usage() function + // below. If erase is true, the above options are removed from the argv + // array and the argc count is updated accordingly. The command line + // options override the flags passed as an argument. This constructor + // may throw the cli_exception exception. + // + database (int& argc, + char* argv[], + bool erase = false, + int flags = SQLITE_OPEN_READWRITE, + bool foreign_keys = true, + const std::string& vfs = "", + details::transfer_ptr = + details::transfer_ptr ()); + + // Attach to the specified connection a database with the specified name + // as the specified schema. Good understanding of SQLite ATTACH/DETACH + // DATABASE statements semantics and ODB connection management is + // strongly recommended when using this mechanism. + // + // The resulting database instance is referred to as an "attached + // database" and the connection it returns as an "attached connection" + // (which is just a proxy for the main connection). Database operations + // executed on the attached database or attached connection are + // automatically translated to refer to the specified schema rather than + // "main". For uniformity attached databases can also be created for the + // pre-attached "main" and "temp" schemas (in this case name can be + // anything). + // + // The automatic translation of the statements relies on their text + // having references to top-level database entities (tables, indexes, + // etc) qualified with the "main" schema. To achieve this, compile your + // headers with `--schema main` and, if using schema migration, with + // `--schema-version-table main.schema_version`. You must also not use + // "main" as an object/table alias in views of native statements. For + // optimal translation performance use 4-character schema names. + // + // The main connection and attached to it databases and connections are + // all meant to be used within the same thread. In particular, the + // attached database holds a counted reference to the main connection + // which means the connection will not be released until all the + // attached to this connection databases are destroyed. + // + // Note that in this model the attached databases are attached to the + // main connection, not to the (main) database, which mimics the + // underlying semantics of SQLite. An alternative model would have been + // to notionally attach the databases to the main database and under the + // hood automatically attach them to each returned connection. While + // this may seem like a more convenient model in some cases, it is also + // less flexible: the current model allows attaching a different set of + // databases to different connections, attaching them on demand as the + // transaction progresses, etc. Also, the more convenient model can be + // implemented on top of this model by deriving an application-specific + // database class and/or providing custom connection factories. + // + // Note that unless the name is a URI with appropriate mode, it is + // opened with the SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE flags. So if + // you want just SQLITE_OPEN_READWRITE, then you will need to verify its + // existence manually prior to calling this constructor. + // + // Note that attaching/detaching databases withing a transaction is only + // supported since SQLite 3.21.0. + // + database (const connection_ptr&, + const std::string& name, + const std::string& schema, + details::transfer_ptr = + details::transfer_ptr ()); + + // The database is automatically detached on destruction but a failure + // to detach is ignored. To detect such a failure perform explicit + // detach. For uniformity detaching a main database is a no-op. + // + void + detach (); + + // Return the main database of an attached database. If this database + // is main, return itself. + // + database& + main_database (); + + // Move-constructible but not move-assignable. + // + // Note: noexcept is not specified since odb::database(odb::database&&) + // can throw. + // +#ifdef ODB_CXX11 + database (database&&); +#endif + + static void + print_usage (std::ostream&); + + public: + const std::string& + name () const + { + return name_; + } + + // Schema name under which this database was attached or empty for the + // main database. + // + const std::string& + schema () const + { + return schema_; + } + + int + flags () const + { + return flags_; + } + + bool + foreign_keys () const + { + return foreign_keys_; + } + + const std::string& + vfs () const + { + return vfs_; + } + + // Object persistence API. + // + public: + + // Make the object persistent. + // + template + typename object_traits::id_type + persist (T& object); + + template + typename object_traits::id_type + persist (const T& object); + + template + typename object_traits::id_type + persist (T* obj_ptr); + + template class P> + typename object_traits::id_type + persist (const P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (const P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (P& obj_ptr); + + template class P> + typename object_traits::id_type + persist (P& obj_ptr); + + template + typename object_traits::id_type + persist (const typename object_traits::pointer_type& obj_ptr); + + // Load an object. Throw object_not_persistent if not found. + // + template + typename object_traits::pointer_type + load (const typename object_traits::id_type& id); + + template + void + load (const typename object_traits::id_type& id, T& object); + + // Load (or reload, if it is already loaded) a section of an object. + // + template + void + load (T& object, section&); + + // Reload an object. + // + template + void + reload (T& object); + + template + void + reload (T* obj_ptr); + + template class P> + void + reload (const P& obj_ptr); + + template class P> + void + reload (const P& obj_ptr); + + template class P> + void + reload (P& obj_ptr); + + template class P> + void + reload (P& obj_ptr); + + template + void + reload (const typename object_traits::pointer_type& obj_ptr); + + // Loan an object if found. Return NULL/false if not found. + // + template + typename object_traits::pointer_type + find (const typename object_traits::id_type& id); + + template + bool + find (const typename object_traits::id_type& id, T& object); + + // Update the state of a modified objects. + // + template + void + update (T& object); + + template + void + update (T* obj_ptr); + + template class P> + void + update (const P& obj_ptr); + + template class P> + void + update (const P& obj_ptr); + + template class P> + void + update (P& obj_ptr); + + template class P> + void + update (P& obj_ptr); + + template + void + update (const typename object_traits::pointer_type& obj_ptr); + + // Update a section of an object. Throws the section_not_loaded + // exception if the section is not loaded. Note also that this + // function does not clear the changed flag if it is set. + // + template + void + update (const T& object, const section&); + + // Make the object transient. Throw object_not_persistent if not + // found. + // + template + void + erase (const typename object_traits::id_type& id); + + template + void + erase (T& object); + + template + void + erase (T* obj_ptr); + + template class P> + void + erase (const P& obj_ptr); + + template class P> + void + erase (const P& obj_ptr); + + template class P> + void + erase (P& obj_ptr); + + template class P> + void + erase (P& obj_ptr); + + template + void + erase (const typename object_traits::pointer_type& obj_ptr); + + // Erase multiple objects matching a query predicate. + // + template + unsigned long long + erase_query (); + + template + unsigned long long + erase_query (const char*); + + template + unsigned long long + erase_query (const std::string&); + + template + unsigned long long + erase_query (const sqlite::query_base&); + + template + unsigned long long + erase_query (const odb::query_base&); + + // Query API. + // + template + result + query (); + + template + result + query (const char*); + + template + result + query (const std::string&); + + template + result + query (const sqlite::query_base&); + + template + result + query (const odb::query_base&); + + // Query one API. + // + template + typename result::pointer_type + query_one (); + + template + bool + query_one (T& object); + + template + T + query_value (); + + template + typename result::pointer_type + query_one (const char*); + + template + bool + query_one (const char*, T& object); + + template + T + query_value (const char*); + + template + typename result::pointer_type + query_one (const std::string&); + + template + bool + query_one (const std::string&, T& object); + + template + T + query_value (const std::string&); + + template + typename result::pointer_type + query_one (const sqlite::query_base&); + + template + bool + query_one (const sqlite::query_base&, T& object); + + template + T + query_value (const sqlite::query_base&); + + template + typename result::pointer_type + query_one (const odb::query_base&); + + template + bool + query_one (const odb::query_base&, T& object); + + template + T + query_value (const odb::query_base&); + + // Query preparation. + // + template + prepared_query + prepare_query (const char* name, const char*); + + template + prepared_query + prepare_query (const char* name, const std::string&); + + template + prepared_query + prepare_query (const char* name, const sqlite::query_base&); + + template + prepared_query + prepare_query (const char* name, const odb::query_base&); + + // Transactions. + // + public: + virtual transaction_impl* + begin (); + + transaction_impl* + begin_immediate (); + + transaction_impl* + begin_exclusive (); + + public: + connection_ptr + connection (); + + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::database::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::database::tracer (t); + } + + using odb::database::tracer; + + // Database schema version. + // + protected: + virtual const schema_version_info& + load_schema_version (const std::string& schema_name) const; + + // Database id constant (useful for meta-programming). + // + public: + static const odb::database_id database_id = id_sqlite; + + public: + virtual + ~database (); + + protected: + virtual odb::connection* + connection_ (); + + private: + friend class transaction_impl; // factory_ + + // Note: remember to update move ctor if adding any new members. + // + std::string name_; + std::string schema_; + int flags_; + bool foreign_keys_; + std::string vfs_; + + // Note: keep last so that all other database members are still valid + // during factory's destruction. + // + details::unique_ptr factory_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_DATABASE_HXX diff --git a/libodb-sqlite/odb/sqlite/database.ixx b/libodb-sqlite/odb/sqlite/database.ixx new file mode 100644 index 0000000..e906a39 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/database.ixx @@ -0,0 +1,622 @@ +// file : odb/sqlite/database.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // move() + +#include + +namespace odb +{ + namespace sqlite + { +#ifdef ODB_CXX11 + inline database:: + database (database&& db) // Has to be inline. + : odb::database (std::move (db)), + name_ (std::move (db.name_)), + schema_ (std::move (db.schema_)), + flags_ (db.flags_), + foreign_keys_ (db.foreign_keys_), + vfs_ (std::move (db.vfs_)), + factory_ (std::move (db.factory_)) + { + factory_->database (*this); // New database instance. + } +#endif + + inline void database:: + detach () + { + if (!schema_.empty ()) + static_cast (*factory_).detach (); + } + + inline database& database:: + main_database () + { + return schema_.empty () + ? *this + : static_cast (*factory_).main_connection_->database (); + } + + inline connection_ptr database:: + connection () + { + // Go through the virtual connection_() function instead of + // directly to allow overriding. + // + return connection_ptr ( + static_cast (connection_ ())); + } + + template + inline typename object_traits::id_type database:: + persist (T& obj) + { + return persist_ (obj); + } + + template + inline typename object_traits::id_type database:: + persist (const T& obj) + { + return persist_ (obj); + } + + template + inline typename object_traits::id_type database:: + persist (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + return persist_ (pobj); + } + + template class P> + inline typename object_traits::id_type database:: + persist (P& p) + { + const P& cr (p); + return persist (cr); + } + + template class P> + inline typename object_traits::id_type database:: + persist (P& p) + { + const P& cr (p); + return persist (cr); + } + + template + inline typename object_traits::id_type database:: + persist (const typename object_traits::pointer_type& pobj) + { + return persist_ (pobj); + } + + template + inline typename object_traits::pointer_type database:: + load (const typename object_traits::id_type& id) + { + return load_ (id); + } + + template + inline void database:: + load (const typename object_traits::id_type& id, T& obj) + { + return load_ (id, obj); + } + + template + inline void database:: + load (T& obj, section& s) + { + return load_ (obj, s); + } + + template + inline typename object_traits::pointer_type database:: + find (const typename object_traits::id_type& id) + { + return find_ (id); + } + + template + inline bool database:: + find (const typename object_traits::id_type& id, T& obj) + { + return find_ (id, obj); + } + + template + inline void database:: + reload (T& obj) + { + reload_ (obj); + } + + template + inline void database:: + reload (T* p) + { + reload (*p); + } + + template class P> + inline void database:: + reload (const P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (const P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template class P> + inline void database:: + reload (P& p) + { + reload (odb::pointer_traits< P >::get_ref (p)); + } + + template + inline void database:: + reload (const typename object_traits::pointer_type& pobj) + { + typedef typename object_traits::pointer_type pointer_type; + + reload (odb::pointer_traits::get_ref (pobj)); + } + + template + inline void database:: + update (T& obj) + { + update_ (obj); + } + + template + inline void database:: + update (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + update_ (pobj); + } + + template class P> + inline void database:: + update (P& p) + { + const P& cr (p); + update (cr); + } + + template class P> + inline void database:: + update (P& p) + { + const P& cr (p); + update (cr); + } + + template + inline void database:: + update (const typename object_traits::pointer_type& pobj) + { + update_ (pobj); + } + + template + inline void database:: + update (const T& obj, const section& s) + { + update_ (obj, s); + } + + template + inline void database:: + erase (const typename object_traits::id_type& id) + { + return erase_ (id); + } + + template + inline void database:: + erase (T& obj) + { + return erase_ (obj); + } + + template + inline void database:: + erase (T* p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (const P& p) + { + typedef typename object_traits::pointer_type object_pointer; + + // The passed pointer should be the same or implicit-convertible + // to the object pointer. This way we make sure the object pointer + // does not assume ownership of the passed object. + // + const object_pointer& pobj (p); + + erase_ (pobj); + } + + template class P> + inline void database:: + erase (P& p) + { + const P& cr (p); + erase (cr); + } + + template class P> + inline void database:: + erase (P& p) + { + const P& cr (p); + erase (cr); + } + + template + inline void database:: + erase (const typename object_traits::pointer_type& pobj) + { + erase_ (pobj); + } + + template + inline unsigned long long database:: + erase_query () + { + // T is always object_type. + // + return erase_query (sqlite::query_base ()); + } + + template + inline unsigned long long database:: + erase_query (const char* q) + { + // T is always object_type. + // + return erase_query (sqlite::query_base (q)); + } + + template + inline unsigned long long database:: + erase_query (const std::string& q) + { + // T is always object_type. + // + return erase_query (sqlite::query_base (q)); + } + + template + inline unsigned long long database:: + erase_query (const sqlite::query_base& q) + { + // T is always object_type. + // + return object_traits_impl::erase_query (*this, q); + } + + template + inline unsigned long long database:: + erase_query (const odb::query_base& q) + { + // Translate to native query. + // + return erase_query (sqlite::query_base (q)); + } + + template + inline result database:: + query () + { + return query (sqlite::query_base ()); + } + + template + inline result database:: + query (const char* q) + { + return query (sqlite::query_base (q)); + } + + template + inline result database:: + query (const std::string& q) + { + return query (sqlite::query_base (q)); + } + + template + inline result database:: + query (const sqlite::query_base& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_::call (*this, q); + } + + template + inline result database:: + query (const odb::query_base& q) + { + // Translate to native query. + // + return query (sqlite::query_base (q)); + } + + template + inline typename result::pointer_type database:: + query_one () + { + return query_one (sqlite::query_base ()); + } + + template + inline bool database:: + query_one (T& o) + { + return query_one (sqlite::query_base (), o); + } + + template + inline T database:: + query_value () + { + return query_value (sqlite::query_base ()); + } + + template + inline typename result::pointer_type database:: + query_one (const char* q) + { + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const char* q, T& o) + { + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const char* q) + { + return query_value (sqlite::query_base (q)); + } + + template + inline typename result::pointer_type database:: + query_one (const std::string& q) + { + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const std::string& q, T& o) + { + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const std::string& q) + { + return query_value (sqlite::query_base (q)); + } + + template + inline typename result::pointer_type database:: + query_one (const sqlite::query_base& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_one_ (q); + } + + template + inline bool database:: + query_one (const sqlite::query_base& q, T& o) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_one_ (q, o); + } + + template + inline T database:: + query_value (const sqlite::query_base& q) + { + // T is always object_type. We also don't need to check for transaction + // here; object_traits::query () does this. + // + return query_value_ (q); + } + + template + inline typename result::pointer_type database:: + query_one (const odb::query_base& q) + { + // Translate to native query. + // + return query_one (sqlite::query_base (q)); + } + + template + inline bool database:: + query_one (const odb::query_base& q, T& o) + { + // Translate to native query. + // + return query_one (sqlite::query_base (q), o); + } + + template + inline T database:: + query_value (const odb::query_base& q) + { + // Translate to native query. + // + return query_value (sqlite::query_base (q)); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const char* q) + { + return prepare_query (n, sqlite::query_base (q)); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const std::string& q) + { + return prepare_query (n, sqlite::query_base (q)); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const sqlite::query_base& q) + { + // Throws if not in transaction. + // + sqlite::connection& c (transaction::current ().connection (*this)); + return c.prepare_query (n, q); + } + + template + inline prepared_query database:: + prepare_query (const char* n, const odb::query_base& q) + { + // Translate to native query. + // + return prepare_query (n, sqlite::query_base (q)); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/details/.gitignore b/libodb-sqlite/odb/sqlite/details/.gitignore new file mode 100644 index 0000000..b298f89 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/.gitignore @@ -0,0 +1 @@ +/options.?xx diff --git a/libodb-sqlite/odb/sqlite/details/build2/config-stub.h b/libodb-sqlite/odb/sqlite/details/build2/config-stub.h new file mode 100644 index 0000000..34ba8ff --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/build2/config-stub.h @@ -0,0 +1,5 @@ +/* file : odb/sqlite/details/build2/config-stub.h + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/libodb-sqlite/odb/sqlite/details/build2/config-vc-stub.h b/libodb-sqlite/odb/sqlite/details/build2/config-vc-stub.h new file mode 100644 index 0000000..70e3e93 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/build2/config-vc-stub.h @@ -0,0 +1,5 @@ +/* file : odb/sqlite/details/build2/config-vc-stub.h + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/libodb-sqlite/odb/sqlite/details/build2/config-vc.h b/libodb-sqlite/odb/sqlite/details/build2/config-vc.h new file mode 100644 index 0000000..75ce442 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/build2/config-vc.h @@ -0,0 +1,15 @@ +/* file : odb/sqlite/details/build2/config-vc.h + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_VC_H +#define ODB_SQLITE_DETAILS_CONFIG_VC_H + +/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ +#ifndef LIBODB_SQLITE_BUILD2 +# define LIBODB_SQLITE_BUILD2 +#endif + +#endif /* ODB_SQLITE_DETAILS_CONFIG_VC_H */ diff --git a/libodb-sqlite/odb/sqlite/details/build2/config.h b/libodb-sqlite/odb/sqlite/details/build2/config.h new file mode 100644 index 0000000..b4a1a1f --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/build2/config.h @@ -0,0 +1,17 @@ +/* file : odb/sqlite/details/build2/config.h + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. The installed case + (when LIBODB_SQLITE_BUILD2 is not necessarily defined) is the only + reason we have it. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_H +#define ODB_SQLITE_DETAILS_CONFIG_H + +/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ +#ifndef LIBODB_SQLITE_BUILD2 +# define LIBODB_SQLITE_BUILD2 +#endif + +#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/libodb-sqlite/odb/sqlite/details/config-vc.h b/libodb-sqlite/odb/sqlite/details/config-vc.h new file mode 100644 index 0000000..f42c2a0 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/config-vc.h @@ -0,0 +1,5 @@ +/* file : odb/sqlite/details/config-vc.h + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Dummy configuration file for Windows/VC++. */ diff --git a/libodb-sqlite/odb/sqlite/details/config.h.in b/libodb-sqlite/odb/sqlite/details/config.h.in new file mode 100644 index 0000000..a223ecb --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/config.h.in @@ -0,0 +1,14 @@ +/* file : odb/sqlite/details/config.h.in + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* This file is automatically processed by configure. */ + +#ifndef ODB_SQLITE_DETAILS_CONFIG_H +#define ODB_SQLITE_DETAILS_CONFIG_H + +#undef LIBODB_SQLITE_STATIC_LIB +#undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY +#undef LIBODB_SQLITE_HAVE_COLUMN_METADATA + +#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/libodb-sqlite/odb/sqlite/details/config.hxx b/libodb-sqlite/odb/sqlite/details/config.hxx new file mode 100644 index 0000000..4f1c5ce --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/config.hxx @@ -0,0 +1,33 @@ +// file : odb/sqlite/details/config.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_CONFIG_HXX +#define ODB_SQLITE_DETAILS_CONFIG_HXX + +// no pre + +#ifdef ODB_COMPILER +# error libodb-sqlite header included in odb-compiled header +#elif !defined(LIBODB_SQLITE_BUILD2) +# ifdef _MSC_VER +# include +# else +# include +# endif +#endif + +// LIBODB_SQLITE_BUILD2 macro can be defined either by the buildfile or by the +// included odb/sqlite/details/config*.h (see above). +// +#ifdef LIBODB_SQLITE_BUILD2 +# include + +# if SQLITE_VERSION_NUMBER >= 3006012 +# define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1 +# endif +# define LIBODB_SQLITE_HAVE_COLUMN_METADATA 1 +#endif + +// no post + +#endif // ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/libodb-sqlite/odb/sqlite/details/conversion.hxx b/libodb-sqlite/odb/sqlite/details/conversion.hxx new file mode 100644 index 0000000..04843b2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/conversion.hxx @@ -0,0 +1,58 @@ +// file : odb/sqlite/details/conversion.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX +#define ODB_SQLITE_DETAILS_CONVERSION_HXX + +#include + +#include + +namespace odb +{ + // @@ Revise this. + // + namespace details {} + + namespace sqlite + { + namespace details + { + using namespace odb::details; + + // Detect whether conversion is specified in type_traits. + // + template + meta::yes + conversion_p_test (typename type_traits::conversion*); + + template + meta::no + conversion_p_test (...); + + template + struct conversion_p + { + static const bool value = + sizeof (conversion_p_test (0)) == sizeof (meta::yes); + }; + + template ::value> + struct conversion; + + template + struct conversion + { + static const char* to () {return type_traits::conversion::to ();} + }; + + template + struct conversion + { + static const char* to () {return 0;} + }; + } + } +} + +#endif // ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/libodb-sqlite/odb/sqlite/details/export.hxx b/libodb-sqlite/odb/sqlite/details/export.hxx new file mode 100644 index 0000000..c0903ae --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/export.hxx @@ -0,0 +1,86 @@ +// file : odb/sqlite/details/export.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_DETAILS_EXPORT_HXX +#define ODB_SQLITE_DETAILS_EXPORT_HXX + +#include + +#ifdef ODB_COMPILER +# error libodb-sqlite header included in odb-compiled header +#elif !defined(LIBODB_SQLITE_BUILD2) +# ifdef _MSC_VER +# include +# else +# include +# endif +#endif + +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported function being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#ifdef LIBODB_SQLITE_BUILD2 + +#if defined(LIBODB_SQLITE_STATIC) // Using static. +# define LIBODB_SQLITE_EXPORT +#elif defined(LIBODB_SQLITE_STATIC_BUILD) // Building static. +# define LIBODB_SQLITE_EXPORT +#elif defined(LIBODB_SQLITE_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +#elif defined(LIBODB_SQLITE_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared but in case +// of shared will be sub-optimal compared to having dllimport. +// +# define LIBODB_SQLITE_EXPORT // Using static or shared. +#endif + +#else // LIBODB_SQLITE_BUILD2 + +#ifdef LIBODB_SQLITE_STATIC_LIB +# define LIBODB_SQLITE_EXPORT +#else +# ifdef _WIN32 +# ifdef _MSC_VER +# ifdef LIBODB_SQLITE_DYNAMIC_LIB +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# endif +# else +# ifdef LIBODB_SQLITE_DYNAMIC_LIB +# ifdef DLL_EXPORT +# define LIBODB_SQLITE_EXPORT __declspec(dllexport) +# else +# define LIBODB_SQLITE_EXPORT +# endif +# else +# define LIBODB_SQLITE_EXPORT __declspec(dllimport) +# endif +# endif +# else +# define LIBODB_SQLITE_EXPORT +# endif +#endif + +#endif // LIBODB_SQLITE_BUILD2 + +#include + +#endif // ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/libodb-sqlite/odb/sqlite/details/options.cli b/libodb-sqlite/odb/sqlite/details/options.cli new file mode 100644 index 0000000..d1955c3 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/options.cli @@ -0,0 +1,47 @@ +// file : odb/sqlite/details/options.cli +// license : GNU GPL v2; see accompanying LICENSE file + +include ; + +namespace odb +{ + namespace sqlite + { + namespace details + { + class options + { + std::string --database + { + "", + "SQLite database file name. If the database file is not specified + then a private, temporary on-disk database will be created. Use + the \cb{:memory:} special name to create a private, temporary + in-memory database." + }; + + bool --create + { + "Create the SQLite database if it does not already exist. By default + opening the database fails if it does not already exist." + }; + + bool --read-only + { + "Open the SQLite database in read-only mode. By default the database + is opened for reading and writing if possible, or reading only if + the file is write-protected by the operating system." + }; + + std::string --options-file + { + "", + "Read additional options from . Each option should appear on a + separate line optionally followed by space or equal sign (\cb{=}) + and an option value. Empty lines and lines starting with \cb{#} are + ignored." + }; + }; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx new file mode 100644 index 0000000..12f4193 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx @@ -0,0 +1,1027 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + // unknown_option + // + unknown_option:: + ~unknown_option () throw () + { + } + + void unknown_option:: + print (::std::ostream& os) const + { + os << "unknown option '" << option ().c_str () << "'"; + } + + const char* unknown_option:: + what () const throw () + { + return "unknown option"; + } + + // unknown_argument + // + unknown_argument:: + ~unknown_argument () throw () + { + } + + void unknown_argument:: + print (::std::ostream& os) const + { + os << "unknown argument '" << argument ().c_str () << "'"; + } + + const char* unknown_argument:: + what () const throw () + { + return "unknown argument"; + } + + // missing_value + // + missing_value:: + ~missing_value () throw () + { + } + + void missing_value:: + print (::std::ostream& os) const + { + os << "missing value for option '" << option ().c_str () << "'"; + } + + const char* missing_value:: + what () const throw () + { + return "missing option value"; + } + + // invalid_value + // + invalid_value:: + ~invalid_value () throw () + { + } + + void invalid_value:: + print (::std::ostream& os) const + { + os << "invalid value '" << value ().c_str () << "' for option '" + << option ().c_str () << "'"; + + if (!message ().empty ()) + os << ": " << message ().c_str (); + } + + const char* invalid_value:: + what () const throw () + { + return "invalid option value"; + } + + // eos_reached + // + void eos_reached:: + print (::std::ostream& os) const + { + os << what (); + } + + const char* eos_reached:: + what () const throw () + { + return "end of argument stream reached"; + } + + // file_io_failure + // + file_io_failure:: + ~file_io_failure () throw () + { + } + + void file_io_failure:: + print (::std::ostream& os) const + { + os << "unable to open file '" << file ().c_str () << "' or read failure"; + } + + const char* file_io_failure:: + what () const throw () + { + return "unable to open file or read failure"; + } + + // unmatched_quote + // + unmatched_quote:: + ~unmatched_quote () throw () + { + } + + void unmatched_quote:: + print (::std::ostream& os) const + { + os << "unmatched quote in argument '" << argument ().c_str () << "'"; + } + + const char* unmatched_quote:: + what () const throw () + { + return "unmatched quote"; + } + + // scanner + // + scanner:: + ~scanner () + { + } + + // argv_scanner + // + bool argv_scanner:: + more () + { + return i_ < argc_; + } + + const char* argv_scanner:: + peek () + { + if (i_ < argc_) + return argv_[i_]; + else + throw eos_reached (); + } + + const char* argv_scanner:: + next () + { + if (i_ < argc_) + { + const char* r (argv_[i_]); + + if (erase_) + { + for (int i (i_ + 1); i < argc_; ++i) + argv_[i - 1] = argv_[i]; + + --argc_; + argv_[argc_] = 0; + } + else + ++i_; + + ++start_position_; + return r; + } + else + throw eos_reached (); + } + + void argv_scanner:: + skip () + { + if (i_ < argc_) + { + ++i_; + ++start_position_; + } + else + throw eos_reached (); + } + + std::size_t argv_scanner:: + position () + { + return start_position_; + } + + // argv_file_scanner + // + int argv_file_scanner::zero_argc_ = 0; + std::string argv_file_scanner::empty_string_; + + bool argv_file_scanner:: + more () + { + if (!args_.empty ()) + return true; + + while (base::more ()) + { + // See if the next argument is the file option. + // + const char* a (base::peek ()); + const option_info* oi = 0; + const char* ov = 0; + + if (!skip_) + { + if ((oi = find (a)) != 0) + { + base::next (); + + if (!base::more ()) + throw missing_value (a); + + ov = base::next (); + } + else if (std::strncmp (a, "-", 1) == 0) + { + if ((ov = std::strchr (a, '=')) != 0) + { + std::string o (a, 0, ov - a); + if ((oi = find (o.c_str ())) != 0) + { + base::next (); + ++ov; + } + } + } + } + + if (oi != 0) + { + if (oi->search_func != 0) + { + std::string f (oi->search_func (ov, oi->arg)); + + if (!f.empty ()) + load (f); + } + else + load (ov); + + if (!args_.empty ()) + return true; + } + else + { + if (!skip_) + skip_ = (std::strcmp (a, "--") == 0); + + return true; + } + } + + return false; + } + + const char* argv_file_scanner:: + peek () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? base::peek () : args_.front ().value.c_str (); + } + + const std::string& argv_file_scanner:: + peek_file () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? empty_string_ : *args_.front ().file; + } + + std::size_t argv_file_scanner:: + peek_line () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? 0 : args_.front ().line; + } + + const char* argv_file_scanner:: + next () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::next (); + else + { + hold_[i_ == 0 ? ++i_ : --i_].swap (args_.front ().value); + args_.pop_front (); + ++start_position_; + return hold_[i_].c_str (); + } + } + + void argv_file_scanner:: + skip () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::skip (); + else + { + args_.pop_front (); + ++start_position_; + } + } + + const argv_file_scanner::option_info* argv_file_scanner:: + find (const char* a) const + { + for (std::size_t i (0); i < options_count_; ++i) + if (std::strcmp (a, options_[i].option) == 0) + return &options_[i]; + + return 0; + } + + std::size_t argv_file_scanner:: + position () + { + return start_position_; + } + + void argv_file_scanner:: + load (const std::string& file) + { + using namespace std; + + ifstream is (file.c_str ()); + + if (!is.is_open ()) + throw file_io_failure (file); + + files_.push_back (file); + + arg a; + a.file = &*files_.rbegin (); + + for (a.line = 1; !is.eof (); ++a.line) + { + string line; + getline (is, line); + + if (is.fail () && !is.eof ()) + throw file_io_failure (file); + + string::size_type n (line.size ()); + + // Trim the line from leading and trailing whitespaces. + // + if (n != 0) + { + const char* f (line.c_str ()); + const char* l (f + n); + + const char* of (f); + while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) + ++f; + + --l; + + const char* ol (l); + while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) + --l; + + if (f != of || l != ol) + line = f <= l ? string (f, l - f + 1) : string (); + } + + // Ignore empty lines, those that start with #. + // + if (line.empty () || line[0] == '#') + continue; + + string::size_type p (string::npos); + if (line.compare (0, 1, "-") == 0) + { + p = line.find (' '); + + string::size_type q (line.find ('=')); + if (q != string::npos && q < p) + p = q; + } + + string s1; + if (p != string::npos) + { + s1.assign (line, 0, p); + + // Skip leading whitespaces in the argument. + // + if (line[p] == '=') + ++p; + else + { + n = line.size (); + for (++p; p < n; ++p) + { + char c (line[p]); + if (c != ' ' && c != '\t' && c != '\r') + break; + } + } + } + else if (!skip_) + skip_ = (line == "--"); + + string s2 (line, p != string::npos ? p : 0); + + // If the string (which is an option value or argument) is + // wrapped in quotes, remove them. + // + n = s2.size (); + char cf (s2[0]), cl (s2[n - 1]); + + if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') + { + if (n == 1 || cf != cl) + throw unmatched_quote (s2); + + s2 = string (s2, 1, n - 2); + } + + if (!s1.empty ()) + { + // See if this is another file option. + // + const option_info* oi; + if (!skip_ && (oi = find (s1.c_str ()))) + { + if (s2.empty ()) + throw missing_value (oi->option); + + if (oi->search_func != 0) + { + string f (oi->search_func (s2.c_str (), oi->arg)); + if (!f.empty ()) + load (f); + } + else + { + // If the path of the file being parsed is not simple and the + // path of the file that needs to be loaded is relative, then + // complete the latter using the former as a base. + // +#ifndef _WIN32 + string::size_type p (file.find_last_of ('/')); + bool c (p != string::npos && s2[0] != '/'); +#else + string::size_type p (file.find_last_of ("/\\")); + bool c (p != string::npos && s2[1] != ':'); +#endif + if (c) + s2.insert (0, file, 0, p + 1); + + load (s2); + } + + continue; + } + + a.value = s1; + args_.push_back (a); + } + + a.value = s2; + args_.push_back (a); + } + } + + template + struct parser + { + static void + parse (X& x, scanner& s) + { + using namespace std; + + const char* o (s.next ()); + if (s.more ()) + { + string v (s.next ()); + istringstream is (v); + if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + const char* v (s.next ()); + + if (std::strcmp (v, "1") == 0 || + std::strcmp (v, "true") == 0 || + std::strcmp (v, "TRUE") == 0 || + std::strcmp (v, "True") == 0) + x = true; + else if (std::strcmp (v, "0") == 0 || + std::strcmp (v, "false") == 0 || + std::strcmp (v, "FALSE") == 0 || + std::strcmp (v, "False") == 0) + x = false; + else + throw invalid_value (o, v); + } + else + throw missing_value (o); + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + } + }; + + template + struct parser > + { + static void + parse (std::pair& x, scanner& s) + { + x.second = s.position (); + parser::parse (x.first, s); + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, scanner& s) + { + X x; + parser::parse (x, s); + c.push_back (x); + } + }; + + template + struct parser > + { + static void + parse (std::set& c, scanner& s) + { + X x; + parser::parse (x, s); + c.insert (x); + } + }; + + template + struct parser > + { + static void + parse (std::map& m, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::size_t pos (s.position ()); + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); + + int ac (2); + char* av[] = + { + const_cast (o), + 0 + }; + + if (!kstr.empty ()) + { + av[1] = const_cast (kstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (k, s); + } + + if (!vstr.empty ()) + { + av[1] = const_cast (vstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (v, s); + } + + m[k] = v; + } + else + throw missing_value (o); + } + }; + + template + struct parser > + { + static void + parse (std::multimap& m, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::size_t pos (s.position ()); + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); + + int ac (2); + char* av[] = + { + const_cast (o), + 0 + }; + + if (!kstr.empty ()) + { + av[1] = const_cast (kstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (k, s); + } + + if (!vstr.empty ()) + { + av[1] = const_cast (vstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (v, s); + } + + m.insert (typename std::multimap::value_type (k, v)); + } + else + throw missing_value (o); + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + s.next (); + x.*M = true; + } + } + } + } +} + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + // options + // + + options:: + options () + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + } + + options:: + options (int& argc, + char** argv, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int start, + int& argc, + char** argv, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int& argc, + char** argv, + int& end, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (int start, + int& argc, + char** argv, + int& end, + bool erase, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (::odb::sqlite::details::cli::scanner& s, + ::odb::sqlite::details::cli::unknown_mode opt, + ::odb::sqlite::details::cli::unknown_mode arg) + : database_ (), + create_ (), + read_only_ (), + options_file_ () + { + _parse (s, opt, arg); + } + + ::odb::sqlite::details::cli::usage_para options:: + print_usage (::std::ostream& os, ::odb::sqlite::details::cli::usage_para p) + { + CLI_POTENTIALLY_UNUSED (os); + + if (p != ::odb::sqlite::details::cli::usage_para::none) + os << ::std::endl; + + os << "--database SQLite database file name. If the database file is not" << ::std::endl + << " specified then a private, temporary on-disk database will" << ::std::endl + << " be created. Use the :memory: special name to create a" << ::std::endl + << " private, temporary in-memory database." << ::std::endl; + + os << std::endl + << "--create Create the SQLite database if it does not already exist." << ::std::endl + << " By default opening the database fails if it does not" << ::std::endl + << " already exist." << ::std::endl; + + os << std::endl + << "--read-only Open the SQLite database in read-only mode. By default" << ::std::endl + << " the database is opened for reading and writing if" << ::std::endl + << " possible, or reading only if the file is write-protected" << ::std::endl + << " by the operating system." << ::std::endl; + + os << std::endl + << "--options-file Read additional options from . Each option should" << ::std::endl + << " appear on a separate line optionally followed by space or" << ::std::endl + << " equal sign (=) and an option value. Empty lines and lines" << ::std::endl + << " starting with # are ignored." << ::std::endl; + + p = ::odb::sqlite::details::cli::usage_para::option; + + return p; + } + + typedef + std::map + _cli_options_map; + + static _cli_options_map _cli_options_map_; + + struct _cli_options_map_init + { + _cli_options_map_init () + { + _cli_options_map_["--database"] = + &::odb::sqlite::details::cli::thunk< options, std::string, &options::database_ >; + _cli_options_map_["--create"] = + &::odb::sqlite::details::cli::thunk< options, &options::create_ >; + _cli_options_map_["--read-only"] = + &::odb::sqlite::details::cli::thunk< options, &options::read_only_ >; + _cli_options_map_["--options-file"] = + &::odb::sqlite::details::cli::thunk< options, std::string, &options::options_file_ >; + } + }; + + static _cli_options_map_init _cli_options_map_init_; + + bool options:: + _parse (const char* o, ::odb::sqlite::details::cli::scanner& s) + { + _cli_options_map::const_iterator i (_cli_options_map_.find (o)); + + if (i != _cli_options_map_.end ()) + { + (*(i->second)) (*this, s); + return true; + } + + return false; + } + + bool options:: + _parse (::odb::sqlite::details::cli::scanner& s, + ::odb::sqlite::details::cli::unknown_mode opt_mode, + ::odb::sqlite::details::cli::unknown_mode arg_mode) + { + bool r = false; + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + opt = false; + s.skip (); + r = true; + continue; + } + + if (opt) + { + if (_parse (o, s)) + { + r = true; + continue; + } + + if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + // Handle combined option values. + // + std::string co; + if (const char* v = std::strchr (o, '=')) + { + co.assign (o, 0, v - o); + ++v; + + int ac (2); + char* av[] = + { + const_cast (co.c_str ()), + const_cast (v) + }; + + ::odb::sqlite::details::cli::argv_scanner ns (0, ac, av); + + if (_parse (co.c_str (), ns)) + { + // Parsed the option but not its value? + // + if (ns.end () != 2) + throw ::odb::sqlite::details::cli::invalid_value (co, v); + + s.next (); + r = true; + continue; + } + else + { + // Set the unknown option and fall through. + // + o = co.c_str (); + } + } + + switch (opt_mode) + { + case ::odb::sqlite::details::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::odb::sqlite::details::cli::unknown_mode::stop: + { + break; + } + case ::odb::sqlite::details::cli::unknown_mode::fail: + { + throw ::odb::sqlite::details::cli::unknown_option (o); + } + } + + break; + } + } + + switch (arg_mode) + { + case ::odb::sqlite::details::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::odb::sqlite::details::cli::unknown_mode::stop: + { + break; + } + case ::odb::sqlite::details::cli::unknown_mode::fail: + { + throw ::odb::sqlite::details::cli::unknown_argument (o); + } + } + + break; + } + + return r; + } + } + } +} + +// Begin epilogue. +// +// +// End epilogue. + diff --git a/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx new file mode 100644 index 0000000..abc4b3f --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx @@ -0,0 +1,530 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef LIBODB_SQLITE_DETAILS_OPTIONS_HXX +#define LIBODB_SQLITE_DETAILS_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include +#include +#include +#include +#include +#include + +#ifndef CLI_POTENTIALLY_UNUSED +# if defined(_MSC_VER) || defined(__xlC__) +# define CLI_POTENTIALLY_UNUSED(x) (void*)&x +# else +# define CLI_POTENTIALLY_UNUSED(x) (void)x +# endif +#endif + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + class usage_para + { + public: + enum value + { + none, + text, + option + }; + + usage_para (value); + + operator value () const + { + return v_; + } + + private: + value v_; + }; + + class unknown_mode + { + public: + enum value + { + skip, + stop, + fail + }; + + unknown_mode (value); + + operator value () const + { + return v_; + } + + private: + value v_; + }; + + // Exceptions. + // + + class exception: public std::exception + { + public: + virtual void + print (::std::ostream&) const = 0; + }; + + ::std::ostream& + operator<< (::std::ostream&, const exception&); + + class unknown_option: public exception + { + public: + virtual + ~unknown_option () throw (); + + unknown_option (const std::string& option); + + const std::string& + option () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class unknown_argument: public exception + { + public: + virtual + ~unknown_argument () throw (); + + unknown_argument (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + class missing_value: public exception + { + public: + virtual + ~missing_value () throw (); + + missing_value (const std::string& option); + + const std::string& + option () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class invalid_value: public exception + { + public: + virtual + ~invalid_value () throw (); + + invalid_value (const std::string& option, + const std::string& value, + const std::string& message = std::string ()); + + const std::string& + option () const; + + const std::string& + value () const; + + const std::string& + message () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + std::string value_; + std::string message_; + }; + + class eos_reached: public exception + { + public: + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + }; + + class file_io_failure: public exception + { + public: + virtual + ~file_io_failure () throw (); + + file_io_failure (const std::string& file); + + const std::string& + file () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string file_; + }; + + class unmatched_quote: public exception + { + public: + virtual + ~unmatched_quote () throw (); + + unmatched_quote (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (::std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + // Command line argument scanner interface. + // + // The values returned by next() are guaranteed to be valid + // for the two previous arguments up until a call to a third + // peek() or next(). + // + // The position() function returns a monotonically-increasing + // number which, if stored, can later be used to determine the + // relative position of the argument returned by the following + // call to next(). Note that if multiple scanners are used to + // extract arguments from multiple sources, then the end + // position of the previous scanner should be used as the + // start position of the next. + // + class scanner + { + public: + virtual + ~scanner (); + + virtual bool + more () = 0; + + virtual const char* + peek () = 0; + + virtual const char* + next () = 0; + + virtual void + skip () = 0; + + virtual std::size_t + position () = 0; + }; + + class argv_scanner: public scanner + { + public: + argv_scanner (int& argc, + char** argv, + bool erase = false, + std::size_t start_position = 0); + + argv_scanner (int start, + int& argc, + char** argv, + bool erase = false, + std::size_t start_position = 0); + + int + end () const; + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + virtual std::size_t + position (); + + protected: + std::size_t start_position_; + int i_; + int& argc_; + char** argv_; + bool erase_; + }; + + class argv_file_scanner: public argv_scanner + { + public: + argv_file_scanner (int& argc, + char** argv, + const std::string& option, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& option, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (const std::string& file, + const std::string& option, + std::size_t start_position = 0); + + struct option_info + { + // If search_func is not NULL, it is called, with the arg + // value as the second argument, to locate the options file. + // If it returns an empty string, then the file is ignored. + // + const char* option; + std::string (*search_func) (const char*, void* arg); + void* arg; + }; + + argv_file_scanner (int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (int start, + int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase = false, + std::size_t start_position = 0); + + argv_file_scanner (const std::string& file, + const option_info* options = 0, + std::size_t options_count = 0, + std::size_t start_position = 0); + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + virtual std::size_t + position (); + + // Return the file path if the peeked at argument came from a file and + // the empty string otherwise. The reference is guaranteed to be valid + // till the end of the scanner lifetime. + // + const std::string& + peek_file (); + + // Return the 1-based line number if the peeked at argument came from + // a file and zero otherwise. + // + std::size_t + peek_line (); + + private: + const option_info* + find (const char*) const; + + void + load (const std::string& file); + + typedef argv_scanner base; + + const std::string option_; + option_info option_info_; + const option_info* options_; + std::size_t options_count_; + + struct arg + { + std::string value; + const std::string* file; + std::size_t line; + }; + + std::deque args_; + std::list files_; + + // Circular buffer of two arguments. + // + std::string hold_[2]; + std::size_t i_; + + bool skip_; + + static int zero_argc_; + static std::string empty_string_; + }; + + template + struct parser; + } + } + } +} + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + class options + { + public: + options (); + + options (int& argc, + char** argv, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int& argc, + char** argv, + int& end, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + options (::odb::sqlite::details::cli::scanner&, + ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, + ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); + + // Option accessors. + // + const std::string& + database () const; + + const bool& + create () const; + + const bool& + read_only () const; + + const std::string& + options_file () const; + + // Print usage information. + // + static ::odb::sqlite::details::cli::usage_para + print_usage (::std::ostream&, + ::odb::sqlite::details::cli::usage_para = ::odb::sqlite::details::cli::usage_para::none); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::odb::sqlite::details::cli::scanner&); + + private: + bool + _parse (::odb::sqlite::details::cli::scanner&, + ::odb::sqlite::details::cli::unknown_mode option, + ::odb::sqlite::details::cli::unknown_mode argument); + + public: + std::string database_; + bool create_; + bool read_only_; + std::string options_file_; + }; + } + } +} + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // LIBODB_SQLITE_DETAILS_OPTIONS_HXX diff --git a/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx new file mode 100644 index 0000000..54092aa --- /dev/null +++ b/libodb-sqlite/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx @@ -0,0 +1,324 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +#include + +namespace odb +{ + namespace sqlite + { + namespace details + { + namespace cli + { + // usage_para + // + inline usage_para:: + usage_para (value v) + : v_ (v) + { + } + + // unknown_mode + // + inline unknown_mode:: + unknown_mode (value v) + : v_ (v) + { + } + + // exception + // + inline ::std::ostream& + operator<< (::std::ostream& os, const exception& e) + { + e.print (os); + return os; + } + + // unknown_option + // + inline unknown_option:: + unknown_option (const std::string& option) + : option_ (option) + { + } + + inline const std::string& unknown_option:: + option () const + { + return option_; + } + + // unknown_argument + // + inline unknown_argument:: + unknown_argument (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unknown_argument:: + argument () const + { + return argument_; + } + + // missing_value + // + inline missing_value:: + missing_value (const std::string& option) + : option_ (option) + { + } + + inline const std::string& missing_value:: + option () const + { + return option_; + } + + // invalid_value + // + inline invalid_value:: + invalid_value (const std::string& option, + const std::string& value, + const std::string& message) + : option_ (option), + value_ (value), + message_ (message) + { + } + + inline const std::string& invalid_value:: + option () const + { + return option_; + } + + inline const std::string& invalid_value:: + value () const + { + return value_; + } + + inline const std::string& invalid_value:: + message () const + { + return message_; + } + + // file_io_failure + // + inline file_io_failure:: + file_io_failure (const std::string& file) + : file_ (file) + { + } + + inline const std::string& file_io_failure:: + file () const + { + return file_; + } + + // unmatched_quote + // + inline unmatched_quote:: + unmatched_quote (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unmatched_quote:: + argument () const + { + return argument_; + } + + // argv_scanner + // + inline argv_scanner:: + argv_scanner (int& argc, + char** argv, + bool erase, + std::size_t sp) + : start_position_ (sp + 1), + i_ (1), + argc_ (argc), + argv_ (argv), + erase_ (erase) + { + } + + inline argv_scanner:: + argv_scanner (int start, + int& argc, + char** argv, + bool erase, + std::size_t sp) + : start_position_ (sp + static_cast (start)), + i_ (start), + argc_ (argc), + argv_ (argv), + erase_ (erase) + { + } + + inline int argv_scanner:: + end () const + { + return i_; + } + + // argv_file_scanner + // + inline argv_file_scanner:: + argv_file_scanner (int& argc, + char** argv, + const std::string& option, + bool erase, + std::size_t sp) + : argv_scanner (argc, argv, erase, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + } + + inline argv_file_scanner:: + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& option, + bool erase, + std::size_t sp) + : argv_scanner (start, argc, argv, erase, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + } + + inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const std::string& option, + std::size_t sp) + : argv_scanner (0, zero_argc_, 0, sp), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + + load (file); + } + + inline argv_file_scanner:: + argv_file_scanner (int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase, + std::size_t sp) + : argv_scanner (argc, argv, erase, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + } + + inline argv_file_scanner:: + argv_file_scanner (int start, + int& argc, + char** argv, + const option_info* options, + std::size_t options_count, + bool erase, + std::size_t sp) + : argv_scanner (start, argc, argv, erase, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + } + + inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const option_info* options, + std::size_t options_count, + std::size_t sp) + : argv_scanner (0, zero_argc_, 0, sp), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + load (file); + } + } + } + } +} + +namespace odb +{ + namespace sqlite + { + namespace details + { + // options + // + + inline const std::string& options:: + database () const + { + return this->database_; + } + + inline const bool& options:: + create () const + { + return this->create_; + } + + inline const bool& options:: + read_only () const + { + return this->read_only_; + } + + inline const std::string& options:: + options_file () const + { + return this->options_file_; + } + } + } +} + +// Begin epilogue. +// +// +// End epilogue. diff --git a/libodb-sqlite/odb/sqlite/error.cxx b/libodb-sqlite/odb/sqlite/error.cxx new file mode 100644 index 0000000..ae6bbe3 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/error.cxx @@ -0,0 +1,94 @@ +// file : odb/sqlite/error.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include // std::bad_alloc +#include + +#include +#include + +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + +using namespace std; + +namespace odb +{ + namespace sqlite + { + void + translate_error (int e, connection& c) + { + sqlite3* h (c.handle ()); + + // Extended error codes are only available in 3.6.5 and later. + // +#if SQLITE_VERSION_NUMBER >= 3006005 + int ee (sqlite3_extended_errcode (h)); +#else + int ee (0); +#endif + string m; + + switch (e) + { + case SQLITE_NOMEM: + { + throw bad_alloc (); + } + case SQLITE_MISUSE: + { + // In case of SQLITE_MISUSE, error code/message may or may not + // be set. + // + ee = e; + m = "SQLite API misuse"; + break; + } +#ifdef SQLITE_ABORT_ROLLBACK + case SQLITE_ABORT: + { + if (ee == SQLITE_ABORT_ROLLBACK) + throw forced_rollback (); + + break; + } +#endif + case SQLITE_LOCKED: + { +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + if (ee != SQLITE_LOCKED_SHAREDCACHE) + throw deadlock (); // The DROP TABLE special case. +#endif + // Getting SQLITE_LOCKED_SHAREDCACHE here means we don't have + // the unlock notify support. Translate this to timeout. + // + throw timeout (); + } + case SQLITE_BUSY: + case SQLITE_IOERR: + { +#if SQLITE_VERSION_NUMBER >= 3006005 + if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) + throw timeout (); +#endif + break; + } + default: + break; + } + + if (m.empty ()) + m = sqlite3_errmsg (h); + + // Get rid of a trailing newline if there is one. + // + string::size_type n (m.size ()); + if (n != 0 && m[n - 1] == '\n') + m.resize (n - 1); + + throw database_exception (e, ee, m); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/error.hxx b/libodb-sqlite/odb/sqlite/error.hxx new file mode 100644 index 0000000..4646f85 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/error.hxx @@ -0,0 +1,27 @@ +// file : odb/sqlite/error.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_ERROR_HXX +#define ODB_SQLITE_ERROR_HXX + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Translate SQLite error and throw an appropriate exception. + // + LIBODB_SQLITE_EXPORT void + translate_error (int error, connection&); + } +} + +#include + +#endif // ODB_SQLITE_ERROR_HXX diff --git a/libodb-sqlite/odb/sqlite/exceptions.cxx b/libodb-sqlite/odb/sqlite/exceptions.cxx new file mode 100644 index 0000000..0621189 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/exceptions.cxx @@ -0,0 +1,92 @@ +// file : odb/sqlite/exceptions.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + // + // forced_rollback + // + + const char* forced_rollback:: + what () const ODB_NOTHROW_NOEXCEPT + { + return "transaction is forced to rollback"; + } + + forced_rollback* forced_rollback:: + clone () const + { + return new forced_rollback (*this); + } + + // + // database_exception + // + + database_exception:: + ~database_exception () ODB_NOTHROW_NOEXCEPT + { + } + + database_exception:: + database_exception (int e, int ee, const string& m) + : error_ (e), extended_error_ (ee), message_ (m) + { + ostringstream ostr; + ostr << error_; + + if (error_ != extended_error_) + ostr << " (" << extended_error_ << ")"; + + ostr << ": " << message_; + what_ = ostr.str (); + } + + const char* database_exception:: + what () const ODB_NOTHROW_NOEXCEPT + { + return what_.c_str (); + } + + database_exception* database_exception:: + clone () const + { + return new database_exception (*this); + } + + // + // cli_exception + // + + cli_exception:: + cli_exception (const std::string& what) + : what_ (what) + { + } + + cli_exception:: + ~cli_exception () ODB_NOTHROW_NOEXCEPT + { + } + + const char* cli_exception:: + what () const ODB_NOTHROW_NOEXCEPT + { + return what_.c_str (); + } + + cli_exception* cli_exception:: + clone () const + { + return new cli_exception (*this); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/exceptions.hxx b/libodb-sqlite/odb/sqlite/exceptions.hxx new file mode 100644 index 0000000..3adb433 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/exceptions.hxx @@ -0,0 +1,101 @@ +// file : odb/sqlite/exceptions.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_EXCEPTIONS_HXX +#define ODB_SQLITE_EXCEPTIONS_HXX + +#include + +#include + +#include +#include // ODB_NOTHROW_NOEXCEPT + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // This exception is thrown if SQLite is forcing the current transaction + // to rollback. This can happen in SQLite 3.7.11 or later if one of the + // connections participating in the shared cache rolls back a transaction. + // See the SQLITE_ABORT_ROLLBACK extended error code for detail on this + // behavior. + // + struct LIBODB_SQLITE_EXPORT forced_rollback: recoverable + { + virtual const char* + what () const ODB_NOTHROW_NOEXCEPT; + + virtual forced_rollback* + clone () const; + }; + + struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception + { + database_exception (int error, + int extended_error, + const std::string& message); + + ~database_exception () ODB_NOTHROW_NOEXCEPT; + + int + error () const + { + return error_; + } + + int + extended_error () const + { + return extended_error_; + } + + const std::string& + message () const + { + return message_; + } + + virtual const char* + what () const ODB_NOTHROW_NOEXCEPT; + + virtual database_exception* + clone () const; + + private: + int error_; + int extended_error_; + std::string message_; + std::string what_; + }; + + struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception + { + cli_exception (const std::string& what); + ~cli_exception () ODB_NOTHROW_NOEXCEPT; + + virtual const char* + what () const ODB_NOTHROW_NOEXCEPT; + + virtual cli_exception* + clone () const; + + private: + std::string what_; + }; + + namespace core + { + using sqlite::database_exception; + using sqlite::cli_exception; + } + } +} + +#include + +#endif // ODB_SQLITE_EXCEPTIONS_HXX diff --git a/libodb-sqlite/odb/sqlite/forward.hxx b/libodb-sqlite/odb/sqlite/forward.hxx new file mode 100644 index 0000000..1be05b4 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/forward.hxx @@ -0,0 +1,112 @@ +// file : odb/sqlite/forward.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_FORWARD_HXX +#define ODB_SQLITE_FORWARD_HXX + +#include + +#include + +namespace odb +{ + namespace sqlite + { + namespace core + { + using namespace odb::common; + } + + // + // + class database; + class connection; + typedef details::shared_ptr connection_ptr; + class connection_factory; + class statement; + class transaction; + class tracer; + + namespace core + { + using sqlite::database; + using sqlite::connection; + using sqlite::connection_ptr; + using sqlite::transaction; + using sqlite::statement; + } + + // Implementation details. + // + enum database_type_id + { + id_integer, + id_real, + id_text, + id_blob, + id_text_stream, + id_blob_stream + }; + + template + struct default_value_traits; + + enum statement_kind + { + statement_select, + statement_insert, + statement_update, + statement_delete, + statement_generic + }; + + class binding; + class select_statement; + + template + class object_statements; + + template + class polymorphic_root_object_statements; + + template + class polymorphic_derived_object_statements; + + template + class no_id_object_statements; + + template + class view_statements; + + template + class container_statements; + + template + class smart_container_statements; + + template + class section_statements; + + class query_base; + class query_params; + } + + namespace details + { + template <> + struct counter_type + { + typedef shared_base counter; + }; + + template <> + struct counter_type + { + typedef shared_base counter; + }; + } +} + +#include + +#endif // ODB_SQLITE_FORWARD_HXX diff --git a/libodb-sqlite/odb/sqlite/no-id-object-result.hxx b/libodb-sqlite/odb/sqlite/no-id-object-result.hxx new file mode 100644 index 0000000..b0edb09 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/no-id-object-result.hxx @@ -0,0 +1,80 @@ +// file : odb/sqlite/no-id-object-result.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX +#define ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include // query_base, query_params +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class no_id_object_result_impl: public odb::no_id_object_result_impl + { + public: + typedef odb::no_id_object_result_impl base_type; + + typedef typename base_type::object_type object_type; + typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~no_id_object_result_impl (); + + no_id_object_result_impl (const query_base&, + const details::shared_ptr&, + statements_type&, + const schema_version_migration*); + + virtual void + load (object_type&); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + virtual void + invalidate (); + + using base_type::current; + + private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; + statements_type& statements_; + object_traits_calls tc_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/libodb-sqlite/odb/sqlite/no-id-object-result.txx b/libodb-sqlite/odb/sqlite/no-id-object-result.txx new file mode 100644 index 0000000..bd26afc --- /dev/null +++ b/libodb-sqlite/odb/sqlite/no-id-object-result.txx @@ -0,0 +1,114 @@ +// file : odb/sqlite/no-id-object-result.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + no_id_object_result_impl:: + ~no_id_object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + void no_id_object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template + no_id_object_result_impl:: + no_id_object_result_impl (const query_base& q, + const details::shared_ptr& s, + statements_type& sts, + const schema_version_migration* svm) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts), + tc_ (svm) + { + } + + template + void no_id_object_result_impl:: + load (object_type& obj) + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + tc_.bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (tc_.grow (im, statements_.select_image_truncated ())) + im.version++; + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + tc_.bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + statement_->reload (); + } + } + + object_traits::callback (this->db_, obj, callback_event::pre_load); + tc_.init (obj, im, &this->db_); + object_traits::callback (this->db_, obj, callback_event::post_load); + } + + template + void no_id_object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + void no_id_object_result_impl:: + cache () + { + } + + template + std::size_t no_id_object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/no-id-object-statements.hxx b/libodb-sqlite/odb/sqlite/no-id-object-statements.hxx new file mode 100644 index 0000000..7a0376a --- /dev/null +++ b/libodb-sqlite/odb/sqlite/no-id-object-statements.hxx @@ -0,0 +1,136 @@ +// file : odb/sqlite/no-id-object-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // Implementation for objects without object id. + // + + template + class no_id_object_statements: public statements_base + { + public: + typedef T object_type; + typedef object_traits_impl object_traits; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + + typedef sqlite::insert_statement insert_statement_type; + + public: + no_id_object_statements (connection_type&); + + virtual + ~no_id_object_statements (); + + // Object image. + // + image_type& + image () {return image_;} + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + object_traits::versioned, // Process if versioned. + insert_image_binding_, + 0)); + } + + return *persist_; + } + + public: + // select = total + // insert = total - inverse; inverse == 0 for object without id + // + static const std::size_t insert_column_count = + object_traits::column_count; + + static const std::size_t select_column_count = + object_traits::column_count; + + private: + no_id_object_statements (const no_id_object_statements&); + no_id_object_statements& operator= (const no_id_object_statements&); + + private: + image_type image_; + + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. + // + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + details::shared_ptr persist_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/no-id-object-statements.txx b/libodb-sqlite/odb/sqlite/no-id-object-statements.txx new file mode 100644 index 0000000..d0a62b2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/no-id-object-statements.txx @@ -0,0 +1,36 @@ +// file : odb/sqlite/no-id-object-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + no_id_object_statements:: + ~no_id_object_statements () + { + } + + template + no_id_object_statements:: + no_id_object_statements (connection_type& conn) + : statements_base (conn), + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count) + { + image_.version = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/polymorphic-object-result.hxx b/libodb-sqlite/odb/sqlite/polymorphic-object-result.hxx new file mode 100644 index 0000000..3239471 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/polymorphic-object-result.hxx @@ -0,0 +1,98 @@ +// file : odb/sqlite/polymorphic-object-result.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX +#define ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include // query_base, query_params +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class polymorphic_object_result_impl: + public odb::polymorphic_object_result_impl + { + public: + typedef odb::polymorphic_object_result_impl base_type; + + typedef typename base_type::id_type id_type; + typedef typename base_type::object_type object_type; + typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename base_type::root_type root_type; + typedef typename base_type::discriminator_type discriminator_type; + + typedef object_traits_impl root_traits; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~polymorphic_object_result_impl (); + + polymorphic_object_result_impl ( + const query_base&, + const details::shared_ptr&, + statements_type&, + const schema_version_migration*); + + virtual void + load (object_type*, bool fetch); + + virtual id_type + load_id (); + + virtual discriminator_type + load_discriminator (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + virtual void + invalidate (); + + using base_type::current; + + private: + void + load_image (); + + private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; + statements_type& statements_; + object_traits_calls tc_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/libodb-sqlite/odb/sqlite/polymorphic-object-result.txx b/libodb-sqlite/odb/sqlite/polymorphic-object-result.txx new file mode 100644 index 0000000..bd22f01 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/polymorphic-object-result.txx @@ -0,0 +1,287 @@ +// file : odb/sqlite/polymorphic-object-result.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + polymorphic_object_result_impl:: + ~polymorphic_object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + void polymorphic_object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template + polymorphic_object_result_impl:: + polymorphic_object_result_impl ( + const query_base& q, + const details::shared_ptr& s, + statements_type& sts, + const schema_version_migration* svm) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts), + tc_ (svm) + { + } + + template + void polymorphic_object_result_impl:: + load (object_type* pobj, bool fetch) + { + if (fetch) + load_image (); + + typename statements_type::root_statements_type& rsts ( + statements_.root_statements ()); + + // This is a top-level call so the statements cannot be locked. + // + assert (!rsts.locked ()); + typename statements_type::auto_lock l (rsts); + + typename object_traits::image_type& i (statements_.image ()); + typename root_traits::image_type& ri (rsts.image ()); + + id_type id (root_traits::id (ri)); + + // Determine this object's dynamic type. + // + typedef typename root_traits::info_type info_type; + discriminator_type d (root_traits::discriminator (ri)); + discriminator_type disc (d); + + // Use the polymorphic_info() helper to get concrete_info if + // object_type is concrete and NULL if it is abstract. + // + const info_type* spi (polymorphic_info (object_traits::info)); + const info_type& pi ( + spi != 0 && spi->discriminator == d + ? *spi + : root_traits::map->find (d)); + + typedef typename root_traits::pointer_type root_pointer_type; + typedef typename root_traits::pointer_traits root_pointer_traits; + + typename object_traits::pointer_cache_traits::insert_guard ig; + + if (pobj == 0) + { + // Need to create a new instance of the dynamic type. + // + root_pointer_type rp (pi.create ()); + pointer_type p ( + root_pointer_traits::template static_pointer_cast (rp)); + + // Insert it as a root pointer (for non-unique pointers, rp should + // still be valid and for unique pointers this is a no-op). + // + ig.reset ( + object_traits::pointer_cache_traits::insert (this->db_, id, rp)); + + pobj = &pointer_traits::get_ref (p); + current (p); + } + else + { + // We are loading into an existing instance. If the static and + // dynamic types differ, then make sure the instance is at least + // of the dynamic type. + // + if (&pi != &object_traits::info) + { + const info_type& dpi (root_traits::map->find (typeid (*pobj))); + + if (&dpi != &pi && dpi.derived (pi)) + throw object_not_persistent (); // @@ type_mismatch ? + } + } + + callback_event ce (callback_event::pre_load); + pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); + + tc_.init (*pobj, i, &this->db_); + + // Initialize the id image and binding and load the rest of the object + // (containers, dynamic part, etc). + // + typename object_traits::id_image_type& idi (statements_.id_image ()); + root_traits::init (idi, id); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + + tc_.load_ (statements_, *pobj, false); + + // Load the dynamic part of the object unless static and dynamic + // types are the same. + // + if (&pi != &object_traits::info) + { + std::size_t d (object_traits::depth); + pi.dispatch (info_type::call_load, this->db_, pobj, &d); + }; + + rsts.load_delayed (tc_.version ()); + l.unlock (); + + ce = callback_event::post_load; + pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); + object_traits::pointer_cache_traits::load (ig.position ()); + ig.release (); + } + + template + typename polymorphic_object_result_impl::id_type + polymorphic_object_result_impl:: + load_id () + { + load_image (); + return root_traits::id (statements_.root_statements ().image ()); + } + + template + typename polymorphic_object_result_impl::discriminator_type + polymorphic_object_result_impl:: + load_discriminator () + { + load_image (); + return root_traits::discriminator ( + statements_.root_statements ().image ()); + } + + template + void polymorphic_object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + struct polymorphic_image_rebind + { + // Derived type version. + // + typedef object_traits_impl traits; + + static bool + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) + { + typename traits::image_type& im (sts.image ()); + + if (traits::check_version (sts.select_image_versions (), im)) + { + binding& b (sts.select_image_binding (traits::depth)); + object_traits_calls tc (svm); + tc.bind (b.bind, 0, 0, im, statement_select); + traits::update_version ( + sts.select_image_versions (), im, sts.select_image_bindings ()); + return true; + } + + return false; + } + }; + + template + struct polymorphic_image_rebind + { + // Root type version. + // + typedef object_traits_impl traits; + + static bool + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) + { + typename traits::image_type& im (sts.image ()); + + if (im.version != sts.select_image_version ()) + { + binding& b (sts.select_image_binding ()); + object_traits_calls tc (svm); + tc.bind (b.bind, im, statement_select); + sts.select_image_version (im.version); + b.version++; + return true; + } + + return false; + } + }; + + template + void polymorphic_object_result_impl:: + load_image () + { + typedef polymorphic_image_rebind image_rebind; + + // The image can grow between calls to load() as a result of other + // statements execution. + // + image_rebind::rebind (statements_, tc_.version ()); + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + typename object_traits::image_type& im (statements_.image ()); + + if (tc_.grow (im, statements_.select_image_truncated ())) + im.version++; + + if (image_rebind::rebind (statements_, tc_.version ())) + statement_->reload (); + } + } + + template + void polymorphic_object_result_impl:: + cache () + { + } + + template + std::size_t polymorphic_object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/polymorphic-object-statements.hxx b/libodb-sqlite/odb/sqlite/polymorphic-object-statements.hxx new file mode 100644 index 0000000..736686b --- /dev/null +++ b/libodb-sqlite/odb/sqlite/polymorphic-object-statements.hxx @@ -0,0 +1,479 @@ +// file : odb/sqlite/polymorphic-object-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // Implementation for polymorphic objects. + // + + template + class polymorphic_root_object_statements: public object_statements + { + public: + typedef typename object_statements::connection_type connection_type; + typedef typename object_statements::object_traits object_traits; + typedef typename object_statements::id_image_type id_image_type; + + typedef + typename object_traits::discriminator_image_type + discriminator_image_type; + + typedef + typename object_statements::select_statement_type + select_statement_type; + + public: + // Interface compatibility with derived_object_statements. + // + typedef polymorphic_root_object_statements root_statements_type; + + root_statements_type& + root_statements () + { + return *this; + } + + public: + // Discriminator binding. + // + discriminator_image_type& + discriminator_image () {return discriminator_image_;} + + std::size_t + discriminator_image_version () const + {return discriminator_image_version_;} + + void + discriminator_image_version (std::size_t v) + {discriminator_image_version_ = v;} + + binding& + discriminator_image_binding () {return discriminator_image_binding_;} + + bool* + discriminator_image_truncated () {return discriminator_image_truncated_;} + + // Id binding for discriminator retrieval. + // + id_image_type& + discriminator_id_image () {return discriminator_id_image_;} + + std::size_t + discriminator_id_image_version () const + {return discriminator_id_image_version_;} + + void + discriminator_id_image_version (std::size_t v) + {discriminator_id_image_version_ = v;} + + binding& + discriminator_id_image_binding () + {return discriminator_id_image_binding_;} + + // + // + select_statement_type& + find_discriminator_statement () + { + if (find_discriminator_ == 0) + { + find_discriminator_.reset ( + new (details::shared) select_statement_type ( + this->conn_, + object_traits::find_discriminator_statement, + false, // Doesn't need to be processed. + false, // Don't optimize. + discriminator_id_image_binding_, + discriminator_image_binding_)); + } + + return *find_discriminator_; + } + + public: + polymorphic_root_object_statements (connection_type&); + + virtual + ~polymorphic_root_object_statements (); + + // Static "override" (statements type). + // + void + load_delayed (const schema_version_migration* svm) + { + assert (this->locked ()); + + if (!this->delayed_.empty ()) + this->template load_delayed_ ( + svm); + } + + public: + static const std::size_t id_column_count = + object_statements::id_column_count; + + static const std::size_t discriminator_column_count = + object_traits::discriminator_column_count; + + static const std::size_t managed_optimistic_column_count = + object_traits::managed_optimistic_column_count; + + private: + // Discriminator image. + // + discriminator_image_type discriminator_image_; + std::size_t discriminator_image_version_; + binding discriminator_image_binding_; + bind discriminator_image_bind_[discriminator_column_count + + managed_optimistic_column_count]; + bool discriminator_image_truncated_[discriminator_column_count + + managed_optimistic_column_count]; + + // Id image for discriminator retrieval (only used as a parameter). + // + id_image_type discriminator_id_image_; + std::size_t discriminator_id_image_version_; + binding discriminator_id_image_binding_; + bind discriminator_id_image_bind_[id_column_count]; + + details::shared_ptr find_discriminator_; + }; + + template + class polymorphic_derived_object_statements: public statements_base + { + public: + typedef T object_type; + typedef object_traits_impl object_traits; + typedef typename object_traits::id_type id_type; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::id_image_type id_image_type; + typedef typename object_traits::image_type image_type; + + typedef typename object_traits::root_type root_type; + typedef + polymorphic_root_object_statements + root_statements_type; + + typedef typename object_traits::base_type base_type; + typedef + typename object_traits::base_traits::statements_type + base_statements_type; + + typedef + typename object_traits::extra_statement_cache_type + extra_statement_cache_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + typedef typename root_statements_type::auto_lock auto_lock; + + public: + polymorphic_derived_object_statements (connection_type&); + + virtual + ~polymorphic_derived_object_statements (); + + public: + // Delayed loading. + // + static void + delayed_loader (odb::database&, + const id_type&, + root_type&, + const schema_version_migration*); + + public: + // Root and immediate base statements. + // + root_statements_type& + root_statements () + { + return root_statements_; + } + + base_statements_type& + base_statements () + { + return base_statements_; + } + + public: + // Object image. + // + image_type& + image () + { + return image_; + } + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + std::size_t + insert_id_binding_version () const { return insert_id_binding_version_;} + + void + insert_id_binding_version (std::size_t v) {insert_id_binding_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_binding_version () const { return update_id_binding_version_;} + + void + update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // Select binding. + // + std::size_t* + select_image_versions () { return select_image_versions_;} + + binding* + select_image_bindings () {return select_image_bindings_;} + + binding& + select_image_binding (std::size_t d) + { + return select_image_bindings_[object_traits::depth - d]; + } + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Object id binding (comes from the root statements). + // + id_image_type& + id_image () {return root_statements_.id_image ();} + + std::size_t + id_image_version () const {return root_statements_.id_image_version ();} + + void + id_image_version (std::size_t v) {root_statements_.id_image_version (v);} + + binding& + id_image_binding () {return root_statements_.id_image_binding ();} + + binding& + optimistic_id_image_binding () { + return root_statements_.optimistic_id_image_binding ();} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + object_traits::versioned, // Process if versioned. + insert_image_binding_, + 0)); + } + + return *persist_; + } + + select_statement_type& + find_statement (std::size_t d) + { + std::size_t i (object_traits::depth - d); + details::shared_ptr& p (find_[i]); + + if (p == 0) + { + p.reset ( + new (details::shared) select_statement_type ( + conn_, + object_traits::find_statements[i], + object_traits::versioned, // Process if versioned. + false, // Don't optimize. + root_statements_.id_image_binding (), + select_image_bindings_[i])); + } + + return *p; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + { + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + object_traits::update_statement, + object_traits::versioned, // Process if versioned. + update_image_binding_)); + } + + return *update_; + } + + delete_statement_type& + erase_statement () + { + if (erase_ == 0) + { + erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::erase_statement, + root_statements_.id_image_binding ())); + } + + return *erase_; + } + + // Extra (container, section) statement cache. + // + extra_statement_cache_type& + extra_statement_cache () + { + return extra_statement_cache_.get ( + conn_, + image_, + id_image (), + id_image_binding (), + &id_image_binding ()); // Note, not id+version. + } + + public: + // select = total - id - separate_load + base::select + // insert = total - inverse + // update = total - inverse - id - readonly - separate_update + // + static const std::size_t id_column_count = + object_traits::id_column_count; + + static const std::size_t select_column_count = + object_traits::column_count - + id_column_count - + object_traits::separate_load_column_count + + base_statements_type::select_column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - + object_traits::inverse_column_count; + + static const std::size_t update_column_count = insert_column_count - + object_traits::id_column_count - + object_traits::readonly_column_count - + object_traits::separate_update_column_count; + + private: + polymorphic_derived_object_statements ( + const polymorphic_derived_object_statements&); + + polymorphic_derived_object_statements& + operator= (const polymorphic_derived_object_statements&); + + private: + root_statements_type& root_statements_; + base_statements_type& base_statements_; + + extra_statement_cache_ptr extra_statement_cache_; + + image_type image_; + + // Select binding. Here we are have an array of statements/bindings + // one for each depth. In other words, if we have classes root, base, + // and derived, then we have the following array of statements: + // + // [0] d + b + r + // [1] d + b + // [2] d + // + // Also, because we have a chain of images bound to these statements, + // we have an array of versions, one entry for each base plus one for + // our own image. + // + // A poly-abstract class only needs the first statement and in this + // case we have only one entry in the the bindings and statements + // arrays (but not versions; we still have a chain of images). + // + std::size_t select_image_versions_[object_traits::depth]; + binding select_image_bindings_[ + object_traits::abstract ? 1 : object_traits::depth]; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. The id binding is copied from the hierarchy root. + // + std::size_t insert_image_version_; + std::size_t insert_id_binding_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + // Update binding. The id suffix binding is copied from the hierarchy + // root. + // + std::size_t update_image_version_; + std::size_t update_id_binding_version_; + binding update_image_binding_; + bind update_image_bind_[update_column_count + id_column_count]; + + details::shared_ptr persist_; + details::shared_ptr find_[ + object_traits::abstract ? 1 : object_traits::depth]; + details::shared_ptr update_; + details::shared_ptr erase_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/polymorphic-object-statements.txx b/libodb-sqlite/odb/sqlite/polymorphic-object-statements.txx new file mode 100644 index 0000000..6a376d3 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/polymorphic-object-statements.txx @@ -0,0 +1,145 @@ +// file : odb/sqlite/polymorphic-object-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // polymorphic_root_object_statements + // + + template + polymorphic_root_object_statements:: + ~polymorphic_root_object_statements () + { + } + + template + polymorphic_root_object_statements:: + polymorphic_root_object_statements (connection_type& conn) + : object_statements (conn), + discriminator_image_binding_ (discriminator_image_bind_, + discriminator_column_count + + managed_optimistic_column_count), + discriminator_id_image_binding_ (discriminator_id_image_bind_, + id_column_count) + { + discriminator_image_.version = 0; + discriminator_id_image_.version = 0; + + discriminator_image_version_ = 0; + discriminator_id_image_version_ = 0; + + std::memset (discriminator_image_bind_, + 0, + sizeof (discriminator_image_bind_)); + std::memset (discriminator_id_image_bind_, + 0, + sizeof (discriminator_id_image_bind_)); + std::memset (discriminator_image_truncated_, + 0, + sizeof (discriminator_image_truncated_)); + + for (std::size_t i (0); + i < discriminator_column_count + managed_optimistic_column_count; + ++i) + { + discriminator_image_bind_[i].truncated = + discriminator_image_truncated_ + i; + } + } + + // + // polymorphic_derived_object_statements + // + + template + polymorphic_derived_object_statements:: + ~polymorphic_derived_object_statements () + { + } + + template + polymorphic_derived_object_statements:: + polymorphic_derived_object_statements (connection_type& conn) + : statements_base (conn), + root_statements_ (conn.statement_cache ().find_object ()), + base_statements_ (conn.statement_cache ().find_object ()), + insert_image_binding_ (insert_image_bind_, insert_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count) + { + image_.base = &base_statements_.image (); + image_.version = 0; + + for (std::size_t i (0); i < object_traits::depth; ++i) + select_image_versions_[i] = 0; + + for (std::size_t i (0); + i < (object_traits::abstract ? 1 : object_traits::depth); + ++i) + { + select_image_bindings_[i].bind = select_image_bind_; + select_image_bindings_[i].count = object_traits::find_column_counts[i]; + } + + insert_image_version_ = 0; + insert_id_binding_version_ = 0; + update_image_version_ = 0; + update_id_binding_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + + template + void polymorphic_derived_object_statements:: + delayed_loader (odb::database& db, + const id_type& id, + root_type& robj, + const schema_version_migration* svm) + { + connection_type& conn (transaction::current ().connection (db)); + polymorphic_derived_object_statements& sts ( + conn.statement_cache ().find_object ()); + root_statements_type& rsts (sts.root_statements ()); + + object_type& obj (static_cast (robj)); + + // The same code as in object_statements::load_delayed_(). + // + object_traits_calls tc (svm); + + if (!tc.find_ (sts, &id)) + throw object_not_persistent (); + + object_traits::callback (db, obj, callback_event::pre_load); + tc.init (obj, sts.image (), &db); + tc.load_ (sts, obj, false); // Load containers, etc. + + rsts.load_delayed (svm); + + { + typename root_statements_type::auto_unlock u (rsts); + object_traits::callback (db, obj, callback_event::post_load); + } + } + } +} diff --git a/libodb-sqlite/odb/sqlite/prepared-query.cxx b/libodb-sqlite/odb/sqlite/prepared-query.cxx new file mode 100644 index 0000000..79df0f2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/prepared-query.cxx @@ -0,0 +1,27 @@ +// file : odb/sqlite/prepared-query.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include + +namespace odb +{ + namespace sqlite + { + prepared_query_impl:: + ~prepared_query_impl () + { + } + + bool prepared_query_impl:: + verify_connection (odb::transaction& t) + { + // The transaction can be started using the main database of any of the + // attached databases. So we verify the main connections match. + // + return &static_cast (t.connection ()).main_connection () == + &static_cast (stmt->connection ()).main_connection (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/prepared-query.hxx b/libodb-sqlite/odb/sqlite/prepared-query.hxx new file mode 100644 index 0000000..a8873a5 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/prepared-query.hxx @@ -0,0 +1,37 @@ +// file : odb/sqlite/prepared-query.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_PREPARED_QUERY_HXX +#define ODB_SQLITE_PREPARED_QUERY_HXX + +#include + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + struct LIBODB_SQLITE_EXPORT prepared_query_impl: odb::prepared_query_impl + { + virtual + ~prepared_query_impl (); + + prepared_query_impl (odb::connection& c): odb::prepared_query_impl (c) {} + + virtual bool + verify_connection (odb::transaction&); + + sqlite::query_base query; + }; + } +} + +#include + +#endif // ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/libodb-sqlite/odb/sqlite/query-const-expr.cxx b/libodb-sqlite/odb/sqlite/query-const-expr.cxx new file mode 100644 index 0000000..c8eaec7 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query-const-expr.cxx @@ -0,0 +1,14 @@ +// file : odb/sqlite/query-const-expr.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + // Sun CC cannot handle this in query.cxx. + // + const query_base query_base::true_expr (true); + } +} diff --git a/libodb-sqlite/odb/sqlite/query-dynamic.cxx b/libodb-sqlite/odb/sqlite/query-dynamic.cxx new file mode 100644 index 0000000..8089aed --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query-dynamic.cxx @@ -0,0 +1,157 @@ +// file : odb/sqlite/query-dynamic.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + static const char* logic_operators[] = {") AND (", ") OR ("}; + static const char* comp_operators[] = {"=", "!=", "<", ">", "<=", ">="}; + + static void + translate (query_base& q, const odb::query_base& s, size_t p) + { + typedef odb::query_base::clause_part part; + + const part& x (s.clause ()[p]); + + switch (x.kind) + { + case part::kind_column: + { + const query_column_base* c ( + static_cast ( + x.native_info[id_sqlite].column)); + + q.append (c->table (), c->column ()); + break; + } + case part::kind_param_val: + case part::kind_param_ref: + { + const query_column_base* c ( + static_cast ( + x.native_info[id_sqlite].column)); + + query_param_factory f ( + reinterpret_cast ( + x.native_info[id_sqlite].param_factory)); + + const odb::query_param* p ( + reinterpret_cast (x.data)); + + q.append (f (p->value, x.kind == part::kind_param_ref), + c->conversion ()); + break; + } + case part::kind_native: + { + q.append (s.strings ()[x.data]); + break; + } + case part::kind_true: + case part::kind_false: + { + q.append (x.kind == part::kind_true); + break; + } + case part::op_add: + { + translate (q, s, x.data); + translate (q, s, p - 1); + break; + } + case part::op_and: + case part::op_or: + { + q += "("; + translate (q, s, x.data); + q += logic_operators[x.kind - part::op_and]; + translate (q, s, p - 1); + q += ")"; + break; + } + case part::op_not: + { + q += "NOT ("; + translate (q, s, p - 1); + q += ")"; + break; + } + case part::op_null: + case part::op_not_null: + { + translate (q, s, p - 1); + q += (x.kind == part::op_null ? "IS NULL" : "IS NOT NULL"); + break; + } + case part::op_in: + { + if (x.data != 0) + { + size_t b (p - x.data); + + translate (q, s, b - 1); // column + q += "IN ("; + + for (size_t i (b); i != p; ++i) + { + if (i != b) + q += ","; + + translate (q, s, i); + } + + q += ")"; + } + else + q.append (false); + + break; + } + case part::op_like: + { + translate (q, s, p - 2); // column + q += "LIKE"; + translate (q, s, p - 1); // pattern + break; + } + case part::op_like_escape: + { + translate (q, s, p - 3); // column + q += "LIKE"; + translate (q, s, p - 2); // pattern + q += "ESCAPE"; + translate (q, s, p - 1); // escape + break; + } + case part::op_eq: + case part::op_ne: + case part::op_lt: + case part::op_gt: + case part::op_le: + case part::op_ge: + { + translate (q, s, x.data); + q += comp_operators[x.kind - part::op_eq]; + translate (q, s, p - 1); + break; + } + } + } + + query_base:: + query_base (const odb::query_base& q) + : parameters_ (new (details::shared) query_params) + { + if (!q.empty ()) + translate (*this, q, q.clause ().size () - 1); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/query-dynamic.hxx b/libodb-sqlite/odb/sqlite/query-dynamic.hxx new file mode 100644 index 0000000..f720a95 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query-dynamic.hxx @@ -0,0 +1,32 @@ +// file : odb/sqlite/query-dynamic.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX +#define ODB_SQLITE_QUERY_DYNAMIC_HXX + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + typedef details::shared_ptr (*query_param_factory) ( + const void* val, bool by_ref); + + template + details::shared_ptr + query_param_factory_impl (const void*, bool); + } +} + +#include +#include + +#include + +#endif // ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/libodb-sqlite/odb/sqlite/query-dynamic.ixx b/libodb-sqlite/odb/sqlite/query-dynamic.ixx new file mode 100644 index 0000000..7fafe3e --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query-dynamic.ixx @@ -0,0 +1,26 @@ +// file : odb/sqlite/query-dynamic.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // + template + inline query_column:: + query_column (odb::query_column& qc, + const char* table, const char* column, const char* conv) + : query_column_base (table, column, conv) + { + native_column_info& ci (qc.native_info[id_sqlite]); + ci.column = static_cast (this); + + // For some reason GCC needs this statically-typed pointer in + // order to instantiate the functions. + // + query_param_factory f (&query_param_factory_impl); + ci.param_factory = reinterpret_cast (f); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/query-dynamic.txx b/libodb-sqlite/odb/sqlite/query-dynamic.txx new file mode 100644 index 0000000..48b7ec4 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query-dynamic.txx @@ -0,0 +1,20 @@ +// file : odb/sqlite/query-dynamic.txx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + template + details::shared_ptr + query_param_factory_impl (const void* val, bool by_ref) + { + const T& v (*static_cast (val)); + + return details::shared_ptr ( + by_ref + ? new (details::shared) query_param_impl (ref_bind (v)) + : new (details::shared) query_param_impl (val_bind (v))); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/query.cxx b/libodb-sqlite/odb/sqlite/query.cxx new file mode 100644 index 0000000..98eb1cd --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query.cxx @@ -0,0 +1,378 @@ +// file : odb/sqlite/query.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + // query_param + // + + query_param:: + ~query_param () + { + } + + // query_params + // + + query_params:: + query_params (const query_params& x) + : details::shared_base (x), + params_ (x.params_), bind_ (x.bind_), binding_ (0, 0) + { + // Here and below we want to maintain up to date binding info so + // that the call to binding() below is an immutable operation, + // provided the query does not have any by-reference parameters. + // This way a by-value-only query can be shared between multiple + // threads without the need for synchronization. + // + if (size_t n = bind_.size ()) + { + binding_.bind = &bind_[0]; + binding_.count = n; + binding_.version++; + } + } + + query_params& query_params:: + operator= (const query_params& x) + { + if (this != &x) + { + params_ = x.params_; + bind_ = x.bind_; + + size_t n (bind_.size ()); + binding_.bind = n != 0 ? &bind_[0] : 0; + binding_.count = n; + binding_.version++; + } + + return *this; + } + + query_params& query_params:: + operator+= (const query_params& x) + { + size_t n (bind_.size ()); + + params_.insert (params_.end (), x.params_.begin (), x.params_.end ()); + bind_.insert (bind_.end (), x.bind_.begin (), x.bind_.end ()); + + if (n != bind_.size ()) + { + binding_.bind = &bind_[0]; + binding_.count = bind_.size (); + binding_.version++; + } + + return *this; + } + + void query_params:: + add (details::shared_ptr p) + { + params_.push_back (p); + bind_.push_back (sqlite::bind ()); + binding_.bind = &bind_[0]; + binding_.count = bind_.size (); + binding_.version++; + + sqlite::bind* b (&bind_.back ()); + memset (b, 0, sizeof (sqlite::bind)); + p->bind (b); + } + + void query_params:: + init () + { + bool inc_ver (false); + + for (size_t i (0); i < params_.size (); ++i) + { + query_param& p (*params_[i]); + + if (p.reference ()) + { + if (p.init ()) + { + p.bind (&bind_[i]); + inc_ver = true; + } + } + } + + if (inc_ver) + binding_.version++; + } + + // query_base + // + + query_base:: + query_base (const query_base& q) + : clause_ (q.clause_), + parameters_ (new (details::shared) query_params (*q.parameters_)) + { + } + + query_base& query_base:: + operator= (const query_base& q) + { + if (this != &q) + { + clause_ = q.clause_; + *parameters_ = *q.parameters_; + } + + return *this; + } + + query_base& query_base:: + operator+= (const query_base& q) + { + clause_.insert (clause_.end (), q.clause_.begin (), q.clause_.end ()); + *parameters_ += *q.parameters_; + return *this; + } + + void query_base:: + append (const string& q) + { + if (!clause_.empty () && + clause_.back ().kind == clause_part::kind_native) + { + string& s (clause_.back ().part); + + char first (!q.empty () ? q[0] : ' '); + char last (!s.empty () ? s[s.size () - 1] : ' '); + + // We don't want extra spaces after '(' as well as before ',' + // and ')'. + // + if (last != ' ' && last != '\n' && last != '(' && + first != ' ' && first != '\n' && first != ',' && first != ')') + s += ' '; + + s += q; + } + else + clause_.push_back (clause_part (clause_part::kind_native, q)); + } + + void query_base:: + append (const char* table, const char* column) + { + string s (table); + s += '.'; + s += column; + + clause_.push_back (clause_part (clause_part::kind_column, s)); + } + + void query_base:: + append (details::shared_ptr p, const char* conv) + { + clause_.push_back (clause_part (clause_part::kind_param)); + + if (conv != 0) + clause_.back ().part = conv; + + parameters_->add (p); + } + + static bool + check_prefix (const string& s) + { + string::size_type n; + + // It is easier to compare to upper and lower-case versions + // rather than getting involved with the portable case- + // insensitive string comparison mess. + // + if (s.compare (0, (n = 5), "WHERE") == 0 || + s.compare (0, (n = 5), "where") == 0 || + s.compare (0, (n = 6), "SELECT") == 0 || + s.compare (0, (n = 6), "select") == 0 || + s.compare (0, (n = 8), "ORDER BY") == 0 || + s.compare (0, (n = 8), "order by") == 0 || + s.compare (0, (n = 8), "GROUP BY") == 0 || + s.compare (0, (n = 8), "group by") == 0 || + s.compare (0, (n = 6), "HAVING") == 0 || + s.compare (0, (n = 6), "having") == 0 || + s.compare (0, (n = 4), "WITH") == 0 || + s.compare (0, (n = 4), "with") == 0 || + s.compare (0, (n = 6), "PRAGMA") == 0 || + s.compare (0, (n = 6), "pragma") == 0) + { + // It either has to be an exact match, or there should be + // a whitespace following the keyword. + // + if (s.size () == n || s[n] == ' ' || s[n] == '\n' || s[n] =='\t') + return true; + } + + return false; + } + + void query_base:: + optimize () + { + // Remove a single TRUE literal or one that is followe by one of + // the other clauses. This avoids useless WHERE clauses like + // + // WHERE TRUE GROUP BY foo + // + clause_type::iterator i (clause_.begin ()), e (clause_.end ()); + + if (i != e && i->kind == clause_part::kind_bool && i->bool_part) + { + clause_type::iterator j (i + 1); + + if (j == e || + (j->kind == clause_part::kind_native && check_prefix (j->part))) + clause_.erase (i); + } + } + + const char* query_base:: + clause_prefix () const + { + if (!clause_.empty ()) + { + const clause_part& p (clause_.front ()); + + if (p.kind == clause_part::kind_native && check_prefix (p.part)) + return ""; + + return "WHERE "; + } + + return ""; + } + + string query_base:: + clause () const + { + string r; + + for (clause_type::const_iterator i (clause_.begin ()), + end (clause_.end ()); + i != end; + ++i) + { + char last (!r.empty () ? r[r.size () - 1] : ' '); + + switch (i->kind) + { + case clause_part::kind_column: + { + if (last != ' ' && last != '\n' && last != '(') + r += ' '; + + r += i->part; + break; + } + case clause_part::kind_param: + { + if (last != ' ' && last != '\n' && last != '(') + r += ' '; + + // Add the conversion expression, if any. + // + string::size_type p (0); + if (!i->part.empty ()) + { + p = i->part.find ("(?)"); + r.append (i->part, 0, p); + } + + r += '?'; + + if (!i->part.empty ()) + r.append (i->part, p + 3, string::npos); + + break; + } + case clause_part::kind_native: + { + // We don't want extra spaces after '(' as well as before ',' + // and ')'. + // + const string& p (i->part); + char first (!p.empty () ? p[0] : ' '); + + if (last != ' ' && first != '\n' && last != '(' && + first != ' ' && last != '\n' && first != ',' && first != ')') + r += ' '; + + r += p; + break; + } + case clause_part::kind_bool: + { + if (last != ' ' && last != '\n' && last != '(') + r += ' '; + + r += i->bool_part ? "1" : "0"; + break; + } + } + } + + return clause_prefix () + r; + } + + query_base + operator&& (const query_base& x, const query_base& y) + { + // Optimize cases where one or both sides are constant truth. + // + bool xt (x.const_true ()), yt (y.const_true ()); + + if (xt && yt) + return x; + + if (xt) + return y; + + if (yt) + return x; + + query_base r ("("); + r += x; + r += ") AND ("; + r += y; + r += ")"; + return r; + } + + query_base + operator|| (const query_base& x, const query_base& y) + { + query_base r ("("); + r += x; + r += ") OR ("; + r += y; + r += ")"; + return r; + } + + query_base + operator! (const query_base& x) + { + query_base r ("NOT ("); + r += x; + r += ")"; + return r; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/query.hxx b/libodb-sqlite/odb/sqlite/query.hxx new file mode 100644 index 0000000..c9cbfaa --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query.hxx @@ -0,0 +1,1728 @@ +// file : odb/sqlite/query.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_QUERY_HXX +#define ODB_SQLITE_QUERY_HXX + +#include + +#include +#include +#include // std::size_t + +#include // odb::query_column +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + template + struct val_bind + { + typedef const T& type; + + explicit + val_bind (type v): val (v) {} + + type val; + }; + + template + struct val_bind + { + typedef const T* type; + + explicit + val_bind (type v): val (v) {} + + type val; + }; + + template + struct ref_bind + { + typedef const T& type; + + explicit + ref_bind (type r): ref (r) {} + + const void* + ptr () const {return &ref;} + + type ref; + }; + + template + struct ref_bind + { + typedef const T* type; + + explicit + ref_bind (type r): ref (r) {} + + // Allow implicit conversion from decayed ref_bind's. + // + ref_bind (ref_bind r): ref (r.ref) {} + ref_bind (ref_bind r): ref (r.ref) {} + + const void* + ptr () const {return ref;} + + type ref; + }; + + template + struct val_bind_typed: val_bind + { + explicit + val_bind_typed (typename val_bind::type v): val_bind (v) {} + }; + + template + struct ref_bind_typed: ref_bind + { + explicit + ref_bind_typed (typename ref_bind::type r): ref_bind (r) {} + }; + + struct LIBODB_SQLITE_EXPORT query_param: details::shared_base + { + virtual + ~query_param (); + + bool + reference () const + { + return value_ != 0; + } + + virtual bool + init () = 0; + + virtual void + bind (sqlite::bind*) = 0; + + protected: + query_param (const void* value) + : value_ (value) + { + } + + protected: + const void* value_; + }; + + class query_base; + + class LIBODB_SQLITE_EXPORT query_params: public details::shared_base + { + public: + typedef sqlite::binding binding_type; + + void + init (); + + binding_type& + binding () {return binding_;} + + private: + friend class query_base; + + query_params (): binding_ (0, 0) {} + query_params (const query_params&); + + query_params& + operator= (const query_params&); + + query_params& + operator+= (const query_params&); + + void + add (details::shared_ptr); + + private: + typedef std::vector > params; + + params params_; + std::vector bind_; + binding_type binding_; + }; + + // + // + template + struct query_column; + + class LIBODB_SQLITE_EXPORT query_base + { + public: + struct clause_part + { + enum kind_type + { + kind_column, + kind_param, + kind_native, + kind_bool + }; + + clause_part (kind_type k): kind (k), bool_part (false) {} + clause_part (kind_type k, const std::string& p) + : kind (k), part (p), bool_part (false) {} + clause_part (bool p): kind (kind_bool), bool_part (p) {} + + kind_type kind; + std::string part; // If kind is param, then part is conversion expr. + bool bool_part; + }; + + query_base () + : parameters_ (new (details::shared) query_params) + { + } + + // True or false literal. + // + explicit + query_base (bool v) + : parameters_ (new (details::shared) query_params) + { + append (v); + } + + explicit + query_base (const char* native) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::kind_native, native)); + } + + explicit + query_base (const std::string& native) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::kind_native, native)); + } + + query_base (const char* table, const char* column) + : parameters_ (new (details::shared) query_params) + { + append (table, column); + } + + template + explicit + query_base (val_bind v) + : parameters_ (new (details::shared) query_params) + { + *this += v; + } + + template + explicit + query_base (val_bind_typed v) + : parameters_ (new (details::shared) query_params) + { + *this += v; + } + + template + explicit + query_base (ref_bind r) + : parameters_ (new (details::shared) query_params) + { + *this += r; + } + + template + explicit + query_base (ref_bind_typed r) + : parameters_ (new (details::shared) query_params) + { + *this += r; + } + + template + query_base (const query_column&); + + // Translate common query representation to SQLite native. Defined + // in query-dynamic.cxx + // + query_base (const odb::query_base&); + + // Copy c-tor and assignment. + // + query_base (const query_base&); + + query_base& + operator= (const query_base&); + + public: + std::string + clause () const; + + const char* + clause_prefix () const; + + // Initialize the by-reference parameters from bound variables. + // + void + init_parameters () const; + + binding& + parameters_binding () const; + + const details::shared_ptr& + parameters () const; + + public: + bool + empty () const + { + return clause_.empty (); + } + + static const query_base true_expr; + + bool + const_true () const + { + return clause_.size () == 1 && + clause_.front ().kind == clause_part::kind_bool && + clause_.front ().bool_part; + } + + void + optimize (); + + public: + template + static val_bind + _val (const T& x) + { + return val_bind (x); + } + + template + static val_bind_typed + _val (const T& x) + { + return val_bind_typed (x); + } + + template + static ref_bind + _ref (const T& x) + { + return ref_bind (x); + } + + template + static ref_bind_typed + _ref (const T& x) + { + return ref_bind_typed (x); + } + + // Some compilers (notably VC++), when deducing const T& from const + // array do not strip const from the array type. As a result, in the + // above signatures we get, for example, T = const char[4] instead + // of T = char[4], which is what we want. So to "fix" such compilers, + // we will have to provide the following specializations of the above + // functions. + // + template + static val_bind + _val (const T (&x) [N]) + { + return val_bind (x); + } + + template + static val_bind_typed + _val (const T (&x) [N]) + { + return val_bind_typed (x); + } + + template + static ref_bind + _ref (const T (&x) [N]) + { + return ref_bind (x); + } + + template + static ref_bind_typed + _ref (const T (&x) [N]) + { + return ref_bind_typed (x); + } + + public: + query_base& + operator+= (const query_base&); + + query_base& + operator+= (const std::string& q) + { + append (q); + return *this; + } + + template + query_base& + operator+= (val_bind v) + { + append::db_type_id> ( + v, details::conversion::to ()); + return *this; + } + + template + query_base& + operator+= (val_bind_typed v) + { + // We are not using default type_traits so no default conversion + // either. + // + append (v, 0); + return *this; + } + + template + query_base& + operator+= (ref_bind r) + { + append::db_type_id> ( + r, details::conversion::to ()); + return *this; + } + + template + query_base& + operator+= (ref_bind_typed r) + { + // We are not using default type_traits so no default conversion + // either. + // + append (r, 0); + return *this; + } + + // Implementation details. + // + public: + template + void + append (val_bind, const char* conv); + + template + void + append (ref_bind, const char* conv); + + void + append (details::shared_ptr, const char* conv); + + void + append (bool v) + { + clause_.push_back (clause_part (v)); + } + + void + append (const std::string& native); + + void + append (const char* native) // Clashes with append(bool). + { + append (std::string (native)); + } + + void + append (const char* table, const char* column); + + private: + typedef std::vector clause_type; + + clause_type clause_; + details::shared_ptr parameters_; + }; + + inline query_base + operator+ (const query_base& x, const query_base& y) + { + query_base r (x); + r += y; + return r; + } + + template + inline query_base + operator+ (const query_base& q, val_bind b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base + operator+ (val_bind b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + + template + inline query_base + operator+ (const query_base& q, val_bind_typed b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base + operator+ (val_bind_typed b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + + template + inline query_base + operator+ (const query_base& q, ref_bind b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + + template + inline query_base + operator+ (const query_base& q, ref_bind_typed b) + { + query_base r (q); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind_typed b, const query_base& q) + { + query_base r; + r += b; + r += q; + return r; + } + + inline query_base + operator+ (const query_base& q, const std::string& s) + { + query_base r (q); + r += s; + return r; + } + + inline query_base + operator+ (const std::string& s, const query_base& q) + { + query_base r (s); + r += q; + return r; + } + + template + inline query_base + operator+ (const std::string& s, val_bind b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base + operator+ (val_bind b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + + template + inline query_base + operator+ (const std::string& s, val_bind_typed b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base + operator+ (val_bind_typed b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + + template + inline query_base + operator+ (const std::string& s, ref_bind b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + + template + inline query_base + operator+ (const std::string& s, ref_bind_typed b) + { + query_base r (s); + r += b; + return r; + } + + template + inline query_base + operator+ (ref_bind_typed b, const std::string& s) + { + query_base r; + r += b; + r += s; + return r; + } + + LIBODB_SQLITE_EXPORT query_base + operator&& (const query_base&, const query_base&); + + LIBODB_SQLITE_EXPORT query_base + operator|| (const query_base&, const query_base&); + + LIBODB_SQLITE_EXPORT query_base + operator! (const query_base&); + + // query_column + // + struct query_column_base + { + // Note that we keep shallow copies of the table, column, and conversion + // expression. The latter can be NULL. + // + query_column_base (const char* table, + const char* column, + const char* conv) + : table_ (table), column_ (column), conversion_ (conv) + { + } + + const char* + table () const + { + return table_; + } + + const char* + column () const + { + return column_; + } + + // Can be NULL. + // + const char* + conversion () const + { + return conversion_; + } + + protected: + const char* table_; + const char* column_; + const char* conversion_; + }; + + template + struct query_column: query_column_base + { + typedef typename decay_traits::type decayed_type; + + // Note that we keep shallow copies of the table, column, and conversion + // expression. The latter can be NULL. + // + query_column (const char* table, const char* column, const char* conv) + : query_column_base (table, column, conv) {} + + // Implementation is in query-dynamic.ixx. + // + query_column (odb::query_column&, + const char* table, const char* column, const char* conv); + + // is_null, is_not_null + // + public: + query_base + is_null () const + { + query_base q (table_, column_); + q += "IS NULL"; + return q; + } + + query_base + is_not_null () const + { + query_base q (table_, column_); + q += "IS NOT NULL"; + return q; + } + + // in + // + public: + query_base + in (decayed_type, decayed_type) const; + + query_base + in (decayed_type, decayed_type, decayed_type) const; + + query_base + in (decayed_type, decayed_type, decayed_type, decayed_type) const; + + query_base + in (decayed_type, decayed_type, decayed_type, decayed_type, + decayed_type) const; + + template + query_base + in_range (I begin, I end) const; + + // like + // + public: + query_base + like (decayed_type pattern) const + { + return like (val_bind (pattern)); + } + + query_base + like (val_bind pattern) const; + + template + query_base + like (val_bind pattern) const + { + return like (val_bind (decayed_type (pattern.val))); + } + + query_base + like (ref_bind pattern) const; + + query_base + like (decayed_type pattern, decayed_type escape) const + { + return like (val_bind (pattern), escape); + } + + query_base + like (val_bind pattern, decayed_type escape) const; + + template + query_base + like (val_bind pattern, decayed_type escape) const + { + return like (val_bind (decayed_type (pattern.val)), escape); + } + + query_base + like (ref_bind pattern, decayed_type escape) const; + + // = + // + public: + query_base + equal (decayed_type v) const + { + return equal (val_bind (v)); + } + + query_base + equal (val_bind v) const + { + query_base q (table_, column_); + q += "="; + q.append (v, conversion_); + return q; + } + + template + query_base + equal (val_bind v) const + { + return equal (val_bind (decayed_type (v.val))); + } + + query_base + equal (ref_bind r) const + { + query_base q (table_, column_); + q += "="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator== (const query_column& c, decayed_type v) + { + return c.equal (v); + } + + friend query_base + operator== (decayed_type v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + friend query_base + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + template + friend query_base + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + template + friend query_base + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, ref_bind r) + { + return c.equal (r); + } + + friend query_base + operator== (ref_bind r, const query_column& c) + { + return c.equal (r); + } + + // != + // + public: + query_base + unequal (decayed_type v) const + { + return unequal (val_bind (v)); + } + + query_base + unequal (val_bind v) const + { + query_base q (table_, column_); + q += "!="; + q.append (v, conversion_); + return q; + } + + template + query_base + unequal (val_bind v) const + { + return unequal (val_bind (decayed_type (v.val))); + } + + query_base + unequal (ref_bind r) const + { + query_base q (table_, column_); + q += "!="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator!= (const query_column& c, decayed_type v) + { + return c.unequal (v); + } + + friend query_base + operator!= (decayed_type v, const query_column& c) + { + return c.unequal (v); + } + + friend query_base + operator!= (const query_column& c, val_bind v) + { + return c.unequal (v); + } + + friend query_base + operator!= (val_bind v, const query_column& c) + { + return c.unequal (v); + } + + template + friend query_base + operator!= (const query_column& c, val_bind v) + { + return c.unequal (v); + } + + template + friend query_base + operator!= (val_bind v, const query_column& c) + { + return c.unequal (v); + } + + friend query_base + operator!= (const query_column& c, ref_bind r) + { + return c.unequal (r); + } + + friend query_base + operator!= (ref_bind r, const query_column& c) + { + return c.unequal (r); + } + + // < + // + public: + query_base + less (decayed_type v) const + { + return less (val_bind (v)); + } + + query_base + less (val_bind v) const + { + query_base q (table_, column_); + q += "<"; + q.append (v, conversion_); + return q; + } + + template + query_base + less (val_bind v) const + { + return less (val_bind (decayed_type (v.val))); + } + + query_base + less (ref_bind r) const + { + query_base q (table_, column_); + q += "<"; + q.append (r, conversion_); + return q; + } + + friend query_base + operator< (const query_column& c, decayed_type v) + { + return c.less (v); + } + + friend query_base + operator< (decayed_type v, const query_column& c) + { + return c.greater (v); + } + + friend query_base + operator< (const query_column& c, val_bind v) + { + return c.less (v); + } + + friend query_base + operator< (val_bind v, const query_column& c) + { + return c.greater (v); + } + + template + friend query_base + operator< (const query_column& c, val_bind v) + { + return c.less (v); + } + + template + friend query_base + operator< (val_bind v, const query_column& c) + { + return c.greater (v); + } + + friend query_base + operator< (const query_column& c, ref_bind r) + { + return c.less (r); + } + + friend query_base + operator< (ref_bind r, const query_column& c) + { + return c.greater (r); + } + + // > + // + public: + query_base + greater (decayed_type v) const + { + return greater (val_bind (v)); + } + + query_base + greater (val_bind v) const + { + query_base q (table_, column_); + q += ">"; + q.append (v, conversion_); + return q; + } + + template + query_base + greater (val_bind v) const + { + return greater (val_bind (decayed_type (v.val))); + } + + query_base + greater (ref_bind r) const + { + query_base q (table_, column_); + q += ">"; + q.append (r, conversion_); + return q; + } + + friend query_base + operator> (const query_column& c, decayed_type v) + { + return c.greater (v); + } + + friend query_base + operator> (decayed_type v, const query_column& c) + { + return c.less (v); + } + + friend query_base + operator> (const query_column& c, val_bind v) + { + return c.greater (v); + } + + friend query_base + operator> (val_bind v, const query_column& c) + { + return c.less (v); + } + + template + friend query_base + operator> (const query_column& c, val_bind v) + { + return c.greater (v); + } + + template + friend query_base + operator> (val_bind v, const query_column& c) + { + return c.less (v); + } + + friend query_base + operator> (const query_column& c, ref_bind r) + { + return c.greater (r); + } + + friend query_base + operator> (ref_bind r, const query_column& c) + { + return c.less (r); + } + + // <= + // + public: + query_base + less_equal (decayed_type v) const + { + return less_equal (val_bind (v)); + } + + query_base + less_equal (val_bind v) const + { + query_base q (table_, column_); + q += "<="; + q.append (v, conversion_); + return q; + } + + template + query_base + less_equal (val_bind v) const + { + return less_equal (val_bind (decayed_type (v.val))); + } + + query_base + less_equal (ref_bind r) const + { + query_base q (table_, column_); + q += "<="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator<= (const query_column& c, decayed_type v) + { + return c.less_equal (v); + } + + friend query_base + operator<= (decayed_type v, const query_column& c) + { + return c.greater_equal (v); + } + + friend query_base + operator<= (const query_column& c, val_bind v) + { + return c.less_equal (v); + } + + friend query_base + operator<= (val_bind v, const query_column& c) + { + return c.greater_equal (v); + } + + template + friend query_base + operator<= (const query_column& c, val_bind v) + { + return c.less_equal (v); + } + + template + friend query_base + operator<= (val_bind v, const query_column& c) + { + return c.greater_equal (v); + } + + friend query_base + operator<= (const query_column& c, ref_bind r) + { + return c.less_equal (r); + } + + friend query_base + operator<= (ref_bind r, const query_column& c) + { + return c.greater_equal (r); + } + + // >= + // + public: + query_base + greater_equal (decayed_type v) const + { + return greater_equal (val_bind (v)); + } + + query_base + greater_equal (val_bind v) const + { + query_base q (table_, column_); + q += ">="; + q.append (v, conversion_); + return q; + } + + template + query_base + greater_equal (val_bind v) const + { + return greater_equal (val_bind (decayed_type (v.val))); + } + + query_base + greater_equal (ref_bind r) const + { + query_base q (table_, column_); + q += ">="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator>= (const query_column& c, decayed_type v) + { + return c.greater_equal (v); + } + + friend query_base + operator>= (decayed_type v, const query_column& c) + { + return c.less_equal (v); + } + + friend query_base + operator>= (const query_column& c, val_bind v) + { + return c.greater_equal (v); + } + + friend query_base + operator>= (val_bind v, const query_column& c) + { + return c.less_equal (v); + } + + template + friend query_base + operator>= (const query_column& c, val_bind v) + { + return c.greater_equal (v); + } + + template + friend query_base + operator>= (val_bind v, const query_column& c) + { + return c.less_equal (v); + } + + friend query_base + operator>= (const query_column& c, ref_bind r) + { + return c.greater_equal (r); + } + + friend query_base + operator>= (ref_bind r, const query_column& c) + { + return c.less_equal (r); + } + + // Column comparison. + // + public: + template + query_base + operator== (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () == + decay_traits::instance ())); + + query_base q (table_, column_); + q += "="; + q.append (c.table (), c.column ()); + return q; + } + + template + query_base + operator!= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () != + decay_traits::instance ())); + + query_base q (table_, column_); + q += "!="; + q.append (c.table (), c.column ()); + return q; + } + + template + query_base + operator< (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () < + decay_traits::instance ())); + + query_base q (table_, column_); + q += "<"; + q.append (c.table (), c.column ()); + return q; + } + + template + query_base + operator> (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () > + decay_traits::instance ())); + + query_base q (table_, column_); + q += ">"; + q.append (c.table (), c.column ()); + return q; + } + + template + query_base + operator<= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () <= + decay_traits::instance ())); + + query_base q (table_, column_); + q += "<="; + q.append (c.table (), c.column ()); + return q; + } + + template + query_base + operator>= (const query_column& c) const + { + // We can compare columns only if we can compare their C++ types. + // + (void) (sizeof (decay_traits::instance () >= + decay_traits::instance ())); + + query_base q (table_, column_); + q += ">="; + q.append (c.table (), c.column ()); + return q; + } + }; + + // Provide operator+() for using columns to construct native + // query fragments (e.g., ORDER BY). + // + template + inline query_base + operator+ (const query_column& c, const std::string& s) + { + query_base q (c.table (), c.column ()); + q += s; + return q; + } + + template + inline query_base + operator+ (const std::string& s, const query_column& c) + { + query_base q (s); + q.append (c.table (), c.column ()); + return q; + } + + template + inline query_base + operator+ (const query_column& c, const query_base& q) + { + query_base r (c.table (), c.column ()); + r += q; + return r; + } + + template + inline query_base + operator+ (const query_base& q, const query_column& c) + { + query_base r (q); + r.append (c.table (), c.column ()); + return r; + } + + // + // + template + struct query_param_impl; + + // INTEGER + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::integer; + b->buffer = &image_; + } + + private: + void + init (typename decay_traits::type v) + { + bool is_null (false); // Can't be NULL. + value_traits::set_image (image_, is_null, v); + } + + private: + long long image_; + }; + + // REAL + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + init (*static_cast (value_)); + return false; + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::real; + b->buffer = &image_; + } + + private: + void + init (typename decay_traits::type v) + { + bool is_null (false); // Can't be NULL. + value_traits::set_image (image_, is_null, v); + } + + private: + double image_; + }; + + // TEXT + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + return init (*static_cast (value_)); + } + + virtual void + bind (sqlite::bind* b) + { + b->type = image_traits::bind_value; + b->buffer = buffer_.data (); + b->size = &size_; + } + + private: + bool + init (typename decay_traits::type v) + { + bool is_null (false); // Can't be NULL. + std::size_t cap (buffer_.capacity ()); + value_traits::set_image (buffer_, size_, is_null, v); + return cap != buffer_.capacity (); + } + + private: + details::buffer buffer_; + std::size_t size_; + }; + + // BLOB + // + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (r.ptr ()) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + return init (*static_cast (value_)); + } + + virtual void + bind (sqlite::bind* b) + { + b->type = sqlite::bind::blob; + b->buffer = buffer_.data (); + b->size = &size_; + } + + private: + bool + init (typename decay_traits::type v) + { + bool is_null (false); // Can't be NULL. + std::size_t cap (buffer_.capacity ()); + value_traits::set_image (buffer_, size_, is_null, v); + return cap != buffer_.capacity (); + } + + private: + details::buffer buffer_; + std::size_t size_; + }; + + // TEXT STREAM (reduce to id_text). + // + template + struct query_param_impl: query_param_impl + { + query_param_impl (ref_bind r) : query_param_impl (r) {} + query_param_impl (val_bind v) : query_param_impl (v) {} + }; + + // BLOB STREAM (reduce to id_blob). + // + template + struct query_param_impl: query_param_impl + { + query_param_impl (ref_bind r) : query_param_impl (r) {} + query_param_impl (val_bind v) : query_param_impl (v) {} + }; + } +} + +// odb::sqlite::query and odb::query specialization for SQLite. +// +namespace odb +{ + namespace sqlite + { + template + class query: public query_base, + public query_selector::columns_type + { + public: + // We don't define any typedefs here since they may clash with + // column names defined by our base type. + // + + query () + { + } + + explicit + query (bool v) + : query_base (v) + { + } + + explicit + query (const char* q) + : query_base (q) + { + } + + explicit + query (const std::string& q) + : query_base (q) + { + } + + template + explicit + query (val_bind v) + : query_base (v) + { + } + + template + explicit + query (ref_bind r) + : query_base (r) + { + } + + query (const query_base& q) + : query_base (q) + { + } + + template + query (const query_column& qc) + : query_base (qc) + { + } + + query (const odb::query_base& q) + : query_base (q) + { + } + }; + + namespace core + { + using sqlite::query; + } + } + + // Derive odb::query from odb::sqlite::query so that it can be + // implicitly converted in sqlite::database::query() calls. + // + template + class query: public sqlite::query + { + public: + // We don't define any typedefs here since they may clash with + // column names defined by our base type. + // + + query () + { + } + + explicit + query (bool v) + : sqlite::query (v) + { + } + + explicit + query (const char* q) + : sqlite::query (q) + { + } + + explicit + query (const std::string& q) + : sqlite::query (q) + { + } + + template + explicit + query (sqlite::val_bind v) + : sqlite::query (v) + { + } + + template + explicit + query (sqlite::ref_bind r) + : sqlite::query (r) + { + } + + query (const sqlite::query_base& q) + : sqlite::query (q) + { + } + + template + query (const sqlite::query_column& qc) + : sqlite::query (qc) + { + } + }; +} + +#include +#include + +#include + +#endif // ODB_SQLITE_QUERY_HXX diff --git a/libodb-sqlite/odb/sqlite/query.ixx b/libodb-sqlite/odb/sqlite/query.ixx new file mode 100644 index 0000000..00e9b66 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query.ixx @@ -0,0 +1,46 @@ +// file : odb/sqlite/query.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + inline void query_base:: + init_parameters () const + { + return parameters_->init (); + } + + inline binding& query_base:: + parameters_binding () const + { + return parameters_->binding (); + } + + inline const details::shared_ptr& query_base:: + parameters () const + { + return parameters_; + } + + template + inline void query_base:: + append (val_bind v, const char* conv) + { + append ( + details::shared_ptr ( + new (details::shared) query_param_impl (v)), + conv); + } + + template + inline void query_base:: + append (ref_bind r, const char* conv) + { + append ( + details::shared_ptr ( + new (details::shared) query_param_impl (r)), + conv); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/query.txx b/libodb-sqlite/odb/sqlite/query.txx new file mode 100644 index 0000000..f381ff0 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/query.txx @@ -0,0 +1,168 @@ +// file : odb/sqlite/query.txx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // query_base + // + + template + query_base:: + query_base (const query_column& c) + : parameters_ (new (details::shared) query_params) + { + // Cannot use IS TRUE here since database type can be a non- + // integral type. + // + append (c.table (), c.column ()); + append ("="); + append (val_bind (true), c.conversion ()); + } + + // + // query_column + // + + // in + // + template + query_base query_column:: + in (decayed_type v1, decayed_type v2) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1), conversion_); + q += ","; + q.append (val_bind (v2), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1), conversion_); + q += ","; + q.append (val_bind (v2), conversion_); + q += ","; + q.append (val_bind (v3), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3, + decayed_type v4) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1), conversion_); + q += ","; + q.append (val_bind (v2), conversion_); + q += ","; + q.append (val_bind (v3), conversion_); + q += ","; + q.append (val_bind (v4), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4, + decayed_type v5) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1), conversion_); + q += ","; + q.append (val_bind (v2), conversion_); + q += ","; + q.append (val_bind (v3), conversion_); + q += ","; + q.append (val_bind (v4), conversion_); + q += ","; + q.append (val_bind (v5), conversion_); + q += ")"; + return q; + } + + template + template + query_base query_column:: + in_range (I begin, I end) const + { + if (begin != end) + { + query_base q (table_, column_); + q += "IN ("; + + for (I i (begin); i != end; ++i) + { + if (i != begin) + q += ","; + + q.append (val_bind (*i), conversion_); + } + + q += ")"; + return q; + } + else + return query_base (false); + } + + // like + // + template + query_base query_column:: + like (val_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (val_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/section-statements.hxx b/libodb-sqlite/odb/sqlite/section-statements.hxx new file mode 100644 index 0000000..e6a5da6 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/section-statements.hxx @@ -0,0 +1,198 @@ +// file : odb/sqlite/section-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX +#define ODB_SQLITE_SECTION_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + // Template argument is the section traits type. + // + template + class section_statements + { + public: + typedef ST traits; + + typedef typename traits::image_type image_type; + typedef typename traits::id_image_type id_image_type; + + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + + typedef sqlite::connection connection_type; + + section_statements (connection_type&, + image_type&, id_image_type&, + binding& id, binding& idv); + + connection_type& + connection () {return conn_;} + + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + + image_type& + image () {return image_;} + + const binding& + id_binding () {return id_binding_;} + + // Id and optimistic concurrency version (if any). + // + const binding& + idv_binding () {return idv_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_binding_version () const { return update_id_binding_version_;} + + void + update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // + // Statements. + // + + select_statement_type& + select_statement () + { + if (select_ == 0) + select_.reset ( + new (details::shared) select_statement_type ( + conn_, + traits::select_statement, + traits::versioned, // Process if versioned. + false, // Don't optimize. + id_binding_, + select_image_binding_)); + + return *select_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + traits::update_statement, + traits::versioned, // Process if versioned. + update_image_binding_)); + + return *update_; + } + + public: + static const std::size_t id_column_count = traits::id_column_count; + static const std::size_t managed_optimistic_load_column_count = + traits::managed_optimistic_load_column_count; + static const std::size_t managed_optimistic_update_column_count = + traits::managed_optimistic_update_column_count; + static const std::size_t select_column_count = traits::load_column_count; + static const std::size_t update_column_count = + traits::update_column_count; + + private: + section_statements (const section_statements&); + section_statements& operator= (const section_statements&); + + protected: + connection_type& conn_; + mutable const schema_version_migration* svm_; + + // These come from object_statements. + // + image_type& image_; + binding& id_binding_; + binding& idv_binding_; + + // Select binding. + // + std::size_t select_image_version_; + + static const std::size_t select_bind_count = + select_column_count != 0 || managed_optimistic_load_column_count != 0 + ? select_column_count + managed_optimistic_load_column_count + : 1; + + binding select_image_binding_; + bind select_image_bind_[select_bind_count]; + bool select_image_truncated_[select_bind_count]; + + // Update binding. + // + std::size_t update_image_version_; + std::size_t update_id_binding_version_; + + static const std::size_t update_bind_count = + update_column_count != 0 || managed_optimistic_update_column_count != 0 + ? update_column_count + id_column_count + + managed_optimistic_update_column_count + : 1; + + binding update_image_binding_; + bind update_image_bind_[update_bind_count]; + + details::shared_ptr select_; + details::shared_ptr update_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/section-statements.txx b/libodb-sqlite/odb/sqlite/section-statements.txx new file mode 100644 index 0000000..ff588b3 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/section-statements.txx @@ -0,0 +1,40 @@ +// file : odb/sqlite/section-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + section_statements:: + section_statements (connection_type& conn, + image_type& im, id_image_type&, + binding& id, binding& idv) + : conn_ (conn), + svm_ (0), + image_ (im), + id_binding_ (id), + idv_binding_ (idv), + select_image_binding_ (select_image_bind_, + select_column_count + + managed_optimistic_load_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count + + managed_optimistic_update_column_count) + { + select_image_version_ = 0; + update_image_version_ = 0; + update_id_binding_version_ = 0; + + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + + for (std::size_t i (0); i < select_bind_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/simple-object-result.hxx b/libodb-sqlite/odb/sqlite/simple-object-result.hxx new file mode 100644 index 0000000..d68af8e --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-result.hxx @@ -0,0 +1,88 @@ +// file : odb/sqlite/simple-object-result.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX +#define ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include // query_base, query_params +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class object_result_impl: public odb::object_result_impl + { + public: + typedef odb::object_result_impl base_type; + + typedef typename base_type::id_type id_type; + typedef typename base_type::object_type object_type; + typedef typename base_type::pointer_type pointer_type; + + typedef object_traits_impl object_traits; + typedef typename base_type::pointer_traits pointer_traits; + + typedef typename object_traits::statements_type statements_type; + + virtual + ~object_result_impl (); + + object_result_impl (const query_base&, + const details::shared_ptr&, + statements_type&, + const schema_version_migration*); + + virtual void + load (object_type&, bool fetch); + + virtual id_type + load_id (); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + virtual void + invalidate (); + + using base_type::current; + + private: + void + load_image (); + + private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; + statements_type& statements_; + object_traits_calls tc_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/libodb-sqlite/odb/sqlite/simple-object-result.txx b/libodb-sqlite/odb/sqlite/simple-object-result.txx new file mode 100644 index 0000000..f27b226 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-result.txx @@ -0,0 +1,158 @@ +// file : odb/sqlite/simple-object-result.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include // result_not_cached + +#include + +namespace odb +{ + namespace sqlite + { + template + object_result_impl:: + ~object_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + void object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template + object_result_impl:: + object_result_impl (const query_base& q, + const details::shared_ptr& s, + statements_type& sts, + const schema_version_migration* svm) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts), + tc_ (svm) + { + } + + template + void object_result_impl:: + load (object_type& obj, bool fetch) + { + if (fetch) + load_image (); + + // This is a top-level call so the statements cannot be locked. + // + assert (!statements_.locked ()); + typename statements_type::auto_lock l (statements_); + + object_traits::callback (this->db_, obj, callback_event::pre_load); + + typename object_traits::image_type& i (statements_.image ()); + tc_.init (obj, i, &this->db_); + + // Initialize the id image and binding and load the rest of the object + // (containers, etc). + // + typename object_traits::id_image_type& idi (statements_.id_image ()); + object_traits::init (idi, object_traits::id (i)); + + binding& idb (statements_.id_image_binding ()); + if (idi.version != statements_.id_image_version () || idb.version == 0) + { + object_traits::bind (idb.bind, idi); + statements_.id_image_version (idi.version); + idb.version++; + } + + tc_.load_ (statements_, obj, false); + statements_.load_delayed (tc_.version ()); + l.unlock (); + object_traits::callback (this->db_, obj, callback_event::post_load); + } + + template + typename object_result_impl::id_type + object_result_impl:: + load_id () + { + load_image (); + return object_traits::id (statements_.image ()); + } + + template + void object_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + void object_result_impl:: + load_image () + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + tc_.bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (tc_.grow (im, statements_.select_image_truncated ())) + im.version++; + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + tc_.bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + statement_->reload (); + } + } + } + + template + void object_result_impl:: + cache () + { + } + + template + std::size_t object_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/simple-object-statements.cxx b/libodb-sqlite/odb/sqlite/simple-object-statements.cxx new file mode 100644 index 0000000..1eb07db --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-statements.cxx @@ -0,0 +1,15 @@ +// file : odb/sqlite/simple-object-statements.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + object_statements_base:: + ~object_statements_base () + { + } + } +} diff --git a/libodb-sqlite/odb/sqlite/simple-object-statements.hxx b/libodb-sqlite/odb/sqlite/simple-object-statements.hxx new file mode 100644 index 0000000..b60fe6c --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-statements.hxx @@ -0,0 +1,591 @@ +// file : odb/sqlite/simple-object-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX +#define ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX + +#include + +#include +#include +#include // std::size_t + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + // The extra_statement_cache class is only defined (and used) in + // the generated source file. However, object_statements may be + // referenced from another source file in the case of a polymorphic + // hierarchy (though in this case the extra statement cache is + // not used). As a result, we cannot have a by-value member and + // instead will store a pointer and lazily allocate the cache if + // and when needed. We will also need to store a pointer to the + // deleter function which will be initialized during allocation + // (at that point we know that the cache class is defined). + // + template + struct extra_statement_cache_ptr + { + typedef I image_type; + typedef ID id_image_type; + typedef sqlite::connection connection_type; + + extra_statement_cache_ptr (): p_ (0) {} + ~extra_statement_cache_ptr () + { + if (p_ != 0) + (this->*deleter_) (0, 0, 0, 0, 0); + } + + T& + get (connection_type& c, + image_type& im, id_image_type& idim, + binding& id, binding* idv) + { + if (p_ == 0) + allocate (&c, &im, &idim, &id, (idv != 0 ? idv : &id)); + + return *p_; + } + + private: + void + allocate (connection_type*, + image_type*, id_image_type*, + binding*, binding*); + + private: + T* p_; + void (extra_statement_cache_ptr::*deleter_) ( + connection_type*, image_type*, id_image_type*, binding*, binding*); + }; + + template + void extra_statement_cache_ptr:: + allocate (connection_type* c, + image_type* im, id_image_type* idim, + binding* id, binding* idv) + { + // To reduce object code size, this function acts as both allocator + // and deleter. + // + if (p_ == 0) + { + p_ = new T (*c, *im, *idim, *id, *idv); + deleter_ = &extra_statement_cache_ptr::allocate; + } + else + delete p_; + } + + // + // Implementation for objects with object id. + // + + class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base + { + public: + // Locking. + // + void + lock () + { + assert (!locked_); + locked_ = true; + } + + void + unlock () + { + assert (locked_); + locked_ = false; + } + + bool + locked () const + { + return locked_; + } + + struct auto_unlock + { + // Unlocks the statement on construction and re-locks it on + // destruction. + // + auto_unlock (object_statements_base&); + ~auto_unlock (); + + private: + auto_unlock (const auto_unlock&); + auto_unlock& operator= (const auto_unlock&); + + private: + object_statements_base& s_; + }; + + public: + virtual + ~object_statements_base (); + + protected: + object_statements_base (connection_type& conn) + : statements_base (conn), locked_ (false) + { + } + + protected: + bool locked_; + }; + + template + struct optimistic_data; + + template + struct optimistic_data + { + typedef T object_type; + typedef object_traits_impl object_traits; + + optimistic_data (bind*); + + binding* + id_image_binding () {return &id_image_binding_;} + + // The id + optimistic column binding. + // + binding id_image_binding_; + + details::shared_ptr erase_; + }; + + template + struct optimistic_data + { + optimistic_data (bind*) {} + + binding* + id_image_binding () {return 0;} + }; + + template + class object_statements: public object_statements_base + { + public: + typedef T object_type; + typedef object_traits_impl object_traits; + typedef typename object_traits::id_type id_type; + typedef typename object_traits::pointer_type pointer_type; + typedef typename object_traits::image_type image_type; + typedef typename object_traits::id_image_type id_image_type; + + typedef + typename object_traits::pointer_cache_traits + pointer_cache_traits; + + typedef + typename object_traits::extra_statement_cache_type + extra_statement_cache_type; + + typedef sqlite::insert_statement insert_statement_type; + typedef sqlite::select_statement select_statement_type; + typedef sqlite::update_statement update_statement_type; + typedef sqlite::delete_statement delete_statement_type; + + // Automatic lock. + // + struct auto_lock + { + // Lock the statements unless they are already locked in which + // case subsequent calls to locked() will return false. + // + auto_lock (object_statements&); + + // Unlock the statemens if we are holding the lock and clear + // the delayed loads. This should only happen in case an + // exception is thrown. In normal circumstances, the user + // should call unlock() explicitly. + // + ~auto_lock (); + + // Return true if this auto_lock instance holds the lock. + // + bool + locked () const; + + // Unlock the statemens. + // + void + unlock (); + + private: + auto_lock (const auto_lock&); + auto_lock& operator= (const auto_lock&); + + private: + object_statements& s_; + bool locked_; + }; + + + public: + object_statements (connection_type&); + + virtual + ~object_statements (); + + // Delayed loading. + // + typedef void (*loader_function) (odb::database&, + const id_type&, + object_type&, + const schema_version_migration*); + + void + delay_load (const id_type& id, + object_type& obj, + const typename pointer_cache_traits::position_type& p, + loader_function l = 0) + { + delayed_.push_back (delayed_load (id, obj, p, l)); + } + + void + load_delayed (const schema_version_migration* svm) + { + assert (locked ()); + + if (!delayed_.empty ()) + load_delayed_ (svm); + } + + void + clear_delayed () + { + if (!delayed_.empty ()) + clear_delayed_ (); + } + + // Object image. + // + image_type& + image () {return image_;} + + // Insert binding. + // + std::size_t + insert_image_version () const { return insert_image_version_;} + + void + insert_image_version (std::size_t v) {insert_image_version_ = v;} + + binding& + insert_image_binding () {return insert_image_binding_;} + + // Update binding. + // + std::size_t + update_image_version () const { return update_image_version_;} + + void + update_image_version (std::size_t v) {update_image_version_ = v;} + + std::size_t + update_id_image_version () const { return update_id_image_version_;} + + void + update_id_image_version (std::size_t v) {update_id_image_version_ = v;} + + binding& + update_image_binding () {return update_image_binding_;} + + // Select binding. + // + std::size_t + select_image_version () const { return select_image_version_;} + + void + select_image_version (std::size_t v) {select_image_version_ = v;} + + binding& + select_image_binding () {return select_image_binding_;} + + bool* + select_image_truncated () {return select_image_truncated_;} + + // Object id image and binding. + // + id_image_type& + id_image () {return id_image_;} + + std::size_t + id_image_version () const {return id_image_version_;} + + void + id_image_version (std::size_t v) {id_image_version_ = v;} + + binding& + id_image_binding () {return id_image_binding_;} + + // Optimistic id + managed column image binding. It points to + // the same suffix as id binding and they are always updated + // at the same time. + // + binding& + optimistic_id_image_binding () {return od_.id_image_binding_;} + + // Statements. + // + insert_statement_type& + persist_statement () + { + if (persist_ == 0) + { + persist_.reset ( + new (details::shared) insert_statement_type ( + conn_, + object_traits::persist_statement, + object_traits::versioned, // Process if versioned. + insert_image_binding_, + (object_traits::auto_id ? &id_image_binding_ : 0))); + } + + return *persist_; + } + + select_statement_type& + find_statement () + { + if (find_ == 0) + { + find_.reset ( + new (details::shared) select_statement_type ( + conn_, + object_traits::find_statement, + object_traits::versioned, // Process if versioned. + false, // Don't optimize. + id_image_binding_, + select_image_binding_)); + } + + return *find_; + } + + update_statement_type& + update_statement () + { + if (update_ == 0) + { + update_.reset ( + new (details::shared) update_statement_type ( + conn_, + object_traits::update_statement, + object_traits::versioned, // Process if versioned. + update_image_binding_)); + } + + return *update_; + } + + delete_statement_type& + erase_statement () + { + if (erase_ == 0) + { + erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::erase_statement, + id_image_binding_)); + } + + return *erase_; + } + + delete_statement_type& + optimistic_erase_statement () + { + if (od_.erase_ == 0) + { + od_.erase_.reset ( + new (details::shared) delete_statement_type ( + conn_, + object_traits::optimistic_erase_statement, + od_.id_image_binding_)); + } + + return *od_.erase_; + } + + // Extra (container, section) statement cache. + // + extra_statement_cache_type& + extra_statement_cache () + { + return extra_statement_cache_.get ( + conn_, + image_, id_image_, + id_image_binding_, od_.id_image_binding ()); + } + + public: + // select = total - separate_load + // insert = total - inverse - managed_optimistic + // update = total - inverse - managed_optimistic - id - readonly + // - separate_update + // + static const std::size_t id_column_count = + object_traits::id_column_count; + + static const std::size_t managed_optimistic_column_count = + object_traits::managed_optimistic_column_count; + + static const std::size_t select_column_count = + object_traits::column_count - + object_traits::separate_load_column_count; + + static const std::size_t insert_column_count = + object_traits::column_count - + object_traits::inverse_column_count - + object_traits::managed_optimistic_column_count; + + static const std::size_t update_column_count = + insert_column_count - + id_column_count - + object_traits::readonly_column_count - + object_traits::separate_update_column_count; + + private: + object_statements (const object_statements&); + object_statements& operator= (const object_statements&); + + protected: + template + void + load_delayed_ (const schema_version_migration*); + + void + clear_delayed_ (); + + protected: + template + friend class polymorphic_derived_object_statements; + + extra_statement_cache_ptr extra_statement_cache_; + + image_type image_; + + // Select binding. + // + std::size_t select_image_version_; + binding select_image_binding_; + bind select_image_bind_[select_column_count]; + bool select_image_truncated_[select_column_count]; + + // Insert binding. + // + std::size_t insert_image_version_; + binding insert_image_binding_; + bind insert_image_bind_[insert_column_count]; + + // Update binding. Note that the id suffix is bound to id_image_ + // below instead of image_ which makes this binding effectively + // bound to two images. As a result, we have to track versions + // for both of them. If this object uses optimistic concurrency, + // then the binding for the managed column (version, timestamp, + // etc) comes after the id and the image for such a column is + // stored as part of the id image. + // + std::size_t update_image_version_; + std::size_t update_id_image_version_; + binding update_image_binding_; + bind update_image_bind_[update_column_count + id_column_count + + managed_optimistic_column_count]; + + // Id image binding (only used as a parameter). Uses the suffix in + // the update bind. + // + id_image_type id_image_; + std::size_t id_image_version_; + binding id_image_binding_; + + // Extra data for objects with optimistic concurrency support. + // + optimistic_data od_; + + details::shared_ptr persist_; + details::shared_ptr find_; + details::shared_ptr update_; + details::shared_ptr erase_; + + // Delayed loading. + // + struct delayed_load + { + typedef typename pointer_cache_traits::position_type position_type; + + delayed_load () {} + delayed_load (const id_type& i, + object_type& o, + const position_type& p, + loader_function l) + : id (i), obj (&o), pos (p), loader (l) + { + } + + id_type id; + object_type* obj; + position_type pos; + loader_function loader; + }; + + typedef std::vector delayed_loads; + delayed_loads delayed_; + + // Delayed vectors swap guard. See the load_delayed_() function for + // details. + // + struct swap_guard + { + swap_guard (object_statements& os, delayed_loads& dl) + : os_ (os), dl_ (dl) + { + dl_.swap (os_.delayed_); + } + + ~swap_guard () + { + os_.clear_delayed (); + dl_.swap (os_.delayed_); + } + + private: + object_statements& os_; + delayed_loads& dl_; + }; + }; + } +} + +#include +#include + +#include + +#endif // ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/simple-object-statements.ixx b/libodb-sqlite/odb/sqlite/simple-object-statements.ixx new file mode 100644 index 0000000..6756c06 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-statements.ixx @@ -0,0 +1,68 @@ +// file : odb/sqlite/simple-object-statements.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace sqlite + { + // + // auto_unlock + // + inline object_statements_base::auto_unlock:: + auto_unlock (object_statements_base& s) + : s_ (s) + { + s_.unlock (); + } + + inline object_statements_base::auto_unlock:: + ~auto_unlock () + { + s_.lock (); + } + + // + // auto_lock + // + template + inline object_statements::auto_lock:: + auto_lock (object_statements& s) + : s_ (s) + { + if (!s_.locked ()) + { + s_.lock (); + locked_ = true; + } + else + locked_ = false; + } + + template + inline object_statements::auto_lock:: + ~auto_lock () + { + if (locked_) + { + s_.unlock (); + s_.clear_delayed (); + } + } + + template + inline bool object_statements::auto_lock:: + locked () const + { + return locked_; + } + + template + inline void object_statements::auto_lock:: + unlock () + { + assert (locked_); + s_.unlock (); + locked_ = false; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/simple-object-statements.txx b/libodb-sqlite/odb/sqlite/simple-object-statements.txx new file mode 100644 index 0000000..b80944d --- /dev/null +++ b/libodb-sqlite/odb/sqlite/simple-object-statements.txx @@ -0,0 +1,146 @@ +// file : odb/sqlite/simple-object-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::memset + +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // optimistic_data + // + + template + optimistic_data:: + optimistic_data (bind* b) + : id_image_binding_ ( + b, + object_traits::id_column_count + + object_traits::managed_optimistic_column_count) + { + } + + // + // object_statements + // + + template + object_statements:: + ~object_statements () + { + } + + template + object_statements:: + object_statements (connection_type& conn) + : object_statements_base (conn), + select_image_binding_ (select_image_bind_, select_column_count), + insert_image_binding_ (insert_image_bind_, insert_column_count), + update_image_binding_ (update_image_bind_, + update_column_count + id_column_count + + managed_optimistic_column_count), + id_image_binding_ (update_image_bind_ + update_column_count, + id_column_count), + od_ (update_image_bind_ + update_column_count) + { + image_.version = 0; + select_image_version_ = 0; + insert_image_version_ = 0; + update_image_version_ = 0; + update_id_image_version_ = 0; + + id_image_.version = 0; + id_image_version_ = 0; + + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); + std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); + std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); + std::memset ( + select_image_truncated_, 0, sizeof (select_image_truncated_)); + + for (std::size_t i (0); i < select_column_count; ++i) + select_image_bind_[i].truncated = select_image_truncated_ + i; + } + + template + template + void object_statements:: + load_delayed_ (const schema_version_migration* svm) + { + database& db (connection ().database ()); + + delayed_loads dls; + swap_guard sg (*this, dls); + + while (!dls.empty ()) + { + delayed_load l (dls.back ()); + typename pointer_cache_traits::insert_guard ig (l.pos); + dls.pop_back (); + + if (l.loader == 0) + { + object_traits_calls tc (svm); + + if (!tc.find_ (static_cast (*this), &l.id)) + throw object_not_persistent (); + + object_traits::callback (db, *l.obj, callback_event::pre_load); + + // Our calls to init/load below can result in additional delayed + // loads being added to the delayed_ vector. We need to process + // those before we call the post callback. + // + tc.init (*l.obj, image (), &db); + + // Load containers, etc. + // + tc.load_ (static_cast (*this), *l.obj, false); + + if (!delayed_.empty ()) + load_delayed_ (svm); + + // Temporarily unlock the statement for the post_load call so that + // it can load objects of this type recursively. This is safe to do + // because we have completely loaded the current object. Also the + // delayed_ list is clear before the unlock and should be clear on + // re-lock (since a callback can only call public API functions + // which will make sure all the delayed loads are processed before + // returning). + // + { + auto_unlock u (*this); + object_traits::callback (db, *l.obj, callback_event::post_load); + } + } + else + l.loader (db, l.id, *l.obj, svm); + + pointer_cache_traits::load (ig.position ()); + ig.release (); + } + } + + template + void object_statements:: + clear_delayed_ () + { + // Remove the objects from the session cache. + // + for (typename delayed_loads::iterator i (delayed_.begin ()), + e (delayed_.end ()); i != e; ++i) + { + pointer_cache_traits::erase (i->pos); + } + + delayed_.clear (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/sqlite-types.hxx b/libodb-sqlite/odb/sqlite/sqlite-types.hxx new file mode 100644 index 0000000..b9839bf --- /dev/null +++ b/libodb-sqlite/odb/sqlite/sqlite-types.hxx @@ -0,0 +1,57 @@ +// file : odb/sqlite/sqlite-types.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_SQLITE_TYPES_HXX +#define ODB_SQLITE_SQLITE_TYPES_HXX + +#include + +#include +#include // std::size_t + +namespace odb +{ + namespace sqlite + { + // The SQLite parameter/result binding. This data structures is modelled + // after MYSQL_BIND from MySQL. + // + struct bind + { + enum buffer_type + { + integer, // Buffer is long long; size, capacity, truncated are unused. + real, // Buffer is double; size, capacity, truncated are unused. + text, // Buffer is a UTF-8 char array. + text16, // Buffer is a UTF-16 2-byte char array (sizes in bytes). + blob, // Buffer is a char array. + stream // Buffer is stream_buffers. Size specifies the BLOB size + // (input only). Capacity and truncated unused. + }; + + buffer_type type; + void* buffer; + std::size_t* size; + std::size_t capacity; + bool* is_null; + bool* truncated; + }; + + // The "out" values should be set in set_image() to point to + // variables that will be receiving the data. The "in" values + // are used in set_value() and contain the data that needs to + // be copied over. + // + struct stream_buffers + { + union {std::string* out; const char* in;} db; + union {std::string* out; const char* in;} table; + union {std::string* out; const char* in;} column; + union {long long* out; long long in;} rowid; + }; + } +} + +#include + +#endif // ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/libodb-sqlite/odb/sqlite/statement-cache.hxx b/libodb-sqlite/odb/sqlite/statement-cache.hxx new file mode 100644 index 0000000..31ca685 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statement-cache.hxx @@ -0,0 +1,60 @@ +// file : odb/sqlite/statement-cache.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENT_CACHE_HXX +#define ODB_SQLITE_STATEMENT_CACHE_HXX + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT statement_cache + { + public: + statement_cache (connection& conn) + : conn_ (conn), + version_seq_ (conn_.database ().schema_version_sequence ()) {} + + template + typename object_traits_impl::statements_type& + find_object (); + + template + view_statements& + find_view (); + + private: + typedef std::map, + details::type_info_comparator> map; + + connection& conn_; + unsigned int version_seq_; + map map_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/libodb-sqlite/odb/sqlite/statement-cache.txx b/libodb-sqlite/odb/sqlite/statement-cache.txx new file mode 100644 index 0000000..c089e32 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statement-cache.txx @@ -0,0 +1,60 @@ +// file : odb/sqlite/statement-cache.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + template + typename object_traits_impl::statements_type& + statement_cache:: + find_object () + { + typedef + typename object_traits_impl::statements_type + statements_type; + + // Clear the cache if the database version has changed. This + // makes sure we don't re-use statements that correspond to + // the old schema. + // + if (version_seq_ != conn_.database ().schema_version_sequence ()) + { + map_.clear (); + version_seq_ = conn_.database ().schema_version_sequence (); + } + + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast (*i->second); + + details::shared_ptr p ( + new (details::shared) statements_type (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + + template + view_statements& statement_cache:: + find_view () + { + // We don't cache any statements for views so no need to clear + // the cache. + + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast&> (*i->second); + + details::shared_ptr > p ( + new (details::shared) view_statements (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/statement.cxx b/libodb-sqlite/odb/sqlite/statement.cxx new file mode 100644 index 0000000..b1b0f58 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statement.cxx @@ -0,0 +1,988 @@ +// file : odb/sqlite/statement.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include // object_not_persistent + +#include +#include +#include +#include + +#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + // LIBODB_SQLITE_HAVE_COLUMN_METADATA +using namespace std; + +namespace odb +{ + namespace sqlite + { + // statement + // + + statement:: + ~statement () + { + if (stmt_ != 0) + { + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->deallocate (conn_, *this); + } + + if (next_ != this) + list_remove (); + + stmt_.reset (); + } + } + + void statement:: + clear () + { + reset (); + } + + void statement:: + init (const char* text, + std::size_t text_size, + statement_kind sk, + const binding* proc, + bool optimize) + { + active_ = false; + + string tmp1; + if (proc != 0) + { + switch (sk) + { + case statement_select: + process_select (tmp1, + text, + &proc->bind->buffer, proc->count, sizeof (bind), + '"', '"', + optimize); + break; + case statement_insert: + process_insert (tmp1, + text, + &proc->bind->buffer, proc->count, sizeof (bind), + '?', + '$'); + break; + case statement_update: + process_update (tmp1, + text, + &proc->bind->buffer, proc->count, sizeof (bind), + '?', + '$'); + break; + case statement_delete: + case statement_generic: + assert (false); + } + + text = tmp1.c_str (); + text_size = tmp1.size (); + } + + string tmp2; + if (conn_.statement_translator_ != 0) + { + conn_.statement_translator_ (tmp2, text, text_size, conn_); + + if (!tmp2.empty ()) + { + text = tmp2.c_str (); + text_size = tmp2.size (); + } + } + +#if SQLITE_VERSION_NUMBER < 3005003 + text_.assign (text, text_size); +#endif + + // Empty statement. + // + if (*text == '\0') + return; + + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + { + // Temporarily store the statement text in prev_ so that + // text() which may be called by the tracer can access it. + // Dirty but efficient. + // +#if SQLITE_VERSION_NUMBER >= 3005003 + prev_ = reinterpret_cast (const_cast (text)); +#endif + t->prepare (conn_, *this); +#if SQLITE_VERSION_NUMBER >= 3005003 + prev_ = 0; +#endif + } + } + + int e; + sqlite3_stmt* stmt (0); + + // sqlite3_prepare_v2() is only available since SQLite 3.3.9 + // but is buggy until 3.3.11. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + while ((e = sqlite3_prepare_v2 (conn_.handle (), + text, + static_cast (text_size), + &stmt, + 0)) == SQLITE_LOCKED) + { + conn_.wait (); + } +#else + e = sqlite3_prepare (conn_.handle (), + text, + static_cast (text_size), + &stmt, + 0); +#endif + + if (e != SQLITE_OK) + translate_error (e, conn_); + + stmt_.reset (stmt); + } + + const char* statement:: + text () const + { + // sqlite3_sql() is only available since 3.5.3. + // +#if SQLITE_VERSION_NUMBER >= 3005003 + if (stmt_ == 0) + // See init() above for details on what's going on here. + // + return prev_ != 0 ? reinterpret_cast (prev_) : ""; + else + return sqlite3_sql (stmt_); +#else + return text_.c_str (); +#endif + } + + bool statement:: + bind_param (const bind* p, size_t n) + { + int e (SQLITE_OK); + bool r (false); + + // SQLite parameters are counted from 1. + // + for (size_t i (0), j (1); e == SQLITE_OK && i < n; ++i) + { + const bind& b (p[i]); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (static_cast (j++)); + + if (b.is_null != 0 && *b.is_null) + { + e = sqlite3_bind_null (stmt_, c); + continue; + } + + switch (b.type) + { + case bind::integer: + { + long long v (*static_cast (b.buffer)); + + e = sqlite3_bind_int64 (stmt_, + c, + // Prior to 3.5.0, sqlite3_int64 was called sqlite_int64. +#if SQLITE_VERSION_NUMBER >= 3005000 + static_cast (v) +#else + static_cast (v) +#endif + ); + break; + } + case bind::real: + { + double v (*static_cast (b.buffer)); + e = sqlite3_bind_double (stmt_, c, v); + break; + } + case bind::text: + { + e = sqlite3_bind_text (stmt_, + c, + static_cast (b.buffer), + static_cast (*b.size), + SQLITE_STATIC); + break; + } + case bind::text16: + { + e = sqlite3_bind_text16 (stmt_, + c, + b.buffer, + static_cast (*b.size), + SQLITE_STATIC); + break; + } + case bind::blob: + { + e = sqlite3_bind_blob (stmt_, + c, + b.buffer, + static_cast (*b.size), + SQLITE_STATIC); + break; + } + case bind::stream: + { +#if SQLITE_VERSION_NUMBER >= 3004000 + e = sqlite3_bind_zeroblob (stmt_, + c, + static_cast (*b.size)); + r = true; +#else + assert (false); +#endif + break; + } + } + } + + if (e != SQLITE_OK) + translate_error (e, conn_); + + return r; + } + + bool statement:: + bind_result (const bind* p, size_t count, bool truncated) + { + bool r (true); + int col_count (sqlite3_data_count (stmt_)); + + int col (0); + for (size_t i (0); i != count && col != col_count; ++i) + { + const bind& b (p[i]); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (col++); + + if (b.type == bind::stream) + col++; // Skip ROWID value that follows. + + if (truncated && (b.truncated == 0 || !*b.truncated)) + continue; + + if (b.truncated != 0) + *b.truncated = false; + + // Check for NULL unless we are reloading a truncated result. + // + if (!truncated) + { + *b.is_null = sqlite3_column_type (stmt_, c) == SQLITE_NULL; + + if (*b.is_null) + continue; + } + + switch (b.type) + { + case bind::integer: + { + *static_cast (b.buffer) = + static_cast (sqlite3_column_int64 (stmt_, c)); + break; + } + case bind::real: + { + *static_cast (b.buffer) = + sqlite3_column_double (stmt_, c); + break; + } + case bind::text: + case bind::text16: + case bind::blob: + { + // SQLite documentation recommends that we first call *_text(), + // *_text16(), or *_blob() function in order to force the type + // conversion, if any. + // + const void* d; + + if (b.type != bind::text16) + { + d = b.type == bind::text + ? sqlite3_column_text (stmt_, c) + : sqlite3_column_blob (stmt_, c); + *b.size = static_cast (sqlite3_column_bytes (stmt_, c)); + } + else + { + d = sqlite3_column_text16 (stmt_, c); + *b.size = static_cast ( + sqlite3_column_bytes16 (stmt_, c)); + } + + if (*b.size > b.capacity) + { + if (b.truncated != 0) + *b.truncated = true; + + r = false; + continue; + } + + memcpy (b.buffer, d, *b.size); + break; + } + case bind::stream: + { + stream_buffers& sb (*static_cast (b.buffer)); + + // SQLite documentation states that these are valid until the + // statement is finalized (or reprepared). For our case, we + // only need it to stay alive until we call set_value() which + // we do while executing the statement (i.e., we don't copy + // images for later processing). + // +#ifdef LIBODB_SQLITE_HAVE_COLUMN_METADATA + sb.db.in = sqlite3_column_database_name (stmt_, c); + sb.table.in = sqlite3_column_table_name (stmt_, c); + sb.column.in = sqlite3_column_origin_name (stmt_, c); +#else + assert (false); +#endif + + // The ROWID comes in the following column. + // + sb.rowid.in = static_cast ( + sqlite3_column_int64 (stmt_, c + 1)); + + break; + } + } + } + + // Make sure that the number of columns in the result returned by + // the database matches the number that we expect. A common cause + // of this assertion is a native view with a number of data members + // not matching the number of columns in the SELECT-list. + // + assert (col == col_count); + + return r; + } + + void statement:: + stream_param (const bind* p, size_t n, const stream_data& d) + { + // Code similar to bind_param(). + // + for (size_t i (0), j (1); i < n; ++i) + { + const bind& b (p[i]); + + if (b.buffer == 0) // Skip NULL entries. + continue; + + int c (static_cast (j++)); + + if ((b.is_null != 0 && *b.is_null) || b.type != bind::stream) + continue; + + // Get column name. + // + const char* col (sqlite3_bind_parameter_name (stmt_, c)); + assert (col != 0); // Statement doesn't contain column name. + + stream_buffers& sb (*static_cast (b.buffer)); + + *sb.db.out = d.db; + *sb.table.out = d.table; + *sb.column.out = col + 1; // Skip '$'. + *sb.rowid.out = d.rowid; + } + } + + inline void + update_hook (void* v, const char* db, const char* table, long long rowid) + { + statement::stream_data& d (*static_cast (v)); + d.db = db; + d.table = table; + d.rowid = rowid; + } + + extern "C" void + odb_sqlite_update_hook (void* v, + int, + const char* db, + const char* table, +#if SQLITE_VERSION_NUMBER >= 3005000 + sqlite3_int64 rowid +#else + sqlite_int64 rowid +#endif + ) + { + update_hook (v, db, table, static_cast (rowid)); + } + + // generic_statement + // + + generic_statement:: + generic_statement (connection_type& conn, const string& text) + : statement (conn, + text, statement_generic, + 0, false), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + generic_statement:: + generic_statement (connection_type& conn, const char* text) + : statement (conn, + text, statement_generic, + 0, false), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + generic_statement:: + generic_statement (connection_type& conn, + const char* text, + size_t text_size) + : statement (conn, + text, text_size, statement_generic, + 0, false), + result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) + { + } + + unsigned long long generic_statement:: + execute () + { + if (stmt_ == 0) // Empty statement or comment. + return 0; + + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + + unsigned long long r (0); + + int e; + sqlite3* h (conn_.handle ()); + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + // Only the first call to sqlite3_step() can return SQLITE_LOCKED. + // + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } +#else + e = sqlite3_step (stmt_); +#endif + + for (; e == SQLITE_ROW; e = sqlite3_step (stmt_)) + r++; + + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + sqlite3_reset (stmt_); + + if (e != SQLITE_DONE) + translate_error (e, conn_); +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) + { + // If the schema has changed, try to re-prepare and re-execute the + // statement. That's what newer versions of SQLite do automatically. + // + if (e == SQLITE_SCHEMA) + { + sqlite3_stmt* stmt (0); + e = sqlite3_prepare (h, + text_.c_str (), + static_cast (text_.size () + 1), + &stmt, + 0); + + if (e != SQLITE_OK) + translate_error (e, conn_); + + stmt_.reset (stmt); + return execute (); // Try again by recursively calling ourselves. + } + else + translate_error (e, conn_); + } +#endif + + if (!result_set_) + r = static_cast (sqlite3_changes (h)); + + return r; + } + + // select_statement + // + + select_statement:: + select_statement (connection_type& conn, + const string& text, + bool process, + bool optimize, + binding& param, + binding& result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (¶m), + result_ (result) + { + } + + select_statement:: + select_statement (connection_type& conn, + const char* text, + bool process, + bool optimize, + binding& param, + binding& result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (¶m), + result_ (result) + { + } + + select_statement:: + select_statement (connection_type& conn, + const string& text, + bool process, + bool optimize, + binding& result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (0), + result_ (result) + { + } + + select_statement:: + select_statement (connection_type& conn, + const char* text, + bool process, + bool optimize, + binding& result) + : statement (conn, + text, statement_select, + (process ? &result : 0), optimize), + param_ (0), + result_ (result) + { + } + + void select_statement:: + execute () + { + if (active ()) + reset (); + + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + + done_ = false; + + if (param_ != 0) + bind_param (param_->bind, param_->count); + + active (true); + } + + void select_statement:: + free_result () + { + reset (); + done_ = true; + } + + bool select_statement:: + next () + { + if (!done_) + { + int e; + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + sqlite3* h (conn_.handle ()); + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } +#else + e = sqlite3_step (stmt_); +#endif + + if (e != SQLITE_ROW) + { + done_ = true; + + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + reset (); + + if (e != SQLITE_DONE) +#else + e = reset (); + + if (e != SQLITE_OK) +#endif + translate_error (e, conn_); + } + } + + return !done_; + } + + select_statement::result select_statement:: + load () + { + if (done_) + return no_data; + + return bind_result (result_.bind, result_.count) ? success : truncated; + } + + void select_statement:: + reload () + { + assert (!done_); + + if (!bind_result (result_.bind, result_.count, true)) + assert (false); + } + + // insert_statement + // + + insert_statement:: + insert_statement (connection_type& conn, + const string& text, + bool process, + binding& param, + binding* returning) + : statement (conn, + text, statement_insert, + (process ? ¶m : 0), false), + param_ (param), + returning_ (returning) + { + } + + insert_statement:: + insert_statement (connection_type& conn, + const char* text, + bool process, + binding& param, + binding* returning) + : statement (conn, + text, statement_insert, + (process ? ¶m : 0), false), + param_ (param), + returning_ (returning) + { + } + + bool insert_statement:: + execute () + { + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + + sqlite3* h (conn_.handle ()); + bool stream (bind_param (param_.bind, param_.count)); + + stream_data sd; + if (stream) + sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); + + int e; + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } +#else + e = sqlite3_step (stmt_); +#endif + + if (stream) + sqlite3_update_hook (h, 0, 0); // Clear the hook. + + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + sqlite3_reset (stmt_); + + if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif + { + // SQLITE_CONSTRAINT error code covers more than just a duplicate + // primary key. Unfortunately, there is nothing more precise that + // we can use (even sqlite3_errmsg() returns generic "constraint + // failed"). But an auto-assigned object id should never cause a + // duplicate primary key. + // + if (returning_ == 0 && e == SQLITE_CONSTRAINT) + return false; + else + translate_error (e, conn_); + } + + // Stream parameters, if any. + // + if (stream) + stream_param (param_.bind, param_.count, sd); + + if (returning_ != 0) + { + bind& b (returning_->bind[0]); + + *b.is_null = false; + *static_cast (b.buffer) = + static_cast ( + sqlite3_last_insert_rowid (h)); + } + + return true; + } + + // update_statement + // + + update_statement:: + update_statement (connection_type& conn, + const string& text, + bool process, + binding& param) + : statement (conn, + text, statement_update, + (process ? ¶m : 0), false), + param_ (param) + { + } + + update_statement:: + update_statement (connection_type& conn, + const char* text, + bool process, + binding& param) + : statement (conn, + text, statement_update, + (process ? ¶m : 0), false), + param_ (param) + { + } + + unsigned long long update_statement:: + execute () + { + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + + sqlite3* h (conn_.handle ()); + bool stream (bind_param (param_.bind, param_.count)); + + stream_data sd; + if (stream) + sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); + + int e; + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } +#else + e = sqlite3_step (stmt_); +#endif + + if (stream) + sqlite3_update_hook (h, 0, 0); // Clear the hook. + + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + sqlite3_reset (stmt_); + + if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif + translate_error (e, conn_); + + int r (sqlite3_changes (h)); + + // Stream parameters, if any. + // + if (stream && r != 0) + stream_param (param_.bind, param_.count, sd); + + return static_cast (r); + } + + // delete_statement + // + + delete_statement:: + delete_statement (connection_type& conn, + const string& text, + binding& param) + : statement (conn, + text, statement_delete, + 0, false), + param_ (param) + { + } + + delete_statement:: + delete_statement (connection_type& conn, + const char* text, + binding& param) + : statement (conn, + text, statement_delete, + 0, false), + param_ (param) + { + } + + unsigned long long delete_statement:: + execute () + { + { + odb::tracer* t; + if ((t = conn_.main_connection ().transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->execute (conn_, *this); + } + + bind_param (param_.bind, param_.count); + + int e; + sqlite3* h (conn_.handle ()); + +#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY + while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) + { + if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) + break; + + sqlite3_reset (stmt_); + conn_.wait (); + } +#else + e = sqlite3_step (stmt_); +#endif + + // sqlite3_step() will return a detailed error code only if we used + // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the + // error. + // +#if SQLITE_VERSION_NUMBER >= 3003011 + sqlite3_reset (stmt_); + + if (e != SQLITE_DONE) +#else + e = sqlite3_reset (stmt_); + + if (e != SQLITE_OK) +#endif + translate_error (e, conn_); + + return static_cast (sqlite3_changes (h)); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/statement.hxx b/libodb-sqlite/odb/sqlite/statement.hxx new file mode 100644 index 0000000..9eeea7b --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statement.hxx @@ -0,0 +1,392 @@ +// file : odb/sqlite/statement.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENT_HXX +#define ODB_SQLITE_STATEMENT_HXX + +#include + +#include + +#include +#include // std::size_t +#include // std::strlen, std::memcpy +#include + +#include + +#include +#include +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class connection; + + class LIBODB_SQLITE_EXPORT statement: public odb::statement, + public active_object + { + public: + typedef sqlite::connection connection_type; + + virtual + ~statement () = 0; + + sqlite3_stmt* + handle () const + { + return stmt_; + } + + virtual const char* + text () const; + + virtual connection_type& + connection () + { + return conn_; + } + + // A statement can be empty. This is used to handle situations + // where a SELECT or UPDATE statement ends up not having any + // columns after processing. An empty statement cannot be + // executed. + // + bool + empty () const + { + return stmt_ == 0; + } + + protected: + // We keep two versions to take advantage of std::string COW. + // + statement (connection_type& conn, + const std::string& text, + statement_kind sk, + const binding* process, + bool optimize) + : active_object (conn) + { + init (text.c_str (), text.size (), sk, process, optimize); + } + + statement (connection_type& conn, + const char* text, + statement_kind sk, + const binding* process, + bool optimize) + : active_object (conn) + { + init (text, std::strlen (text), sk, process, optimize); + } + + statement (connection_type& conn, + const char* text, + std::size_t text_size, + statement_kind sk, + const binding* process, + bool optimize) + : active_object (conn) + { + init (text, text_size, sk, process, optimize); + } + + protected: + // Return true if we bound any stream parameters. + // + bool + bind_param (const bind*, std::size_t count); + + // Extract row columns into the bound buffers. If the truncated + // argument is true, then only truncated columns are extracted. + // Return true if all the data was extracted successfully and + // false if one or more columns were truncated. + // + bool + bind_result (const bind*, std::size_t count, bool truncated = false); + + // Stream (so to speak) parameters. + // + struct stream_data + { + std::string db; + std::string table; + long long rowid; + }; + + void + stream_param (const bind*, std::size_t count, const stream_data&); + + friend void + update_hook (void*, const char*, const char*, long long); + + // Active state. + // + protected: + bool + active () const + { + return active_; + } + + void + active (bool active) + { + assert (active); + + if (!active_) + { + list_add (); + active_ = true; + } + } + + int + reset () + { + int r (SQLITE_OK); + + if (active_) + { + r = sqlite3_reset (stmt_); + list_remove (); + active_ = false; + } + + return r; + } + + // The active_object interface. + // + virtual void + clear (); + + protected: + auto_handle stmt_; + +#if SQLITE_VERSION_NUMBER < 3005003 + std::string text_; +#endif + + bool active_; + + private: + void + init (const char* text, + std::size_t text_size, + statement_kind, + const binding* process, + bool optimize); + }; + + class LIBODB_SQLITE_EXPORT generic_statement: public statement + { + public: + generic_statement (connection_type&, const std::string& text); + generic_statement (connection_type&, const char* text); + generic_statement (connection_type&, + const char* text, + std::size_t text_size); + + unsigned long long + execute (); + + private: + generic_statement (const generic_statement&); + generic_statement& operator= (const generic_statement&); + + private: + bool result_set_; + }; + + class LIBODB_SQLITE_EXPORT select_statement: public statement + { + public: + select_statement (connection_type& conn, + const std::string& text, + bool process_text, + bool optimize_text, + binding& param, + binding& result); + + select_statement (connection_type& conn, + const char* text, + bool process_text, + bool optimize_text, + binding& param, + binding& result); + + select_statement (connection_type& conn, + const std::string& text, + bool process_text, + bool optimize_text, + binding& result); + + select_statement (connection_type& conn, + const char* text, + bool process_text, + bool optimize_text, + binding& result); + + // Common select interface expected by the generated code. + // + public: + enum result + { + success, + no_data, + truncated + }; + + void + execute (); + + // Load next row columns into bound buffers. + // + result + fetch () + { + return next () ? load () : no_data; + } + + // Reload truncated columns into bound buffers. + // + void + refetch () + { + reload (); + } + + // Free the result set. + // + void + free_result (); + + // More fine-grained SQLite-specific interface that splits fetch() + // into next() and load(). + // + public: + // Return false if there is no more rows. You should call next() + // until it returns false or, alternatively, call free_result (). + // Otherwise the statement will remain unfinished. + // + bool + next (); + + result + load (); + + void + reload (); + + private: + select_statement (const select_statement&); + select_statement& operator= (const select_statement&); + + private: + bool done_; + binding* param_; + binding& result_; + }; + + struct auto_result + { + explicit auto_result (select_statement& s): s_ (s) {} + ~auto_result () {s_.free_result ();} + + private: + auto_result (const auto_result&); + auto_result& operator= (const auto_result&); + + private: + select_statement& s_; + }; + + class LIBODB_SQLITE_EXPORT insert_statement: public statement + { + public: + insert_statement (connection_type& conn, + const std::string& text, + bool process_text, + binding& param, + binding* returning); + + insert_statement (connection_type& conn, + const char* text, + bool process_text, + binding& param, + binding* returning); + + // Return true if successful and false if the row is a duplicate. + // All other errors are reported by throwing exceptions. + // + bool + execute (); + + private: + insert_statement (const insert_statement&); + insert_statement& operator= (const insert_statement&); + + private: + binding& param_; + binding* returning_; + }; + + class LIBODB_SQLITE_EXPORT update_statement: public statement + { + public: + update_statement (connection_type& conn, + const std::string& text, + bool process_text, + binding& param); + + update_statement (connection_type& conn, + const char* text, + bool process_text, + binding& param); + + unsigned long long + execute (); + + private: + update_statement (const update_statement&); + update_statement& operator= (const update_statement&); + + private: + binding& param_; + }; + + class LIBODB_SQLITE_EXPORT delete_statement: public statement + { + public: + delete_statement (connection_type& conn, + const std::string& text, + binding& param); + + delete_statement (connection_type& conn, + const char* text, + binding& param); + + unsigned long long + execute (); + + private: + delete_statement (const delete_statement&); + delete_statement& operator= (const delete_statement&); + + private: + binding& param_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STATEMENT_HXX diff --git a/libodb-sqlite/odb/sqlite/statements-base.cxx b/libodb-sqlite/odb/sqlite/statements-base.cxx new file mode 100644 index 0000000..bde8c55 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statements-base.cxx @@ -0,0 +1,15 @@ +// file : odb/sqlite/statements-base.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + namespace sqlite + { + statements_base:: + ~statements_base () + { + } + } +} diff --git a/libodb-sqlite/odb/sqlite/statements-base.hxx b/libodb-sqlite/odb/sqlite/statements-base.hxx new file mode 100644 index 0000000..5851d1b --- /dev/null +++ b/libodb-sqlite/odb/sqlite/statements-base.hxx @@ -0,0 +1,63 @@ +// file : odb/sqlite/statements-base.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STATEMENTS_BASE_HXX +#define ODB_SQLITE_STATEMENTS_BASE_HXX + +#include + +#include +#include + +#include +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT statements_base: public details::shared_base + { + public: + typedef sqlite::connection connection_type; + + connection_type& + connection () + { + return conn_; + } + + // Schema version. database::schema_version_migration() is thread- + // safe which means it is also slow. Cache the result in statements + // so we can avoid the mutex lock. This is thread-safe since if the + // version is updated, then the statements cache will be expired. + // + const schema_version_migration& + version_migration (const char* name = "") const + { + if (svm_ == 0) + svm_ = &conn_.database ().schema_version_migration (name); + + return *svm_; + } + + public: + virtual + ~statements_base (); + + protected: + statements_base (connection_type& conn): conn_ (conn), svm_ (0) {} + + protected: + connection_type& conn_; + mutable const schema_version_migration* svm_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/libodb-sqlite/odb/sqlite/stream.cxx b/libodb-sqlite/odb/sqlite/stream.cxx new file mode 100644 index 0000000..8420ba2 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/stream.cxx @@ -0,0 +1,120 @@ +// file : odb/sqlite/stream.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#if SQLITE_VERSION_NUMBER >= 3004000 + +#include + +#include // invalid_argument + +#include +#include +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + stream:: + stream (const char* db, + const char* table, + const char* column, + long long rowid, + bool rw) + : active_object (transaction::current ().connection ()) + { + int e (sqlite3_blob_open (conn_.handle (), + db, + table, + column, + static_cast (rowid), + rw, + &h_)); + + if (e != SQLITE_OK) + translate_error (e, conn_); + + list_add (); // Add ourselves to the active objects list. + } + + size_t stream:: + size () const + { + return static_cast (sqlite3_blob_bytes (h_)); + } + + void stream:: + read (void* buf, size_t n, size_t o) + { + int e (sqlite3_blob_read ( + h_, buf, static_cast (n), static_cast (o))); + + if (e != SQLITE_OK) + { + if (e == SQLITE_ERROR) + throw invalid_argument ("read past end"); + else + translate_error (e, conn_); + } + } + + void stream:: + write (const void* buf, size_t n, size_t o) + { + int e (sqlite3_blob_write ( + h_, buf, static_cast (n), static_cast (o))); + + if (e != SQLITE_OK) + { + if (e == SQLITE_ERROR) + throw invalid_argument ("write past end"); + else + translate_error (e, conn_); + } + } + + void stream:: + close (bool check) + { + if (h_ != 0) + { + list_remove (); + + int e (sqlite3_blob_close (h_)); + h_ = 0; // No use trying again. + + if (check && e != SQLITE_OK) + translate_error (e, conn_); + } + } + +#if SQLITE_VERSION_NUMBER >= 3007004 + void stream:: + reopen (long long rowid) + { + int e (sqlite3_blob_reopen (h_, rowid)); + + if (e != SQLITE_OK) + // According to the SQLite documentation, the handle is now + // considered aborted, which means we still need to close it. + // + translate_error (e, conn_); + } +#endif + + void stream:: + clear () + { + // This call can be part of the stack unwinding, so don't check + // for the errors. + // + close (false); + } + } +} + +#endif // SQLITE_VERSION_NUMBER >= 3004000 diff --git a/libodb-sqlite/odb/sqlite/stream.hxx b/libodb-sqlite/odb/sqlite/stream.hxx new file mode 100644 index 0000000..6ee76cb --- /dev/null +++ b/libodb-sqlite/odb/sqlite/stream.hxx @@ -0,0 +1,85 @@ +// file : odb/sqlite/stream.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_STREAM_HXX +#define ODB_SQLITE_STREAM_HXX + +#include + +#include + +#include // std::size_t + +#include +#include + +namespace odb +{ + namespace sqlite + { + // SQLite incremental BLOB/TEXT I/O stream. Available since + // SQLite 3.4.0. + // + class LIBODB_SQLITE_EXPORT stream: public active_object + { + public: + // @@ TODO: db is actually what we now (and SQLite in other places) + // call schema (see database::schema(), ATTACH DATABASE). So we + // should probably rename this at some point for consistency. + // + stream (const char* db, + const char* table, + const char* column, + long long rowid, + bool rw); + + std::size_t + size () const; + + // The following two functions throw std::invalid_argument if + // offset + n is past size(). + // + void + read (void* buf, std::size_t n, std::size_t offset = 0); + + void + write (const void* buf, std::size_t n, std::size_t offset = 0); + + sqlite3_blob* + handle () const {return h_;} + + // Close without reporting errors, if any. + // + virtual + ~stream () {close (false);} + + // Close, by default with reporting errors, if any. + // + void + close (bool check = true); + + // Open the same BLOB but in a different row. Can be faster + // than creating a new stream instance. Note that the stream + // must be in the open state prior to calling this function. + // Only available since SQLite 3.7.4. + // +#if SQLITE_VERSION_NUMBER >= 3007004 + void + reopen (long long rowid); +#endif + + protected: + // The active_object interface. + // + virtual void + clear (); + + private: + sqlite3_blob* h_; + }; + } +} + +#include + +#endif // ODB_SQLITE_STREAM_HXX diff --git a/libodb-sqlite/odb/sqlite/text-stream.hxx b/libodb-sqlite/odb/sqlite/text-stream.hxx new file mode 100644 index 0000000..7a9b467 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/text-stream.hxx @@ -0,0 +1,31 @@ +// file : odb/sqlite/text-stream.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TEXT_STREAM_HXX +#define ODB_SQLITE_TEXT_STREAM_HXX + +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + class text_stream: public stream + { + public: + text_stream (const text& b, bool rw) + : stream (b.db ().c_str (), + b.table ().c_str (), + b.column ().c_str (), + b.rowid (), + rw) {} + }; + } +} + +#include + +#endif // ODB_SQLITE_TEXT_STREAM_HXX diff --git a/libodb-sqlite/odb/sqlite/text.hxx b/libodb-sqlite/odb/sqlite/text.hxx new file mode 100644 index 0000000..3f681fb --- /dev/null +++ b/libodb-sqlite/odb/sqlite/text.hxx @@ -0,0 +1,69 @@ +// file : odb/sqlite/text.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TEXT_HXX +#define ODB_SQLITE_TEXT_HXX + +#include + +#include +#include // std::size_t + +// Carefully allow this header to be included into the ODB compilation. +// +#ifndef ODB_COMPILER +# include +# include +#endif + +namespace odb +{ + namespace sqlite + { +#ifdef ODB_COMPILER + #pragma db sqlite:type("TEXT STREAM") + class text +#else + class text +#endif + { + public: + // TEXT size to provision for. Set before calling persist() or update(). + // + explicit + text (std::size_t size = 0): size_ (size) {} + + std::size_t size () const {return size_;} + void size (std::size_t s) {size_ = s;} + + const std::string& db () const {return db_;} + const std::string& table () const {return table_;} + const std::string& column () const {return column_;} + long long rowid () const {return rowid_;} + + void + clear () + { + size_ = 0; + db_.clear (); + table_.clear (); + column_.clear (); + rowid_ = 0; + } + + private: +#ifndef ODB_COMPILER + friend struct default_value_traits; +#endif + std::size_t size_; + mutable std::string db_; + mutable std::string table_; + mutable std::string column_; + mutable long long rowid_; + }; + } +} + +#include + +#endif // ODB_SQLITE_TEXT_HXX diff --git a/libodb-sqlite/odb/sqlite/tracer.cxx b/libodb-sqlite/odb/sqlite/tracer.cxx new file mode 100644 index 0000000..49f6b00 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/tracer.cxx @@ -0,0 +1,60 @@ +// file : odb/sqlite/tracer.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + tracer:: + ~tracer () + { + } + + void tracer:: + prepare (connection&, const statement&) + { + } + + void tracer:: + execute (connection& c, const statement& s) + { + execute (c, s.text ()); + } + + void tracer:: + deallocate (connection&, const statement&) + { + } + + void tracer:: + prepare (odb::connection& c, const odb::statement& s) + { + prepare (static_cast (c), + static_cast (s)); + } + + void tracer:: + execute (odb::connection& c, const odb::statement& s) + { + execute (static_cast (c), + static_cast (s)); + } + + void tracer:: + execute (odb::connection& c, const char* s) + { + execute (static_cast (c), s); + } + + void tracer:: + deallocate (odb::connection& c, const odb::statement& s) + { + deallocate (static_cast (c), + static_cast (s)); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/tracer.hxx b/libodb-sqlite/odb/sqlite/tracer.hxx new file mode 100644 index 0000000..b12573b --- /dev/null +++ b/libodb-sqlite/odb/sqlite/tracer.hxx @@ -0,0 +1,61 @@ +// file : odb/sqlite/tracer.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRACER_HXX +#define ODB_SQLITE_TRACER_HXX + +#include + +#include + +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT tracer: private odb::tracer + { + public: + virtual + ~tracer (); + + virtual void + prepare (connection&, const statement&); + + virtual void + execute (connection&, const statement&); + + virtual void + execute (connection&, const char* statement) = 0; + + virtual void + deallocate (connection&, const statement&); + + private: + // Allow these classes to convert sqlite::tracer to odb::tracer. + // + friend class database; + friend class connection; + friend class transaction; + + virtual void + prepare (odb::connection&, const odb::statement&); + + virtual void + execute (odb::connection&, const odb::statement&); + + virtual void + execute (odb::connection&, const char* statement); + + virtual void + deallocate (odb::connection&, const odb::statement&); + }; + } +} + +#include + +#endif // ODB_SQLITE_TRACER_HXX diff --git a/libodb-sqlite/odb/sqlite/traits-calls.hxx b/libodb-sqlite/odb/sqlite/traits-calls.hxx new file mode 100644 index 0000000..9d5b59f --- /dev/null +++ b/libodb-sqlite/odb/sqlite/traits-calls.hxx @@ -0,0 +1,214 @@ +// file : odb/sqlite/traits-calls.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRAITS_CALLS_HXX +#define ODB_SQLITE_TRAITS_CALLS_HXX + +#include + +#include // std::size_t + +#include +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // object_traits_calls + // + + template ::versioned> + struct object_traits_calls; + + template + struct object_traits_calls + { + typedef object_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + object_traits_calls (const schema_version_migration*) {} + + const schema_version_migration* + version () const {return 0;} + + static bool + grow (image_type& i, bool* t) + { + return traits::grow (i, t); + } + + static void + bind (bind_type* b, image_type& i, statement_kind sk) + { + traits::bind (b, i, sk); + } + + // Poly-derived version. + // + static void + bind (bind_type* b, + const bind_type* id, std::size_t id_size, + image_type& i, + statement_kind sk) + { + traits::bind (b, id, id_size, i, sk); + } + + static void + init (T& o, const image_type& i, odb::database* db) + { + traits::init (o, i, db); + } + + static bool + find_ (typename traits::statements_type& sts, + const typename traits::id_type* id) + { + return traits::find_ (sts, id); + } + + static void + load_ (typename traits::statements_type& sts, T& o, bool reload) + { + return traits::load_ (sts, o, reload); + } + }; + + template + struct object_traits_calls + { + typedef object_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + object_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + + const schema_version_migration* + version () const {return &svm_;} + + bool + grow (image_type& i, bool* t) const + { + return traits::grow (i, t, svm_); + } + + void + bind (bind_type* b, image_type& i, statement_kind sk) const + { + traits::bind (b, i, sk, svm_); + } + + // Poly-derived version. + // + void + bind (bind_type* b, + const bind_type* id, std::size_t id_size, + image_type& i, + statement_kind sk) const + { + traits::bind (b, id, id_size, i, sk, svm_); + } + + void + init (T& o, const image_type& i, odb::database* db) const + { + traits::init (o, i, db, svm_); + } + + bool + find_ (typename traits::statements_type& sts, + const typename traits::id_type* id) const + { + return traits::find_ (sts, id, svm_); + } + + void + load_ (typename traits::statements_type& sts, T& o, bool reload) const + { + return traits::load_ (sts, o, reload, svm_); + } + + private: + const schema_version_migration& svm_; + }; + + // + // view_traits_calls + // + + template ::versioned> + struct view_traits_calls; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + view_traits_calls (const schema_version_migration*) {} + + static bool + grow (image_type& i, bool* t) + { + return traits::grow (i, t); + } + + static void + bind (bind_type* b, image_type& i) + { + traits::bind (b, i); + } + + static void + init (T& o, const image_type& i, odb::database* db) + { + traits::init (o, i, db); + } + }; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef sqlite::bind bind_type; + + view_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + + bool + grow (image_type& i, bool* t) const + { + return traits::grow (i, t, svm_); + } + + void + bind (bind_type* b, image_type& i) const + { + traits::bind (b, i, svm_); + } + + void + init (T& o, const image_type& i, odb::database* db) const + { + traits::init (o, i, db, svm_); + } + + private: + const schema_version_migration& svm_; + }; + } +} + +#include + +#endif // ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/libodb-sqlite/odb/sqlite/traits.cxx b/libodb-sqlite/odb/sqlite/traits.cxx new file mode 100644 index 0000000..a47455d --- /dev/null +++ b/libodb-sqlite/odb/sqlite/traits.cxx @@ -0,0 +1,219 @@ +// file : odb/sqlite/traits.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +using namespace std; + +namespace odb +{ + namespace sqlite + { + using details::buffer; + + // + // default_value_traits + // + void default_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const string& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v.c_str (), n); + } + + // + // c_string_value_traits + // + void c_string_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const char* v) + { + is_null = false; + n = strlen (v); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } + + // + // c_array_value_traits_base + // + void c_array_value_traits_base:: + set_value (char* const& v, + const details::buffer& b, + size_t n, + bool is_null, + size_t N) + { + if (!is_null) + { + n = n < N ? n : N; + + if (n != 0) + memcpy (v, b.data (), n); + } + else + n = 0; + + if (n != N) // Append '\0' if there is space. + v[n] = '\0'; + } + + void c_array_value_traits_base:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const char* v, + size_t N) + { + is_null = false; + + // Figure out the length. We cannot use strlen since it may + // not be 0-terminated (strnlen is not standard). + // + for (n = 0; n != N && v[n] != '\0'; ++n) ; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } + + // + // default_value_traits + // +#ifdef _WIN32 + void default_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const wstring& v) + { + is_null = false; + n = v.size () * 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v.c_str (), n); + } + + // + // c_wstring_value_traits + // + void c_wstring_value_traits:: + set_image (buffer& b, size_t& n, bool& is_null, const wchar_t* v) + { + is_null = false; + n = wcslen (v) * 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } + + // + // c_warray_value_traits_base + // + void c_warray_value_traits_base:: + set_value (wchar_t* const& v, + const details::buffer& b, + size_t n, + bool is_null, + size_t N) + { + if (!is_null) + { + n /= 2; + n = n < N ? n : N; + + if (n != 0) + memcpy (v, b.data (), n * sizeof (wchar_t)); + } + else + n = 0; + + if (n != N) // Append '\0' if there is space. + v[n] = L'\0'; + } + + void c_warray_value_traits_base:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const wchar_t* v, + size_t N) + { + is_null = false; + + // Figure out the length. We cannot use wcslen since it may + // not be 0-terminated (wcsnlen is not standard). + // + for (n = 0; n != N && v[n] != L'\0'; ++n) ; + + n *= 2; + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + memcpy (b.data (), v, n); + } +#endif // _WIN32 + + // + // default_value_traits, id_blob> + // + // std::vector has to be qualified for Sun CC. + // + void default_value_traits, id_blob>:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b.data (), &v.front (), n); + } + + // + // default_value_traits, id_blob> + // + // std::vector has to be qualified for Sun CC. + // + void default_value_traits, id_blob>:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b.data (), &v.front (), n); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/traits.hxx b/libodb-sqlite/odb/sqlite/traits.hxx new file mode 100644 index 0000000..a8cf578 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/traits.hxx @@ -0,0 +1,1099 @@ +// file : odb/sqlite/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRAITS_HXX +#define ODB_SQLITE_TRAITS_HXX + +#include + +#include // ODB_CXX11 + +#include +#include +#include // std::numeric_limits +#include // std::size_t +#include // std::memcpy, std::memset, std::strlen + +#ifdef ODB_CXX11 +# include +#endif + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace odb +{ + namespace sqlite + { + // + // image_traits + // + + template + struct image_traits; + + template + struct image_traits {typedef long long image_type;}; + + template + struct image_traits {typedef double image_type;}; + + template + struct image_traits + { + typedef details::buffer image_type; + + // By default the text is in UTF-8. + // + static const bind::buffer_type bind_value = bind::text; + }; + + template + struct image_traits {typedef details::buffer image_type;}; + + template + struct image_traits + { + typedef stream_buffers image_type; + }; + + template + struct image_traits + { + typedef stream_buffers image_type; + }; + + // + // value_traits + // + + template + struct wrapped_value_traits; + + template + struct default_value_traits; + + template ::r> + struct select_traits; + + template + struct select_traits + { + typedef default_value_traits type; + }; + + template + struct select_traits + { + typedef + wrapped_value_traits::null_handler> + type; + }; + + template + class value_traits: public select_traits::type + { + }; + + // The wrapped_value_traits specializations should be able to handle + // any value type which means we have to have every possible signature + // of the set_value() and set_image() functions. + // + template + struct wrapped_value_traits + { + typedef wrapper_traits wtraits; + typedef typename wtraits::unrestricted_wrapped_type wrapped_type; + + typedef W value_type; + typedef wrapped_type query_type; + typedef typename image_traits::image_type image_type; + + typedef value_traits vtraits; + + static void + set_value (W& v, const image_type& i, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (image_type& i, bool& is_null, const W& v) + { + vtraits::set_image (i, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB. + // + static void + set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) + { + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB STREAM. + // + static void + set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) + { + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } + }; + + template + struct wrapped_value_traits + { + typedef wrapper_traits wtraits; + typedef typename wtraits::unrestricted_wrapped_type wrapped_type; + + typedef W value_type; + typedef wrapped_type query_type; + typedef typename image_traits::image_type image_type; + + typedef value_traits vtraits; + + static void + set_value (W& v, const image_type& i, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (image_type& i, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (i, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB. + // + static void + set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } + + // TEXT and BLOB STREAM. + // + static void + set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), b, n, is_null); + } + + static void + set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); + } + }; + + template + struct default_value_traits + { + typedef T value_type; + typedef T query_type; + typedef typename image_traits::image_type image_type; + + static void + set_value (T& v, const image_type& i, bool is_null) + { + if (!is_null) + v = T (i); + else + v = T (); + } + + static void + set_image (image_type& i, bool& is_null, T v) + { + is_null = false; + i = image_type (v); + } + }; + + // Float & double specialization. SQLite converts NaNs to NULLs so + // we convert NULLs to NaNs for consistency. + // + template + struct real_value_traits + { + typedef T value_type; + typedef T query_type; + typedef double image_type; + + static void + set_value (T& v, double i, bool is_null) + { + if (!is_null) + v = T (i); + else + v = std::numeric_limits::quiet_NaN (); + } + + static void + set_image (double& i, bool& is_null, T v) + { + is_null = false; + i = image_type (v); + } + }; + + template <> + struct default_value_traits: real_value_traits {}; + + template <> + struct default_value_traits: real_value_traits {}; + + // std::string specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + typedef std::string value_type; + typedef std::string query_type; + typedef details::buffer image_type; + + static void + set_value (std::string& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (b.data (), n); + else + v.erase (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const std::string&); + }; + + // char*/const char* specialization + // + // Specialization for const char* which only supports initialization + // of an image from the value but not the other way around. This way + // we can pass such values to the queries. + // + struct LIBODB_SQLITE_EXPORT c_string_value_traits + { + typedef const char* value_type; + typedef details::buffer image_type; + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const char*); + }; + + template <> + struct default_value_traits: c_string_value_traits {}; + + template <> + struct default_value_traits: + c_string_value_traits {}; + + // char[N] specialization. + // + struct LIBODB_SQLITE_EXPORT c_array_value_traits_base + { + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null, + std::size_t N); + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v, + std::size_t N); + }; + + template + struct default_value_traits + { + typedef char* value_type; + typedef char query_type[N]; + typedef details::buffer image_type; + + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (v, b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v) + { + c_array_value_traits_base::set_image (b, n, is_null, v, N); + } + }; + + // std::array (string) specialization. + // +#ifdef ODB_CXX11 + template + struct default_value_traits, id_text> + { + typedef std::array value_type; + typedef std::array query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (v.data (), b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + c_array_value_traits_base::set_image (b, n, is_null, v.data (), N); + } + }; +#endif + + // char specialization. + // + template <> + struct default_value_traits + { + typedef char value_type; + typedef char query_type; + typedef details::buffer image_type; + + static void + set_value (char& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_array_value_traits_base::set_value (&v, b, n, is_null, 1); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + char v) + { + c_array_value_traits_base::set_image (b, n, is_null, &v, 1); + } + }; + +#ifdef _WIN32 + // std::wstring specialization. Using UTF-16 binding. + // + struct wstring_image_traits + { + typedef details::buffer image_type; + static const bind::buffer_type bind_value = bind::text16; + }; + + template <> + struct image_traits: wstring_image_traits {}; + + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits + { + typedef std::wstring value_type; + typedef std::wstring query_type; + typedef details::buffer image_type; + + static void + set_value (std::wstring& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (reinterpret_cast (b.data ()), n / 2); + else + v.erase (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const std::wstring&); + }; + + // wchar_t*/const wchar_t* specialization. + // + struct LIBODB_SQLITE_EXPORT c_wstring_value_traits + { + typedef const wchar_t* value_type; + typedef details::buffer image_type; + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const wchar_t*); + }; + + template <> + struct image_traits: wstring_image_traits {}; + + template <> + struct default_value_traits: c_wstring_value_traits {}; + + template <> + struct image_traits: wstring_image_traits {}; + + template <> + struct default_value_traits: + c_wstring_value_traits {}; + + // wchar_t[N] specialization. + // + struct LIBODB_SQLITE_EXPORT c_warray_value_traits_base + { + static void + set_value (wchar_t* const& v, + const details::buffer& b, + std::size_t n, + bool is_null, + std::size_t N); + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const wchar_t* v, + std::size_t N); + }; + + template + struct image_traits: wstring_image_traits {}; + + template + struct default_value_traits + { + typedef wchar_t* value_type; + typedef wchar_t query_type[N]; + typedef details::buffer image_type; + + static void + set_value (wchar_t* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (v, b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const wchar_t* v) + { + c_warray_value_traits_base::set_image (b, n, is_null, v, N); + } + }; + + // std::array (string) specialization. + // +#ifdef ODB_CXX11 + template + struct image_traits, id_text>: + wstring_image_traits {}; + + template + struct default_value_traits, id_text> + { + typedef std::array value_type; + typedef std::array query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (v.data (), b, n, is_null, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + c_warray_value_traits_base::set_image (b, n, is_null, v.data (), N); + } + }; +#endif + + // wchar_t specialization. + // + template <> + struct image_traits: wstring_image_traits {}; + + template <> + struct default_value_traits + { + typedef wchar_t value_type; + typedef wchar_t query_type; + typedef details::buffer image_type; + + static void + set_value (wchar_t& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + c_warray_value_traits_base::set_value (&v, b, n, is_null, 1); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + wchar_t v) + { + c_warray_value_traits_base::set_image (b, n, is_null, &v, 1); + } + }; +#endif // _WIN32 + + // std::vector (buffer) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits< + std::vector, id_blob> + { + public: + typedef std::vector value_type; + typedef std::vector query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + v.assign (b.data (), b.data () + n); + else + v.clear (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const value_type&); + }; + + // std::vector (buffer) specialization. + // + template <> + struct LIBODB_SQLITE_EXPORT default_value_traits< + std::vector, id_blob> + { + public: + typedef std::vector value_type; + typedef std::vector query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + { + const unsigned char* d ( + reinterpret_cast (b.data ())); + v.assign (d, d + n); + } + else + v.clear (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const value_type&); + }; + + // char[N] (buffer) specialization. + // + template + struct default_value_traits + { + public: + typedef char* value_type; + typedef char query_type[N]; + typedef details::buffer image_type; + + static void + set_value (char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v, b.data (), (n < N ? n : N)); + else + std::memset (v, 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const char* v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v, n); + } + }; + + // unsigned char[N] (buffer) specialization. + // + template + struct default_value_traits + { + public: + typedef unsigned char* value_type; + typedef unsigned char query_type[N]; + typedef details::buffer image_type; + + static void + set_value (unsigned char* const& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v, b.data (), (n < N ? n : N)); + else + std::memset (v, 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const unsigned char* v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v, n); + } + }; + +#ifdef ODB_CXX11 + // std::array (buffer) specialization. + // + template + struct default_value_traits, id_blob> + { + public: + typedef std::array value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v.data (), b.data (), (n < N ? n : N)); + else + std::memset (v.data (), 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v.data (), n); + } + }; + + // std::array (buffer) specialization. + // + template + struct default_value_traits, id_blob> + { + public: + typedef std::array value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + std::memcpy (v.data (), b.data (), (n < N ? n : N)); + else + std::memset (v.data (), 0, N); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = N; + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), v.data (), n); + } + }; +#endif + + // text (stream) specialization. + // + template <> + struct default_value_traits + { + public: + typedef text value_type; + typedef std::string query_type; + typedef stream_buffers image_type; + + static void + set_value (text& v, const stream_buffers& b, std::size_t, bool is_null) + { + if (!is_null) + { + v.db_ = b.db.in; + v.table_ = b.table.in; + v.column_ = b.column.in; + v.rowid_ = b.rowid.in; + } + } + + static void + set_image (stream_buffers& b, + std::size_t& n, + bool& is_null, + const text& v) + { + is_null = false; + n = v.size_; + + b.db.out = &v.db_; + b.table.out = &v.table_; + b.column.out = &v.column_; + b.rowid.out = &v.rowid_; + } + }; + + // blob (stream) specialization. + // + template <> + struct default_value_traits + { + public: + typedef blob value_type; + typedef std::vector query_type; + typedef stream_buffers image_type; + + static void + set_value (blob& v, const stream_buffers& b, std::size_t, bool is_null) + { + if (!is_null) + { + v.db_ = b.db.in; + v.table_ = b.table.in; + v.column_ = b.column.in; + v.rowid_ = b.rowid.in; + } + } + + static void + set_image (stream_buffers& b, + std::size_t& n, + bool& is_null, + const blob& v) + { + is_null = false; + n = v.size_; + + b.db.out = &v.db_; + b.table.out = &v.table_; + b.column.out = &v.column_; + b.rowid.out = &v.rowid_; + } + }; + + // + // type_traits + // + + template + struct default_type_traits; + + template + class type_traits: public default_type_traits {}; + + // Integral types. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_integer; + }; + + // Float types. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_real; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_real; + }; + + // String types. + // + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + template + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + +#ifdef ODB_CXX11 + template + struct default_type_traits > + { + static const database_type_id db_type_id = id_text; + }; +#endif + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text; + }; + + // Binary types. + // + template + struct default_type_traits + { + static const database_type_id db_type_id = id_blob; + }; + + template <> + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; + + template <> + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; + +#ifdef ODB_CXX11 + template + struct default_type_traits > + { + static const database_type_id db_type_id = id_blob; + }; +#endif + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_text_stream; + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_id = id_blob_stream; + }; + } +} + +#include + +#endif // ODB_SQLITE_TRAITS_HXX diff --git a/libodb-sqlite/odb/sqlite/transaction-impl.cxx b/libodb-sqlite/odb/sqlite/transaction-impl.cxx new file mode 100644 index 0000000..6485f7e --- /dev/null +++ b/libodb-sqlite/odb/sqlite/transaction-impl.cxx @@ -0,0 +1,172 @@ +// file : odb/sqlite/transaction-impl.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + transaction_impl:: + transaction_impl (database_type& db, lock l) + : odb::transaction_impl (db), lock_ (l) + { + } + + transaction_impl:: + transaction_impl (connection_ptr c, lock l) + : odb::transaction_impl (c->database (), *c), + connection_ (c), + lock_ (l) + { + } + + transaction_impl:: + ~transaction_impl () + { + } + + void transaction_impl:: + start () + { + // Grab a connection if we don't already have one. + // + if (connection_ == 0) + { + connection_ = static_cast (database_).connection (); + odb::transaction_impl::connection_ = connection_.get (); + } + + connection_type& mc (connection_->main_connection ()); + + switch (lock_) + { + case deferred: + { + mc.begin_statement ().execute (); + break; + } + case immediate: + { + mc.begin_immediate_statement ().execute (); + break; + } + case exclusive: + { + mc.begin_exclusive_statement ().execute (); + break; + } + } + } + + // In SQLite, when a commit fails (e.g., because of the deferred + // foreign key constraint violation), the transaction may not + // be automatically rolled back. So we have to do it ourselves. + // + struct commit_guard + { + commit_guard (connection& c): c_ (&c) {} + void release () {c_ = 0;} + + ~commit_guard () + { + if (c_ != 0 && sqlite3_get_autocommit (c_->handle ()) == 0) + { + // This is happening while another exception is active. + // + try + { + c_->rollback_statement ().execute (); + } + catch (...) {} + } + } + + private: + connection* c_; + }; + + void transaction_impl:: + commit () + { + connection_type& mc (connection_->main_connection ()); + + // Invalidate query results and reset active statements. + // + // Active statements will prevent COMMIT from completing (write + // statements) or releasing the locks (read statements). Normally, a + // statement is automatically reset on completion, however, if an + // exception is thrown, that may not happen. + // + // Note: must be done via the main connection. + // + mc.clear (); + + { + commit_guard cg (mc); + mc.commit_statement ().execute (); + cg.release (); + } + + // Release the connection. + // + connection_.reset (); + } + + void transaction_impl:: + rollback () + { + connection_type& mc (connection_->main_connection ()); + + // Invalidate query results and reset active statements (the same + // reasoning as in commit()). + // + // Note: must be done via the main connection. + // + mc.clear (); + + mc.rollback_statement ().execute (); + + // Release the connection. + // + connection_.reset (); + } + + odb::connection& transaction_impl:: + connection (odb::database* pdb) + { + if (pdb == 0) + return *connection_; + + // Pick the corresponding connection for main/attached database. + // + database_type& db (static_cast (*pdb)); + + assert (&db.main_database () == + &static_cast (database_).main_database ()); + + return db.schema ().empty () + ? connection_->main_connection () + : *static_cast (*db.factory_).attached_connection_; + } + + // Store transaction tracer in the main connection. + // + void transaction_impl:: + tracer (odb::tracer* t) + { + connection_->main_connection ().transaction_tracer_ = t; + } + + odb::tracer* transaction_impl:: + tracer () const + { + return connection_->main_connection ().transaction_tracer_; + } + } +} diff --git a/libodb-sqlite/odb/sqlite/transaction-impl.hxx b/libodb-sqlite/odb/sqlite/transaction-impl.hxx new file mode 100644 index 0000000..d1a310b --- /dev/null +++ b/libodb-sqlite/odb/sqlite/transaction-impl.hxx @@ -0,0 +1,66 @@ +// file : odb/sqlite/transaction-impl.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX +#define ODB_SQLITE_TRANSACTION_IMPL_HXX + +#include + +#include + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + class LIBODB_SQLITE_EXPORT transaction_impl: public odb::transaction_impl + { + public: + typedef sqlite::database database_type; + typedef sqlite::connection connection_type; + + enum lock + { + deferred, + immediate, + exclusive + }; + + transaction_impl (database_type&, lock); + transaction_impl (connection_ptr, lock); + + virtual + ~transaction_impl (); + + virtual void + start (); + + virtual void + commit (); + + virtual void + rollback (); + + virtual odb::connection& + connection (odb::database*); + + virtual void + tracer (odb::tracer*); + + virtual odb::tracer* + tracer () const; + + private: + connection_ptr connection_; + lock lock_; + }; + } +} + +#include + +#endif // ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/libodb-sqlite/odb/sqlite/transaction.cxx b/libodb-sqlite/odb/sqlite/transaction.cxx new file mode 100644 index 0000000..8b4ab23 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/transaction.cxx @@ -0,0 +1,26 @@ +// file : odb/sqlite/transaction.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include + +namespace odb +{ + namespace sqlite + { + transaction& transaction:: + current () + { + // While the impl type can be of the concrete type, the transaction + // object can be created as either odb:: or odb::sqlite:: type. To + // work around that we are going to hard-cast one two the other + // relying on the fact that they have the same representation and + // no virtual functions. The former is checked in the tests. + // + odb::transaction& b (odb::transaction::current ()); + assert (dynamic_cast (&b.implementation ()) != 0); + return reinterpret_cast (b); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/transaction.hxx b/libodb-sqlite/odb/sqlite/transaction.hxx new file mode 100644 index 0000000..5e8c141 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/transaction.hxx @@ -0,0 +1,87 @@ +// file : odb/sqlite/transaction.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_TRANSACTION_HXX +#define ODB_SQLITE_TRANSACTION_HXX + +#include + +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + class transaction_impl; + + class LIBODB_SQLITE_EXPORT transaction: public odb::transaction + { + public: + typedef sqlite::database database_type; + typedef sqlite::connection connection_type; + + explicit + transaction (transaction_impl*, bool make_current = true); + + transaction (); + + // Return the database this transaction is on. + // + database_type& + database (); + + // Return the underlying database connection for this transaction. + // + connection_type& + connection (); + + connection_type& + connection (odb::database&); + + // Return current transaction or throw if there is no transaction + // in effect. + // + static transaction& + current (); + + // Set the current thread's transaction. + // + static void + current (transaction&); + + // SQL statement tracing. + // + public: + typedef sqlite::tracer tracer_type; + + void + tracer (tracer_type& t) + { + odb::transaction::tracer (t); + } + + void + tracer (tracer_type* t) + { + odb::transaction::tracer (t); + } + + using odb::transaction::tracer; + + public: + transaction_impl& + implementation (); + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_TRANSACTION_HXX diff --git a/libodb-sqlite/odb/sqlite/transaction.ixx b/libodb-sqlite/odb/sqlite/transaction.ixx new file mode 100644 index 0000000..de4bd3e --- /dev/null +++ b/libodb-sqlite/odb/sqlite/transaction.ixx @@ -0,0 +1,57 @@ +// file : odb/sqlite/transaction.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include + +namespace odb +{ + namespace sqlite + { + inline transaction:: + transaction (transaction_impl* impl, bool make_current) + : odb::transaction (impl, make_current) + { + } + + inline transaction:: + transaction () + : odb::transaction () + { + } + + inline transaction_impl& transaction:: + implementation () + { + // We can use static_cast here since we have an instance of + // sqlite::transaction. + // + return static_cast ( + odb::transaction::implementation ()); + } + + inline transaction::database_type& transaction:: + database () + { + return static_cast (odb::transaction::database ()); + } + + inline transaction::connection_type& transaction:: + connection () + { + return static_cast (odb::transaction::connection ()); + } + + inline transaction::connection_type& transaction:: + connection (odb::database& db) + { + return static_cast (odb::transaction::connection (db)); + } + + inline void transaction:: + current (transaction& t) + { + odb::transaction::current (t); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/version-build2-stub.hxx b/libodb-sqlite/odb/sqlite/version-build2-stub.hxx new file mode 100644 index 0000000..a6bb4d0 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/version-build2-stub.hxx @@ -0,0 +1,4 @@ +// file : odb/sqlite/version-build2-stub.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include diff --git a/libodb-sqlite/odb/sqlite/version-build2.hxx b/libodb-sqlite/odb/sqlite/version-build2.hxx new file mode 100644 index 0000000..e69de29 diff --git a/libodb-sqlite/odb/sqlite/version-build2.hxx.in b/libodb-sqlite/odb/sqlite/version-build2.hxx.in new file mode 100644 index 0000000..50fef2d --- /dev/null +++ b/libodb-sqlite/odb/sqlite/version-build2.hxx.in @@ -0,0 +1,42 @@ +// file : odb/sqlite/version-build2.hxx.in +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. + +// The numeric version format is AAAAABBBBBCCCCCDDDE where: +// +// AAAAA - major version number +// BBBBB - minor version number +// CCCCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) +// +// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: +// +// Version AAAAABBBBBCCCCCDDDE +// +// 0.1.0 0000000001000000000 +// 0.1.2 0000000001000020000 +// 1.2.3 0000100002000030000 +// 2.2.0-a.1 0000200001999990010 +// 3.0.0-b.2 0000299999999995020 +// 2.2.0-a.1.z 0000200001999990011 +// +#define LIBODB_SQLITE_VERSION $libodb_sqlite.version.project_number$ULL +#define LIBODB_SQLITE_VERSION_STR "$libodb_sqlite.version.project$" +#define LIBODB_SQLITE_VERSION_ID "$libodb_sqlite.version.project_id$" + +#define LIBODB_SQLITE_VERSION_MAJOR $libodb_sqlite.version.major$ +#define LIBODB_SQLITE_VERSION_MINOR $libodb_sqlite.version.minor$ +#define LIBODB_SQLITE_VERSION_PATCH $libodb_sqlite.version.patch$ + +#define LIBODB_SQLITE_PRE_RELEASE $libodb_sqlite.version.pre_release$ + +#define LIBODB_SQLITE_SNAPSHOT $libodb_sqlite.version.snapshot_sn$ULL +#define LIBODB_SQLITE_SNAPSHOT_ID "$libodb_sqlite.version.snapshot_id$" + +#include + +$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ + +#endif // LIBODB_SQLITE_VERSION diff --git a/libodb-sqlite/odb/sqlite/version.hxx b/libodb-sqlite/odb/sqlite/version.hxx new file mode 100644 index 0000000..ad468de --- /dev/null +++ b/libodb-sqlite/odb/sqlite/version.hxx @@ -0,0 +1,47 @@ +// file : odb/sqlite/version.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifdef LIBODB_SQLITE_BUILD2 +# include +#else + +#ifndef ODB_SQLITE_VERSION_HXX +#define ODB_SQLITE_VERSION_HXX + +#include + +#include + +// Version format is AABBCCDD where +// +// AA - major version number +// BB - minor version number +// CC - bugfix version number +// DD - alpha / beta (DD + 50) version number +// +// When DD is not 00, 1 is subtracted from AABBCC. For example: +// +// Version AABBCCDD +// 2.0.0 02000000 +// 2.1.0 02010000 +// 2.1.1 02010100 +// 2.2.0.a1 02019901 +// 3.0.0.b2 02999952 +// + +// Check that we have compatible ODB version. +// +#if ODB_VERSION != 20476 +# error incompatible odb interface version detected +#endif + +// libodb-sqlite version: odb interface version plus the bugfix +// version. +// +#define LIBODB_SQLITE_VERSION 2049976 +#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.26" + +#include + +#endif // ODB_SQLITE_VERSION_HXX +#endif // LIBODB_SQLITE_BUILD2 diff --git a/libodb-sqlite/odb/sqlite/view-result.hxx b/libodb-sqlite/odb/sqlite/view-result.hxx new file mode 100644 index 0000000..ce3d747 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/view-result.hxx @@ -0,0 +1,80 @@ +// file : odb/sqlite/view-result.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_VIEW_RESULT_HXX +#define ODB_SQLITE_VIEW_RESULT_HXX + +#include + +#include // std::size_t + +#include +#include + +#include + +#include +#include // query_base, query_params +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class view_result_impl: public odb::view_result_impl + { + public: + typedef odb::view_result_impl base_type; + + typedef typename base_type::view_type view_type; + typedef typename base_type::pointer_type pointer_type; + + typedef view_traits_impl view_traits; + typedef typename base_type::pointer_traits pointer_traits; + + typedef view_statements statements_type; + + virtual + ~view_result_impl (); + + view_result_impl (const query_base&, + const details::shared_ptr&, + statements_type&, + const schema_version_migration*); + + virtual void + load (view_type&); + + virtual void + next (); + + virtual void + cache (); + + virtual std::size_t + size (); + + virtual void + invalidate (); + + using base_type::current; + + private: + // We need to hold on to the query parameters because SQLite uses + // the parameter buffers to find each next row. + // + details::shared_ptr params_; + details::shared_ptr statement_; + statements_type& statements_; + view_traits_calls tc_; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_VIEW_RESULT_HXX diff --git a/libodb-sqlite/odb/sqlite/view-result.txx b/libodb-sqlite/odb/sqlite/view-result.txx new file mode 100644 index 0000000..60efb81 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/view-result.txx @@ -0,0 +1,114 @@ +// file : odb/sqlite/view-result.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include +#include + +#include + +namespace odb +{ + namespace sqlite + { + template + view_result_impl:: + ~view_result_impl () + { + if (!this->end_) + statement_->free_result (); + } + + template + void view_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template + view_result_impl:: + view_result_impl (const query_base& q, + const details::shared_ptr& s, + statements_type& sts, + const schema_version_migration* svm) + : base_type (sts.connection ()), + params_ (q.parameters ()), + statement_ (s), + statements_ (sts), + tc_ (svm) + { + } + + template + void view_result_impl:: + load (view_type& view) + { + // The image can grow between calls to load() as a result of other + // statements execution. + // + typename view_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.image_version ()) + { + binding& b (statements_.image_binding ()); + tc_.bind (b.bind, im); + statements_.image_version (im.version); + b.version++; + } + + select_statement::result r (statement_->load ()); + + if (r == select_statement::truncated) + { + if (tc_.grow (im, statements_.image_truncated ())) + im.version++; + + if (im.version != statements_.image_version ()) + { + binding& b (statements_.image_binding ()); + tc_.bind (b.bind, im); + statements_.image_version (im.version); + b.version++; + statement_->reload (); + } + } + + view_traits::callback (this->db_, view, callback_event::pre_load); + tc_.init (view, im, &this->db_); + view_traits::callback (this->db_, view, callback_event::post_load); + } + + template + void view_result_impl:: + next () + { + this->current (pointer_type ()); + + if (!statement_->next ()) + { + statement_->free_result (); + this->end_ = true; + } + } + + template + void view_result_impl:: + cache () + { + } + + template + std::size_t view_result_impl:: + size () + { + throw result_not_cached (); + } + } +} diff --git a/libodb-sqlite/odb/sqlite/view-statements.hxx b/libodb-sqlite/odb/sqlite/view-statements.hxx new file mode 100644 index 0000000..0bd79ee --- /dev/null +++ b/libodb-sqlite/odb/sqlite/view-statements.hxx @@ -0,0 +1,88 @@ +// file : odb/sqlite/view-statements.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX +#define ODB_SQLITE_VIEW_STATEMENTS_HXX + +#include + +#include // std::size_t + +#include +#include + +#include +#include +#include +#include + +namespace odb +{ + namespace sqlite + { + template + class view_statements: public statements_base + { + public: + typedef T view_type; + typedef view_traits_impl view_traits; + typedef typename view_traits::pointer_type pointer_type; + typedef typename view_traits::image_type image_type; + + public: + view_statements (connection_type&); + + virtual + ~view_statements (); + + // View image. + // + image_type& + image () + { + return image_; + } + + std::size_t + image_version () const + { + return image_version_; + } + + void + image_version (std::size_t v) + { + image_version_ = v; + } + + binding& + image_binding () + { + return image_binding_; + } + + bool* + image_truncated () + { + return image_truncated_; + } + + private: + view_statements (const view_statements&); + view_statements& operator= (const view_statements&); + + private: + image_type image_; + std::size_t image_version_; + binding image_binding_; + bind image_bind_[view_traits::column_count]; + bool image_truncated_[view_traits::column_count]; + }; + } +} + +#include + +#include + +#endif // ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/libodb-sqlite/odb/sqlite/view-statements.txx b/libodb-sqlite/odb/sqlite/view-statements.txx new file mode 100644 index 0000000..0531a92 --- /dev/null +++ b/libodb-sqlite/odb/sqlite/view-statements.txx @@ -0,0 +1,33 @@ +// file : odb/sqlite/view-statements.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::size_t +#include // std::memset + +namespace odb +{ + namespace sqlite + { + template + view_statements:: + ~view_statements () + { + } + + template + view_statements:: + view_statements (connection_type& conn) + : statements_base (conn), + image_binding_ (image_bind_, view_traits::column_count) + { + image_.version = 0; + image_version_ = 0; + + std::memset (image_bind_, 0, sizeof (image_bind_)); + std::memset (image_truncated_, 0, sizeof (image_truncated_)); + + for (std::size_t i (0); i < view_traits::column_count; ++i) + image_bind_[i].truncated = image_truncated_ + i; + } + } +} diff --git a/libodb-sqlite/tests/.gitignore b/libodb-sqlite/tests/.gitignore new file mode 100644 index 0000000..e54525b --- /dev/null +++ b/libodb-sqlite/tests/.gitignore @@ -0,0 +1 @@ +driver diff --git a/libodb-sqlite/tests/basics/buildfile b/libodb-sqlite/tests/basics/buildfile new file mode 100644 index 0000000..5d671d3 --- /dev/null +++ b/libodb-sqlite/tests/basics/buildfile @@ -0,0 +1,6 @@ +# file : tests/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb-sqlite%lib{odb-sqlite} + +exe{driver}: {hxx cxx}{*} $libs diff --git a/libodb-sqlite/tests/basics/driver.cxx b/libodb-sqlite/tests/basics/driver.cxx new file mode 100644 index 0000000..b998574 --- /dev/null +++ b/libodb-sqlite/tests/basics/driver.cxx @@ -0,0 +1,52 @@ +// file : tests/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Basic test to make sure the library is usable. Functionality testing +// is done in the odb-tests package. + +#include +#include + +#include +#include +#include + +using namespace odb::sqlite; + +int +main () +{ + { + std::ostringstream os; + database::print_usage (os); + assert (!os.str ().empty ()); + } + + database db (":memory:"); + + { + transaction t (db.begin ()); + db.execute ("CREATE TABLE test (id INTEGER PRIMARY KEY, str TEXT)"); + t.commit (); + } + + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'abc')"); + t.commit (); + } + + try + { + transaction t (db.begin ()); + db.execute ("INSERT INTO test VALUES (123, 'ABC')"); + assert (false); + } + catch (const database_exception&) {} + + { + transaction t (db.begin ()); + db.execute ("DROP TABLE test"); + t.commit (); + } +} diff --git a/libodb-sqlite/tests/build/.gitignore b/libodb-sqlite/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libodb-sqlite/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libodb-sqlite/tests/build/bootstrap.build b/libodb-sqlite/tests/build/bootstrap.build new file mode 100644 index 0000000..6ee38db --- /dev/null +++ b/libodb-sqlite/tests/build/bootstrap.build @@ -0,0 +1,8 @@ +# file : tests/build/bootstrap.build +# license : GNU GPL v2; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/libodb-sqlite/tests/build/root.build b/libodb-sqlite/tests/build/root.build new file mode 100644 index 0000000..6c5a90b --- /dev/null +++ b/libodb-sqlite/tests/build/root.build @@ -0,0 +1,23 @@ +# file : tests/build/root.build +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/libodb-sqlite/tests/buildfile b/libodb-sqlite/tests/buildfile new file mode 100644 index 0000000..57588a4 --- /dev/null +++ b/libodb-sqlite/tests/buildfile @@ -0,0 +1,4 @@ +# file : tests/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -build/} diff --git a/m4/acx-pthread.m4 b/m4/acx-pthread.m4 deleted file mode 100644 index 204b32d..0000000 --- a/m4/acx-pthread.m4 +++ /dev/null @@ -1,259 +0,0 @@ -dnl -dnl NOTE: This file was modified. See the comments starting with 'CS:' -dnl for more information. In particular, it was changed to use C++ -dnl instead of C. -dnl -dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl @summary figure out how to build C++ programs using POSIX threads -dnl -dnl This macro figures out how to build C++ programs using POSIX threads. -dnl It sets the PTHREAD_LIBS output variable to the threads library and -dnl linker flags, and the PTHREAD_CXXFLAGS output variable to any special -dnl C++ compiler flags that are needed. (The user can also force certain -dnl compiler flags/libs to be tested by setting these environment -dnl variables.) -dnl -dnl Also sets PTHREAD_CXX to any special C++ compiler that is needed for -dnl multi-threaded programs (defaults to the value of CXX otherwise). -dnl (This is necessary on AIX to use the special xlC_r compiler alias.) -dnl -dnl NOTE: You are assumed to not only compile your program with these -dnl flags, but also link it with them as well. e.g. you should link -dnl with $PTHREAD_CXX $CXXFLAGS $PTHREAD_CXXFLAGS $LDFLAGS ... $PTHREAD_LIBS -dnl $LIBS -dnl -dnl If you are only building threads programs, you may wish to use -dnl these variables in your default LIBS, CXXFLAGS, and CXX: -dnl -dnl LIBS="$PTHREAD_LIBS $LIBS" -dnl CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" -dnl CXX="$PTHREAD_CXX" -dnl -dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute -dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to -dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if a threads -dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to -dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the -dnl default action will define HAVE_PTHREAD. -dnl -dnl Please let the authors know if this macro fails on any platform, or -dnl if you have any other suggestions or comments. This macro was based -dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with -dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros -dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. -dnl We are also grateful for the helpful feedback of numerous users. -dnl -dnl @category InstalledPackages -dnl @author Steven G. Johnson -dnl @version 2006-05-29 -dnl @license GPLWithACException - -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG(C++) -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CXXFLAGS" != x; then - save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CXXFLAGS=$PTHREAD_CXXFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CXXFLAGS="" - fi - LIBS="$save_LIBS" - CXXFLAGS="$save_CXXFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -# CS: On GNU/Linux with gcc both -pthread and -lpthread are valid. -# However, libtool links libraries with -nostdlib which results in -# -pthread being stripped from the linker command line. To resolve -# this we move pthread from after -mthreads to after pthreads. -# -acx_pthread_flags="pthreads pthread none -Kthread -kthread lthread -pthread -pthreads -mthreads --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - # CS: Move -mt to the front of the list; Sun CC will use -mt, - # gcc will use -pthreads. - # - acx_pthread_flags="-mt -pthreads pthread -pthread $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CXXFLAGS="$flag" - ;; - - pthread-config) - AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) - if test x"$acx_pthread_config" = xno; then continue; fi - PTHREAD_CXXFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CXXFLAGS="$CXXFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - # - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0);], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CXXFLAGS="$save_CXXFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CXXFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" - -dnl # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. -dnl AC_MSG_CHECKING([for joinable pthread attribute]) -dnl attr_name=unknown -dnl for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do -dnl AC_TRY_LINK([#include ], [int attr=$attr; return attr;], -dnl [attr_name=$attr; break]) -dnl done -dnl AC_MSG_RESULT($attr_name) -dnl if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then -dnl AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, -dnl [Define to necessary symbol if this constant -dnl uses a non-standard name on your system.]) -dnl fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - # CS: Add _REENTRANT in Linux to emulate -pthread. - # - *-linux* | *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CXXFLAGS="$flag $PTHREAD_CXXFLAGS" - fi - - LIBS="$save_LIBS" - CXXFLAGS="$save_CXXFLAGS" - -dnl # More AIX lossage: must compile with xlC_r -dnl if test x"$GXX" != xyes; then -dnl AC_CHECK_PROGS(PTHREAD_CXX, xlC_r, ${CXX}) -dnl else -dnl PTHREAD_CXX=$CXX -dnl fi - -else - PTHREAD_CXX="$CXX" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CXXFLAGS) -AC_SUBST(PTHREAD_CXX) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 deleted file mode 100644 index 0864209..0000000 --- a/m4/disable-rpath.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl file : m4/disable-rpath.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -AC_DEFUN([DISABLE_RPATH],[ - -AC_MSG_CHECKING([whether to use rpath]) -AC_ARG_ENABLE( - [rpath], - [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])], - [libtool_rpath="$enable_rpath"], - [libtool_rpath="yes"]) -AC_MSG_RESULT($libtool_rpath) - -# Patch libtool to not use rpath if requested. -# -AC_CONFIG_COMMANDS( - [libtool-rpath-patch], - [if test "$libtool_use_rpath" = "no"; then - sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/' - mv libtool-2 libtool - chmod 755 libtool - fi], - [libtool_use_rpath=$libtool_rpath]) -])dnl diff --git a/m4/libodb.m4 b/m4/libodb.m4 deleted file mode 100644 index 0dba7c4..0000000 --- a/m4/libodb.m4 +++ /dev/null @@ -1,81 +0,0 @@ -dnl file : m4/libodb.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl -AC_DEFUN([LIBODB], [ -libodb_found=no - -AC_ARG_WITH( - [libodb], - [AC_HELP_STRING([--with-libodb=DIR],[location of libodb build directory])], - [libodb_dir=${withval}], - [libodb_dir=]) - -AC_MSG_CHECKING([for libodb]) - -# If libodb_dir was given, add the necessary preprocessor and linker flags. -# -if test x"$libodb_dir" != x; then - save_CPPFLAGS="$CPPFLAGS" - save_LDFLAGS="$LDFLAGS" - - AS_SET_CATFILE([abs_libodb_dir], [$ac_pwd], [$libodb_dir]) - - CPPFLAGS="$CPPFLAGS -I$abs_libodb_dir" - LDFLAGS="$LDFLAGS -L$abs_libodb_dir/odb" -fi - -save_LIBS="$LIBS" -LIBS="-lodb $LIBS" - -CXX_LIBTOOL_LINK_IFELSE([ -AC_LANG_SOURCE([ -#include - -void -f () -{ -} - -const char* -g () -{ - try - { - f (); - } - catch (const odb::exception& e) - { - return e.what (); - } - return 0; -} - -int -main () -{ - const char* m (g ()); - return m != 0; -} -])], -[libodb_found=yes]) - -if test x"$libodb_found" = xno; then - LIBS="$save_LIBS" - - if test x"$libodb_dir" != x; then - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - fi -fi - -if test x"$libodb_found" = xyes; then - AC_MSG_RESULT([yes]) - $1 -else - AC_MSG_RESULT([no]) - $2 -fi -])dnl diff --git a/m4/libsqlite.m4 b/m4/libsqlite.m4 deleted file mode 100644 index 421e990..0000000 --- a/m4/libsqlite.m4 +++ /dev/null @@ -1,92 +0,0 @@ -dnl file : m4/libsqlite.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -dnl LIBSQLITE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) -dnl -dnl Also sets libsqlite_unlock_notify to yes if sqlite3_unlock_notify() -dnl functionality is available. -dnl -dnl Also sets libsqlite_column_metadata to yes if sqlite3_column_*() -dnl functions are available. -dnl -AC_DEFUN([LIBSQLITE], [ -libsqlite_found=no -libsqlite_unlock_notify=no -libsqlite_column_metadata=no - -AC_MSG_CHECKING([for libsqlite3]) - -save_LIBS="$LIBS" -LIBS="-lsqlite3 $LIBS" - -CXX_LIBTOOL_LINK_IFELSE([ -AC_LANG_SOURCE([ -#include - -int -main () -{ - sqlite3* handle; - sqlite3_open ("", &handle); - sqlite3_stmt* stmt; - sqlite3_prepare (handle, "", 0, &stmt, 0); - sqlite3_finalize (stmt); - sqlite3_close (handle); -} -])], -[ -libsqlite_found=yes -]) - -if test x"$libsqlite_found" = xno; then - LIBS="$save_LIBS" -fi - -# Check for unlock_notify. -# -if test x"$libsqlite_found" = xyes; then -CXX_LIBTOOL_LINK_IFELSE([ -AC_LANG_SOURCE([ -#include - -int -main () -{ - sqlite3* handle (0); - sqlite3_unlock_notify (handle, 0, 0); -} -])], -[ -libsqlite_unlock_notify=yes -]) -fi - -# Check for column_metadata. -# -if test x"$libsqlite_found" = xyes; then -CXX_LIBTOOL_LINK_IFELSE([ -AC_LANG_SOURCE([ -#include - -int -main () -{ - sqlite3_stmt* stmt (0); - sqlite3_column_database_name (stmt, 0); - sqlite3_column_table_name (stmt, 0); - sqlite3_column_origin_name (stmt, 0); -} -])], -[ -libsqlite_column_metadata=yes -]) -fi - -if test x"$libsqlite_found" = xyes; then - AC_MSG_RESULT([yes]) - $1 -else - AC_MSG_RESULT([no]) - $2 -fi -])dnl diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 deleted file mode 100644 index 302639f..0000000 --- a/m4/libtool-link.m4 +++ /dev/null @@ -1,45 +0,0 @@ -dnl file : m4/libtool-link.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -dnl -dnl CXX_LIBTOOL_LINK_IFELSE (input, [action-if-true], [action-if-false]) -dnl -dnl Similar to AC_LINK_IFELSE except it uses libtool to perform the -dnl linking and it does this using the C++ compiler. -dnl -AC_DEFUN([CXX_LIBTOOL_LINK_IFELSE],[ -AC_LANG_SAVE -AC_LANG(C++) - -if test -d .libs; then - delete_libs_dir=no -else - delete_libs_dir=yes -fi - -AC_COMPILE_IFELSE([$1], -[ - ac_try='./libtool --tag=CXX --mode=link $CXX -no-install $CXXFLAGS $LDFLAGS -o conftest conftest.$OBJEXT $LIBS >&AS_MESSAGE_LOG_FD' - if _AC_DO_VAR(ac_try); then - libtool_link_ok=yes - else - libtool_link_ok=no - fi -], -[ - libtool_link_ok=no -]) - -if test x"$delete_libs_dir" = xyes; then - rm -rf .libs -fi - -if test x"$libtool_link_ok" = xyes; then -[$2] -: -else -[$3] -: -fi - -AC_LANG_RESTORE])dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 deleted file mode 100644 index c48ea56..0000000 --- a/m4/pkgconfig.m4 +++ /dev/null @@ -1,11 +0,0 @@ -dnl file : m4/pkgconfig.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -AC_DEFUN([PKGCONFIG],[ -AC_ARG_WITH( - [pkgconfigdir], - [AC_HELP_STRING([--with-pkgconfigdir=DIR],[location of pkgconfig dir (default is libdir/pkgconfig)])], - [pkgconfigdir=${withval}], - [pkgconfigdir='${libdir}/pkgconfig']) -AC_SUBST([pkgconfigdir]) -])dnl diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 deleted file mode 100644 index 5fb1c11..0000000 --- a/m4/static-lib.m4 +++ /dev/null @@ -1,17 +0,0 @@ -dnl file : m4/static-lib.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -dnl STATIC_LIB(MACRO, DESCRIPTION) -dnl -dnl Define MACRO if we are on MinGW and are only building static library. -dnl -AC_DEFUN([STATIC_LIB], -[ -if test x$enable_shared = xno; then - case $host_os in - mingw*) - AC_DEFINE([$1], [1], [$2]) - ;; - esac -fi -])dnl diff --git a/m4/threads.m4 b/m4/threads.m4 deleted file mode 100644 index 6f2e25f..0000000 --- a/m4/threads.m4 +++ /dev/null @@ -1,68 +0,0 @@ -dnl file : m4/threads.m4 -dnl license : GNU GPL v2; see accompanying LICENSE file -dnl -AC_DEFUN([THREADS],[ - -threads_thread_keyword=no - -AC_ARG_ENABLE( - [threads], - AS_HELP_STRING([--disable-threads], [disable threads (enabled by default)]), - [AS_IF([test x"$enableval" = xno], [threads=none], [threads=check])], - [threads=check]) - -# If thread support is not disabled by the user, figure out what we can use. -# -if test x$threads = xcheck; then - case $host_os in - windows* | mingw*) - case $host_os in - mingw*) - CXXFLAGS="$CXXFLAGS -mthreads" - ;; - esac - - # Newer versions of GCC can be configured to use either Win32 or POSIX - # threads. It appears that -mthreads should be used in both cases but - # if the model is POSIX then GCC will also link -lpthread by default. - # Use that fact to test which model we have. - # - AC_TRY_LINK([#include ], - [pthread_create(0,0,0,0);], - [threads=posix], - [threads=win32]) - ;; - *) - ACX_PTHREAD - - if test x$acx_pthread_ok = xyes; then - threads=posix - LIBS="$LIBS $PTHREAD_LIBS" - CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" - - # Check if we can use the __thread keyword. - # - AC_MSG_CHECKING([for __thread keyword]) - - CXX_LIBTOOL_LINK_IFELSE([ - AC_LANG_SOURCE([ - __thread int tls_var; - - int - main () - { - tls_var = 0; - } - ])], - [threads_thread_keyword=yes]) - - AC_MSG_RESULT([$threads_thread_keyword]) - fi - ;; - esac -fi - -if test x$threads = xcheck; then - AC_MSG_ERROR([thread support not available; use --disable-threads to force single-threaded mode]) -fi -])dnl diff --git a/makefile b/makefile deleted file mode 100644 index f28752a..0000000 --- a/makefile +++ /dev/null @@ -1,36 +0,0 @@ -# file : makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make - -dirs := odb/sqlite - -default := $(out_base)/ -dist := $(out_base)/.dist -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) - -$(dist): export dirs := $(dirs) -$(dist): export docs := GPLv2 LICENSE README NEWS version.txt -$(dist): data_dist := INSTALL libodb-sqlite-vc8.sln libodb-sqlite-vc9.sln \ -libodb-sqlite-vc10.sln libodb-sqlite-vc11.sln libodb-sqlite-vc12.sln \ -$(subst $(src_base)/,,$(shell find $(src_base)/etc -type f)) -$(dist): exec_dist := bootstrap -$(dist): export extra_dist := $(data_dist) $(exec_dist) -$(dist): export version = $(shell cat $(src_root)/version.txt) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs))) - $(call dist-data,$(docs) $(data_dist) libodb-sqlite.pc.in) - $(call dist-exec,$(exec_dist)) - $(call dist-dir,m4) - $(call meta-automake) - $(call meta-autoconf) - -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs))) - -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/automake.make) -$(call include,$(bld_root)/meta/autoconf.make) - -$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile)) diff --git a/manifest b/manifest deleted file mode 100644 index fef85a0..0000000 --- a/manifest +++ /dev/null @@ -1,22 +0,0 @@ -: 1 -name: libodb-sqlite -version: 2.5.0-b.26.z -project: odb -summary: SQLite ODB runtime library -license: GPL-2.0-only -license: other: proprietary ; Not free/open source. -topics: C++, ORM, SQLite, SQL -description-file: README -changes-file: NEWS -url: https://www.codesynthesis.com/products/odb/ -doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml -src-url: https://git.codesynthesis.com/cgit/odb/libodb-sqlite/ -email: odb-users@codesynthesis.com -build-warning-email: odb-builds@codesynthesis.com -builds: all -requires: c++11 -depends: * build2 >= 0.16.0- -depends: * bpkg >= 0.16.0- -depends: libsqlite3 ^3.6.18 -depends: libodb [2.5.0-b.26.1 2.5.0-b.27) -depends: * cli ^1.2.0- ? ($config.libodb_sqlite.develop) diff --git a/odb/sqlite/Makefile.am b/odb/sqlite/Makefile.am deleted file mode 100644 index 0f66fc3..0000000 --- a/odb/sqlite/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -# file : odb/sqlite/Makefile.am -# license : GNU GPL v2; see accompanying LICENSE file - -lib_LTLIBRARIES = libodb-sqlite.la -libodb_sqlite_la_SOURCES = __path__(sources) - -odbsqliteincludedir = $(includedir)/odb/sqlite/ -nobase_odbsqliteinclude_HEADERS = __path__(headers) -nobase_nodist_odbsqliteinclude_HEADERS = details/config.h - -EXTRA_DIST = __file__(extra_dist) - -AM_CPPFLAGS= -I'$(top_builddir)' -I'$(top_srcdir)' -DLIBODB_SQLITE_DYNAMIC_LIB -AM_LDFLAGS = -release __value__(interface_version) -no-undefined diff --git a/odb/sqlite/auto-handle.hxx b/odb/sqlite/auto-handle.hxx deleted file mode 100644 index d25e919..0000000 --- a/odb/sqlite/auto-handle.hxx +++ /dev/null @@ -1,101 +0,0 @@ -// file : odb/sqlite/auto-handle.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_AUTO_HANDLE_HXX -#define ODB_SQLITE_AUTO_HANDLE_HXX - -#include - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - template - struct handle_traits; - - template <> - struct handle_traits - { - static void - release (sqlite3* h) - { - if (sqlite3_close (h) == SQLITE_BUSY) - { - // Connection has outstanding prepared statements. - // - assert (false); - } - } - }; - - template <> - struct handle_traits - { - static void - release (sqlite3_stmt* h) - { - sqlite3_finalize (h); - } - }; - - template - class auto_handle - { - public: - auto_handle (H* h = 0) - : h_ (h) - { - } - - ~auto_handle () - { - if (h_ != 0) - handle_traits::release (h_); - } - - H* - get () const - { - return h_; - } - - void - reset (H* h = 0) - { - if (h_ != 0) - handle_traits::release (h_); - - h_ = h; - } - - H* - release () - { - H* h (h_); - h_ = 0; - return h; - } - - operator H* () const - { - return h_; - } - - private: - auto_handle (const auto_handle&); - auto_handle& operator= (const auto_handle&); - - private: - H* h_; - }; - } -} - -#include - -#endif // ODB_SQLITE_AUTO_HANDLE_HXX diff --git a/odb/sqlite/binding.hxx b/odb/sqlite/binding.hxx deleted file mode 100644 index 3807130..0000000 --- a/odb/sqlite/binding.hxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : odb/sqlite/binding.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_BINDING_HXX -#define ODB_SQLITE_BINDING_HXX - -#include - -#include // std::size_t - -#include - -#include - -namespace odb -{ - namespace sqlite - { - class binding - { - public: - typedef sqlite::bind bind_type; - - binding (): bind (0), count (0), version (0) {} - - binding (bind_type* b, std::size_t n) - : bind (b), count (n), version (0) - { - } - - bind_type* bind; - std::size_t count; - std::size_t version; - - private: - binding (const binding&); - binding& operator= (const binding&); - }; - } -} - -#include - -#endif // ODB_SQLITE_BINDING_HXX diff --git a/odb/sqlite/blob-stream.hxx b/odb/sqlite/blob-stream.hxx deleted file mode 100644 index caa7c24..0000000 --- a/odb/sqlite/blob-stream.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// file : odb/sqlite/blob-stream.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_BLOB_STREAM_HXX -#define ODB_SQLITE_BLOB_STREAM_HXX - -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - class blob_stream: public stream - { - public: - blob_stream (const blob& b, bool rw) - : stream (b.db ().c_str (), - b.table ().c_str (), - b.column ().c_str (), - b.rowid (), - rw) {} - }; - } -} - -#include - -#endif // ODB_SQLITE_BLOB_STREAM_HXX diff --git a/odb/sqlite/blob.hxx b/odb/sqlite/blob.hxx deleted file mode 100644 index a4892a2..0000000 --- a/odb/sqlite/blob.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// file : odb/sqlite/blob.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_BLOB_HXX -#define ODB_SQLITE_BLOB_HXX - -#include - -#include -#include // std::size_t - -// Carefully allow this header to be included into the ODB compilation. -// -#ifndef ODB_COMPILER -# include -#endif - -namespace odb -{ - namespace sqlite - { -#ifdef ODB_COMPILER - #pragma db sqlite:type("BLOB STREAM") - class blob -#else - class blob -#endif - { - public: - // BLOB size to provision for. Set before calling persist() or update(). - // - explicit - blob (std::size_t size = 0): size_ (size) {} - - std::size_t size () const {return size_;} - void size (std::size_t s) {size_ = s;} - - const std::string& db () const {return db_;} - const std::string& table () const {return table_;} - const std::string& column () const {return column_;} - long long rowid () const {return rowid_;} - - void - clear () - { - size_ = 0; - db_.clear (); - table_.clear (); - column_.clear (); - rowid_ = 0; - } - - private: -#ifndef ODB_COMPILER - friend struct default_value_traits; -#endif - std::size_t size_; - mutable std::string db_; - mutable std::string table_; - mutable std::string column_; - mutable long long rowid_; - }; - } -} - -#include - -#endif // ODB_SQLITE_BLOB_HXX diff --git a/odb/sqlite/buildfile b/odb/sqlite/buildfile deleted file mode 100644 index d2da43f..0000000 --- a/odb/sqlite/buildfile +++ /dev/null @@ -1,155 +0,0 @@ -# file : odb/sqlite/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -define cli: file -cli{*}: extension = cli - -import int_libs = libodb%lib{odb} -import int_libs += libsqlite3%lib{sqlite3} - -lib{odb-sqlite}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ - details/{hxx ixx txx cxx}{* -options} \ - details/build2/{h}{*} \ - $int_libs - -# Include the generated version header into the distribution (so that we don't -# pick up an installed one) and don't remove it when cleaning in src (so that -# clean results in a state identical to distributed). -# -hxx{version-build2}: in{version-build2} $src_root/manifest -hxx{version-build2}: -{ - dist = true - clean = ($src_root != $out_root) -} - -# Build options. -# -cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 - -obja{*}: cxx.poptions += -DLIBODB_SQLITE_STATIC_BUILD -objs{*}: cxx.poptions += -DLIBODB_SQLITE_SHARED_BUILD - -# Export options. -# -lib{odb-sqlite}: -{ - cxx.export.poptions = "-I$out_root" "-I$src_root" -DLIBODB_SQLITE_BUILD2 - cxx.export.libs = $int_libs -} - -liba{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_STATIC -libs{odb-sqlite}: cxx.export.poptions += -DLIBODB_SQLITE_SHARED - -# For pre-releases use the complete version to make sure they cannot be used -# in place of another pre-release or the final version. See the version module -# for details on the version.* variable values. -# -if $version.pre_release - lib{odb-sqlite}: bin.lib.version = @"-$version.project_id" -else - lib{odb-sqlite}: bin.lib.version = @"-$version.major.$version.minor" - -develop = $config.libodb_sqlite.develop - -## Consumption build ($develop == false). -# - -# Use pregenerated versions in the consumption build. -# -lib{odb-sqlite}: details/pregenerated/{hxx ixx cxx}{**}: include = (!$develop) - -if! $develop - cxx.poptions =+ "-I($src_base/details/pregenerated)" # Note: must come first. - -# Don't install pregenerated headers since they are only used internally in -# the database implementation (also below). -# -details/pregenerated/{hxx ixx}{*}: install = false - -# Distribute pregenerated versions only in the consumption build. -# -details/pregenerated/{hxx ixx cxx}{*}: dist = (!$develop) - -# -## - -## Development build ($develop == true). -# - -lib{odb-sqlite}: details/{hxx ixx cxx}{options}: include = $develop - -if $develop - import! [metadata] cli = cli%exe{cli} - -# In the development build distribute regenerated {hxx ixx cxx}{options}, -# remapping their locations to the paths of the pregenerated versions (which -# are only distributed in the consumption build; see above). This way we make -# sure that the distributed files are always up-to-date. -# -
: details/cli{options} $cli -{ - install = false - dist = ($develop ? details/pregenerated/odb/sqlite/details/ : false) - - # Symlink the generated code in src for convenience of development. - # - backlink = true -} -% -if $develop -{{ - options = --include-with-brackets --include-prefix odb/sqlite/details \ - --guard-prefix LIBODB_SQLITE_DETAILS --generate-file-scanner \ - --cli-namespace odb::sqlite::details::cli --long-usage \ - --no-combined-flags - - $cli $options -o $out_base/details/ $path($<[0]) - - # If the result differs from the pregenerated version, copy it over. - # - d = [dir_path] $src_base/details/pregenerated/odb/sqlite/details/ - - if diff $d/options.hxx $path($>[0]) >- && \ - diff $d/options.ixx $path($>[1]) >- && \ - diff $d/options.cxx $path($>[2]) >- - exit - end - - cp $path($>[0]) $d/options.hxx - cp $path($>[1]) $d/options.ixx - cp $path($>[2]) $d/options.cxx -}} - -# Install into the odb/sqlite/ subdirectory of, say, /usr/include/ -# recreating subdirectories. -# -install_include = [dir_path] include/odb/sqlite/ - -{hxx ixx txx}{*}: -{ - install = $install_include - install.subdirs = true -} - -# We want these to be picked up whether LIBODB_SQLITE_BUILD2 is defined or not. -# -hxx{version}@./: install = false -hxx{version-build2}: install = $install_include/version.hxx -hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx - -details/build2/ -{ - h{*}: install = false - - if ($cxx.target.system == 'win32-msvc') - { - h{config-vc}@./: install = $install_include/details/ - h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h - } - else - { - h{config}@./: install = $install_include/details/ - h{config-stub}@./: install = $install_include/details/build2/config.h - } -} diff --git a/odb/sqlite/connection-factory.cxx b/odb/sqlite/connection-factory.cxx deleted file mode 100644 index 794c6dd..0000000 --- a/odb/sqlite/connection-factory.cxx +++ /dev/null @@ -1,417 +0,0 @@ -// file : odb/sqlite/connection-factory.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include - -#include -#include - -#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - -using namespace std; - -namespace odb -{ - using namespace details; - - namespace sqlite - { - // - // serial_connection_factory - // - - serial_connection_factory:: - ~serial_connection_factory () - { - // We should hold the last reference to the connection. - // - if (connection_ != 0) - assert (connection_.count () == 1); - } - - connection_ptr serial_connection_factory:: - create () - { - return connection_ptr (new (shared) connection (*this)); - } - - connection_ptr serial_connection_factory:: - connect () - { - return connection_; - } - - void serial_connection_factory:: - database (database_type& db) - { - connection_factory::database (db); - - if (!connection_) - connection_ = create (); - } - - // - // single_connection_factory - // - - single_connection_factory:: - ~single_connection_factory () - { - // If the connection is currently in use, wait for it to return to - // the factory. - // - lock l (mutex_); - } - - single_connection_factory::single_connection_ptr - single_connection_factory:: - create () - { - return single_connection_ptr (new (shared) single_connection (*this)); - } - - connection_ptr single_connection_factory:: - connect () - { - mutex_.lock (); - connection_->callback_ = &connection_->cb_; - connection_ptr r (connection_); - connection_.reset (); - return r; - } - - void single_connection_factory:: - database (database_type& db) - { - connection_factory::database (db); - - if (!connection_) - connection_ = create (); - } - - bool single_connection_factory:: - release (single_connection* c) - { - c->callback_ = 0; - connection_.reset (inc_ref (c)); - connection_->recycle (); - mutex_.unlock (); - return false; - } - - // - // single_connection_factory::single_connection - // - - single_connection_factory::single_connection:: - single_connection (single_connection_factory& f, int extra_flags) - : connection (f, extra_flags) - { - cb_.arg = this; - cb_.zero_counter = &zero_counter; - } - - single_connection_factory::single_connection:: - single_connection (single_connection_factory& f, sqlite3* handle) - : connection (f, handle) - { - cb_.arg = this; - cb_.zero_counter = &zero_counter; - } - - bool single_connection_factory::single_connection:: - zero_counter (void* arg) - { - single_connection* c (static_cast (arg)); - return static_cast (c->factory_).release (c); - } - - // - // new_connection_factory - // - - connection_ptr new_connection_factory:: - connect () - { - return connection_ptr (new (shared) connection (*this, extra_flags_)); - } - - void new_connection_factory:: - database (database_type& db) - { - bool first (db_ == 0); - - connection_factory::database (db); - - if (!first) - return; - - // Unless explicitly disabled, enable shared cache. - // -#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) - if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) - extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; -#endif - } - - // - // connection_pool_factory - // - - connection_pool_factory::pooled_connection_ptr connection_pool_factory:: - create () - { - return pooled_connection_ptr ( - new (shared) pooled_connection (*this, extra_flags_)); - } - - connection_pool_factory:: - ~connection_pool_factory () - { - // Wait for all the connections currently in use to return to the pool. - // - lock l (mutex_); - while (in_use_ != 0) - { - waiters_++; - cond_.wait (l); - waiters_--; - } - } - - connection_ptr connection_pool_factory:: - connect () - { - lock l (mutex_); - - while (true) - { - // See if we have a spare connection. - // - if (connections_.size () != 0) - { - shared_ptr c (connections_.back ()); - connections_.pop_back (); - - c->callback_ = &c->cb_; - in_use_++; - return c; - } - - // See if we can create a new one. - // - if(max_ == 0 || in_use_ < max_) - { - shared_ptr c (create ()); - c->callback_ = &c->cb_; - in_use_++; - return c; - } - - // Wait until someone releases a connection. - // - waiters_++; - cond_.wait (l); - waiters_--; - } - } - - void connection_pool_factory:: - database (database_type& db) - { - bool first (db_ == 0); - - connection_factory::database (db); - - if (!first) - return; - - // Unless explicitly disabled, enable shared cache. - // -#if SQLITE_VERSION_NUMBER >= 3006018 && defined(LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY) - if ((db_->flags () & SQLITE_OPEN_PRIVATECACHE) == 0) - extra_flags_ |= SQLITE_OPEN_SHAREDCACHE; -#endif - - if (min_ > 0) - { - connections_.reserve (min_); - - for(size_t i (0); i < min_; ++i) - connections_.push_back (create ()); - } - } - - bool connection_pool_factory:: - release (pooled_connection* c) - { - c->callback_ = 0; - - lock l (mutex_); - - // Determine if we need to keep or free this connection. - // - bool keep (waiters_ != 0 || - min_ == 0 || - (connections_.size () + in_use_ <= min_)); - - in_use_--; - - if (keep) - { - connections_.push_back (pooled_connection_ptr (inc_ref (c))); - connections_.back ()->recycle (); - } - - if (waiters_ != 0) - cond_.signal (); - - return !keep; - } - - // - // connection_pool_factory::pooled_connection - // - - connection_pool_factory::pooled_connection:: - pooled_connection (connection_pool_factory& f, int extra_flags) - : connection (f, extra_flags) - { - cb_.arg = this; - cb_.zero_counter = &zero_counter; - } - - connection_pool_factory::pooled_connection:: - pooled_connection (connection_pool_factory& f, sqlite3* handle) - : connection (f, handle) - { - cb_.arg = this; - cb_.zero_counter = &zero_counter; - } - - bool connection_pool_factory::pooled_connection:: - zero_counter (void* arg) - { - pooled_connection* c (static_cast (arg)); - return static_cast (c->factory_).release (c); - } - - // - // default_attached_connection_factory - // - - void default_attached_connection_factory:: - detach () - { - // Note that this function may be called several times, for example, in - // case of detach_database() failure. - // - if (attached_connection_ != 0) - { - // We should hold the last reference to the attached connection. - // - assert (attached_connection_.count () == 1); - - // While it may seem like a good idea to also invalidate query results - // and reset active statements, if any such result/statement is still - // alive, then there would be bigger problems since it would have a - // dangling reference to the connection. In a way, that's the same - // reason we don't do it in the connection destructor. - - // Remove ourselves from the active object list of the main - // connection. - // - if (next_ != this) // Might have already been done. - list_remove (); - - const string& s (database ().schema ()); - - if (s != "main" && s != "temp") - main_factory ().detach_database (main_connection_, s); - - // Explicitly free the attached connection so that we don't try to - // redo this. - // - attached_connection_.reset (); - } - } - - default_attached_connection_factory:: - ~default_attached_connection_factory () - { - if (attached_connection_ != 0) - { - // This can throw. Ignoring the failure to detach seems like the most - // sensible thing to do here. - // - try{ detach (); } catch (...) {} - } - } - - connection_ptr default_attached_connection_factory:: - connect () - { - return attached_connection_; - } - - void default_attached_connection_factory:: - database (database_type& db) - { - attached_connection_factory::database (db); - - if (!attached_connection_) - { - const string& s (db.schema ()); - - if (s != "main" && s != "temp") - main_factory ().attach_database (main_connection_, db.name (), s); - - attached_connection_.reset ( - new (shared) connection (*this, - s != "main" ? &translate_statement : 0)); - - // Add ourselves to the active object list of the main connection. - // - list_add (); - } - } - - void default_attached_connection_factory:: - clear () - { - attached_connection_->clear (); - } - - void default_attached_connection_factory:: - translate_statement (string& r, - const char* text, - size_t text_size, - connection& conn) - { - r.assign (text, text_size); - - // Things will fall apart if any of the statements we translate use - // "main" as a table alias. So we have this crude check even though it - // means we cannot use "main" for other aliases (e.g., column). - // - assert (r.find ("AS \"main\"") == string::npos); - - const string& s (conn.database ().schema ()); - for (size_t p (0); (p = r.find ("\"main\".", p, 7)) != string::npos; ) - { - // Verify the preceding character. - // - if (p != 0 && r[p - 1] == '.') - { - p += 7; - continue; - } - - r.replace (p + 1, 4, s); - p += s.size () + 3; - } - } - } -} diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx deleted file mode 100644 index b410997..0000000 --- a/odb/sqlite/connection-factory.hxx +++ /dev/null @@ -1,273 +0,0 @@ -// file : odb/sqlite/connection-factory.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX -#define ODB_SQLITE_CONNECTION_FACTORY_HXX - -#include - -#include -#include // std::size_t -#include - -#include -#include -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - // Share a single connection in a guaranteed serial database access. - // - // For example, a single-threaded application that executes all the - // operations via the database instance without messing with multiple - // connections/transactions would qualify. - // - class LIBODB_SQLITE_EXPORT serial_connection_factory: - public connection_factory - { - public: - serial_connection_factory () {} - - virtual connection_ptr - connect (); - - virtual void - database (database_type&); - - virtual - ~serial_connection_factory (); - - private: - serial_connection_factory (const serial_connection_factory&); - serial_connection_factory& operator= (const serial_connection_factory&); - - protected: - // This function is called when the factory needs to create the - // connection. - // - virtual connection_ptr - create (); - - connection_ptr connection_; - }; - - // Share a single connection potentially between multiple threads. - // - class LIBODB_SQLITE_EXPORT single_connection_factory: - public connection_factory - { - public: - single_connection_factory () {} - - virtual connection_ptr - connect (); - - virtual void - database (database_type&); - - virtual - ~single_connection_factory (); - - private: - single_connection_factory (const single_connection_factory&); - single_connection_factory& operator= (const single_connection_factory&); - - protected: - class LIBODB_SQLITE_EXPORT single_connection: public connection - { - public: - single_connection (single_connection_factory&, int extra_flags = 0); - single_connection (single_connection_factory&, sqlite3*); - - private: - static bool - zero_counter (void*); - - private: - friend class single_connection_factory; - shared_base::refcount_callback cb_; - }; - - friend class single_connection; - - typedef details::shared_ptr single_connection_ptr; - - // This function is called when the factory needs to create the - // connection. - // - virtual single_connection_ptr - create (); - - protected: - // Return true if the connection should be deleted, false otherwise. - // - bool - release (single_connection*); - - protected: - details::mutex mutex_; - single_connection_ptr connection_; - }; - - // Create a new connection every time one is requested. - // - class LIBODB_SQLITE_EXPORT new_connection_factory: - public connection_factory - { - public: - new_connection_factory (): extra_flags_ (0) {} - - virtual connection_ptr - connect (); - - virtual void - database (database_type&); - - private: - new_connection_factory (const new_connection_factory&); - new_connection_factory& operator= (const new_connection_factory&); - - private: - int extra_flags_; - }; - - // Pool a number of connections. - // - class LIBODB_SQLITE_EXPORT connection_pool_factory: - public connection_factory - { - public: - // The max_connections argument specifies the maximum number of - // concurrent connections this pool will maintain. If this value - // is 0 then the pool will create a new connection every time all - // of the existing connections are in use. - // - // The min_connections argument specifies the minimum number of - // connections that should be maintained by the pool. If the - // number of connections maintained by the pool exceeds this - // number and there are no active waiters for a new connection, - // then the pool will release the excess connections. If this - // value is 0 then the pool will maintain all the connections - // that were ever created. - // - // The ping argument specifies whether to ping the connection to - // make sure it is still alive before returning it to the caller. - // - connection_pool_factory (std::size_t max_connections = 0, - std::size_t min_connections = 0) - : max_ (max_connections), - min_ (min_connections), - extra_flags_ (0), - in_use_ (0), - waiters_ (0), - cond_ (mutex_) - { - // max_connections == 0 means unlimited. - // - assert (max_connections == 0 || max_connections >= min_connections); - } - - virtual connection_ptr - connect (); - - virtual void - database (database_type&); - - virtual - ~connection_pool_factory (); - - private: - connection_pool_factory (const connection_pool_factory&); - connection_pool_factory& operator= (const connection_pool_factory&); - - protected: - class LIBODB_SQLITE_EXPORT pooled_connection: public connection - { - public: - pooled_connection (connection_pool_factory&, int extra_flags = 0); - pooled_connection (connection_pool_factory&, sqlite3*); - - private: - static bool - zero_counter (void*); - - private: - friend class connection_pool_factory; - shared_base::refcount_callback cb_; - }; - - friend class pooled_connection; - - typedef details::shared_ptr pooled_connection_ptr; - typedef std::vector connections; - - // This function is called whenever the pool needs to create a new - // connection. - // - virtual pooled_connection_ptr - create (); - - protected: - // Return true if the connection should be deleted, false otherwise. - // - bool - release (pooled_connection*); - - protected: - const std::size_t max_; - const std::size_t min_; - int extra_flags_; - - std::size_t in_use_; // Number of connections currently in use. - std::size_t waiters_; // Number of threads waiting for a connection. - - connections connections_; - - details::mutex mutex_; - details::condition cond_; - }; - - class LIBODB_SQLITE_EXPORT default_attached_connection_factory: - public attached_connection_factory - { - public: - explicit - default_attached_connection_factory (const connection_ptr& main) - : attached_connection_factory (main) {} - - using attached_connection_factory::database; // Accessor. - - virtual void - database (database_type&); - - virtual connection_ptr - connect (); - - virtual void - detach (); - - // Active object interface. - // - virtual void - clear (); - - virtual - ~default_attached_connection_factory (); - - protected: - static void - translate_statement (std::string&, const char*, std::size_t, connection&); - }; - } -} - -#include - -#endif // ODB_SQLITE_CONNECTION_FACTORY_HXX diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx deleted file mode 100644 index 0445163..0000000 --- a/odb/sqlite/connection.cxx +++ /dev/null @@ -1,310 +0,0 @@ -// file : odb/sqlite/connection.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::bad_alloc -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include // deadlock - -#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - -using namespace std; - -extern "C" void -odb_sqlite_connection_unlock_callback (void**, int); - -namespace odb -{ - using namespace details; - - namespace sqlite - { - connection:: - connection (connection_factory& cf, - int extra_flags, - statement_translator* st) - : odb::connection (cf), - statement_translator_ (st), - unlock_cond_ (unlock_mutex_), - active_objects_ (0) - { - database_type& db (database ()); - - int f (db.flags () | extra_flags); - const string& n (db.name ()); - - // If we are opening a temporary database, then add the create flag. - // - if (n.empty () || n == ":memory:") - f |= SQLITE_OPEN_CREATE; - - // A connection can only be used by a single thread at a time. So - // disable locking in SQLite unless explicitly requested. - // -#if defined(SQLITE_OPEN_NOMUTEX) - if ((f & SQLITE_OPEN_FULLMUTEX) == 0) - f |= SQLITE_OPEN_NOMUTEX; -#endif - - sqlite3* h (0); - - // sqlite3_open_v2() was only addedin SQLite 3.5.0. - // -#if SQLITE_VERSION_NUMBER >= 3005000 - const string& vfs (db.vfs ()); - int e ( - sqlite3_open_v2 ( - n.c_str (), &h, f, (vfs.empty () ? 0 : vfs.c_str ()))); -#else - // Readonly opening not supported in SQLite earlier than 3.5.0. - // - assert ((f & SQLITE_OPEN_READONLY) == 0); - int e (sqlite3_open (n.c_str (), &h)); -#endif - - handle_.reset (h); - - if (e != SQLITE_OK) - { - if (handle_ == 0) - throw bad_alloc (); - - translate_error (e, *this); - } - - init (); - } - - connection:: - connection (connection_factory& cf, - sqlite3* handle, - statement_translator* st) - : odb::connection (cf), - handle_ (handle), - statement_translator_ (st), - unlock_cond_ (unlock_mutex_), - active_objects_ (0) - { - init (); - } - - void connection:: - init () - { - database_type& db (database ()); - - // Enable/disable foreign key constraints. - // - generic_statement st ( - *this, - db.foreign_keys () - ? "PRAGMA foreign_keys=ON" - : "PRAGMA foreign_keys=OFF", - db.foreign_keys () ? 22 : 23); - st.execute (); - - // String lengths include '\0', as per the SQLite manual suggestion. - // - begin_.reset (new (shared) generic_statement (*this, "BEGIN", 6)); - commit_.reset (new (shared) generic_statement (*this, "COMMIT", 7)); - rollback_.reset (new (shared) generic_statement (*this, "ROLLBACK", 9)); - - // Create statement cache. - // - statement_cache_.reset (new statement_cache_type (*this)); - } - - connection:: - connection (attached_connection_factory& cf, statement_translator* st) - : odb::connection (cf), - handle_ (0), - statement_translator_ (st), - unlock_cond_ (unlock_mutex_), - active_objects_ (0) - { - // Copy some things over from the main connection. - // - connection& main (*cf.main_connection_); - - tracer_ = main.tracer_; - - // Create statement cache. - // - statement_cache_.reset (new statement_cache_type (*this)); - } - - connection:: - ~connection () - { - // Destroy prepared query statements before freeing the connections. - // - recycle (); - clear_prepared_map (); - } - - generic_statement& connection:: - begin_statement () - { - return static_cast (*begin_); - } - - generic_statement& connection:: - begin_immediate_statement () - { - if (!begin_immediate_) - begin_immediate_.reset ( - new (shared) generic_statement (*this, "BEGIN IMMEDIATE", 16)); - - return static_cast (*begin_immediate_); - } - - generic_statement& connection:: - begin_exclusive_statement () - { - if (!begin_exclusive_) - begin_exclusive_.reset ( - new (shared) generic_statement (*this, "BEGIN EXCLUSIVE", 16)); - - return static_cast (*begin_exclusive_); - } - - generic_statement& connection:: - commit_statement () - { - return static_cast (*commit_); - } - - generic_statement& connection:: - rollback_statement () - { - return static_cast (*rollback_); - } - - transaction_impl* connection:: - begin () - { - return new transaction_impl ( - connection_ptr (inc_ref (this)), transaction_impl::deferred); - } - - transaction_impl* connection:: - begin_immediate () - { - return new transaction_impl ( - connection_ptr (inc_ref (this)), transaction_impl::immediate); - } - - transaction_impl* connection:: - begin_exclusive () - { - return new transaction_impl ( - connection_ptr (inc_ref (this)), transaction_impl::exclusive); - } - - unsigned long long connection:: - execute (const char* s, std::size_t n) - { - generic_statement st (*this, s, n); - return st.execute (); - } - - inline void - connection_unlock_callback (void** args, int n) - { - for (int i (0); i < n; ++i) - { - connection* c (static_cast (args[i])); - details::lock l (c->unlock_mutex_); - c->unlocked_ = true; - c->unlock_cond_.signal (); - } - } - - void connection:: - wait () - { -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - unlocked_ = false; - - // unlock_notify() returns SQLITE_OK or SQLITE_LOCKED (deadlock). - // - int e (sqlite3_unlock_notify (handle (), - &odb_sqlite_connection_unlock_callback, - this)); - if (e == SQLITE_LOCKED) - throw deadlock (); - - details::lock l (unlock_mutex_); - - while (!unlocked_) - unlock_cond_.wait (l); -#else - translate_error (SQLITE_LOCKED, *this); -#endif - } - - void connection:: - clear () - { - invalidate_results (); - - // The current first active_object may remove itself from the list and - // make the second object (if any) the new first. - // - for (active_object** pp (&active_objects_); *pp != 0; ) - { - active_object* p (*pp); - p->clear (); - - // Move to the next object if this one decided to stay on the list. - // - if (*pp == p) - pp = &p->next_; - } - } - - // connection_factory - // - connection_factory:: - ~connection_factory () - { - } - - void connection_factory:: - database (database_type& db) - { - odb::connection_factory::db_ = &db; - db_ = &db; - } - - void connection_factory:: - attach_database (const connection_ptr& conn, - const std::string& name, - const std::string& schema) - { - conn->execute ("ATTACH DATABASE '" + name + "' AS \"" + schema + '"'); - } - - void connection_factory:: - detach_database (const connection_ptr& conn, const std::string& schema) - { - conn->execute ("DETACH DATABASE \"" + schema + '"'); - } - } -} - -extern "C" void -odb_sqlite_connection_unlock_callback (void** args, int n) -{ - odb::sqlite::connection_unlock_callback (args, n); -} diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx deleted file mode 100644 index dbe4494..0000000 --- a/odb/sqlite/connection.hxx +++ /dev/null @@ -1,356 +0,0 @@ -// file : odb/sqlite/connection.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_CONNECTION_HXX -#define ODB_SQLITE_CONNECTION_HXX - -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - class statement_cache; - class generic_statement; - class connection_factory; - class attached_connection_factory; - - class connection; - typedef details::shared_ptr connection_ptr; - - // SQLite "active object", i.e., an object that needs to be - // "cleared" before the transaction can be committed and the - // connection released. These form a doubly-linked list. - // - class LIBODB_SQLITE_EXPORT active_object - { - public: - // This function may remove the object from the list since it may no - // longer be "active". - // - virtual void - clear () = 0; - - protected: - active_object (connection& c): prev_ (0), next_ (this), conn_ (c) {} - - void - list_add (); - - void - list_remove (); - - protected: - friend class connection; - - // prev_ == 0 means we are the first element. - // next_ == 0 means we are the last element. - // next_ == this means we are not on the list (prev_ should be 0). - // - active_object* prev_; - active_object* next_; - - connection& conn_; - }; - - class LIBODB_SQLITE_EXPORT connection: public odb::connection - { - public: - typedef sqlite::statement_cache statement_cache_type; - typedef sqlite::database database_type; - - // Translate the database schema in the statement text (used to - // implement attached databases). If the result is empty, then no - // translation is required and the original text should be used as is. - // - typedef void (statement_translator) (std::string& result, - const char* text, - std::size_t text_size, - connection&); - virtual - ~connection (); - - connection (connection_factory&, - int extra_flags = 0, - statement_translator* = 0); - - connection (connection_factory&, - sqlite3* handle, - statement_translator* = 0); - - // Create an attached connection (see the attached database constructor - // for details). - // - connection (attached_connection_factory&, statement_translator*); - - database_type& - database (); - - // Return the main connection of an attached connection. If this - // connection is main, return itself. - // - connection& - main_connection (); - - static connection_ptr - main_connection (const connection_ptr&); - - public: - virtual transaction_impl* - begin (); - - transaction_impl* - begin_immediate (); - - transaction_impl* - begin_exclusive (); - - public: - using odb::connection::execute; - - virtual unsigned long long - execute (const char* statement, std::size_t length); - - // Query preparation. - // - public: - template - prepared_query - prepare_query (const char* name, const char*); - - template - prepared_query - prepare_query (const char* name, const std::string&); - - template - prepared_query - prepare_query (const char* name, const sqlite::query_base&); - - template - prepared_query - prepare_query (const char* name, const odb::query_base&); - - // SQL statement tracing. - // - public: - typedef sqlite::tracer tracer_type; - - void - tracer (tracer_type& t) - { - odb::connection::tracer (t); - } - - void - tracer (tracer_type* t) - { - odb::connection::tracer (t); - } - - using odb::connection::tracer; - - public: - sqlite3* - handle (); - - statement_cache_type& - statement_cache () - { - return *statement_cache_; - } - - // Wait for the locks to be released via unlock notification. Can - // be called after getting SQLITE_LOCKED_SHAREDCACHE. - // - void - wait (); - - public: - // Reset active statements. Also invalidates query results by first - // calling invalidate_results(). - // - void - clear (); - - public: - // Note: only available on main connection. - // - generic_statement& - begin_statement (); - - generic_statement& - begin_immediate_statement (); - - generic_statement& - begin_exclusive_statement (); - - generic_statement& - commit_statement (); - - generic_statement& - rollback_statement (); - - protected: - friend class attached_connection_factory; - - connection_factory& - factory (); - - private: - connection (const connection&); - connection& operator= (const connection&); - - private: - void - init (); - - private: - // Note that we use NULL handle as an indication of an attached - // connection. - // - auto_handle handle_; - - statement_translator* statement_translator_; - - // Keep statement_cache_ after handle_ so that it is destroyed before - // the connection is closed. - // - details::unique_ptr statement_cache_; - - // Note: using odb::statement in order to break the connection-statement - // dependency cycle. - // - details::shared_ptr begin_; - details::shared_ptr begin_immediate_; - details::shared_ptr begin_exclusive_; - details::shared_ptr commit_; - details::shared_ptr rollback_; - - // Unlock notification machinery. - // - private: - bool unlocked_; - details::mutex unlock_mutex_; - details::condition unlock_cond_; - - friend void - connection_unlock_callback (void**, int); - - private: - friend class statement; // statement_translator_ - friend class transaction_impl; // invalidate_results() - - // Linked list of active objects currently associated - // with this connection. - // - private: - friend class active_object; - active_object* active_objects_; - }; - - class LIBODB_SQLITE_EXPORT connection_factory: - public odb::connection_factory - { - public: - typedef sqlite::database database_type; - - virtual void - database (database_type&); - - database_type& - database () {return *db_;} - - virtual connection_ptr - connect () = 0; - - virtual - ~connection_factory (); - - connection_factory (): db_ (0) {} - - // Attach/detach additional databases. Connection is one of the main - // connections created by this factory. Note: not called for "main" and - // "temp" schemas. - // - // The default implementations simply execute the ATTACH DATABASE and - // DETACH DATABASE SQLite statements. - // - virtual void - attach_database (const connection_ptr&, - const std::string& name, - const std::string& schema); - - virtual void - detach_database (const connection_ptr&, const std::string& schema); - - // Needed to break the circular connection_factory-database dependency - // (odb::connection_factory has the odb::database member). - // - protected: - database_type* db_; - }; - - // The call to database() should cause ATTACH DATABASE (or otherwise make - // sure the database is attached). Destruction of the factory should cause - // DETACH DATABASE (or otherwise notice that this factory no longer needs - // the database attached). - // - // Note that attached_connection_factory is an active object that - // registers itself with the main connection in order to get notified on - // transaction finalization. - // - class LIBODB_SQLITE_EXPORT attached_connection_factory: - public connection_factory, - public active_object - { - public: - explicit - attached_connection_factory (const connection_ptr& main) - : active_object (*main), main_connection_ (main) {} - - virtual void - detach () = 0; - - protected: - friend class database; - friend class connection; - friend class transaction_impl; - - connection_factory& - main_factory (); - - // Note that this essentially establishes a "framework" for all the - // attached connection factory implementations: they hold a counted - // reference to the main connection and they maintain a single shared - // attached connection. - // - connection_ptr main_connection_; - connection_ptr attached_connection_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_CONNECTION_HXX diff --git a/odb/sqlite/connection.ixx b/odb/sqlite/connection.ixx deleted file mode 100644 index 094fd52..0000000 --- a/odb/sqlite/connection.ixx +++ /dev/null @@ -1,108 +0,0 @@ -// file : odb/sqlite/connection.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - // active_object - // - inline void active_object:: - list_add () - { - next_ = conn_.active_objects_; - conn_.active_objects_ = this; - - if (next_ != 0) - next_->prev_ = this; - } - - inline void active_object:: - list_remove () - { - (prev_ == 0 ? conn_.active_objects_ : prev_->next_) = next_; - - if (next_ != 0) - next_->prev_ = prev_; - - prev_ = 0; - next_ = this; - } - - // connection - // - inline database& connection:: - database () - { - return static_cast (factory_).database (); - } - - inline connection& connection:: - main_connection () - { - return handle_ != 0 - ? *this - : *static_cast (factory_).main_connection_; - } - - inline connection_ptr connection:: - main_connection (const connection_ptr& c) - { - return c->handle_ != 0 - ? c - : static_cast (c->factory_).main_connection_; - } - - inline sqlite3* connection:: - handle () - { - return handle_ != 0 - ? handle_ - : static_cast (factory_).main_connection_->handle_; - } - - inline connection_factory& connection:: - factory () - { - return static_cast (factory_); - } - - template - inline prepared_query connection:: - prepare_query (const char* n, const char* q) - { - return prepare_query (n, query (q)); - } - - template - inline prepared_query connection:: - prepare_query (const char* n, const std::string& q) - { - return prepare_query (n, query (q)); - } - - template - inline prepared_query connection:: - prepare_query (const char* n, const sqlite::query_base& q) - { - return query_::call (*this, n, q); - } - - template - inline prepared_query connection:: - prepare_query (const char* n, const odb::query_base& q) - { - // Translate to native query. - // - return prepare_query (n, sqlite::query_base (q)); - } - - // attached_connection_factory - // - inline connection_factory& attached_connection_factory:: - main_factory () - { - return main_connection_->factory (); - } - } -} diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx deleted file mode 100644 index b9cccf0..0000000 --- a/odb/sqlite/container-statements.hxx +++ /dev/null @@ -1,355 +0,0 @@ -// file : odb/sqlite/container-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX -#define ODB_SQLITE_CONTAINER_STATEMENTS_HXX - -#include - -#include // std::size_t - -#include -#include -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - class connection; - - // Template argument is the generated abstract container traits type. - // That is, it doesn't need to provide column counts and statements. - // - template - class container_statements - { - public: - typedef T traits; - - typedef typename traits::data_image_type data_image_type; - typedef typename traits::functions_type functions_type; - - typedef sqlite::insert_statement insert_statement_type; - typedef sqlite::select_statement select_statement_type; - typedef sqlite::delete_statement delete_statement_type; - - typedef sqlite::connection connection_type; - - container_statements (connection_type&, binding& id_binding); - - connection_type& - connection () - { - return conn_; - } - - // Functions. - // - functions_type& - functions () - { - return functions_; - } - - // Schema version. - // - const schema_version_migration& - version_migration () const {return *svm_;} - - void - version_migration (const schema_version_migration& svm) {svm_ = &svm;} - - // Id image binding (external). - // - const binding& - id_binding () - { - return id_binding_; - } - - // Data image. The image is split into the id (that comes as a - // binding) and index/key plus value which are in data_image_type. - // The select binding is a subset of the full binding (no id). - // - data_image_type& - data_image () - { - return data_image_; - } - - bind* - data_bind () - { - return insert_image_binding_.bind; - } - - bool - data_binding_test_version () const - { - return data_id_binding_version_ != id_binding_.version || - data_image_version_ != data_image_.version || - insert_image_binding_.version == 0; - } - - void - data_binding_update_version () - { - data_id_binding_version_ = id_binding_.version; - data_image_version_ = data_image_.version; - insert_image_binding_.version++; - select_image_binding_.version++; - } - - bool* - select_image_truncated () - { - return select_image_truncated_; - } - - // - // Statements. - // - - insert_statement_type& - insert_statement () - { - if (insert_ == 0) - insert_.reset ( - new (details::shared) insert_statement_type ( - conn_, - insert_text_, - versioned_, // Process if versioned. - insert_image_binding_, - 0)); - - return *insert_; - } - - select_statement_type& - select_statement () - { - if (select_ == 0) - select_.reset ( - new (details::shared) select_statement_type ( - conn_, - select_text_, - versioned_, // Process if versioned. - false, // Don't optimize. - id_binding_, - select_image_binding_)); - - return *select_; - } - - delete_statement_type& - delete_statement () - { - if (delete_ == 0) - delete_.reset ( - new (details::shared) delete_statement_type ( - conn_, delete_text_, id_binding_)); - - return *delete_; - } - - private: - container_statements (const container_statements&); - container_statements& operator= (const container_statements&); - - protected: - connection_type& conn_; - binding& id_binding_; - - functions_type functions_; - - data_image_type data_image_; - std::size_t data_image_version_; - std::size_t data_id_binding_version_; - - binding insert_image_binding_; - - binding select_image_binding_; - bool* select_image_truncated_; - - const char* insert_text_; - const char* select_text_; - const char* delete_text_; - - bool versioned_; - const schema_version_migration* svm_; - - details::shared_ptr insert_; - details::shared_ptr select_; - details::shared_ptr delete_; - }; - - template - class smart_container_statements: public container_statements - { - public: - typedef T traits; - typedef typename traits::cond_image_type cond_image_type; - - typedef sqlite::update_statement update_statement_type; - typedef sqlite::delete_statement delete_statement_type; - - typedef sqlite::connection connection_type; - - smart_container_statements (connection_type&, binding& id_binding); - - // Condition image. The image is split into the id (that comes as - // a binding) and index/key/value which is in cond_image_type. - // - cond_image_type& - cond_image () - { - return cond_image_; - } - - bind* - cond_bind () - { - return cond_image_binding_.bind; - } - - bool - cond_binding_test_version () const - { - return cond_id_binding_version_ != this->id_binding_.version || - cond_image_version_ != cond_image_.version || - cond_image_binding_.version == 0; - } - - void - cond_binding_update_version () - { - cond_id_binding_version_ = this->id_binding_.version; - cond_image_version_ = cond_image_.version; - cond_image_binding_.version++; - } - - // Update image. The image is split as follows: value comes - // from the data image, id comes as binding, and index/key - // comes from the condition image. - // - bind* - update_bind () - { - return update_image_binding_.bind; - } - - bool - update_binding_test_version () const - { - return update_id_binding_version_ != this->id_binding_.version || - update_cond_image_version_ != cond_image_.version || - update_data_image_version_ != this->data_image_.version || - update_image_binding_.version == 0; - } - - void - update_binding_update_version () - { - update_id_binding_version_ = this->id_binding_.version; - update_cond_image_version_ = cond_image_.version; - update_data_image_version_ = this->data_image_.version; - update_image_binding_.version++; - } - - // - // Statements. - // - - delete_statement_type& - delete_statement () - { - if (this->delete_ == 0) - this->delete_.reset ( - new (details::shared) delete_statement_type ( - this->conn_, - this->delete_text_, - this->cond_image_binding_)); - - return *this->delete_; - } - - update_statement_type& - update_statement () - { - if (update_ == 0) - update_.reset ( - new (details::shared) update_statement_type ( - this->conn_, - update_text_, - this->versioned_, // Process if versioned. - update_image_binding_)); - - return *update_; - } - - protected: - cond_image_type cond_image_; - std::size_t cond_image_version_; - std::size_t cond_id_binding_version_; - binding cond_image_binding_; - - std::size_t update_id_binding_version_; - std::size_t update_cond_image_version_; - std::size_t update_data_image_version_; - binding update_image_binding_; - - const char* update_text_; - - details::shared_ptr update_; - }; - - // Template argument is the generated concrete container traits type. - // - template - class container_statements_impl: public T::statements_type - { - public: - typedef T traits; - typedef typename T::statements_type base; - typedef sqlite::connection connection_type; - - container_statements_impl (connection_type&, binding&); - - private: - container_statements_impl (const container_statements_impl&); - container_statements_impl& operator= (const container_statements_impl&); - - private: - bind data_image_bind_[traits::data_column_count]; - bool select_image_truncated_array_[traits::data_column_count - - traits::id_column_count]; - }; - - template - class smart_container_statements_impl: public container_statements_impl - { - public: - typedef T traits; - typedef sqlite::connection connection_type; - - smart_container_statements_impl (connection_type&, binding&); - - private: - bind cond_image_bind_[traits::cond_column_count]; - bind update_image_bind_[traits::value_column_count + - traits::cond_column_count]; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_CONTAINER_STATEMENTS_HXX diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx deleted file mode 100644 index 6db91f2..0000000 --- a/odb/sqlite/container-statements.txx +++ /dev/null @@ -1,107 +0,0 @@ -// file : odb/sqlite/container-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::size_t -#include // std::memset - -namespace odb -{ - namespace sqlite - { - // container_statements - // - template - container_statements:: - container_statements (connection_type& conn, binding& id) - : conn_ (conn), - id_binding_ (id), - functions_ (this), - insert_image_binding_ (0, 0), // Initialized by impl. - select_image_binding_ (0, 0), // Initialized by impl. - svm_ (0) - { - functions_.insert_ = &traits::insert; - functions_.select_ = &traits::select; - functions_.delete__ = &traits::delete_; - - data_image_.version = 0; - data_image_version_ = 0; - data_id_binding_version_ = 0; - } - - // smart_container_statements - // - template - smart_container_statements:: - smart_container_statements (connection_type& conn, binding& id) - : container_statements (conn, id), - cond_image_binding_ (0, 0), // Initialized by impl. - update_image_binding_ (0, 0) // Initialized by impl. - { - this->functions_.update_ = &traits::update; - - cond_image_.version = 0; - cond_image_version_ = 0; - cond_id_binding_version_ = 0; - - update_id_binding_version_ = 0; - update_cond_image_version_ = 0; - update_data_image_version_ = 0; - } - - // container_statements_impl - // - template - container_statements_impl:: - container_statements_impl (connection_type& conn, binding& id) - : base (conn, id) - { - this->select_image_truncated_ = select_image_truncated_array_; - - this->insert_image_binding_.bind = data_image_bind_; - this->insert_image_binding_.count = traits::data_column_count; - - this->select_image_binding_.bind = data_image_bind_ + - traits::id_column_count; - this->select_image_binding_.count = traits::data_column_count - - traits::id_column_count; - - std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); - std::memset (select_image_truncated_array_, - 0, - sizeof (select_image_truncated_array_)); - - for (std::size_t i (0); - i < traits::data_column_count - traits::id_column_count; - ++i) - data_image_bind_[i + traits::id_column_count].truncated = - select_image_truncated_array_ + i; - - this->insert_text_ = traits::insert_statement; - this->select_text_ = traits::select_statement; - this->delete_text_ = traits::delete_statement; - - this->versioned_ = traits::versioned; - } - - // smart_container_statements_impl - // - template - smart_container_statements_impl:: - smart_container_statements_impl (connection_type& conn, binding& id) - : container_statements_impl (conn, id) - { - this->cond_image_binding_.bind = cond_image_bind_; - this->cond_image_binding_.count = traits::cond_column_count; - - this->update_image_binding_.bind = update_image_bind_; - this->update_image_binding_.count = traits::value_column_count + - traits::cond_column_count; - - std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); - std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - - this->update_text_ = traits::update_statement; - } - } -} diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx deleted file mode 100644 index a7cf098..0000000 --- a/odb/sqlite/database.cxx +++ /dev/null @@ -1,306 +0,0 @@ -// file : odb/sqlite/database.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifdef _WIN32 -# include // WideCharToMultiByte -#endif - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - using odb::details::transfer_ptr; - - database:: - ~database () - { - } - - database:: - database (const string& name, - int flags, - bool foreign_keys, - const string& vfs, - transfer_ptr factory) - : odb::database (id_sqlite), - name_ (name), - flags_ (flags), - foreign_keys_ (foreign_keys), - vfs_ (vfs), - factory_ (factory.transfer ()) - { - if (!factory_) - factory_.reset (new connection_pool_factory ()); - - factory_->database (*this); - } - -#ifdef _WIN32 - database:: - database (const wstring& name, - int flags, - bool foreign_keys, - const string& vfs, - transfer_ptr factory) - : odb::database (id_sqlite), - flags_ (flags), - foreign_keys_ (foreign_keys), - vfs_ (vfs), - factory_ (factory.transfer ()) - { - // Convert UTF-16 name to UTF-8 using the WideCharToMultiByte() Win32 - // function. - // - int n ( - WideCharToMultiByte ( - CP_UTF8, - 0, - name.c_str (), - static_cast (name.size ()), - 0, - 0, - 0, - 0)); - - if (n == 0) - throw database_exception ( - SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); - - // This string is not shared so we are going to modify the underlying - // buffer directly. - // - name_.resize (static_cast (n)); - - n = WideCharToMultiByte ( - CP_UTF8, - 0, - name.c_str (), - static_cast (name.size ()), - const_cast (name_.c_str ()), - n, - 0, - 0); - - if (n == 0) - throw database_exception ( - SQLITE_CANTOPEN, SQLITE_CANTOPEN, "unable to open database file"); - - if (!factory_) - factory_.reset (new connection_pool_factory ()); - - factory_->database (*this); - } -#endif - - database:: - database (int& argc, - char* argv[], - bool erase, - int flags, - bool foreign_keys, - const string& vfs, - transfer_ptr factory) - : odb::database (id_sqlite), - flags_ (flags), - foreign_keys_ (foreign_keys), - vfs_ (vfs), - factory_ (factory.transfer ()) - { - using namespace details; - - try - { - cli::argv_file_scanner scan (argc, argv, "--options-file", erase); - options ops (scan, cli::unknown_mode::skip, cli::unknown_mode::skip); - - name_ = ops.database (); - - if (ops.create ()) - flags_ |= SQLITE_OPEN_CREATE; - - if (ops.read_only ()) - flags_ = (flags_ & ~SQLITE_OPEN_READWRITE) | SQLITE_OPEN_READONLY; - } - catch (const cli::exception& e) - { - ostringstream ostr; - ostr << e; - throw cli_exception (ostr.str ()); - } - - if (!factory_) - factory_.reset (new connection_pool_factory ()); - - factory_->database (*this); - } - - database:: - database (const connection_ptr& conn, - const string& name, - const string& schema, - transfer_ptr factory) - : odb::database (id_sqlite), - name_ (name), - schema_ (schema), - flags_ (0), - factory_ (factory.transfer ()) - { - assert (!schema_.empty ()); - - // Copy some things over from the connection's database. - // - database& db (conn->database ()); - - tracer_ = db.tracer_; - foreign_keys_ = db.foreign_keys_; - - if (!factory_) - factory_.reset (new default_attached_connection_factory ( - connection::main_connection (conn))); - - factory_->database (*this); - } - - void database:: - print_usage (ostream& os) - { - details::options::print_usage (os); - } - - transaction_impl* database:: - begin () - { - return new transaction_impl (*this, transaction_impl::deferred); - } - - transaction_impl* database:: - begin_immediate () - { - return new transaction_impl (*this, transaction_impl::immediate); - } - - transaction_impl* database:: - begin_exclusive () - { - return new transaction_impl (*this, transaction_impl::exclusive); - } - - odb::connection* database:: - connection_ () - { - connection_ptr c (factory_->connect ()); - return c.release (); - } - - const database::schema_version_info& database:: - load_schema_version (const string& name) const - { - schema_version_info& svi (schema_version_map_[name]); - - // Construct the SELECT statement text. - // - string text ("SELECT \"version\", \"migration\" FROM "); - - if (!svi.version_table.empty ()) - text += svi.version_table; // Already quoted. - else if (!schema_version_table_.empty ()) - text += schema_version_table_; // Already quoted. - else - text += "\"main\".\"schema_version\""; - - text += " WHERE \"name\" = ?"; - - // Bind parameters and results. - // - size_t psize[1] = {name.size ()}; - bind pbind[1] = {{bind::text, - const_cast (name.c_str ()), - &psize[0], - 0, 0, 0}}; - binding param (pbind, 1); - param.version++; - - long long migration; - bool rnull[2]; - bind rbind[2] = {{bind::integer, &svi.version, 0, 0, &rnull[0], 0}, - {bind::integer, &migration, 0, 0, &rnull[1], 0}}; - binding result (rbind, 2); - result.version++; - - // If we are not in transaction, SQLite will start an implicit one - // which suits us just fine. - // - connection_ptr cp; - if (!transaction::has_current ()) - cp = factory_->connect (); - - sqlite::connection& c ( - cp != 0 - ? *cp - : transaction::current ().connection (const_cast (*this))); - - try - { - select_statement st (c, - text, - false, // Don't process. - false, // Don't optimize. - param, - result); - st.execute (); - auto_result ar (st); - - switch (st.fetch ()) - { - case select_statement::success: - { - svi.migration = migration != 0; - assert (st.fetch () == select_statement::no_data); - break; - } - case select_statement::no_data: - { - svi.version = 0; // No schema. - break; - } - case select_statement::truncated: - { - assert (false); - break; - } - } - } - catch (const database_exception& e) - { - // Try to detect the case where there is no version table. SQLite - // doesn't have an extended error code for this so we have to use - // the error text. - // - if (e.error () == SQLITE_ERROR && - e.message ().compare (0, 14, "no such table:") == 0) - svi.version = 0; // No schema. - else - throw; - } - - return svi; - } - } -} diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx deleted file mode 100644 index e1e62cc..0000000 --- a/odb/sqlite/database.hxx +++ /dev/null @@ -1,567 +0,0 @@ -// file : odb/sqlite/database.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_DATABASE_HXX -#define ODB_SQLITE_DATABASE_HXX - -#include - -#include - -#include -#include // std::ostream - -#include -#include // ODB_CXX11 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -// We use the sqlite3_open_v2() flags in our interface. Define them -// for SQLite earlier that 3.5.0. -// -#if SQLITE_VERSION_NUMBER < 3005000 -# define SQLITE_OPEN_READONLY 0x00000001 -# define SQLITE_OPEN_READWRITE 0x00000002 -# define SQLITE_OPEN_CREATE 0x00000004 -#endif - -namespace odb -{ - namespace sqlite - { - class transaction_impl; - - class LIBODB_SQLITE_EXPORT database: public odb::database - { - public: - database (const std::string& name, - int flags = SQLITE_OPEN_READWRITE, - bool foreign_keys = true, - const std::string& vfs = "", - details::transfer_ptr = - details::transfer_ptr ()); - -#ifdef _WIN32 - database (const std::wstring& name, - int flags = SQLITE_OPEN_READWRITE, - bool foreign_keys = true, - const std::string& vfs = "", - details::transfer_ptr = - details::transfer_ptr ()); -#endif - - // Extract the database parameters from the command line. The - // following options are recognized: - // - // --database - // --create - // --read-only - // --options-file - // - // For more information, see the output of the print_usage() function - // below. If erase is true, the above options are removed from the argv - // array and the argc count is updated accordingly. The command line - // options override the flags passed as an argument. This constructor - // may throw the cli_exception exception. - // - database (int& argc, - char* argv[], - bool erase = false, - int flags = SQLITE_OPEN_READWRITE, - bool foreign_keys = true, - const std::string& vfs = "", - details::transfer_ptr = - details::transfer_ptr ()); - - // Attach to the specified connection a database with the specified name - // as the specified schema. Good understanding of SQLite ATTACH/DETACH - // DATABASE statements semantics and ODB connection management is - // strongly recommended when using this mechanism. - // - // The resulting database instance is referred to as an "attached - // database" and the connection it returns as an "attached connection" - // (which is just a proxy for the main connection). Database operations - // executed on the attached database or attached connection are - // automatically translated to refer to the specified schema rather than - // "main". For uniformity attached databases can also be created for the - // pre-attached "main" and "temp" schemas (in this case name can be - // anything). - // - // The automatic translation of the statements relies on their text - // having references to top-level database entities (tables, indexes, - // etc) qualified with the "main" schema. To achieve this, compile your - // headers with `--schema main` and, if using schema migration, with - // `--schema-version-table main.schema_version`. You must also not use - // "main" as an object/table alias in views of native statements. For - // optimal translation performance use 4-character schema names. - // - // The main connection and attached to it databases and connections are - // all meant to be used within the same thread. In particular, the - // attached database holds a counted reference to the main connection - // which means the connection will not be released until all the - // attached to this connection databases are destroyed. - // - // Note that in this model the attached databases are attached to the - // main connection, not to the (main) database, which mimics the - // underlying semantics of SQLite. An alternative model would have been - // to notionally attach the databases to the main database and under the - // hood automatically attach them to each returned connection. While - // this may seem like a more convenient model in some cases, it is also - // less flexible: the current model allows attaching a different set of - // databases to different connections, attaching them on demand as the - // transaction progresses, etc. Also, the more convenient model can be - // implemented on top of this model by deriving an application-specific - // database class and/or providing custom connection factories. - // - // Note that unless the name is a URI with appropriate mode, it is - // opened with the SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE flags. So if - // you want just SQLITE_OPEN_READWRITE, then you will need to verify its - // existence manually prior to calling this constructor. - // - // Note that attaching/detaching databases withing a transaction is only - // supported since SQLite 3.21.0. - // - database (const connection_ptr&, - const std::string& name, - const std::string& schema, - details::transfer_ptr = - details::transfer_ptr ()); - - // The database is automatically detached on destruction but a failure - // to detach is ignored. To detect such a failure perform explicit - // detach. For uniformity detaching a main database is a no-op. - // - void - detach (); - - // Return the main database of an attached database. If this database - // is main, return itself. - // - database& - main_database (); - - // Move-constructible but not move-assignable. - // - // Note: noexcept is not specified since odb::database(odb::database&&) - // can throw. - // -#ifdef ODB_CXX11 - database (database&&); -#endif - - static void - print_usage (std::ostream&); - - public: - const std::string& - name () const - { - return name_; - } - - // Schema name under which this database was attached or empty for the - // main database. - // - const std::string& - schema () const - { - return schema_; - } - - int - flags () const - { - return flags_; - } - - bool - foreign_keys () const - { - return foreign_keys_; - } - - const std::string& - vfs () const - { - return vfs_; - } - - // Object persistence API. - // - public: - - // Make the object persistent. - // - template - typename object_traits::id_type - persist (T& object); - - template - typename object_traits::id_type - persist (const T& object); - - template - typename object_traits::id_type - persist (T* obj_ptr); - - template class P> - typename object_traits::id_type - persist (const P& obj_ptr); - - template class P> - typename object_traits::id_type - persist (const P& obj_ptr); - - template class P> - typename object_traits::id_type - persist (P& obj_ptr); - - template class P> - typename object_traits::id_type - persist (P& obj_ptr); - - template - typename object_traits::id_type - persist (const typename object_traits::pointer_type& obj_ptr); - - // Load an object. Throw object_not_persistent if not found. - // - template - typename object_traits::pointer_type - load (const typename object_traits::id_type& id); - - template - void - load (const typename object_traits::id_type& id, T& object); - - // Load (or reload, if it is already loaded) a section of an object. - // - template - void - load (T& object, section&); - - // Reload an object. - // - template - void - reload (T& object); - - template - void - reload (T* obj_ptr); - - template class P> - void - reload (const P& obj_ptr); - - template class P> - void - reload (const P& obj_ptr); - - template class P> - void - reload (P& obj_ptr); - - template class P> - void - reload (P& obj_ptr); - - template - void - reload (const typename object_traits::pointer_type& obj_ptr); - - // Loan an object if found. Return NULL/false if not found. - // - template - typename object_traits::pointer_type - find (const typename object_traits::id_type& id); - - template - bool - find (const typename object_traits::id_type& id, T& object); - - // Update the state of a modified objects. - // - template - void - update (T& object); - - template - void - update (T* obj_ptr); - - template class P> - void - update (const P& obj_ptr); - - template class P> - void - update (const P& obj_ptr); - - template class P> - void - update (P& obj_ptr); - - template class P> - void - update (P& obj_ptr); - - template - void - update (const typename object_traits::pointer_type& obj_ptr); - - // Update a section of an object. Throws the section_not_loaded - // exception if the section is not loaded. Note also that this - // function does not clear the changed flag if it is set. - // - template - void - update (const T& object, const section&); - - // Make the object transient. Throw object_not_persistent if not - // found. - // - template - void - erase (const typename object_traits::id_type& id); - - template - void - erase (T& object); - - template - void - erase (T* obj_ptr); - - template class P> - void - erase (const P& obj_ptr); - - template class P> - void - erase (const P& obj_ptr); - - template class P> - void - erase (P& obj_ptr); - - template class P> - void - erase (P& obj_ptr); - - template - void - erase (const typename object_traits::pointer_type& obj_ptr); - - // Erase multiple objects matching a query predicate. - // - template - unsigned long long - erase_query (); - - template - unsigned long long - erase_query (const char*); - - template - unsigned long long - erase_query (const std::string&); - - template - unsigned long long - erase_query (const sqlite::query_base&); - - template - unsigned long long - erase_query (const odb::query_base&); - - // Query API. - // - template - result - query (); - - template - result - query (const char*); - - template - result - query (const std::string&); - - template - result - query (const sqlite::query_base&); - - template - result - query (const odb::query_base&); - - // Query one API. - // - template - typename result::pointer_type - query_one (); - - template - bool - query_one (T& object); - - template - T - query_value (); - - template - typename result::pointer_type - query_one (const char*); - - template - bool - query_one (const char*, T& object); - - template - T - query_value (const char*); - - template - typename result::pointer_type - query_one (const std::string&); - - template - bool - query_one (const std::string&, T& object); - - template - T - query_value (const std::string&); - - template - typename result::pointer_type - query_one (const sqlite::query_base&); - - template - bool - query_one (const sqlite::query_base&, T& object); - - template - T - query_value (const sqlite::query_base&); - - template - typename result::pointer_type - query_one (const odb::query_base&); - - template - bool - query_one (const odb::query_base&, T& object); - - template - T - query_value (const odb::query_base&); - - // Query preparation. - // - template - prepared_query - prepare_query (const char* name, const char*); - - template - prepared_query - prepare_query (const char* name, const std::string&); - - template - prepared_query - prepare_query (const char* name, const sqlite::query_base&); - - template - prepared_query - prepare_query (const char* name, const odb::query_base&); - - // Transactions. - // - public: - virtual transaction_impl* - begin (); - - transaction_impl* - begin_immediate (); - - transaction_impl* - begin_exclusive (); - - public: - connection_ptr - connection (); - - // SQL statement tracing. - // - public: - typedef sqlite::tracer tracer_type; - - void - tracer (tracer_type& t) - { - odb::database::tracer (t); - } - - void - tracer (tracer_type* t) - { - odb::database::tracer (t); - } - - using odb::database::tracer; - - // Database schema version. - // - protected: - virtual const schema_version_info& - load_schema_version (const std::string& schema_name) const; - - // Database id constant (useful for meta-programming). - // - public: - static const odb::database_id database_id = id_sqlite; - - public: - virtual - ~database (); - - protected: - virtual odb::connection* - connection_ (); - - private: - friend class transaction_impl; // factory_ - - // Note: remember to update move ctor if adding any new members. - // - std::string name_; - std::string schema_; - int flags_; - bool foreign_keys_; - std::string vfs_; - - // Note: keep last so that all other database members are still valid - // during factory's destruction. - // - details::unique_ptr factory_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_DATABASE_HXX diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx deleted file mode 100644 index e906a39..0000000 --- a/odb/sqlite/database.ixx +++ /dev/null @@ -1,622 +0,0 @@ -// file : odb/sqlite/database.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // move() - -#include - -namespace odb -{ - namespace sqlite - { -#ifdef ODB_CXX11 - inline database:: - database (database&& db) // Has to be inline. - : odb::database (std::move (db)), - name_ (std::move (db.name_)), - schema_ (std::move (db.schema_)), - flags_ (db.flags_), - foreign_keys_ (db.foreign_keys_), - vfs_ (std::move (db.vfs_)), - factory_ (std::move (db.factory_)) - { - factory_->database (*this); // New database instance. - } -#endif - - inline void database:: - detach () - { - if (!schema_.empty ()) - static_cast (*factory_).detach (); - } - - inline database& database:: - main_database () - { - return schema_.empty () - ? *this - : static_cast (*factory_).main_connection_->database (); - } - - inline connection_ptr database:: - connection () - { - // Go through the virtual connection_() function instead of - // directly to allow overriding. - // - return connection_ptr ( - static_cast (connection_ ())); - } - - template - inline typename object_traits::id_type database:: - persist (T& obj) - { - return persist_ (obj); - } - - template - inline typename object_traits::id_type database:: - persist (const T& obj) - { - return persist_ (obj); - } - - template - inline typename object_traits::id_type database:: - persist (T* p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - return persist_ (pobj); - } - - template class P> - inline typename object_traits::id_type database:: - persist (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - return persist_ (pobj); - } - - template class P> - inline typename object_traits::id_type database:: - persist (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - return persist_ (pobj); - } - - template class P> - inline typename object_traits::id_type database:: - persist (P& p) - { - const P& cr (p); - return persist (cr); - } - - template class P> - inline typename object_traits::id_type database:: - persist (P& p) - { - const P& cr (p); - return persist (cr); - } - - template - inline typename object_traits::id_type database:: - persist (const typename object_traits::pointer_type& pobj) - { - return persist_ (pobj); - } - - template - inline typename object_traits::pointer_type database:: - load (const typename object_traits::id_type& id) - { - return load_ (id); - } - - template - inline void database:: - load (const typename object_traits::id_type& id, T& obj) - { - return load_ (id, obj); - } - - template - inline void database:: - load (T& obj, section& s) - { - return load_ (obj, s); - } - - template - inline typename object_traits::pointer_type database:: - find (const typename object_traits::id_type& id) - { - return find_ (id); - } - - template - inline bool database:: - find (const typename object_traits::id_type& id, T& obj) - { - return find_ (id, obj); - } - - template - inline void database:: - reload (T& obj) - { - reload_ (obj); - } - - template - inline void database:: - reload (T* p) - { - reload (*p); - } - - template class P> - inline void database:: - reload (const P& p) - { - reload (odb::pointer_traits< P >::get_ref (p)); - } - - template class P> - inline void database:: - reload (const P& p) - { - reload (odb::pointer_traits< P >::get_ref (p)); - } - - template class P> - inline void database:: - reload (P& p) - { - reload (odb::pointer_traits< P >::get_ref (p)); - } - - template class P> - inline void database:: - reload (P& p) - { - reload (odb::pointer_traits< P >::get_ref (p)); - } - - template - inline void database:: - reload (const typename object_traits::pointer_type& pobj) - { - typedef typename object_traits::pointer_type pointer_type; - - reload (odb::pointer_traits::get_ref (pobj)); - } - - template - inline void database:: - update (T& obj) - { - update_ (obj); - } - - template - inline void database:: - update (T* p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - update_ (pobj); - } - - template class P> - inline void database:: - update (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - update_ (pobj); - } - - template class P> - inline void database:: - update (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - update_ (pobj); - } - - template class P> - inline void database:: - update (P& p) - { - const P& cr (p); - update (cr); - } - - template class P> - inline void database:: - update (P& p) - { - const P& cr (p); - update (cr); - } - - template - inline void database:: - update (const typename object_traits::pointer_type& pobj) - { - update_ (pobj); - } - - template - inline void database:: - update (const T& obj, const section& s) - { - update_ (obj, s); - } - - template - inline void database:: - erase (const typename object_traits::id_type& id) - { - return erase_ (id); - } - - template - inline void database:: - erase (T& obj) - { - return erase_ (obj); - } - - template - inline void database:: - erase (T* p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - erase_ (pobj); - } - - template class P> - inline void database:: - erase (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - erase_ (pobj); - } - - template class P> - inline void database:: - erase (const P& p) - { - typedef typename object_traits::pointer_type object_pointer; - - // The passed pointer should be the same or implicit-convertible - // to the object pointer. This way we make sure the object pointer - // does not assume ownership of the passed object. - // - const object_pointer& pobj (p); - - erase_ (pobj); - } - - template class P> - inline void database:: - erase (P& p) - { - const P& cr (p); - erase (cr); - } - - template class P> - inline void database:: - erase (P& p) - { - const P& cr (p); - erase (cr); - } - - template - inline void database:: - erase (const typename object_traits::pointer_type& pobj) - { - erase_ (pobj); - } - - template - inline unsigned long long database:: - erase_query () - { - // T is always object_type. - // - return erase_query (sqlite::query_base ()); - } - - template - inline unsigned long long database:: - erase_query (const char* q) - { - // T is always object_type. - // - return erase_query (sqlite::query_base (q)); - } - - template - inline unsigned long long database:: - erase_query (const std::string& q) - { - // T is always object_type. - // - return erase_query (sqlite::query_base (q)); - } - - template - inline unsigned long long database:: - erase_query (const sqlite::query_base& q) - { - // T is always object_type. - // - return object_traits_impl::erase_query (*this, q); - } - - template - inline unsigned long long database:: - erase_query (const odb::query_base& q) - { - // Translate to native query. - // - return erase_query (sqlite::query_base (q)); - } - - template - inline result database:: - query () - { - return query (sqlite::query_base ()); - } - - template - inline result database:: - query (const char* q) - { - return query (sqlite::query_base (q)); - } - - template - inline result database:: - query (const std::string& q) - { - return query (sqlite::query_base (q)); - } - - template - inline result database:: - query (const sqlite::query_base& q) - { - // T is always object_type. We also don't need to check for transaction - // here; object_traits::query () does this. - // - return query_::call (*this, q); - } - - template - inline result database:: - query (const odb::query_base& q) - { - // Translate to native query. - // - return query (sqlite::query_base (q)); - } - - template - inline typename result::pointer_type database:: - query_one () - { - return query_one (sqlite::query_base ()); - } - - template - inline bool database:: - query_one (T& o) - { - return query_one (sqlite::query_base (), o); - } - - template - inline T database:: - query_value () - { - return query_value (sqlite::query_base ()); - } - - template - inline typename result::pointer_type database:: - query_one (const char* q) - { - return query_one (sqlite::query_base (q)); - } - - template - inline bool database:: - query_one (const char* q, T& o) - { - return query_one (sqlite::query_base (q), o); - } - - template - inline T database:: - query_value (const char* q) - { - return query_value (sqlite::query_base (q)); - } - - template - inline typename result::pointer_type database:: - query_one (const std::string& q) - { - return query_one (sqlite::query_base (q)); - } - - template - inline bool database:: - query_one (const std::string& q, T& o) - { - return query_one (sqlite::query_base (q), o); - } - - template - inline T database:: - query_value (const std::string& q) - { - return query_value (sqlite::query_base (q)); - } - - template - inline typename result::pointer_type database:: - query_one (const sqlite::query_base& q) - { - // T is always object_type. We also don't need to check for transaction - // here; object_traits::query () does this. - // - return query_one_ (q); - } - - template - inline bool database:: - query_one (const sqlite::query_base& q, T& o) - { - // T is always object_type. We also don't need to check for transaction - // here; object_traits::query () does this. - // - return query_one_ (q, o); - } - - template - inline T database:: - query_value (const sqlite::query_base& q) - { - // T is always object_type. We also don't need to check for transaction - // here; object_traits::query () does this. - // - return query_value_ (q); - } - - template - inline typename result::pointer_type database:: - query_one (const odb::query_base& q) - { - // Translate to native query. - // - return query_one (sqlite::query_base (q)); - } - - template - inline bool database:: - query_one (const odb::query_base& q, T& o) - { - // Translate to native query. - // - return query_one (sqlite::query_base (q), o); - } - - template - inline T database:: - query_value (const odb::query_base& q) - { - // Translate to native query. - // - return query_value (sqlite::query_base (q)); - } - - template - inline prepared_query database:: - prepare_query (const char* n, const char* q) - { - return prepare_query (n, sqlite::query_base (q)); - } - - template - inline prepared_query database:: - prepare_query (const char* n, const std::string& q) - { - return prepare_query (n, sqlite::query_base (q)); - } - - template - inline prepared_query database:: - prepare_query (const char* n, const sqlite::query_base& q) - { - // Throws if not in transaction. - // - sqlite::connection& c (transaction::current ().connection (*this)); - return c.prepare_query (n, q); - } - - template - inline prepared_query database:: - prepare_query (const char* n, const odb::query_base& q) - { - // Translate to native query. - // - return prepare_query (n, sqlite::query_base (q)); - } - } -} diff --git a/odb/sqlite/details/.gitignore b/odb/sqlite/details/.gitignore deleted file mode 100644 index b298f89..0000000 --- a/odb/sqlite/details/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/options.?xx diff --git a/odb/sqlite/details/build2/config-stub.h b/odb/sqlite/details/build2/config-stub.h deleted file mode 100644 index 34ba8ff..0000000 --- a/odb/sqlite/details/build2/config-stub.h +++ /dev/null @@ -1,5 +0,0 @@ -/* file : odb/sqlite/details/build2/config-stub.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -#include diff --git a/odb/sqlite/details/build2/config-vc-stub.h b/odb/sqlite/details/build2/config-vc-stub.h deleted file mode 100644 index 70e3e93..0000000 --- a/odb/sqlite/details/build2/config-vc-stub.h +++ /dev/null @@ -1,5 +0,0 @@ -/* file : odb/sqlite/details/build2/config-vc-stub.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -#include diff --git a/odb/sqlite/details/build2/config-vc.h b/odb/sqlite/details/build2/config-vc.h deleted file mode 100644 index 75ce442..0000000 --- a/odb/sqlite/details/build2/config-vc.h +++ /dev/null @@ -1,15 +0,0 @@ -/* file : odb/sqlite/details/build2/config-vc.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* Configuration file for Windows/VC++ for the build2 build. */ - -#ifndef ODB_SQLITE_DETAILS_CONFIG_VC_H -#define ODB_SQLITE_DETAILS_CONFIG_VC_H - -/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ -#ifndef LIBODB_SQLITE_BUILD2 -# define LIBODB_SQLITE_BUILD2 -#endif - -#endif /* ODB_SQLITE_DETAILS_CONFIG_VC_H */ diff --git a/odb/sqlite/details/build2/config.h b/odb/sqlite/details/build2/config.h deleted file mode 100644 index b4a1a1f..0000000 --- a/odb/sqlite/details/build2/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* file : odb/sqlite/details/build2/config.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* Static configuration file for the build2 build. The installed case - (when LIBODB_SQLITE_BUILD2 is not necessarily defined) is the only - reason we have it. */ - -#ifndef ODB_SQLITE_DETAILS_CONFIG_H -#define ODB_SQLITE_DETAILS_CONFIG_H - -/* Define LIBODB_SQLITE_BUILD2 for the installed case. */ -#ifndef LIBODB_SQLITE_BUILD2 -# define LIBODB_SQLITE_BUILD2 -#endif - -#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/odb/sqlite/details/config-vc.h b/odb/sqlite/details/config-vc.h deleted file mode 100644 index f42c2a0..0000000 --- a/odb/sqlite/details/config-vc.h +++ /dev/null @@ -1,5 +0,0 @@ -/* file : odb/sqlite/details/config-vc.h - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* Dummy configuration file for Windows/VC++. */ diff --git a/odb/sqlite/details/config.h.in b/odb/sqlite/details/config.h.in deleted file mode 100644 index a223ecb..0000000 --- a/odb/sqlite/details/config.h.in +++ /dev/null @@ -1,14 +0,0 @@ -/* file : odb/sqlite/details/config.h.in - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* This file is automatically processed by configure. */ - -#ifndef ODB_SQLITE_DETAILS_CONFIG_H -#define ODB_SQLITE_DETAILS_CONFIG_H - -#undef LIBODB_SQLITE_STATIC_LIB -#undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY -#undef LIBODB_SQLITE_HAVE_COLUMN_METADATA - -#endif /* ODB_SQLITE_DETAILS_CONFIG_H */ diff --git a/odb/sqlite/details/config.hxx b/odb/sqlite/details/config.hxx deleted file mode 100644 index 4f1c5ce..0000000 --- a/odb/sqlite/details/config.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : odb/sqlite/details/config.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_DETAILS_CONFIG_HXX -#define ODB_SQLITE_DETAILS_CONFIG_HXX - -// no pre - -#ifdef ODB_COMPILER -# error libodb-sqlite header included in odb-compiled header -#elif !defined(LIBODB_SQLITE_BUILD2) -# ifdef _MSC_VER -# include -# else -# include -# endif -#endif - -// LIBODB_SQLITE_BUILD2 macro can be defined either by the buildfile or by the -// included odb/sqlite/details/config*.h (see above). -// -#ifdef LIBODB_SQLITE_BUILD2 -# include - -# if SQLITE_VERSION_NUMBER >= 3006012 -# define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1 -# endif -# define LIBODB_SQLITE_HAVE_COLUMN_METADATA 1 -#endif - -// no post - -#endif // ODB_SQLITE_DETAILS_CONFIG_HXX diff --git a/odb/sqlite/details/conversion.hxx b/odb/sqlite/details/conversion.hxx deleted file mode 100644 index 04843b2..0000000 --- a/odb/sqlite/details/conversion.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// file : odb/sqlite/details/conversion.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX -#define ODB_SQLITE_DETAILS_CONVERSION_HXX - -#include - -#include - -namespace odb -{ - // @@ Revise this. - // - namespace details {} - - namespace sqlite - { - namespace details - { - using namespace odb::details; - - // Detect whether conversion is specified in type_traits. - // - template - meta::yes - conversion_p_test (typename type_traits::conversion*); - - template - meta::no - conversion_p_test (...); - - template - struct conversion_p - { - static const bool value = - sizeof (conversion_p_test (0)) == sizeof (meta::yes); - }; - - template ::value> - struct conversion; - - template - struct conversion - { - static const char* to () {return type_traits::conversion::to ();} - }; - - template - struct conversion - { - static const char* to () {return 0;} - }; - } - } -} - -#endif // ODB_SQLITE_DETAILS_CONVERSION_HXX diff --git a/odb/sqlite/details/export.hxx b/odb/sqlite/details/export.hxx deleted file mode 100644 index c0903ae..0000000 --- a/odb/sqlite/details/export.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// file : odb/sqlite/details/export.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_DETAILS_EXPORT_HXX -#define ODB_SQLITE_DETAILS_EXPORT_HXX - -#include - -#ifdef ODB_COMPILER -# error libodb-sqlite header included in odb-compiled header -#elif !defined(LIBODB_SQLITE_BUILD2) -# ifdef _MSC_VER -# include -# else -# include -# endif -#endif - -// Normally we don't export class templates (but do complete specializations), -// inline functions, and classes with only inline member functions. Exporting -// classes that inherit from non-exported/imported bases (e.g., std::string) -// will end up badly. The only known workarounds are to not inherit or to not -// export. Also, MinGW GCC doesn't like seeing non-exported function being -// used before their inline definition. The workaround is to reorder code. In -// the end it's all trial and error. - -#ifdef LIBODB_SQLITE_BUILD2 - -#if defined(LIBODB_SQLITE_STATIC) // Using static. -# define LIBODB_SQLITE_EXPORT -#elif defined(LIBODB_SQLITE_STATIC_BUILD) // Building static. -# define LIBODB_SQLITE_EXPORT -#elif defined(LIBODB_SQLITE_SHARED) // Using shared. -# ifdef _WIN32 -# define LIBODB_SQLITE_EXPORT __declspec(dllimport) -# else -# define LIBODB_SQLITE_EXPORT -# endif -#elif defined(LIBODB_SQLITE_SHARED_BUILD) // Building shared. -# ifdef _WIN32 -# define LIBODB_SQLITE_EXPORT __declspec(dllexport) -# else -# define LIBODB_SQLITE_EXPORT -# endif -#else -// If none of the above macros are defined, then we assume we are being used -// by some third-party build system that cannot/doesn't signal the library -// type. Note that this fallback works for both static and shared but in case -// of shared will be sub-optimal compared to having dllimport. -// -# define LIBODB_SQLITE_EXPORT // Using static or shared. -#endif - -#else // LIBODB_SQLITE_BUILD2 - -#ifdef LIBODB_SQLITE_STATIC_LIB -# define LIBODB_SQLITE_EXPORT -#else -# ifdef _WIN32 -# ifdef _MSC_VER -# ifdef LIBODB_SQLITE_DYNAMIC_LIB -# define LIBODB_SQLITE_EXPORT __declspec(dllexport) -# else -# define LIBODB_SQLITE_EXPORT __declspec(dllimport) -# endif -# else -# ifdef LIBODB_SQLITE_DYNAMIC_LIB -# ifdef DLL_EXPORT -# define LIBODB_SQLITE_EXPORT __declspec(dllexport) -# else -# define LIBODB_SQLITE_EXPORT -# endif -# else -# define LIBODB_SQLITE_EXPORT __declspec(dllimport) -# endif -# endif -# else -# define LIBODB_SQLITE_EXPORT -# endif -#endif - -#endif // LIBODB_SQLITE_BUILD2 - -#include - -#endif // ODB_SQLITE_DETAILS_EXPORT_HXX diff --git a/odb/sqlite/details/options.cli b/odb/sqlite/details/options.cli deleted file mode 100644 index d1955c3..0000000 --- a/odb/sqlite/details/options.cli +++ /dev/null @@ -1,47 +0,0 @@ -// file : odb/sqlite/details/options.cli -// license : GNU GPL v2; see accompanying LICENSE file - -include ; - -namespace odb -{ - namespace sqlite - { - namespace details - { - class options - { - std::string --database - { - "", - "SQLite database file name. If the database file is not specified - then a private, temporary on-disk database will be created. Use - the \cb{:memory:} special name to create a private, temporary - in-memory database." - }; - - bool --create - { - "Create the SQLite database if it does not already exist. By default - opening the database fails if it does not already exist." - }; - - bool --read-only - { - "Open the SQLite database in read-only mode. By default the database - is opened for reading and writing if possible, or reading only if - the file is write-protected by the operating system." - }; - - std::string --options-file - { - "", - "Read additional options from . Each option should appear on a - separate line optionally followed by space or equal sign (\cb{=}) - and an option value. Empty lines and lines starting with \cb{#} are - ignored." - }; - }; - } - } -} diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx deleted file mode 100644 index 12f4193..0000000 --- a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.cxx +++ /dev/null @@ -1,1027 +0,0 @@ -// -*- C++ -*- -// -// This file was generated by CLI, a command line interface -// compiler for C++. -// - -// Begin prologue. -// -// -// End prologue. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - namespace details - { - namespace cli - { - // unknown_option - // - unknown_option:: - ~unknown_option () throw () - { - } - - void unknown_option:: - print (::std::ostream& os) const - { - os << "unknown option '" << option ().c_str () << "'"; - } - - const char* unknown_option:: - what () const throw () - { - return "unknown option"; - } - - // unknown_argument - // - unknown_argument:: - ~unknown_argument () throw () - { - } - - void unknown_argument:: - print (::std::ostream& os) const - { - os << "unknown argument '" << argument ().c_str () << "'"; - } - - const char* unknown_argument:: - what () const throw () - { - return "unknown argument"; - } - - // missing_value - // - missing_value:: - ~missing_value () throw () - { - } - - void missing_value:: - print (::std::ostream& os) const - { - os << "missing value for option '" << option ().c_str () << "'"; - } - - const char* missing_value:: - what () const throw () - { - return "missing option value"; - } - - // invalid_value - // - invalid_value:: - ~invalid_value () throw () - { - } - - void invalid_value:: - print (::std::ostream& os) const - { - os << "invalid value '" << value ().c_str () << "' for option '" - << option ().c_str () << "'"; - - if (!message ().empty ()) - os << ": " << message ().c_str (); - } - - const char* invalid_value:: - what () const throw () - { - return "invalid option value"; - } - - // eos_reached - // - void eos_reached:: - print (::std::ostream& os) const - { - os << what (); - } - - const char* eos_reached:: - what () const throw () - { - return "end of argument stream reached"; - } - - // file_io_failure - // - file_io_failure:: - ~file_io_failure () throw () - { - } - - void file_io_failure:: - print (::std::ostream& os) const - { - os << "unable to open file '" << file ().c_str () << "' or read failure"; - } - - const char* file_io_failure:: - what () const throw () - { - return "unable to open file or read failure"; - } - - // unmatched_quote - // - unmatched_quote:: - ~unmatched_quote () throw () - { - } - - void unmatched_quote:: - print (::std::ostream& os) const - { - os << "unmatched quote in argument '" << argument ().c_str () << "'"; - } - - const char* unmatched_quote:: - what () const throw () - { - return "unmatched quote"; - } - - // scanner - // - scanner:: - ~scanner () - { - } - - // argv_scanner - // - bool argv_scanner:: - more () - { - return i_ < argc_; - } - - const char* argv_scanner:: - peek () - { - if (i_ < argc_) - return argv_[i_]; - else - throw eos_reached (); - } - - const char* argv_scanner:: - next () - { - if (i_ < argc_) - { - const char* r (argv_[i_]); - - if (erase_) - { - for (int i (i_ + 1); i < argc_; ++i) - argv_[i - 1] = argv_[i]; - - --argc_; - argv_[argc_] = 0; - } - else - ++i_; - - ++start_position_; - return r; - } - else - throw eos_reached (); - } - - void argv_scanner:: - skip () - { - if (i_ < argc_) - { - ++i_; - ++start_position_; - } - else - throw eos_reached (); - } - - std::size_t argv_scanner:: - position () - { - return start_position_; - } - - // argv_file_scanner - // - int argv_file_scanner::zero_argc_ = 0; - std::string argv_file_scanner::empty_string_; - - bool argv_file_scanner:: - more () - { - if (!args_.empty ()) - return true; - - while (base::more ()) - { - // See if the next argument is the file option. - // - const char* a (base::peek ()); - const option_info* oi = 0; - const char* ov = 0; - - if (!skip_) - { - if ((oi = find (a)) != 0) - { - base::next (); - - if (!base::more ()) - throw missing_value (a); - - ov = base::next (); - } - else if (std::strncmp (a, "-", 1) == 0) - { - if ((ov = std::strchr (a, '=')) != 0) - { - std::string o (a, 0, ov - a); - if ((oi = find (o.c_str ())) != 0) - { - base::next (); - ++ov; - } - } - } - } - - if (oi != 0) - { - if (oi->search_func != 0) - { - std::string f (oi->search_func (ov, oi->arg)); - - if (!f.empty ()) - load (f); - } - else - load (ov); - - if (!args_.empty ()) - return true; - } - else - { - if (!skip_) - skip_ = (std::strcmp (a, "--") == 0); - - return true; - } - } - - return false; - } - - const char* argv_file_scanner:: - peek () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? base::peek () : args_.front ().value.c_str (); - } - - const std::string& argv_file_scanner:: - peek_file () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? empty_string_ : *args_.front ().file; - } - - std::size_t argv_file_scanner:: - peek_line () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? 0 : args_.front ().line; - } - - const char* argv_file_scanner:: - next () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::next (); - else - { - hold_[i_ == 0 ? ++i_ : --i_].swap (args_.front ().value); - args_.pop_front (); - ++start_position_; - return hold_[i_].c_str (); - } - } - - void argv_file_scanner:: - skip () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::skip (); - else - { - args_.pop_front (); - ++start_position_; - } - } - - const argv_file_scanner::option_info* argv_file_scanner:: - find (const char* a) const - { - for (std::size_t i (0); i < options_count_; ++i) - if (std::strcmp (a, options_[i].option) == 0) - return &options_[i]; - - return 0; - } - - std::size_t argv_file_scanner:: - position () - { - return start_position_; - } - - void argv_file_scanner:: - load (const std::string& file) - { - using namespace std; - - ifstream is (file.c_str ()); - - if (!is.is_open ()) - throw file_io_failure (file); - - files_.push_back (file); - - arg a; - a.file = &*files_.rbegin (); - - for (a.line = 1; !is.eof (); ++a.line) - { - string line; - getline (is, line); - - if (is.fail () && !is.eof ()) - throw file_io_failure (file); - - string::size_type n (line.size ()); - - // Trim the line from leading and trailing whitespaces. - // - if (n != 0) - { - const char* f (line.c_str ()); - const char* l (f + n); - - const char* of (f); - while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) - ++f; - - --l; - - const char* ol (l); - while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) - --l; - - if (f != of || l != ol) - line = f <= l ? string (f, l - f + 1) : string (); - } - - // Ignore empty lines, those that start with #. - // - if (line.empty () || line[0] == '#') - continue; - - string::size_type p (string::npos); - if (line.compare (0, 1, "-") == 0) - { - p = line.find (' '); - - string::size_type q (line.find ('=')); - if (q != string::npos && q < p) - p = q; - } - - string s1; - if (p != string::npos) - { - s1.assign (line, 0, p); - - // Skip leading whitespaces in the argument. - // - if (line[p] == '=') - ++p; - else - { - n = line.size (); - for (++p; p < n; ++p) - { - char c (line[p]); - if (c != ' ' && c != '\t' && c != '\r') - break; - } - } - } - else if (!skip_) - skip_ = (line == "--"); - - string s2 (line, p != string::npos ? p : 0); - - // If the string (which is an option value or argument) is - // wrapped in quotes, remove them. - // - n = s2.size (); - char cf (s2[0]), cl (s2[n - 1]); - - if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') - { - if (n == 1 || cf != cl) - throw unmatched_quote (s2); - - s2 = string (s2, 1, n - 2); - } - - if (!s1.empty ()) - { - // See if this is another file option. - // - const option_info* oi; - if (!skip_ && (oi = find (s1.c_str ()))) - { - if (s2.empty ()) - throw missing_value (oi->option); - - if (oi->search_func != 0) - { - string f (oi->search_func (s2.c_str (), oi->arg)); - if (!f.empty ()) - load (f); - } - else - { - // If the path of the file being parsed is not simple and the - // path of the file that needs to be loaded is relative, then - // complete the latter using the former as a base. - // -#ifndef _WIN32 - string::size_type p (file.find_last_of ('/')); - bool c (p != string::npos && s2[0] != '/'); -#else - string::size_type p (file.find_last_of ("/\\")); - bool c (p != string::npos && s2[1] != ':'); -#endif - if (c) - s2.insert (0, file, 0, p + 1); - - load (s2); - } - - continue; - } - - a.value = s1; - args_.push_back (a); - } - - a.value = s2; - args_.push_back (a); - } - } - - template - struct parser - { - static void - parse (X& x, scanner& s) - { - using namespace std; - - const char* o (s.next ()); - if (s.more ()) - { - string v (s.next ()); - istringstream is (v); - if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) - throw invalid_value (o, v); - } - else - throw missing_value (o); - } - }; - - template <> - struct parser - { - static void - parse (bool& x, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - const char* v (s.next ()); - - if (std::strcmp (v, "1") == 0 || - std::strcmp (v, "true") == 0 || - std::strcmp (v, "TRUE") == 0 || - std::strcmp (v, "True") == 0) - x = true; - else if (std::strcmp (v, "0") == 0 || - std::strcmp (v, "false") == 0 || - std::strcmp (v, "FALSE") == 0 || - std::strcmp (v, "False") == 0) - x = false; - else - throw invalid_value (o, v); - } - else - throw missing_value (o); - } - }; - - template <> - struct parser - { - static void - parse (std::string& x, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - x = s.next (); - else - throw missing_value (o); - } - }; - - template - struct parser > - { - static void - parse (std::pair& x, scanner& s) - { - x.second = s.position (); - parser::parse (x.first, s); - } - }; - - template - struct parser > - { - static void - parse (std::vector& c, scanner& s) - { - X x; - parser::parse (x, s); - c.push_back (x); - } - }; - - template - struct parser > - { - static void - parse (std::set& c, scanner& s) - { - X x; - parser::parse (x, s); - c.insert (x); - } - }; - - template - struct parser > - { - static void - parse (std::map& m, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - std::size_t pos (s.position ()); - std::string ov (s.next ()); - std::string::size_type p = ov.find ('='); - - K k = K (); - V v = V (); - std::string kstr (ov, 0, p); - std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); - - int ac (2); - char* av[] = - { - const_cast (o), - 0 - }; - - if (!kstr.empty ()) - { - av[1] = const_cast (kstr.c_str ()); - argv_scanner s (0, ac, av, false, pos); - parser::parse (k, s); - } - - if (!vstr.empty ()) - { - av[1] = const_cast (vstr.c_str ()); - argv_scanner s (0, ac, av, false, pos); - parser::parse (v, s); - } - - m[k] = v; - } - else - throw missing_value (o); - } - }; - - template - struct parser > - { - static void - parse (std::multimap& m, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - std::size_t pos (s.position ()); - std::string ov (s.next ()); - std::string::size_type p = ov.find ('='); - - K k = K (); - V v = V (); - std::string kstr (ov, 0, p); - std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); - - int ac (2); - char* av[] = - { - const_cast (o), - 0 - }; - - if (!kstr.empty ()) - { - av[1] = const_cast (kstr.c_str ()); - argv_scanner s (0, ac, av, false, pos); - parser::parse (k, s); - } - - if (!vstr.empty ()) - { - av[1] = const_cast (vstr.c_str ()); - argv_scanner s (0, ac, av, false, pos); - parser::parse (v, s); - } - - m.insert (typename std::multimap::value_type (k, v)); - } - else - throw missing_value (o); - } - }; - - template - void - thunk (X& x, scanner& s) - { - parser::parse (x.*M, s); - } - - template - void - thunk (X& x, scanner& s) - { - s.next (); - x.*M = true; - } - } - } - } -} - -#include - -namespace odb -{ - namespace sqlite - { - namespace details - { - // options - // - - options:: - options () - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - } - - options:: - options (int& argc, - char** argv, - bool erase, - ::odb::sqlite::details::cli::unknown_mode opt, - ::odb::sqlite::details::cli::unknown_mode arg) - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); - } - - options:: - options (int start, - int& argc, - char** argv, - bool erase, - ::odb::sqlite::details::cli::unknown_mode opt, - ::odb::sqlite::details::cli::unknown_mode arg) - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); - } - - options:: - options (int& argc, - char** argv, - int& end, - bool erase, - ::odb::sqlite::details::cli::unknown_mode opt, - ::odb::sqlite::details::cli::unknown_mode arg) - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - ::odb::sqlite::details::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); - } - - options:: - options (int start, - int& argc, - char** argv, - int& end, - bool erase, - ::odb::sqlite::details::cli::unknown_mode opt, - ::odb::sqlite::details::cli::unknown_mode arg) - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - ::odb::sqlite::details::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); - } - - options:: - options (::odb::sqlite::details::cli::scanner& s, - ::odb::sqlite::details::cli::unknown_mode opt, - ::odb::sqlite::details::cli::unknown_mode arg) - : database_ (), - create_ (), - read_only_ (), - options_file_ () - { - _parse (s, opt, arg); - } - - ::odb::sqlite::details::cli::usage_para options:: - print_usage (::std::ostream& os, ::odb::sqlite::details::cli::usage_para p) - { - CLI_POTENTIALLY_UNUSED (os); - - if (p != ::odb::sqlite::details::cli::usage_para::none) - os << ::std::endl; - - os << "--database SQLite database file name. If the database file is not" << ::std::endl - << " specified then a private, temporary on-disk database will" << ::std::endl - << " be created. Use the :memory: special name to create a" << ::std::endl - << " private, temporary in-memory database." << ::std::endl; - - os << std::endl - << "--create Create the SQLite database if it does not already exist." << ::std::endl - << " By default opening the database fails if it does not" << ::std::endl - << " already exist." << ::std::endl; - - os << std::endl - << "--read-only Open the SQLite database in read-only mode. By default" << ::std::endl - << " the database is opened for reading and writing if" << ::std::endl - << " possible, or reading only if the file is write-protected" << ::std::endl - << " by the operating system." << ::std::endl; - - os << std::endl - << "--options-file Read additional options from . Each option should" << ::std::endl - << " appear on a separate line optionally followed by space or" << ::std::endl - << " equal sign (=) and an option value. Empty lines and lines" << ::std::endl - << " starting with # are ignored." << ::std::endl; - - p = ::odb::sqlite::details::cli::usage_para::option; - - return p; - } - - typedef - std::map - _cli_options_map; - - static _cli_options_map _cli_options_map_; - - struct _cli_options_map_init - { - _cli_options_map_init () - { - _cli_options_map_["--database"] = - &::odb::sqlite::details::cli::thunk< options, std::string, &options::database_ >; - _cli_options_map_["--create"] = - &::odb::sqlite::details::cli::thunk< options, &options::create_ >; - _cli_options_map_["--read-only"] = - &::odb::sqlite::details::cli::thunk< options, &options::read_only_ >; - _cli_options_map_["--options-file"] = - &::odb::sqlite::details::cli::thunk< options, std::string, &options::options_file_ >; - } - }; - - static _cli_options_map_init _cli_options_map_init_; - - bool options:: - _parse (const char* o, ::odb::sqlite::details::cli::scanner& s) - { - _cli_options_map::const_iterator i (_cli_options_map_.find (o)); - - if (i != _cli_options_map_.end ()) - { - (*(i->second)) (*this, s); - return true; - } - - return false; - } - - bool options:: - _parse (::odb::sqlite::details::cli::scanner& s, - ::odb::sqlite::details::cli::unknown_mode opt_mode, - ::odb::sqlite::details::cli::unknown_mode arg_mode) - { - bool r = false; - bool opt = true; - - while (s.more ()) - { - const char* o = s.peek (); - - if (std::strcmp (o, "--") == 0) - { - opt = false; - s.skip (); - r = true; - continue; - } - - if (opt) - { - if (_parse (o, s)) - { - r = true; - continue; - } - - if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') - { - // Handle combined option values. - // - std::string co; - if (const char* v = std::strchr (o, '=')) - { - co.assign (o, 0, v - o); - ++v; - - int ac (2); - char* av[] = - { - const_cast (co.c_str ()), - const_cast (v) - }; - - ::odb::sqlite::details::cli::argv_scanner ns (0, ac, av); - - if (_parse (co.c_str (), ns)) - { - // Parsed the option but not its value? - // - if (ns.end () != 2) - throw ::odb::sqlite::details::cli::invalid_value (co, v); - - s.next (); - r = true; - continue; - } - else - { - // Set the unknown option and fall through. - // - o = co.c_str (); - } - } - - switch (opt_mode) - { - case ::odb::sqlite::details::cli::unknown_mode::skip: - { - s.skip (); - r = true; - continue; - } - case ::odb::sqlite::details::cli::unknown_mode::stop: - { - break; - } - case ::odb::sqlite::details::cli::unknown_mode::fail: - { - throw ::odb::sqlite::details::cli::unknown_option (o); - } - } - - break; - } - } - - switch (arg_mode) - { - case ::odb::sqlite::details::cli::unknown_mode::skip: - { - s.skip (); - r = true; - continue; - } - case ::odb::sqlite::details::cli::unknown_mode::stop: - { - break; - } - case ::odb::sqlite::details::cli::unknown_mode::fail: - { - throw ::odb::sqlite::details::cli::unknown_argument (o); - } - } - - break; - } - - return r; - } - } - } -} - -// Begin epilogue. -// -// -// End epilogue. - diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx deleted file mode 100644 index abc4b3f..0000000 --- a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.hxx +++ /dev/null @@ -1,530 +0,0 @@ -// -*- C++ -*- -// -// This file was generated by CLI, a command line interface -// compiler for C++. -// - -#ifndef LIBODB_SQLITE_DETAILS_OPTIONS_HXX -#define LIBODB_SQLITE_DETAILS_OPTIONS_HXX - -// Begin prologue. -// -// -// End prologue. - -#include -#include -#include -#include -#include -#include - -#ifndef CLI_POTENTIALLY_UNUSED -# if defined(_MSC_VER) || defined(__xlC__) -# define CLI_POTENTIALLY_UNUSED(x) (void*)&x -# else -# define CLI_POTENTIALLY_UNUSED(x) (void)x -# endif -#endif - -namespace odb -{ - namespace sqlite - { - namespace details - { - namespace cli - { - class usage_para - { - public: - enum value - { - none, - text, - option - }; - - usage_para (value); - - operator value () const - { - return v_; - } - - private: - value v_; - }; - - class unknown_mode - { - public: - enum value - { - skip, - stop, - fail - }; - - unknown_mode (value); - - operator value () const - { - return v_; - } - - private: - value v_; - }; - - // Exceptions. - // - - class exception: public std::exception - { - public: - virtual void - print (::std::ostream&) const = 0; - }; - - ::std::ostream& - operator<< (::std::ostream&, const exception&); - - class unknown_option: public exception - { - public: - virtual - ~unknown_option () throw (); - - unknown_option (const std::string& option); - - const std::string& - option () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - }; - - class unknown_argument: public exception - { - public: - virtual - ~unknown_argument () throw (); - - unknown_argument (const std::string& argument); - - const std::string& - argument () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string argument_; - }; - - class missing_value: public exception - { - public: - virtual - ~missing_value () throw (); - - missing_value (const std::string& option); - - const std::string& - option () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - }; - - class invalid_value: public exception - { - public: - virtual - ~invalid_value () throw (); - - invalid_value (const std::string& option, - const std::string& value, - const std::string& message = std::string ()); - - const std::string& - option () const; - - const std::string& - value () const; - - const std::string& - message () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - std::string value_; - std::string message_; - }; - - class eos_reached: public exception - { - public: - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - }; - - class file_io_failure: public exception - { - public: - virtual - ~file_io_failure () throw (); - - file_io_failure (const std::string& file); - - const std::string& - file () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string file_; - }; - - class unmatched_quote: public exception - { - public: - virtual - ~unmatched_quote () throw (); - - unmatched_quote (const std::string& argument); - - const std::string& - argument () const; - - virtual void - print (::std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string argument_; - }; - - // Command line argument scanner interface. - // - // The values returned by next() are guaranteed to be valid - // for the two previous arguments up until a call to a third - // peek() or next(). - // - // The position() function returns a monotonically-increasing - // number which, if stored, can later be used to determine the - // relative position of the argument returned by the following - // call to next(). Note that if multiple scanners are used to - // extract arguments from multiple sources, then the end - // position of the previous scanner should be used as the - // start position of the next. - // - class scanner - { - public: - virtual - ~scanner (); - - virtual bool - more () = 0; - - virtual const char* - peek () = 0; - - virtual const char* - next () = 0; - - virtual void - skip () = 0; - - virtual std::size_t - position () = 0; - }; - - class argv_scanner: public scanner - { - public: - argv_scanner (int& argc, - char** argv, - bool erase = false, - std::size_t start_position = 0); - - argv_scanner (int start, - int& argc, - char** argv, - bool erase = false, - std::size_t start_position = 0); - - int - end () const; - - virtual bool - more (); - - virtual const char* - peek (); - - virtual const char* - next (); - - virtual void - skip (); - - virtual std::size_t - position (); - - protected: - std::size_t start_position_; - int i_; - int& argc_; - char** argv_; - bool erase_; - }; - - class argv_file_scanner: public argv_scanner - { - public: - argv_file_scanner (int& argc, - char** argv, - const std::string& option, - bool erase = false, - std::size_t start_position = 0); - - argv_file_scanner (int start, - int& argc, - char** argv, - const std::string& option, - bool erase = false, - std::size_t start_position = 0); - - argv_file_scanner (const std::string& file, - const std::string& option, - std::size_t start_position = 0); - - struct option_info - { - // If search_func is not NULL, it is called, with the arg - // value as the second argument, to locate the options file. - // If it returns an empty string, then the file is ignored. - // - const char* option; - std::string (*search_func) (const char*, void* arg); - void* arg; - }; - - argv_file_scanner (int& argc, - char** argv, - const option_info* options, - std::size_t options_count, - bool erase = false, - std::size_t start_position = 0); - - argv_file_scanner (int start, - int& argc, - char** argv, - const option_info* options, - std::size_t options_count, - bool erase = false, - std::size_t start_position = 0); - - argv_file_scanner (const std::string& file, - const option_info* options = 0, - std::size_t options_count = 0, - std::size_t start_position = 0); - - virtual bool - more (); - - virtual const char* - peek (); - - virtual const char* - next (); - - virtual void - skip (); - - virtual std::size_t - position (); - - // Return the file path if the peeked at argument came from a file and - // the empty string otherwise. The reference is guaranteed to be valid - // till the end of the scanner lifetime. - // - const std::string& - peek_file (); - - // Return the 1-based line number if the peeked at argument came from - // a file and zero otherwise. - // - std::size_t - peek_line (); - - private: - const option_info* - find (const char*) const; - - void - load (const std::string& file); - - typedef argv_scanner base; - - const std::string option_; - option_info option_info_; - const option_info* options_; - std::size_t options_count_; - - struct arg - { - std::string value; - const std::string* file; - std::size_t line; - }; - - std::deque args_; - std::list files_; - - // Circular buffer of two arguments. - // - std::string hold_[2]; - std::size_t i_; - - bool skip_; - - static int zero_argc_; - static std::string empty_string_; - }; - - template - struct parser; - } - } - } -} - -#include - -namespace odb -{ - namespace sqlite - { - namespace details - { - class options - { - public: - options (); - - options (int& argc, - char** argv, - bool erase = false, - ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, - ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); - - options (int start, - int& argc, - char** argv, - bool erase = false, - ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, - ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); - - options (int& argc, - char** argv, - int& end, - bool erase = false, - ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, - ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); - - options (int start, - int& argc, - char** argv, - int& end, - bool erase = false, - ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, - ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); - - options (::odb::sqlite::details::cli::scanner&, - ::odb::sqlite::details::cli::unknown_mode option = ::odb::sqlite::details::cli::unknown_mode::fail, - ::odb::sqlite::details::cli::unknown_mode argument = ::odb::sqlite::details::cli::unknown_mode::stop); - - // Option accessors. - // - const std::string& - database () const; - - const bool& - create () const; - - const bool& - read_only () const; - - const std::string& - options_file () const; - - // Print usage information. - // - static ::odb::sqlite::details::cli::usage_para - print_usage (::std::ostream&, - ::odb::sqlite::details::cli::usage_para = ::odb::sqlite::details::cli::usage_para::none); - - // Implementation details. - // - protected: - bool - _parse (const char*, ::odb::sqlite::details::cli::scanner&); - - private: - bool - _parse (::odb::sqlite::details::cli::scanner&, - ::odb::sqlite::details::cli::unknown_mode option, - ::odb::sqlite::details::cli::unknown_mode argument); - - public: - std::string database_; - bool create_; - bool read_only_; - std::string options_file_; - }; - } - } -} - -#include - -// Begin epilogue. -// -// -// End epilogue. - -#endif // LIBODB_SQLITE_DETAILS_OPTIONS_HXX diff --git a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx b/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx deleted file mode 100644 index 54092aa..0000000 --- a/odb/sqlite/details/pregenerated/odb/sqlite/details/options.ixx +++ /dev/null @@ -1,324 +0,0 @@ -// -*- C++ -*- -// -// This file was generated by CLI, a command line interface -// compiler for C++. -// - -// Begin prologue. -// -// -// End prologue. - -#include - -namespace odb -{ - namespace sqlite - { - namespace details - { - namespace cli - { - // usage_para - // - inline usage_para:: - usage_para (value v) - : v_ (v) - { - } - - // unknown_mode - // - inline unknown_mode:: - unknown_mode (value v) - : v_ (v) - { - } - - // exception - // - inline ::std::ostream& - operator<< (::std::ostream& os, const exception& e) - { - e.print (os); - return os; - } - - // unknown_option - // - inline unknown_option:: - unknown_option (const std::string& option) - : option_ (option) - { - } - - inline const std::string& unknown_option:: - option () const - { - return option_; - } - - // unknown_argument - // - inline unknown_argument:: - unknown_argument (const std::string& argument) - : argument_ (argument) - { - } - - inline const std::string& unknown_argument:: - argument () const - { - return argument_; - } - - // missing_value - // - inline missing_value:: - missing_value (const std::string& option) - : option_ (option) - { - } - - inline const std::string& missing_value:: - option () const - { - return option_; - } - - // invalid_value - // - inline invalid_value:: - invalid_value (const std::string& option, - const std::string& value, - const std::string& message) - : option_ (option), - value_ (value), - message_ (message) - { - } - - inline const std::string& invalid_value:: - option () const - { - return option_; - } - - inline const std::string& invalid_value:: - value () const - { - return value_; - } - - inline const std::string& invalid_value:: - message () const - { - return message_; - } - - // file_io_failure - // - inline file_io_failure:: - file_io_failure (const std::string& file) - : file_ (file) - { - } - - inline const std::string& file_io_failure:: - file () const - { - return file_; - } - - // unmatched_quote - // - inline unmatched_quote:: - unmatched_quote (const std::string& argument) - : argument_ (argument) - { - } - - inline const std::string& unmatched_quote:: - argument () const - { - return argument_; - } - - // argv_scanner - // - inline argv_scanner:: - argv_scanner (int& argc, - char** argv, - bool erase, - std::size_t sp) - : start_position_ (sp + 1), - i_ (1), - argc_ (argc), - argv_ (argv), - erase_ (erase) - { - } - - inline argv_scanner:: - argv_scanner (int start, - int& argc, - char** argv, - bool erase, - std::size_t sp) - : start_position_ (sp + static_cast (start)), - i_ (start), - argc_ (argc), - argv_ (argv), - erase_ (erase) - { - } - - inline int argv_scanner:: - end () const - { - return i_; - } - - // argv_file_scanner - // - inline argv_file_scanner:: - argv_file_scanner (int& argc, - char** argv, - const std::string& option, - bool erase, - std::size_t sp) - : argv_scanner (argc, argv, erase, sp), - option_ (option), - options_ (&option_info_), - options_count_ (1), - i_ (1), - skip_ (false) - { - option_info_.option = option_.c_str (); - option_info_.search_func = 0; - } - - inline argv_file_scanner:: - argv_file_scanner (int start, - int& argc, - char** argv, - const std::string& option, - bool erase, - std::size_t sp) - : argv_scanner (start, argc, argv, erase, sp), - option_ (option), - options_ (&option_info_), - options_count_ (1), - i_ (1), - skip_ (false) - { - option_info_.option = option_.c_str (); - option_info_.search_func = 0; - } - - inline argv_file_scanner:: - argv_file_scanner (const std::string& file, - const std::string& option, - std::size_t sp) - : argv_scanner (0, zero_argc_, 0, sp), - option_ (option), - options_ (&option_info_), - options_count_ (1), - i_ (1), - skip_ (false) - { - option_info_.option = option_.c_str (); - option_info_.search_func = 0; - - load (file); - } - - inline argv_file_scanner:: - argv_file_scanner (int& argc, - char** argv, - const option_info* options, - std::size_t options_count, - bool erase, - std::size_t sp) - : argv_scanner (argc, argv, erase, sp), - options_ (options), - options_count_ (options_count), - i_ (1), - skip_ (false) - { - } - - inline argv_file_scanner:: - argv_file_scanner (int start, - int& argc, - char** argv, - const option_info* options, - std::size_t options_count, - bool erase, - std::size_t sp) - : argv_scanner (start, argc, argv, erase, sp), - options_ (options), - options_count_ (options_count), - i_ (1), - skip_ (false) - { - } - - inline argv_file_scanner:: - argv_file_scanner (const std::string& file, - const option_info* options, - std::size_t options_count, - std::size_t sp) - : argv_scanner (0, zero_argc_, 0, sp), - options_ (options), - options_count_ (options_count), - i_ (1), - skip_ (false) - { - load (file); - } - } - } - } -} - -namespace odb -{ - namespace sqlite - { - namespace details - { - // options - // - - inline const std::string& options:: - database () const - { - return this->database_; - } - - inline const bool& options:: - create () const - { - return this->create_; - } - - inline const bool& options:: - read_only () const - { - return this->read_only_; - } - - inline const std::string& options:: - options_file () const - { - return this->options_file_; - } - } - } -} - -// Begin epilogue. -// -// -// End epilogue. diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx deleted file mode 100644 index ae6bbe3..0000000 --- a/odb/sqlite/error.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// file : odb/sqlite/error.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include // std::bad_alloc -#include - -#include -#include - -#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - -using namespace std; - -namespace odb -{ - namespace sqlite - { - void - translate_error (int e, connection& c) - { - sqlite3* h (c.handle ()); - - // Extended error codes are only available in 3.6.5 and later. - // -#if SQLITE_VERSION_NUMBER >= 3006005 - int ee (sqlite3_extended_errcode (h)); -#else - int ee (0); -#endif - string m; - - switch (e) - { - case SQLITE_NOMEM: - { - throw bad_alloc (); - } - case SQLITE_MISUSE: - { - // In case of SQLITE_MISUSE, error code/message may or may not - // be set. - // - ee = e; - m = "SQLite API misuse"; - break; - } -#ifdef SQLITE_ABORT_ROLLBACK - case SQLITE_ABORT: - { - if (ee == SQLITE_ABORT_ROLLBACK) - throw forced_rollback (); - - break; - } -#endif - case SQLITE_LOCKED: - { -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - if (ee != SQLITE_LOCKED_SHAREDCACHE) - throw deadlock (); // The DROP TABLE special case. -#endif - // Getting SQLITE_LOCKED_SHAREDCACHE here means we don't have - // the unlock notify support. Translate this to timeout. - // - throw timeout (); - } - case SQLITE_BUSY: - case SQLITE_IOERR: - { -#if SQLITE_VERSION_NUMBER >= 3006005 - if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED) - throw timeout (); -#endif - break; - } - default: - break; - } - - if (m.empty ()) - m = sqlite3_errmsg (h); - - // Get rid of a trailing newline if there is one. - // - string::size_type n (m.size ()); - if (n != 0 && m[n - 1] == '\n') - m.resize (n - 1); - - throw database_exception (e, ee, m); - } - } -} diff --git a/odb/sqlite/error.hxx b/odb/sqlite/error.hxx deleted file mode 100644 index 4646f85..0000000 --- a/odb/sqlite/error.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : odb/sqlite/error.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_ERROR_HXX -#define ODB_SQLITE_ERROR_HXX - -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - class connection; - - // Translate SQLite error and throw an appropriate exception. - // - LIBODB_SQLITE_EXPORT void - translate_error (int error, connection&); - } -} - -#include - -#endif // ODB_SQLITE_ERROR_HXX diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx deleted file mode 100644 index 0621189..0000000 --- a/odb/sqlite/exceptions.cxx +++ /dev/null @@ -1,92 +0,0 @@ -// file : odb/sqlite/exceptions.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - // - // forced_rollback - // - - const char* forced_rollback:: - what () const ODB_NOTHROW_NOEXCEPT - { - return "transaction is forced to rollback"; - } - - forced_rollback* forced_rollback:: - clone () const - { - return new forced_rollback (*this); - } - - // - // database_exception - // - - database_exception:: - ~database_exception () ODB_NOTHROW_NOEXCEPT - { - } - - database_exception:: - database_exception (int e, int ee, const string& m) - : error_ (e), extended_error_ (ee), message_ (m) - { - ostringstream ostr; - ostr << error_; - - if (error_ != extended_error_) - ostr << " (" << extended_error_ << ")"; - - ostr << ": " << message_; - what_ = ostr.str (); - } - - const char* database_exception:: - what () const ODB_NOTHROW_NOEXCEPT - { - return what_.c_str (); - } - - database_exception* database_exception:: - clone () const - { - return new database_exception (*this); - } - - // - // cli_exception - // - - cli_exception:: - cli_exception (const std::string& what) - : what_ (what) - { - } - - cli_exception:: - ~cli_exception () ODB_NOTHROW_NOEXCEPT - { - } - - const char* cli_exception:: - what () const ODB_NOTHROW_NOEXCEPT - { - return what_.c_str (); - } - - cli_exception* cli_exception:: - clone () const - { - return new cli_exception (*this); - } - } -} diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx deleted file mode 100644 index 3adb433..0000000 --- a/odb/sqlite/exceptions.hxx +++ /dev/null @@ -1,101 +0,0 @@ -// file : odb/sqlite/exceptions.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_EXCEPTIONS_HXX -#define ODB_SQLITE_EXCEPTIONS_HXX - -#include - -#include - -#include -#include // ODB_NOTHROW_NOEXCEPT - -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - // This exception is thrown if SQLite is forcing the current transaction - // to rollback. This can happen in SQLite 3.7.11 or later if one of the - // connections participating in the shared cache rolls back a transaction. - // See the SQLITE_ABORT_ROLLBACK extended error code for detail on this - // behavior. - // - struct LIBODB_SQLITE_EXPORT forced_rollback: recoverable - { - virtual const char* - what () const ODB_NOTHROW_NOEXCEPT; - - virtual forced_rollback* - clone () const; - }; - - struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception - { - database_exception (int error, - int extended_error, - const std::string& message); - - ~database_exception () ODB_NOTHROW_NOEXCEPT; - - int - error () const - { - return error_; - } - - int - extended_error () const - { - return extended_error_; - } - - const std::string& - message () const - { - return message_; - } - - virtual const char* - what () const ODB_NOTHROW_NOEXCEPT; - - virtual database_exception* - clone () const; - - private: - int error_; - int extended_error_; - std::string message_; - std::string what_; - }; - - struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception - { - cli_exception (const std::string& what); - ~cli_exception () ODB_NOTHROW_NOEXCEPT; - - virtual const char* - what () const ODB_NOTHROW_NOEXCEPT; - - virtual cli_exception* - clone () const; - - private: - std::string what_; - }; - - namespace core - { - using sqlite::database_exception; - using sqlite::cli_exception; - } - } -} - -#include - -#endif // ODB_SQLITE_EXCEPTIONS_HXX diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx deleted file mode 100644 index 1be05b4..0000000 --- a/odb/sqlite/forward.hxx +++ /dev/null @@ -1,112 +0,0 @@ -// file : odb/sqlite/forward.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_FORWARD_HXX -#define ODB_SQLITE_FORWARD_HXX - -#include - -#include - -namespace odb -{ - namespace sqlite - { - namespace core - { - using namespace odb::common; - } - - // - // - class database; - class connection; - typedef details::shared_ptr connection_ptr; - class connection_factory; - class statement; - class transaction; - class tracer; - - namespace core - { - using sqlite::database; - using sqlite::connection; - using sqlite::connection_ptr; - using sqlite::transaction; - using sqlite::statement; - } - - // Implementation details. - // - enum database_type_id - { - id_integer, - id_real, - id_text, - id_blob, - id_text_stream, - id_blob_stream - }; - - template - struct default_value_traits; - - enum statement_kind - { - statement_select, - statement_insert, - statement_update, - statement_delete, - statement_generic - }; - - class binding; - class select_statement; - - template - class object_statements; - - template - class polymorphic_root_object_statements; - - template - class polymorphic_derived_object_statements; - - template - class no_id_object_statements; - - template - class view_statements; - - template - class container_statements; - - template - class smart_container_statements; - - template - class section_statements; - - class query_base; - class query_params; - } - - namespace details - { - template <> - struct counter_type - { - typedef shared_base counter; - }; - - template <> - struct counter_type - { - typedef shared_base counter; - }; - } -} - -#include - -#endif // ODB_SQLITE_FORWARD_HXX diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj b/odb/sqlite/libodb-sqlite-vc10.vcxproj deleted file mode 100644 index 844eeb4..0000000 --- a/odb/sqlite/libodb-sqlite-vc10.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} - Win32Proj - libodb-sqlite - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\bin\ - odb-sqlite-d-__value__(interface_version)-vc10 - - - true - ..\..\bin64\ - odb-sqlite-d-__value__(interface_version)-vc10 - - - false - ..\..\bin\ - odb-sqlite-__value__(interface_version)-vc10 - - - false - ..\..\bin64\ - odb-sqlite-__value__(interface_version)-vc10 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib\odb-sqlite-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib64\odb-sqlite-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib\odb-sqlite.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib64\odb-sqlite.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters deleted file mode 100644 index 6a1e44f..0000000 --- a/odb/sqlite/libodb-sqlite-vc10.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} - cxx - - - {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/odb/sqlite/libodb-sqlite-vc11.vcxproj b/odb/sqlite/libodb-sqlite-vc11.vcxproj deleted file mode 100644 index 670370c..0000000 --- a/odb/sqlite/libodb-sqlite-vc11.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} - Win32Proj - libodb-sqlite - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\bin\ - odb-sqlite-d-__value__(interface_version)-vc11 - - - true - ..\..\bin64\ - odb-sqlite-d-__value__(interface_version)-vc11 - - - false - ..\..\bin\ - odb-sqlite-__value__(interface_version)-vc11 - - - false - ..\..\bin64\ - odb-sqlite-__value__(interface_version)-vc11 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib\odb-sqlite-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib64\odb-sqlite-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib\odb-sqlite.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib64\odb-sqlite.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters deleted file mode 100644 index 6a1e44f..0000000 --- a/odb/sqlite/libodb-sqlite-vc11.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} - cxx - - - {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj b/odb/sqlite/libodb-sqlite-vc12.vcxproj deleted file mode 100644 index f74ccbc..0000000 --- a/odb/sqlite/libodb-sqlite-vc12.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BE62AFC4-4624-4CDA-A7CD-E9451D34AB6E} - Win32Proj - libodb-sqlite - - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\bin\ - odb-sqlite-d-__value__(interface_version)-vc12 - - - true - ..\..\bin64\ - odb-sqlite-d-__value__(interface_version)-vc12 - - - false - ..\..\bin\ - odb-sqlite-__value__(interface_version)-vc12 - - - false - ..\..\bin64\ - odb-sqlite-__value__(interface_version)-vc12 - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - true - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib\odb-sqlite-d.lib - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - true - - - odb-d.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - $(TargetPath) - ..\..\lib64\odb-sqlite-d.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - true - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib\odb-sqlite.lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_SQLITE_DYNAMIC_LIB;LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY;LIBODB_SQLITE_HAVE_COLUMN_METADATA;%(PreprocessorDefinitions) - ..\.. - 4355;4800;4290;4251;4267;%(DisableSpecificWarnings) - true - - - odb.lib;sqlite3.lib;%(AdditionalDependencies) - Windows - true - true - true - $(TargetPath) - ..\..\lib64\odb-sqlite.lib - - - -__header_entries__(headers) - - -__source_entries__(sources) - - - - - diff --git a/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters b/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters deleted file mode 100644 index 6a1e44f..0000000 --- a/odb/sqlite/libodb-sqlite-vc12.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {CAE48EC7-E979-4076-ABDB-DF5CFD41D7AB} - cxx - - - {1C70458E-63CA-455F-AFDC-E2F291BD0F2A} - h;hxx;ixx;txx - - - -__header_filter_entries__(headers) - - -__source_filter_entries__(sources) - - diff --git a/odb/sqlite/libodb-sqlite-vc8.vcproj b/odb/sqlite/libodb-sqlite-vc8.vcproj deleted file mode 100644 index ef5c743..0000000 --- a/odb/sqlite/libodb-sqlite-vc8.vcproj +++ /dev/null @@ -1,352 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entries__(sources) - - -__file_entries__(headers) - - - - - diff --git a/odb/sqlite/libodb-sqlite-vc9.vcproj b/odb/sqlite/libodb-sqlite-vc9.vcproj deleted file mode 100644 index f21c203..0000000 --- a/odb/sqlite/libodb-sqlite-vc9.vcproj +++ /dev/null @@ -1,359 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entries__(sources) - - -__file_entries__(headers) - - - - - diff --git a/odb/sqlite/makefile b/odb/sqlite/makefile deleted file mode 100644 index 485b9ec..0000000 --- a/odb/sqlite/makefile +++ /dev/null @@ -1,159 +0,0 @@ -# file : odb/sqlite/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -cxx := \ -connection.cxx \ -connection-factory.cxx \ -database.cxx \ -error.cxx \ -exceptions.cxx \ -prepared-query.cxx \ -query.cxx \ -query-dynamic.cxx \ -query-const-expr.cxx \ -simple-object-statements.cxx \ -statement.cxx \ -statements-base.cxx \ -stream.cxx \ -tracer.cxx \ -traits.cxx \ -transaction.cxx \ -transaction-impl.cxx - -cli_tun := details/options.cli -cxx_tun := $(cxx) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -odb_sqlite.l := $(out_base)/odb-sqlite.l -odb_sqlite.l.cpp-options := $(out_base)/odb-sqlite.l.cpp-options - -default := $(out_base)/ -dist := $(out_base)/.dist -clean := $(out_base)/.clean - -# Import. -# -$(call import,\ - $(scf_root)/import/cli/stub.make,\ - cli: cli,cli-rules: cli_rules) - -$(call import,\ - $(scf_root)/import/libodb/stub.make,\ - l: odb.l,cpp-options: odb.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libsqlite/stub.make,\ - l: sqlite.l,cpp-options: sqlite.l.cpp-options) - -# Build. -# -$(odb_sqlite.l): $(cxx_obj) $(odb.l) $(sqlite.l) -$(odb_sqlite.l.cpp-options): value := -I$(out_root) -I$(src_root) -$(odb_sqlite.l.cpp-options): $(odb.l.cpp-options) $(sqlite.l.cpp-options) - -$(cxx_obj) $(cxx_od): $(odb_sqlite.l.cpp-options) $(out_base)/details/config.h - -genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) -gen := $(addprefix $(out_base)/,$(genf)) - -# Don't try to depend on the installed executable. -# -ifneq ($(cli),cli) -$(gen): $(cli) -endif - -$(gen): cli := $(cli) -$(gen): cli_options += \ ---long-usage \ ---generate-file-scanner \ ---cli-namespace odb::sqlite::details::cli \ ---guard-prefix LIBODB_SQLITE_DETAILS - -$(out_base)/details/config.h: | $(out_base)/details/. - @echo '/* file : odb/sqlite/details/config.h' >$@ - @echo ' * note : automatically generated' >>$@ - @echo ' */' >>$@ - @echo '' >>$@ - @echo '#ifndef ODB_SQLITE_DETAILS_CONFIG_H' >>$@ - @echo '#define ODB_SQLITE_DETAILS_CONFIG_H' >>$@ - @echo '' >>$@ - @echo '#include ' >>$@ - @echo '' >>$@ - @echo '#if SQLITE_VERSION_NUMBER >= 3006012' >>$@ - @echo ' #define LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY 1' >>$@ - @echo '#endif' >>$@ - @echo '#define LIBODB_SQLITE_HAVE_COLUMN_METADATA 1' >>$@ - @echo '' >>$@ - @echo '#endif /* ODB_SQLITE_DETAILS_CONFIG_H */' >>$@ - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen) $(out_base)/details/config.h) - -# Convenience alias for default target. -# -$(out_base)/: $(odb_sqlite.l) - -# Dist. -# -$(dist): sources_dist := $(cxx) -$(dist): export sources := $(sources_dist) $(cli_tun:.cli=.cxx) -$(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \ --name '*.hxx' -o -name '*.ixx' -o -name '*.txx')) -$(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) -$(dist): export headers = $(sort $(headers_dist) $(gen_headers)) -$(dist): gen_dist := $(gen) -$(dist): data_dist := $(cli_tun) details/config.h.in details/config-vc.h -$(dist): export extra_dist := $(data_dist) \ -libodb-sqlite-vc8.vcproj libodb-sqlite-vc9.vcproj \ -libodb-sqlite-vc10.vcxproj libodb-sqlite-vc10.vcxproj.filters \ -libodb-sqlite-vc11.vcxproj libodb-sqlite-vc11.vcxproj.filters \ -libodb-sqlite-vc12.vcxproj libodb-sqlite-vc12.vcxproj.filters -$(dist): export interface_version = $(shell sed -e \ -'s/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version.txt) - -$(dist): $(gen) - $(call dist-data,$(sources_dist) $(headers_dist) $(data_dist)) - $(call dist-data,$(gen_dist),$(dist_prefix)/odb/sqlite/details) - $(call meta-vc8proj,$(src_base)/libodb-sqlite-vc8.vcproj) - $(call meta-vc9proj,$(src_base)/libodb-sqlite-vc9.vcproj) - $(call meta-vc10proj,$(src_base)/libodb-sqlite-vc10.vcxproj) - $(call meta-vc11proj,$(src_base)/libodb-sqlite-vc11.vcxproj) - $(call meta-vc12proj,$(src_base)/libodb-sqlite-vc12.vcxproj) - $(call meta-automake) - -# Clean. -# -$(clean): $(odb_sqlite.l).o.clean \ - $(odb_sqlite.l.cpp-options).clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean)) - $(call message,rm $$1,rm -f $$1,$(out_base)/details/config.h) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(odb_sqlite.l): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := details/config.h $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(cli_rules)) -$(call include,$(bld_root)/cxx/o-l.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) diff --git a/odb/sqlite/no-id-object-result.hxx b/odb/sqlite/no-id-object-result.hxx deleted file mode 100644 index b0edb09..0000000 --- a/odb/sqlite/no-id-object-result.hxx +++ /dev/null @@ -1,80 +0,0 @@ -// file : odb/sqlite/no-id-object-result.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX -#define ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include // query_base, query_params -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class no_id_object_result_impl: public odb::no_id_object_result_impl - { - public: - typedef odb::no_id_object_result_impl base_type; - - typedef typename base_type::object_type object_type; - typedef typename base_type::pointer_type pointer_type; - - typedef object_traits_impl object_traits; - typedef typename base_type::pointer_traits pointer_traits; - - typedef typename object_traits::statements_type statements_type; - - virtual - ~no_id_object_result_impl (); - - no_id_object_result_impl (const query_base&, - const details::shared_ptr&, - statements_type&, - const schema_version_migration*); - - virtual void - load (object_type&); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - virtual void - invalidate (); - - using base_type::current; - - private: - // We need to hold on to the query parameters because SQLite uses - // the parameter buffers to find each next row. - // - details::shared_ptr params_; - details::shared_ptr statement_; - statements_type& statements_; - object_traits_calls tc_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX diff --git a/odb/sqlite/no-id-object-result.txx b/odb/sqlite/no-id-object-result.txx deleted file mode 100644 index bd26afc..0000000 --- a/odb/sqlite/no-id-object-result.txx +++ /dev/null @@ -1,114 +0,0 @@ -// file : odb/sqlite/no-id-object-result.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include // result_not_cached - -#include - -namespace odb -{ - namespace sqlite - { - template - no_id_object_result_impl:: - ~no_id_object_result_impl () - { - if (!this->end_) - statement_->free_result (); - } - - template - void no_id_object_result_impl:: - invalidate () - { - if (!this->end_) - { - statement_->free_result (); - this->end_ = true; - } - - params_.reset (); - statement_.reset (); - } - - template - no_id_object_result_impl:: - no_id_object_result_impl (const query_base& q, - const details::shared_ptr& s, - statements_type& sts, - const schema_version_migration* svm) - : base_type (sts.connection ()), - params_ (q.parameters ()), - statement_ (s), - statements_ (sts), - tc_ (svm) - { - } - - template - void no_id_object_result_impl:: - load (object_type& obj) - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename object_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - tc_.bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (tc_.grow (im, statements_.select_image_truncated ())) - im.version++; - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - tc_.bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - statement_->reload (); - } - } - - object_traits::callback (this->db_, obj, callback_event::pre_load); - tc_.init (obj, im, &this->db_); - object_traits::callback (this->db_, obj, callback_event::post_load); - } - - template - void no_id_object_result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - void no_id_object_result_impl:: - cache () - { - } - - template - std::size_t no_id_object_result_impl:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/no-id-object-statements.hxx b/odb/sqlite/no-id-object-statements.hxx deleted file mode 100644 index 7a0376a..0000000 --- a/odb/sqlite/no-id-object-statements.hxx +++ /dev/null @@ -1,136 +0,0 @@ -// file : odb/sqlite/no-id-object-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX -#define ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // Implementation for objects without object id. - // - - template - class no_id_object_statements: public statements_base - { - public: - typedef T object_type; - typedef object_traits_impl object_traits; - typedef typename object_traits::pointer_type pointer_type; - typedef typename object_traits::image_type image_type; - - typedef sqlite::insert_statement insert_statement_type; - - public: - no_id_object_statements (connection_type&); - - virtual - ~no_id_object_statements (); - - // Object image. - // - image_type& - image () {return image_;} - - // Insert binding. - // - std::size_t - insert_image_version () const { return insert_image_version_;} - - void - insert_image_version (std::size_t v) {insert_image_version_ = v;} - - binding& - insert_image_binding () {return insert_image_binding_;} - - // Select binding. - // - std::size_t - select_image_version () const { return select_image_version_;} - - void - select_image_version (std::size_t v) {select_image_version_ = v;} - - binding& - select_image_binding () {return select_image_binding_;} - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Statements. - // - insert_statement_type& - persist_statement () - { - if (persist_ == 0) - { - persist_.reset ( - new (details::shared) insert_statement_type ( - conn_, - object_traits::persist_statement, - object_traits::versioned, // Process if versioned. - insert_image_binding_, - 0)); - } - - return *persist_; - } - - public: - // select = total - // insert = total - inverse; inverse == 0 for object without id - // - static const std::size_t insert_column_count = - object_traits::column_count; - - static const std::size_t select_column_count = - object_traits::column_count; - - private: - no_id_object_statements (const no_id_object_statements&); - no_id_object_statements& operator= (const no_id_object_statements&); - - private: - image_type image_; - - // Select binding. - // - std::size_t select_image_version_; - binding select_image_binding_; - bind select_image_bind_[select_column_count]; - bool select_image_truncated_[select_column_count]; - - // Insert binding. - // - std::size_t insert_image_version_; - binding insert_image_binding_; - bind insert_image_bind_[insert_column_count]; - - details::shared_ptr persist_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/no-id-object-statements.txx b/odb/sqlite/no-id-object-statements.txx deleted file mode 100644 index d0a62b2..0000000 --- a/odb/sqlite/no-id-object-statements.txx +++ /dev/null @@ -1,36 +0,0 @@ -// file : odb/sqlite/no-id-object-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::memset - -namespace odb -{ - namespace sqlite - { - template - no_id_object_statements:: - ~no_id_object_statements () - { - } - - template - no_id_object_statements:: - no_id_object_statements (connection_type& conn) - : statements_base (conn), - select_image_binding_ (select_image_bind_, select_column_count), - insert_image_binding_ (insert_image_bind_, insert_column_count) - { - image_.version = 0; - select_image_version_ = 0; - insert_image_version_ = 0; - - std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - - for (std::size_t i (0); i < select_column_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - } -} diff --git a/odb/sqlite/polymorphic-object-result.hxx b/odb/sqlite/polymorphic-object-result.hxx deleted file mode 100644 index 3239471..0000000 --- a/odb/sqlite/polymorphic-object-result.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// file : odb/sqlite/polymorphic-object-result.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX -#define ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include // query_base, query_params -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class polymorphic_object_result_impl: - public odb::polymorphic_object_result_impl - { - public: - typedef odb::polymorphic_object_result_impl base_type; - - typedef typename base_type::id_type id_type; - typedef typename base_type::object_type object_type; - typedef typename base_type::pointer_type pointer_type; - - typedef object_traits_impl object_traits; - typedef typename base_type::pointer_traits pointer_traits; - - typedef typename base_type::root_type root_type; - typedef typename base_type::discriminator_type discriminator_type; - - typedef object_traits_impl root_traits; - - typedef typename object_traits::statements_type statements_type; - - virtual - ~polymorphic_object_result_impl (); - - polymorphic_object_result_impl ( - const query_base&, - const details::shared_ptr&, - statements_type&, - const schema_version_migration*); - - virtual void - load (object_type*, bool fetch); - - virtual id_type - load_id (); - - virtual discriminator_type - load_discriminator (); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - virtual void - invalidate (); - - using base_type::current; - - private: - void - load_image (); - - private: - // We need to hold on to the query parameters because SQLite uses - // the parameter buffers to find each next row. - // - details::shared_ptr params_; - details::shared_ptr statement_; - statements_type& statements_; - object_traits_calls tc_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx deleted file mode 100644 index bd22f01..0000000 --- a/odb/sqlite/polymorphic-object-result.txx +++ /dev/null @@ -1,287 +0,0 @@ -// file : odb/sqlite/polymorphic-object-result.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include -#include // result_not_cached - -#include - -namespace odb -{ - namespace sqlite - { - template - polymorphic_object_result_impl:: - ~polymorphic_object_result_impl () - { - if (!this->end_) - statement_->free_result (); - } - - template - void polymorphic_object_result_impl:: - invalidate () - { - if (!this->end_) - { - statement_->free_result (); - this->end_ = true; - } - - params_.reset (); - statement_.reset (); - } - - template - polymorphic_object_result_impl:: - polymorphic_object_result_impl ( - const query_base& q, - const details::shared_ptr& s, - statements_type& sts, - const schema_version_migration* svm) - : base_type (sts.connection ()), - params_ (q.parameters ()), - statement_ (s), - statements_ (sts), - tc_ (svm) - { - } - - template - void polymorphic_object_result_impl:: - load (object_type* pobj, bool fetch) - { - if (fetch) - load_image (); - - typename statements_type::root_statements_type& rsts ( - statements_.root_statements ()); - - // This is a top-level call so the statements cannot be locked. - // - assert (!rsts.locked ()); - typename statements_type::auto_lock l (rsts); - - typename object_traits::image_type& i (statements_.image ()); - typename root_traits::image_type& ri (rsts.image ()); - - id_type id (root_traits::id (ri)); - - // Determine this object's dynamic type. - // - typedef typename root_traits::info_type info_type; - discriminator_type d (root_traits::discriminator (ri)); - discriminator_type disc (d); - - // Use the polymorphic_info() helper to get concrete_info if - // object_type is concrete and NULL if it is abstract. - // - const info_type* spi (polymorphic_info (object_traits::info)); - const info_type& pi ( - spi != 0 && spi->discriminator == d - ? *spi - : root_traits::map->find (d)); - - typedef typename root_traits::pointer_type root_pointer_type; - typedef typename root_traits::pointer_traits root_pointer_traits; - - typename object_traits::pointer_cache_traits::insert_guard ig; - - if (pobj == 0) - { - // Need to create a new instance of the dynamic type. - // - root_pointer_type rp (pi.create ()); - pointer_type p ( - root_pointer_traits::template static_pointer_cast (rp)); - - // Insert it as a root pointer (for non-unique pointers, rp should - // still be valid and for unique pointers this is a no-op). - // - ig.reset ( - object_traits::pointer_cache_traits::insert (this->db_, id, rp)); - - pobj = &pointer_traits::get_ref (p); - current (p); - } - else - { - // We are loading into an existing instance. If the static and - // dynamic types differ, then make sure the instance is at least - // of the dynamic type. - // - if (&pi != &object_traits::info) - { - const info_type& dpi (root_traits::map->find (typeid (*pobj))); - - if (&dpi != &pi && dpi.derived (pi)) - throw object_not_persistent (); // @@ type_mismatch ? - } - } - - callback_event ce (callback_event::pre_load); - pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - - tc_.init (*pobj, i, &this->db_); - - // Initialize the id image and binding and load the rest of the object - // (containers, dynamic part, etc). - // - typename object_traits::id_image_type& idi (statements_.id_image ()); - root_traits::init (idi, id); - - binding& idb (statements_.id_image_binding ()); - if (idi.version != statements_.id_image_version () || idb.version == 0) - { - object_traits::bind (idb.bind, idi); - statements_.id_image_version (idi.version); - idb.version++; - } - - tc_.load_ (statements_, *pobj, false); - - // Load the dynamic part of the object unless static and dynamic - // types are the same. - // - if (&pi != &object_traits::info) - { - std::size_t d (object_traits::depth); - pi.dispatch (info_type::call_load, this->db_, pobj, &d); - }; - - rsts.load_delayed (tc_.version ()); - l.unlock (); - - ce = callback_event::post_load; - pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - object_traits::pointer_cache_traits::load (ig.position ()); - ig.release (); - } - - template - typename polymorphic_object_result_impl::id_type - polymorphic_object_result_impl:: - load_id () - { - load_image (); - return root_traits::id (statements_.root_statements ().image ()); - } - - template - typename polymorphic_object_result_impl::discriminator_type - polymorphic_object_result_impl:: - load_discriminator () - { - load_image (); - return root_traits::discriminator ( - statements_.root_statements ().image ()); - } - - template - void polymorphic_object_result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - struct polymorphic_image_rebind - { - // Derived type version. - // - typedef object_traits_impl traits; - - static bool - rebind (typename traits::statements_type& sts, - const schema_version_migration* svm) - { - typename traits::image_type& im (sts.image ()); - - if (traits::check_version (sts.select_image_versions (), im)) - { - binding& b (sts.select_image_binding (traits::depth)); - object_traits_calls tc (svm); - tc.bind (b.bind, 0, 0, im, statement_select); - traits::update_version ( - sts.select_image_versions (), im, sts.select_image_bindings ()); - return true; - } - - return false; - } - }; - - template - struct polymorphic_image_rebind - { - // Root type version. - // - typedef object_traits_impl traits; - - static bool - rebind (typename traits::statements_type& sts, - const schema_version_migration* svm) - { - typename traits::image_type& im (sts.image ()); - - if (im.version != sts.select_image_version ()) - { - binding& b (sts.select_image_binding ()); - object_traits_calls tc (svm); - tc.bind (b.bind, im, statement_select); - sts.select_image_version (im.version); - b.version++; - return true; - } - - return false; - } - }; - - template - void polymorphic_object_result_impl:: - load_image () - { - typedef polymorphic_image_rebind image_rebind; - - // The image can grow between calls to load() as a result of other - // statements execution. - // - image_rebind::rebind (statements_, tc_.version ()); - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - typename object_traits::image_type& im (statements_.image ()); - - if (tc_.grow (im, statements_.select_image_truncated ())) - im.version++; - - if (image_rebind::rebind (statements_, tc_.version ())) - statement_->reload (); - } - } - - template - void polymorphic_object_result_impl:: - cache () - { - } - - template - std::size_t polymorphic_object_result_impl:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/polymorphic-object-statements.hxx b/odb/sqlite/polymorphic-object-statements.hxx deleted file mode 100644 index 736686b..0000000 --- a/odb/sqlite/polymorphic-object-statements.hxx +++ /dev/null @@ -1,479 +0,0 @@ -// file : odb/sqlite/polymorphic-object-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX -#define ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // Implementation for polymorphic objects. - // - - template - class polymorphic_root_object_statements: public object_statements - { - public: - typedef typename object_statements::connection_type connection_type; - typedef typename object_statements::object_traits object_traits; - typedef typename object_statements::id_image_type id_image_type; - - typedef - typename object_traits::discriminator_image_type - discriminator_image_type; - - typedef - typename object_statements::select_statement_type - select_statement_type; - - public: - // Interface compatibility with derived_object_statements. - // - typedef polymorphic_root_object_statements root_statements_type; - - root_statements_type& - root_statements () - { - return *this; - } - - public: - // Discriminator binding. - // - discriminator_image_type& - discriminator_image () {return discriminator_image_;} - - std::size_t - discriminator_image_version () const - {return discriminator_image_version_;} - - void - discriminator_image_version (std::size_t v) - {discriminator_image_version_ = v;} - - binding& - discriminator_image_binding () {return discriminator_image_binding_;} - - bool* - discriminator_image_truncated () {return discriminator_image_truncated_;} - - // Id binding for discriminator retrieval. - // - id_image_type& - discriminator_id_image () {return discriminator_id_image_;} - - std::size_t - discriminator_id_image_version () const - {return discriminator_id_image_version_;} - - void - discriminator_id_image_version (std::size_t v) - {discriminator_id_image_version_ = v;} - - binding& - discriminator_id_image_binding () - {return discriminator_id_image_binding_;} - - // - // - select_statement_type& - find_discriminator_statement () - { - if (find_discriminator_ == 0) - { - find_discriminator_.reset ( - new (details::shared) select_statement_type ( - this->conn_, - object_traits::find_discriminator_statement, - false, // Doesn't need to be processed. - false, // Don't optimize. - discriminator_id_image_binding_, - discriminator_image_binding_)); - } - - return *find_discriminator_; - } - - public: - polymorphic_root_object_statements (connection_type&); - - virtual - ~polymorphic_root_object_statements (); - - // Static "override" (statements type). - // - void - load_delayed (const schema_version_migration* svm) - { - assert (this->locked ()); - - if (!this->delayed_.empty ()) - this->template load_delayed_ ( - svm); - } - - public: - static const std::size_t id_column_count = - object_statements::id_column_count; - - static const std::size_t discriminator_column_count = - object_traits::discriminator_column_count; - - static const std::size_t managed_optimistic_column_count = - object_traits::managed_optimistic_column_count; - - private: - // Discriminator image. - // - discriminator_image_type discriminator_image_; - std::size_t discriminator_image_version_; - binding discriminator_image_binding_; - bind discriminator_image_bind_[discriminator_column_count + - managed_optimistic_column_count]; - bool discriminator_image_truncated_[discriminator_column_count + - managed_optimistic_column_count]; - - // Id image for discriminator retrieval (only used as a parameter). - // - id_image_type discriminator_id_image_; - std::size_t discriminator_id_image_version_; - binding discriminator_id_image_binding_; - bind discriminator_id_image_bind_[id_column_count]; - - details::shared_ptr find_discriminator_; - }; - - template - class polymorphic_derived_object_statements: public statements_base - { - public: - typedef T object_type; - typedef object_traits_impl object_traits; - typedef typename object_traits::id_type id_type; - typedef typename object_traits::pointer_type pointer_type; - typedef typename object_traits::id_image_type id_image_type; - typedef typename object_traits::image_type image_type; - - typedef typename object_traits::root_type root_type; - typedef - polymorphic_root_object_statements - root_statements_type; - - typedef typename object_traits::base_type base_type; - typedef - typename object_traits::base_traits::statements_type - base_statements_type; - - typedef - typename object_traits::extra_statement_cache_type - extra_statement_cache_type; - - typedef sqlite::insert_statement insert_statement_type; - typedef sqlite::select_statement select_statement_type; - typedef sqlite::update_statement update_statement_type; - typedef sqlite::delete_statement delete_statement_type; - - typedef typename root_statements_type::auto_lock auto_lock; - - public: - polymorphic_derived_object_statements (connection_type&); - - virtual - ~polymorphic_derived_object_statements (); - - public: - // Delayed loading. - // - static void - delayed_loader (odb::database&, - const id_type&, - root_type&, - const schema_version_migration*); - - public: - // Root and immediate base statements. - // - root_statements_type& - root_statements () - { - return root_statements_; - } - - base_statements_type& - base_statements () - { - return base_statements_; - } - - public: - // Object image. - // - image_type& - image () - { - return image_; - } - - // Insert binding. - // - std::size_t - insert_image_version () const { return insert_image_version_;} - - void - insert_image_version (std::size_t v) {insert_image_version_ = v;} - - std::size_t - insert_id_binding_version () const { return insert_id_binding_version_;} - - void - insert_id_binding_version (std::size_t v) {insert_id_binding_version_ = v;} - - binding& - insert_image_binding () {return insert_image_binding_;} - - // Update binding. - // - std::size_t - update_image_version () const { return update_image_version_;} - - void - update_image_version (std::size_t v) {update_image_version_ = v;} - - std::size_t - update_id_binding_version () const { return update_id_binding_version_;} - - void - update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} - - binding& - update_image_binding () {return update_image_binding_;} - - // Select binding. - // - std::size_t* - select_image_versions () { return select_image_versions_;} - - binding* - select_image_bindings () {return select_image_bindings_;} - - binding& - select_image_binding (std::size_t d) - { - return select_image_bindings_[object_traits::depth - d]; - } - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Object id binding (comes from the root statements). - // - id_image_type& - id_image () {return root_statements_.id_image ();} - - std::size_t - id_image_version () const {return root_statements_.id_image_version ();} - - void - id_image_version (std::size_t v) {root_statements_.id_image_version (v);} - - binding& - id_image_binding () {return root_statements_.id_image_binding ();} - - binding& - optimistic_id_image_binding () { - return root_statements_.optimistic_id_image_binding ();} - - // Statements. - // - insert_statement_type& - persist_statement () - { - if (persist_ == 0) - { - persist_.reset ( - new (details::shared) insert_statement_type ( - conn_, - object_traits::persist_statement, - object_traits::versioned, // Process if versioned. - insert_image_binding_, - 0)); - } - - return *persist_; - } - - select_statement_type& - find_statement (std::size_t d) - { - std::size_t i (object_traits::depth - d); - details::shared_ptr& p (find_[i]); - - if (p == 0) - { - p.reset ( - new (details::shared) select_statement_type ( - conn_, - object_traits::find_statements[i], - object_traits::versioned, // Process if versioned. - false, // Don't optimize. - root_statements_.id_image_binding (), - select_image_bindings_[i])); - } - - return *p; - } - - update_statement_type& - update_statement () - { - if (update_ == 0) - { - update_.reset ( - new (details::shared) update_statement_type ( - conn_, - object_traits::update_statement, - object_traits::versioned, // Process if versioned. - update_image_binding_)); - } - - return *update_; - } - - delete_statement_type& - erase_statement () - { - if (erase_ == 0) - { - erase_.reset ( - new (details::shared) delete_statement_type ( - conn_, - object_traits::erase_statement, - root_statements_.id_image_binding ())); - } - - return *erase_; - } - - // Extra (container, section) statement cache. - // - extra_statement_cache_type& - extra_statement_cache () - { - return extra_statement_cache_.get ( - conn_, - image_, - id_image (), - id_image_binding (), - &id_image_binding ()); // Note, not id+version. - } - - public: - // select = total - id - separate_load + base::select - // insert = total - inverse - // update = total - inverse - id - readonly - separate_update - // - static const std::size_t id_column_count = - object_traits::id_column_count; - - static const std::size_t select_column_count = - object_traits::column_count - - id_column_count - - object_traits::separate_load_column_count + - base_statements_type::select_column_count; - - static const std::size_t insert_column_count = - object_traits::column_count - - object_traits::inverse_column_count; - - static const std::size_t update_column_count = insert_column_count - - object_traits::id_column_count - - object_traits::readonly_column_count - - object_traits::separate_update_column_count; - - private: - polymorphic_derived_object_statements ( - const polymorphic_derived_object_statements&); - - polymorphic_derived_object_statements& - operator= (const polymorphic_derived_object_statements&); - - private: - root_statements_type& root_statements_; - base_statements_type& base_statements_; - - extra_statement_cache_ptr extra_statement_cache_; - - image_type image_; - - // Select binding. Here we are have an array of statements/bindings - // one for each depth. In other words, if we have classes root, base, - // and derived, then we have the following array of statements: - // - // [0] d + b + r - // [1] d + b - // [2] d - // - // Also, because we have a chain of images bound to these statements, - // we have an array of versions, one entry for each base plus one for - // our own image. - // - // A poly-abstract class only needs the first statement and in this - // case we have only one entry in the the bindings and statements - // arrays (but not versions; we still have a chain of images). - // - std::size_t select_image_versions_[object_traits::depth]; - binding select_image_bindings_[ - object_traits::abstract ? 1 : object_traits::depth]; - bind select_image_bind_[select_column_count]; - bool select_image_truncated_[select_column_count]; - - // Insert binding. The id binding is copied from the hierarchy root. - // - std::size_t insert_image_version_; - std::size_t insert_id_binding_version_; - binding insert_image_binding_; - bind insert_image_bind_[insert_column_count]; - - // Update binding. The id suffix binding is copied from the hierarchy - // root. - // - std::size_t update_image_version_; - std::size_t update_id_binding_version_; - binding update_image_binding_; - bind update_image_bind_[update_column_count + id_column_count]; - - details::shared_ptr persist_; - details::shared_ptr find_[ - object_traits::abstract ? 1 : object_traits::depth]; - details::shared_ptr update_; - details::shared_ptr erase_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/polymorphic-object-statements.txx b/odb/sqlite/polymorphic-object-statements.txx deleted file mode 100644 index 6a376d3..0000000 --- a/odb/sqlite/polymorphic-object-statements.txx +++ /dev/null @@ -1,145 +0,0 @@ -// file : odb/sqlite/polymorphic-object-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::memset - -#include -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // polymorphic_root_object_statements - // - - template - polymorphic_root_object_statements:: - ~polymorphic_root_object_statements () - { - } - - template - polymorphic_root_object_statements:: - polymorphic_root_object_statements (connection_type& conn) - : object_statements (conn), - discriminator_image_binding_ (discriminator_image_bind_, - discriminator_column_count + - managed_optimistic_column_count), - discriminator_id_image_binding_ (discriminator_id_image_bind_, - id_column_count) - { - discriminator_image_.version = 0; - discriminator_id_image_.version = 0; - - discriminator_image_version_ = 0; - discriminator_id_image_version_ = 0; - - std::memset (discriminator_image_bind_, - 0, - sizeof (discriminator_image_bind_)); - std::memset (discriminator_id_image_bind_, - 0, - sizeof (discriminator_id_image_bind_)); - std::memset (discriminator_image_truncated_, - 0, - sizeof (discriminator_image_truncated_)); - - for (std::size_t i (0); - i < discriminator_column_count + managed_optimistic_column_count; - ++i) - { - discriminator_image_bind_[i].truncated = - discriminator_image_truncated_ + i; - } - } - - // - // polymorphic_derived_object_statements - // - - template - polymorphic_derived_object_statements:: - ~polymorphic_derived_object_statements () - { - } - - template - polymorphic_derived_object_statements:: - polymorphic_derived_object_statements (connection_type& conn) - : statements_base (conn), - root_statements_ (conn.statement_cache ().find_object ()), - base_statements_ (conn.statement_cache ().find_object ()), - insert_image_binding_ (insert_image_bind_, insert_column_count), - update_image_binding_ (update_image_bind_, - update_column_count + id_column_count) - { - image_.base = &base_statements_.image (); - image_.version = 0; - - for (std::size_t i (0); i < object_traits::depth; ++i) - select_image_versions_[i] = 0; - - for (std::size_t i (0); - i < (object_traits::abstract ? 1 : object_traits::depth); - ++i) - { - select_image_bindings_[i].bind = select_image_bind_; - select_image_bindings_[i].count = object_traits::find_column_counts[i]; - } - - insert_image_version_ = 0; - insert_id_binding_version_ = 0; - update_image_version_ = 0; - update_id_binding_version_ = 0; - - std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); - std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - - for (std::size_t i (0); i < select_column_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - - template - void polymorphic_derived_object_statements:: - delayed_loader (odb::database& db, - const id_type& id, - root_type& robj, - const schema_version_migration* svm) - { - connection_type& conn (transaction::current ().connection (db)); - polymorphic_derived_object_statements& sts ( - conn.statement_cache ().find_object ()); - root_statements_type& rsts (sts.root_statements ()); - - object_type& obj (static_cast (robj)); - - // The same code as in object_statements::load_delayed_(). - // - object_traits_calls tc (svm); - - if (!tc.find_ (sts, &id)) - throw object_not_persistent (); - - object_traits::callback (db, obj, callback_event::pre_load); - tc.init (obj, sts.image (), &db); - tc.load_ (sts, obj, false); // Load containers, etc. - - rsts.load_delayed (svm); - - { - typename root_statements_type::auto_unlock u (rsts); - object_traits::callback (db, obj, callback_event::post_load); - } - } - } -} diff --git a/odb/sqlite/prepared-query.cxx b/odb/sqlite/prepared-query.cxx deleted file mode 100644 index 79df0f2..0000000 --- a/odb/sqlite/prepared-query.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : odb/sqlite/prepared-query.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include - -namespace odb -{ - namespace sqlite - { - prepared_query_impl:: - ~prepared_query_impl () - { - } - - bool prepared_query_impl:: - verify_connection (odb::transaction& t) - { - // The transaction can be started using the main database of any of the - // attached databases. So we verify the main connections match. - // - return &static_cast (t.connection ()).main_connection () == - &static_cast (stmt->connection ()).main_connection (); - } - } -} diff --git a/odb/sqlite/prepared-query.hxx b/odb/sqlite/prepared-query.hxx deleted file mode 100644 index a8873a5..0000000 --- a/odb/sqlite/prepared-query.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// file : odb/sqlite/prepared-query.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_PREPARED_QUERY_HXX -#define ODB_SQLITE_PREPARED_QUERY_HXX - -#include - -#include - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - struct LIBODB_SQLITE_EXPORT prepared_query_impl: odb::prepared_query_impl - { - virtual - ~prepared_query_impl (); - - prepared_query_impl (odb::connection& c): odb::prepared_query_impl (c) {} - - virtual bool - verify_connection (odb::transaction&); - - sqlite::query_base query; - }; - } -} - -#include - -#endif // ODB_SQLITE_PREPARED_QUERY_HXX diff --git a/odb/sqlite/query-const-expr.cxx b/odb/sqlite/query-const-expr.cxx deleted file mode 100644 index c8eaec7..0000000 --- a/odb/sqlite/query-const-expr.cxx +++ /dev/null @@ -1,14 +0,0 @@ -// file : odb/sqlite/query-const-expr.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - namespace sqlite - { - // Sun CC cannot handle this in query.cxx. - // - const query_base query_base::true_expr (true); - } -} diff --git a/odb/sqlite/query-dynamic.cxx b/odb/sqlite/query-dynamic.cxx deleted file mode 100644 index 8089aed..0000000 --- a/odb/sqlite/query-dynamic.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// file : odb/sqlite/query-dynamic.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::size_t - -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - static const char* logic_operators[] = {") AND (", ") OR ("}; - static const char* comp_operators[] = {"=", "!=", "<", ">", "<=", ">="}; - - static void - translate (query_base& q, const odb::query_base& s, size_t p) - { - typedef odb::query_base::clause_part part; - - const part& x (s.clause ()[p]); - - switch (x.kind) - { - case part::kind_column: - { - const query_column_base* c ( - static_cast ( - x.native_info[id_sqlite].column)); - - q.append (c->table (), c->column ()); - break; - } - case part::kind_param_val: - case part::kind_param_ref: - { - const query_column_base* c ( - static_cast ( - x.native_info[id_sqlite].column)); - - query_param_factory f ( - reinterpret_cast ( - x.native_info[id_sqlite].param_factory)); - - const odb::query_param* p ( - reinterpret_cast (x.data)); - - q.append (f (p->value, x.kind == part::kind_param_ref), - c->conversion ()); - break; - } - case part::kind_native: - { - q.append (s.strings ()[x.data]); - break; - } - case part::kind_true: - case part::kind_false: - { - q.append (x.kind == part::kind_true); - break; - } - case part::op_add: - { - translate (q, s, x.data); - translate (q, s, p - 1); - break; - } - case part::op_and: - case part::op_or: - { - q += "("; - translate (q, s, x.data); - q += logic_operators[x.kind - part::op_and]; - translate (q, s, p - 1); - q += ")"; - break; - } - case part::op_not: - { - q += "NOT ("; - translate (q, s, p - 1); - q += ")"; - break; - } - case part::op_null: - case part::op_not_null: - { - translate (q, s, p - 1); - q += (x.kind == part::op_null ? "IS NULL" : "IS NOT NULL"); - break; - } - case part::op_in: - { - if (x.data != 0) - { - size_t b (p - x.data); - - translate (q, s, b - 1); // column - q += "IN ("; - - for (size_t i (b); i != p; ++i) - { - if (i != b) - q += ","; - - translate (q, s, i); - } - - q += ")"; - } - else - q.append (false); - - break; - } - case part::op_like: - { - translate (q, s, p - 2); // column - q += "LIKE"; - translate (q, s, p - 1); // pattern - break; - } - case part::op_like_escape: - { - translate (q, s, p - 3); // column - q += "LIKE"; - translate (q, s, p - 2); // pattern - q += "ESCAPE"; - translate (q, s, p - 1); // escape - break; - } - case part::op_eq: - case part::op_ne: - case part::op_lt: - case part::op_gt: - case part::op_le: - case part::op_ge: - { - translate (q, s, x.data); - q += comp_operators[x.kind - part::op_eq]; - translate (q, s, p - 1); - break; - } - } - } - - query_base:: - query_base (const odb::query_base& q) - : parameters_ (new (details::shared) query_params) - { - if (!q.empty ()) - translate (*this, q, q.clause ().size () - 1); - } - } -} diff --git a/odb/sqlite/query-dynamic.hxx b/odb/sqlite/query-dynamic.hxx deleted file mode 100644 index f720a95..0000000 --- a/odb/sqlite/query-dynamic.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// file : odb/sqlite/query-dynamic.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_QUERY_DYNAMIC_HXX -#define ODB_SQLITE_QUERY_DYNAMIC_HXX - -#include - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - typedef details::shared_ptr (*query_param_factory) ( - const void* val, bool by_ref); - - template - details::shared_ptr - query_param_factory_impl (const void*, bool); - } -} - -#include -#include - -#include - -#endif // ODB_SQLITE_QUERY_DYNAMIC_HXX diff --git a/odb/sqlite/query-dynamic.ixx b/odb/sqlite/query-dynamic.ixx deleted file mode 100644 index 7fafe3e..0000000 --- a/odb/sqlite/query-dynamic.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// file : odb/sqlite/query-dynamic.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - // - // - template - inline query_column:: - query_column (odb::query_column& qc, - const char* table, const char* column, const char* conv) - : query_column_base (table, column, conv) - { - native_column_info& ci (qc.native_info[id_sqlite]); - ci.column = static_cast (this); - - // For some reason GCC needs this statically-typed pointer in - // order to instantiate the functions. - // - query_param_factory f (&query_param_factory_impl); - ci.param_factory = reinterpret_cast (f); - } - } -} diff --git a/odb/sqlite/query-dynamic.txx b/odb/sqlite/query-dynamic.txx deleted file mode 100644 index 48b7ec4..0000000 --- a/odb/sqlite/query-dynamic.txx +++ /dev/null @@ -1,20 +0,0 @@ -// file : odb/sqlite/query-dynamic.txx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - template - details::shared_ptr - query_param_factory_impl (const void* val, bool by_ref) - { - const T& v (*static_cast (val)); - - return details::shared_ptr ( - by_ref - ? new (details::shared) query_param_impl (ref_bind (v)) - : new (details::shared) query_param_impl (val_bind (v))); - } - } -} diff --git a/odb/sqlite/query.cxx b/odb/sqlite/query.cxx deleted file mode 100644 index 98eb1cd..0000000 --- a/odb/sqlite/query.cxx +++ /dev/null @@ -1,378 +0,0 @@ -// file : odb/sqlite/query.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::size_t -#include // std::memset - -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - // query_param - // - - query_param:: - ~query_param () - { - } - - // query_params - // - - query_params:: - query_params (const query_params& x) - : details::shared_base (x), - params_ (x.params_), bind_ (x.bind_), binding_ (0, 0) - { - // Here and below we want to maintain up to date binding info so - // that the call to binding() below is an immutable operation, - // provided the query does not have any by-reference parameters. - // This way a by-value-only query can be shared between multiple - // threads without the need for synchronization. - // - if (size_t n = bind_.size ()) - { - binding_.bind = &bind_[0]; - binding_.count = n; - binding_.version++; - } - } - - query_params& query_params:: - operator= (const query_params& x) - { - if (this != &x) - { - params_ = x.params_; - bind_ = x.bind_; - - size_t n (bind_.size ()); - binding_.bind = n != 0 ? &bind_[0] : 0; - binding_.count = n; - binding_.version++; - } - - return *this; - } - - query_params& query_params:: - operator+= (const query_params& x) - { - size_t n (bind_.size ()); - - params_.insert (params_.end (), x.params_.begin (), x.params_.end ()); - bind_.insert (bind_.end (), x.bind_.begin (), x.bind_.end ()); - - if (n != bind_.size ()) - { - binding_.bind = &bind_[0]; - binding_.count = bind_.size (); - binding_.version++; - } - - return *this; - } - - void query_params:: - add (details::shared_ptr p) - { - params_.push_back (p); - bind_.push_back (sqlite::bind ()); - binding_.bind = &bind_[0]; - binding_.count = bind_.size (); - binding_.version++; - - sqlite::bind* b (&bind_.back ()); - memset (b, 0, sizeof (sqlite::bind)); - p->bind (b); - } - - void query_params:: - init () - { - bool inc_ver (false); - - for (size_t i (0); i < params_.size (); ++i) - { - query_param& p (*params_[i]); - - if (p.reference ()) - { - if (p.init ()) - { - p.bind (&bind_[i]); - inc_ver = true; - } - } - } - - if (inc_ver) - binding_.version++; - } - - // query_base - // - - query_base:: - query_base (const query_base& q) - : clause_ (q.clause_), - parameters_ (new (details::shared) query_params (*q.parameters_)) - { - } - - query_base& query_base:: - operator= (const query_base& q) - { - if (this != &q) - { - clause_ = q.clause_; - *parameters_ = *q.parameters_; - } - - return *this; - } - - query_base& query_base:: - operator+= (const query_base& q) - { - clause_.insert (clause_.end (), q.clause_.begin (), q.clause_.end ()); - *parameters_ += *q.parameters_; - return *this; - } - - void query_base:: - append (const string& q) - { - if (!clause_.empty () && - clause_.back ().kind == clause_part::kind_native) - { - string& s (clause_.back ().part); - - char first (!q.empty () ? q[0] : ' '); - char last (!s.empty () ? s[s.size () - 1] : ' '); - - // We don't want extra spaces after '(' as well as before ',' - // and ')'. - // - if (last != ' ' && last != '\n' && last != '(' && - first != ' ' && first != '\n' && first != ',' && first != ')') - s += ' '; - - s += q; - } - else - clause_.push_back (clause_part (clause_part::kind_native, q)); - } - - void query_base:: - append (const char* table, const char* column) - { - string s (table); - s += '.'; - s += column; - - clause_.push_back (clause_part (clause_part::kind_column, s)); - } - - void query_base:: - append (details::shared_ptr p, const char* conv) - { - clause_.push_back (clause_part (clause_part::kind_param)); - - if (conv != 0) - clause_.back ().part = conv; - - parameters_->add (p); - } - - static bool - check_prefix (const string& s) - { - string::size_type n; - - // It is easier to compare to upper and lower-case versions - // rather than getting involved with the portable case- - // insensitive string comparison mess. - // - if (s.compare (0, (n = 5), "WHERE") == 0 || - s.compare (0, (n = 5), "where") == 0 || - s.compare (0, (n = 6), "SELECT") == 0 || - s.compare (0, (n = 6), "select") == 0 || - s.compare (0, (n = 8), "ORDER BY") == 0 || - s.compare (0, (n = 8), "order by") == 0 || - s.compare (0, (n = 8), "GROUP BY") == 0 || - s.compare (0, (n = 8), "group by") == 0 || - s.compare (0, (n = 6), "HAVING") == 0 || - s.compare (0, (n = 6), "having") == 0 || - s.compare (0, (n = 4), "WITH") == 0 || - s.compare (0, (n = 4), "with") == 0 || - s.compare (0, (n = 6), "PRAGMA") == 0 || - s.compare (0, (n = 6), "pragma") == 0) - { - // It either has to be an exact match, or there should be - // a whitespace following the keyword. - // - if (s.size () == n || s[n] == ' ' || s[n] == '\n' || s[n] =='\t') - return true; - } - - return false; - } - - void query_base:: - optimize () - { - // Remove a single TRUE literal or one that is followe by one of - // the other clauses. This avoids useless WHERE clauses like - // - // WHERE TRUE GROUP BY foo - // - clause_type::iterator i (clause_.begin ()), e (clause_.end ()); - - if (i != e && i->kind == clause_part::kind_bool && i->bool_part) - { - clause_type::iterator j (i + 1); - - if (j == e || - (j->kind == clause_part::kind_native && check_prefix (j->part))) - clause_.erase (i); - } - } - - const char* query_base:: - clause_prefix () const - { - if (!clause_.empty ()) - { - const clause_part& p (clause_.front ()); - - if (p.kind == clause_part::kind_native && check_prefix (p.part)) - return ""; - - return "WHERE "; - } - - return ""; - } - - string query_base:: - clause () const - { - string r; - - for (clause_type::const_iterator i (clause_.begin ()), - end (clause_.end ()); - i != end; - ++i) - { - char last (!r.empty () ? r[r.size () - 1] : ' '); - - switch (i->kind) - { - case clause_part::kind_column: - { - if (last != ' ' && last != '\n' && last != '(') - r += ' '; - - r += i->part; - break; - } - case clause_part::kind_param: - { - if (last != ' ' && last != '\n' && last != '(') - r += ' '; - - // Add the conversion expression, if any. - // - string::size_type p (0); - if (!i->part.empty ()) - { - p = i->part.find ("(?)"); - r.append (i->part, 0, p); - } - - r += '?'; - - if (!i->part.empty ()) - r.append (i->part, p + 3, string::npos); - - break; - } - case clause_part::kind_native: - { - // We don't want extra spaces after '(' as well as before ',' - // and ')'. - // - const string& p (i->part); - char first (!p.empty () ? p[0] : ' '); - - if (last != ' ' && first != '\n' && last != '(' && - first != ' ' && last != '\n' && first != ',' && first != ')') - r += ' '; - - r += p; - break; - } - case clause_part::kind_bool: - { - if (last != ' ' && last != '\n' && last != '(') - r += ' '; - - r += i->bool_part ? "1" : "0"; - break; - } - } - } - - return clause_prefix () + r; - } - - query_base - operator&& (const query_base& x, const query_base& y) - { - // Optimize cases where one or both sides are constant truth. - // - bool xt (x.const_true ()), yt (y.const_true ()); - - if (xt && yt) - return x; - - if (xt) - return y; - - if (yt) - return x; - - query_base r ("("); - r += x; - r += ") AND ("; - r += y; - r += ")"; - return r; - } - - query_base - operator|| (const query_base& x, const query_base& y) - { - query_base r ("("); - r += x; - r += ") OR ("; - r += y; - r += ")"; - return r; - } - - query_base - operator! (const query_base& x) - { - query_base r ("NOT ("); - r += x; - r += ")"; - return r; - } - } -} diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx deleted file mode 100644 index c9cbfaa..0000000 --- a/odb/sqlite/query.hxx +++ /dev/null @@ -1,1728 +0,0 @@ -// file : odb/sqlite/query.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_QUERY_HXX -#define ODB_SQLITE_QUERY_HXX - -#include - -#include -#include -#include // std::size_t - -#include // odb::query_column -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - template - struct val_bind - { - typedef const T& type; - - explicit - val_bind (type v): val (v) {} - - type val; - }; - - template - struct val_bind - { - typedef const T* type; - - explicit - val_bind (type v): val (v) {} - - type val; - }; - - template - struct ref_bind - { - typedef const T& type; - - explicit - ref_bind (type r): ref (r) {} - - const void* - ptr () const {return &ref;} - - type ref; - }; - - template - struct ref_bind - { - typedef const T* type; - - explicit - ref_bind (type r): ref (r) {} - - // Allow implicit conversion from decayed ref_bind's. - // - ref_bind (ref_bind r): ref (r.ref) {} - ref_bind (ref_bind r): ref (r.ref) {} - - const void* - ptr () const {return ref;} - - type ref; - }; - - template - struct val_bind_typed: val_bind - { - explicit - val_bind_typed (typename val_bind::type v): val_bind (v) {} - }; - - template - struct ref_bind_typed: ref_bind - { - explicit - ref_bind_typed (typename ref_bind::type r): ref_bind (r) {} - }; - - struct LIBODB_SQLITE_EXPORT query_param: details::shared_base - { - virtual - ~query_param (); - - bool - reference () const - { - return value_ != 0; - } - - virtual bool - init () = 0; - - virtual void - bind (sqlite::bind*) = 0; - - protected: - query_param (const void* value) - : value_ (value) - { - } - - protected: - const void* value_; - }; - - class query_base; - - class LIBODB_SQLITE_EXPORT query_params: public details::shared_base - { - public: - typedef sqlite::binding binding_type; - - void - init (); - - binding_type& - binding () {return binding_;} - - private: - friend class query_base; - - query_params (): binding_ (0, 0) {} - query_params (const query_params&); - - query_params& - operator= (const query_params&); - - query_params& - operator+= (const query_params&); - - void - add (details::shared_ptr); - - private: - typedef std::vector > params; - - params params_; - std::vector bind_; - binding_type binding_; - }; - - // - // - template - struct query_column; - - class LIBODB_SQLITE_EXPORT query_base - { - public: - struct clause_part - { - enum kind_type - { - kind_column, - kind_param, - kind_native, - kind_bool - }; - - clause_part (kind_type k): kind (k), bool_part (false) {} - clause_part (kind_type k, const std::string& p) - : kind (k), part (p), bool_part (false) {} - clause_part (bool p): kind (kind_bool), bool_part (p) {} - - kind_type kind; - std::string part; // If kind is param, then part is conversion expr. - bool bool_part; - }; - - query_base () - : parameters_ (new (details::shared) query_params) - { - } - - // True or false literal. - // - explicit - query_base (bool v) - : parameters_ (new (details::shared) query_params) - { - append (v); - } - - explicit - query_base (const char* native) - : parameters_ (new (details::shared) query_params) - { - clause_.push_back (clause_part (clause_part::kind_native, native)); - } - - explicit - query_base (const std::string& native) - : parameters_ (new (details::shared) query_params) - { - clause_.push_back (clause_part (clause_part::kind_native, native)); - } - - query_base (const char* table, const char* column) - : parameters_ (new (details::shared) query_params) - { - append (table, column); - } - - template - explicit - query_base (val_bind v) - : parameters_ (new (details::shared) query_params) - { - *this += v; - } - - template - explicit - query_base (val_bind_typed v) - : parameters_ (new (details::shared) query_params) - { - *this += v; - } - - template - explicit - query_base (ref_bind r) - : parameters_ (new (details::shared) query_params) - { - *this += r; - } - - template - explicit - query_base (ref_bind_typed r) - : parameters_ (new (details::shared) query_params) - { - *this += r; - } - - template - query_base (const query_column&); - - // Translate common query representation to SQLite native. Defined - // in query-dynamic.cxx - // - query_base (const odb::query_base&); - - // Copy c-tor and assignment. - // - query_base (const query_base&); - - query_base& - operator= (const query_base&); - - public: - std::string - clause () const; - - const char* - clause_prefix () const; - - // Initialize the by-reference parameters from bound variables. - // - void - init_parameters () const; - - binding& - parameters_binding () const; - - const details::shared_ptr& - parameters () const; - - public: - bool - empty () const - { - return clause_.empty (); - } - - static const query_base true_expr; - - bool - const_true () const - { - return clause_.size () == 1 && - clause_.front ().kind == clause_part::kind_bool && - clause_.front ().bool_part; - } - - void - optimize (); - - public: - template - static val_bind - _val (const T& x) - { - return val_bind (x); - } - - template - static val_bind_typed - _val (const T& x) - { - return val_bind_typed (x); - } - - template - static ref_bind - _ref (const T& x) - { - return ref_bind (x); - } - - template - static ref_bind_typed - _ref (const T& x) - { - return ref_bind_typed (x); - } - - // Some compilers (notably VC++), when deducing const T& from const - // array do not strip const from the array type. As a result, in the - // above signatures we get, for example, T = const char[4] instead - // of T = char[4], which is what we want. So to "fix" such compilers, - // we will have to provide the following specializations of the above - // functions. - // - template - static val_bind - _val (const T (&x) [N]) - { - return val_bind (x); - } - - template - static val_bind_typed - _val (const T (&x) [N]) - { - return val_bind_typed (x); - } - - template - static ref_bind - _ref (const T (&x) [N]) - { - return ref_bind (x); - } - - template - static ref_bind_typed - _ref (const T (&x) [N]) - { - return ref_bind_typed (x); - } - - public: - query_base& - operator+= (const query_base&); - - query_base& - operator+= (const std::string& q) - { - append (q); - return *this; - } - - template - query_base& - operator+= (val_bind v) - { - append::db_type_id> ( - v, details::conversion::to ()); - return *this; - } - - template - query_base& - operator+= (val_bind_typed v) - { - // We are not using default type_traits so no default conversion - // either. - // - append (v, 0); - return *this; - } - - template - query_base& - operator+= (ref_bind r) - { - append::db_type_id> ( - r, details::conversion::to ()); - return *this; - } - - template - query_base& - operator+= (ref_bind_typed r) - { - // We are not using default type_traits so no default conversion - // either. - // - append (r, 0); - return *this; - } - - // Implementation details. - // - public: - template - void - append (val_bind, const char* conv); - - template - void - append (ref_bind, const char* conv); - - void - append (details::shared_ptr, const char* conv); - - void - append (bool v) - { - clause_.push_back (clause_part (v)); - } - - void - append (const std::string& native); - - void - append (const char* native) // Clashes with append(bool). - { - append (std::string (native)); - } - - void - append (const char* table, const char* column); - - private: - typedef std::vector clause_type; - - clause_type clause_; - details::shared_ptr parameters_; - }; - - inline query_base - operator+ (const query_base& x, const query_base& y) - { - query_base r (x); - r += y; - return r; - } - - template - inline query_base - operator+ (const query_base& q, val_bind b) - { - query_base r (q); - r += b; - return r; - } - - template - inline query_base - operator+ (val_bind b, const query_base& q) - { - query_base r; - r += b; - r += q; - return r; - } - - template - inline query_base - operator+ (const query_base& q, val_bind_typed b) - { - query_base r (q); - r += b; - return r; - } - - template - inline query_base - operator+ (val_bind_typed b, const query_base& q) - { - query_base r; - r += b; - r += q; - return r; - } - - template - inline query_base - operator+ (const query_base& q, ref_bind b) - { - query_base r (q); - r += b; - return r; - } - - template - inline query_base - operator+ (ref_bind b, const query_base& q) - { - query_base r; - r += b; - r += q; - return r; - } - - template - inline query_base - operator+ (const query_base& q, ref_bind_typed b) - { - query_base r (q); - r += b; - return r; - } - - template - inline query_base - operator+ (ref_bind_typed b, const query_base& q) - { - query_base r; - r += b; - r += q; - return r; - } - - inline query_base - operator+ (const query_base& q, const std::string& s) - { - query_base r (q); - r += s; - return r; - } - - inline query_base - operator+ (const std::string& s, const query_base& q) - { - query_base r (s); - r += q; - return r; - } - - template - inline query_base - operator+ (const std::string& s, val_bind b) - { - query_base r (s); - r += b; - return r; - } - - template - inline query_base - operator+ (val_bind b, const std::string& s) - { - query_base r; - r += b; - r += s; - return r; - } - - template - inline query_base - operator+ (const std::string& s, val_bind_typed b) - { - query_base r (s); - r += b; - return r; - } - - template - inline query_base - operator+ (val_bind_typed b, const std::string& s) - { - query_base r; - r += b; - r += s; - return r; - } - - template - inline query_base - operator+ (const std::string& s, ref_bind b) - { - query_base r (s); - r += b; - return r; - } - - template - inline query_base - operator+ (ref_bind b, const std::string& s) - { - query_base r; - r += b; - r += s; - return r; - } - - template - inline query_base - operator+ (const std::string& s, ref_bind_typed b) - { - query_base r (s); - r += b; - return r; - } - - template - inline query_base - operator+ (ref_bind_typed b, const std::string& s) - { - query_base r; - r += b; - r += s; - return r; - } - - LIBODB_SQLITE_EXPORT query_base - operator&& (const query_base&, const query_base&); - - LIBODB_SQLITE_EXPORT query_base - operator|| (const query_base&, const query_base&); - - LIBODB_SQLITE_EXPORT query_base - operator! (const query_base&); - - // query_column - // - struct query_column_base - { - // Note that we keep shallow copies of the table, column, and conversion - // expression. The latter can be NULL. - // - query_column_base (const char* table, - const char* column, - const char* conv) - : table_ (table), column_ (column), conversion_ (conv) - { - } - - const char* - table () const - { - return table_; - } - - const char* - column () const - { - return column_; - } - - // Can be NULL. - // - const char* - conversion () const - { - return conversion_; - } - - protected: - const char* table_; - const char* column_; - const char* conversion_; - }; - - template - struct query_column: query_column_base - { - typedef typename decay_traits::type decayed_type; - - // Note that we keep shallow copies of the table, column, and conversion - // expression. The latter can be NULL. - // - query_column (const char* table, const char* column, const char* conv) - : query_column_base (table, column, conv) {} - - // Implementation is in query-dynamic.ixx. - // - query_column (odb::query_column&, - const char* table, const char* column, const char* conv); - - // is_null, is_not_null - // - public: - query_base - is_null () const - { - query_base q (table_, column_); - q += "IS NULL"; - return q; - } - - query_base - is_not_null () const - { - query_base q (table_, column_); - q += "IS NOT NULL"; - return q; - } - - // in - // - public: - query_base - in (decayed_type, decayed_type) const; - - query_base - in (decayed_type, decayed_type, decayed_type) const; - - query_base - in (decayed_type, decayed_type, decayed_type, decayed_type) const; - - query_base - in (decayed_type, decayed_type, decayed_type, decayed_type, - decayed_type) const; - - template - query_base - in_range (I begin, I end) const; - - // like - // - public: - query_base - like (decayed_type pattern) const - { - return like (val_bind (pattern)); - } - - query_base - like (val_bind pattern) const; - - template - query_base - like (val_bind pattern) const - { - return like (val_bind (decayed_type (pattern.val))); - } - - query_base - like (ref_bind pattern) const; - - query_base - like (decayed_type pattern, decayed_type escape) const - { - return like (val_bind (pattern), escape); - } - - query_base - like (val_bind pattern, decayed_type escape) const; - - template - query_base - like (val_bind pattern, decayed_type escape) const - { - return like (val_bind (decayed_type (pattern.val)), escape); - } - - query_base - like (ref_bind pattern, decayed_type escape) const; - - // = - // - public: - query_base - equal (decayed_type v) const - { - return equal (val_bind (v)); - } - - query_base - equal (val_bind v) const - { - query_base q (table_, column_); - q += "="; - q.append (v, conversion_); - return q; - } - - template - query_base - equal (val_bind v) const - { - return equal (val_bind (decayed_type (v.val))); - } - - query_base - equal (ref_bind r) const - { - query_base q (table_, column_); - q += "="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator== (const query_column& c, decayed_type v) - { - return c.equal (v); - } - - friend query_base - operator== (decayed_type v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, val_bind v) - { - return c.equal (v); - } - - friend query_base - operator== (val_bind v, const query_column& c) - { - return c.equal (v); - } - - template - friend query_base - operator== (const query_column& c, val_bind v) - { - return c.equal (v); - } - - template - friend query_base - operator== (val_bind v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, ref_bind r) - { - return c.equal (r); - } - - friend query_base - operator== (ref_bind r, const query_column& c) - { - return c.equal (r); - } - - // != - // - public: - query_base - unequal (decayed_type v) const - { - return unequal (val_bind (v)); - } - - query_base - unequal (val_bind v) const - { - query_base q (table_, column_); - q += "!="; - q.append (v, conversion_); - return q; - } - - template - query_base - unequal (val_bind v) const - { - return unequal (val_bind (decayed_type (v.val))); - } - - query_base - unequal (ref_bind r) const - { - query_base q (table_, column_); - q += "!="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator!= (const query_column& c, decayed_type v) - { - return c.unequal (v); - } - - friend query_base - operator!= (decayed_type v, const query_column& c) - { - return c.unequal (v); - } - - friend query_base - operator!= (const query_column& c, val_bind v) - { - return c.unequal (v); - } - - friend query_base - operator!= (val_bind v, const query_column& c) - { - return c.unequal (v); - } - - template - friend query_base - operator!= (const query_column& c, val_bind v) - { - return c.unequal (v); - } - - template - friend query_base - operator!= (val_bind v, const query_column& c) - { - return c.unequal (v); - } - - friend query_base - operator!= (const query_column& c, ref_bind r) - { - return c.unequal (r); - } - - friend query_base - operator!= (ref_bind r, const query_column& c) - { - return c.unequal (r); - } - - // < - // - public: - query_base - less (decayed_type v) const - { - return less (val_bind (v)); - } - - query_base - less (val_bind v) const - { - query_base q (table_, column_); - q += "<"; - q.append (v, conversion_); - return q; - } - - template - query_base - less (val_bind v) const - { - return less (val_bind (decayed_type (v.val))); - } - - query_base - less (ref_bind r) const - { - query_base q (table_, column_); - q += "<"; - q.append (r, conversion_); - return q; - } - - friend query_base - operator< (const query_column& c, decayed_type v) - { - return c.less (v); - } - - friend query_base - operator< (decayed_type v, const query_column& c) - { - return c.greater (v); - } - - friend query_base - operator< (const query_column& c, val_bind v) - { - return c.less (v); - } - - friend query_base - operator< (val_bind v, const query_column& c) - { - return c.greater (v); - } - - template - friend query_base - operator< (const query_column& c, val_bind v) - { - return c.less (v); - } - - template - friend query_base - operator< (val_bind v, const query_column& c) - { - return c.greater (v); - } - - friend query_base - operator< (const query_column& c, ref_bind r) - { - return c.less (r); - } - - friend query_base - operator< (ref_bind r, const query_column& c) - { - return c.greater (r); - } - - // > - // - public: - query_base - greater (decayed_type v) const - { - return greater (val_bind (v)); - } - - query_base - greater (val_bind v) const - { - query_base q (table_, column_); - q += ">"; - q.append (v, conversion_); - return q; - } - - template - query_base - greater (val_bind v) const - { - return greater (val_bind (decayed_type (v.val))); - } - - query_base - greater (ref_bind r) const - { - query_base q (table_, column_); - q += ">"; - q.append (r, conversion_); - return q; - } - - friend query_base - operator> (const query_column& c, decayed_type v) - { - return c.greater (v); - } - - friend query_base - operator> (decayed_type v, const query_column& c) - { - return c.less (v); - } - - friend query_base - operator> (const query_column& c, val_bind v) - { - return c.greater (v); - } - - friend query_base - operator> (val_bind v, const query_column& c) - { - return c.less (v); - } - - template - friend query_base - operator> (const query_column& c, val_bind v) - { - return c.greater (v); - } - - template - friend query_base - operator> (val_bind v, const query_column& c) - { - return c.less (v); - } - - friend query_base - operator> (const query_column& c, ref_bind r) - { - return c.greater (r); - } - - friend query_base - operator> (ref_bind r, const query_column& c) - { - return c.less (r); - } - - // <= - // - public: - query_base - less_equal (decayed_type v) const - { - return less_equal (val_bind (v)); - } - - query_base - less_equal (val_bind v) const - { - query_base q (table_, column_); - q += "<="; - q.append (v, conversion_); - return q; - } - - template - query_base - less_equal (val_bind v) const - { - return less_equal (val_bind (decayed_type (v.val))); - } - - query_base - less_equal (ref_bind r) const - { - query_base q (table_, column_); - q += "<="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator<= (const query_column& c, decayed_type v) - { - return c.less_equal (v); - } - - friend query_base - operator<= (decayed_type v, const query_column& c) - { - return c.greater_equal (v); - } - - friend query_base - operator<= (const query_column& c, val_bind v) - { - return c.less_equal (v); - } - - friend query_base - operator<= (val_bind v, const query_column& c) - { - return c.greater_equal (v); - } - - template - friend query_base - operator<= (const query_column& c, val_bind v) - { - return c.less_equal (v); - } - - template - friend query_base - operator<= (val_bind v, const query_column& c) - { - return c.greater_equal (v); - } - - friend query_base - operator<= (const query_column& c, ref_bind r) - { - return c.less_equal (r); - } - - friend query_base - operator<= (ref_bind r, const query_column& c) - { - return c.greater_equal (r); - } - - // >= - // - public: - query_base - greater_equal (decayed_type v) const - { - return greater_equal (val_bind (v)); - } - - query_base - greater_equal (val_bind v) const - { - query_base q (table_, column_); - q += ">="; - q.append (v, conversion_); - return q; - } - - template - query_base - greater_equal (val_bind v) const - { - return greater_equal (val_bind (decayed_type (v.val))); - } - - query_base - greater_equal (ref_bind r) const - { - query_base q (table_, column_); - q += ">="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator>= (const query_column& c, decayed_type v) - { - return c.greater_equal (v); - } - - friend query_base - operator>= (decayed_type v, const query_column& c) - { - return c.less_equal (v); - } - - friend query_base - operator>= (const query_column& c, val_bind v) - { - return c.greater_equal (v); - } - - friend query_base - operator>= (val_bind v, const query_column& c) - { - return c.less_equal (v); - } - - template - friend query_base - operator>= (const query_column& c, val_bind v) - { - return c.greater_equal (v); - } - - template - friend query_base - operator>= (val_bind v, const query_column& c) - { - return c.less_equal (v); - } - - friend query_base - operator>= (const query_column& c, ref_bind r) - { - return c.greater_equal (r); - } - - friend query_base - operator>= (ref_bind r, const query_column& c) - { - return c.less_equal (r); - } - - // Column comparison. - // - public: - template - query_base - operator== (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () == - decay_traits::instance ())); - - query_base q (table_, column_); - q += "="; - q.append (c.table (), c.column ()); - return q; - } - - template - query_base - operator!= (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () != - decay_traits::instance ())); - - query_base q (table_, column_); - q += "!="; - q.append (c.table (), c.column ()); - return q; - } - - template - query_base - operator< (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () < - decay_traits::instance ())); - - query_base q (table_, column_); - q += "<"; - q.append (c.table (), c.column ()); - return q; - } - - template - query_base - operator> (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () > - decay_traits::instance ())); - - query_base q (table_, column_); - q += ">"; - q.append (c.table (), c.column ()); - return q; - } - - template - query_base - operator<= (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () <= - decay_traits::instance ())); - - query_base q (table_, column_); - q += "<="; - q.append (c.table (), c.column ()); - return q; - } - - template - query_base - operator>= (const query_column& c) const - { - // We can compare columns only if we can compare their C++ types. - // - (void) (sizeof (decay_traits::instance () >= - decay_traits::instance ())); - - query_base q (table_, column_); - q += ">="; - q.append (c.table (), c.column ()); - return q; - } - }; - - // Provide operator+() for using columns to construct native - // query fragments (e.g., ORDER BY). - // - template - inline query_base - operator+ (const query_column& c, const std::string& s) - { - query_base q (c.table (), c.column ()); - q += s; - return q; - } - - template - inline query_base - operator+ (const std::string& s, const query_column& c) - { - query_base q (s); - q.append (c.table (), c.column ()); - return q; - } - - template - inline query_base - operator+ (const query_column& c, const query_base& q) - { - query_base r (c.table (), c.column ()); - r += q; - return r; - } - - template - inline query_base - operator+ (const query_base& q, const query_column& c) - { - query_base r (q); - r.append (c.table (), c.column ()); - return r; - } - - // - // - template - struct query_param_impl; - - // INTEGER - // - template - struct query_param_impl: query_param - { - query_param_impl (ref_bind r) : query_param (r.ptr ()) {} - query_param_impl (val_bind v) : query_param (0) {init (v.val);} - - virtual bool - init () - { - init (*static_cast (value_)); - return false; - } - - virtual void - bind (sqlite::bind* b) - { - b->type = sqlite::bind::integer; - b->buffer = &image_; - } - - private: - void - init (typename decay_traits::type v) - { - bool is_null (false); // Can't be NULL. - value_traits::set_image (image_, is_null, v); - } - - private: - long long image_; - }; - - // REAL - // - template - struct query_param_impl: query_param - { - query_param_impl (ref_bind r) : query_param (r.ptr ()) {} - query_param_impl (val_bind v) : query_param (0) {init (v.val);} - - virtual bool - init () - { - init (*static_cast (value_)); - return false; - } - - virtual void - bind (sqlite::bind* b) - { - b->type = sqlite::bind::real; - b->buffer = &image_; - } - - private: - void - init (typename decay_traits::type v) - { - bool is_null (false); // Can't be NULL. - value_traits::set_image (image_, is_null, v); - } - - private: - double image_; - }; - - // TEXT - // - template - struct query_param_impl: query_param - { - query_param_impl (ref_bind r) : query_param (r.ptr ()) {} - query_param_impl (val_bind v) : query_param (0) {init (v.val);} - - virtual bool - init () - { - return init (*static_cast (value_)); - } - - virtual void - bind (sqlite::bind* b) - { - b->type = image_traits::bind_value; - b->buffer = buffer_.data (); - b->size = &size_; - } - - private: - bool - init (typename decay_traits::type v) - { - bool is_null (false); // Can't be NULL. - std::size_t cap (buffer_.capacity ()); - value_traits::set_image (buffer_, size_, is_null, v); - return cap != buffer_.capacity (); - } - - private: - details::buffer buffer_; - std::size_t size_; - }; - - // BLOB - // - template - struct query_param_impl: query_param - { - query_param_impl (ref_bind r) : query_param (r.ptr ()) {} - query_param_impl (val_bind v) : query_param (0) {init (v.val);} - - virtual bool - init () - { - return init (*static_cast (value_)); - } - - virtual void - bind (sqlite::bind* b) - { - b->type = sqlite::bind::blob; - b->buffer = buffer_.data (); - b->size = &size_; - } - - private: - bool - init (typename decay_traits::type v) - { - bool is_null (false); // Can't be NULL. - std::size_t cap (buffer_.capacity ()); - value_traits::set_image (buffer_, size_, is_null, v); - return cap != buffer_.capacity (); - } - - private: - details::buffer buffer_; - std::size_t size_; - }; - - // TEXT STREAM (reduce to id_text). - // - template - struct query_param_impl: query_param_impl - { - query_param_impl (ref_bind r) : query_param_impl (r) {} - query_param_impl (val_bind v) : query_param_impl (v) {} - }; - - // BLOB STREAM (reduce to id_blob). - // - template - struct query_param_impl: query_param_impl - { - query_param_impl (ref_bind r) : query_param_impl (r) {} - query_param_impl (val_bind v) : query_param_impl (v) {} - }; - } -} - -// odb::sqlite::query and odb::query specialization for SQLite. -// -namespace odb -{ - namespace sqlite - { - template - class query: public query_base, - public query_selector::columns_type - { - public: - // We don't define any typedefs here since they may clash with - // column names defined by our base type. - // - - query () - { - } - - explicit - query (bool v) - : query_base (v) - { - } - - explicit - query (const char* q) - : query_base (q) - { - } - - explicit - query (const std::string& q) - : query_base (q) - { - } - - template - explicit - query (val_bind v) - : query_base (v) - { - } - - template - explicit - query (ref_bind r) - : query_base (r) - { - } - - query (const query_base& q) - : query_base (q) - { - } - - template - query (const query_column& qc) - : query_base (qc) - { - } - - query (const odb::query_base& q) - : query_base (q) - { - } - }; - - namespace core - { - using sqlite::query; - } - } - - // Derive odb::query from odb::sqlite::query so that it can be - // implicitly converted in sqlite::database::query() calls. - // - template - class query: public sqlite::query - { - public: - // We don't define any typedefs here since they may clash with - // column names defined by our base type. - // - - query () - { - } - - explicit - query (bool v) - : sqlite::query (v) - { - } - - explicit - query (const char* q) - : sqlite::query (q) - { - } - - explicit - query (const std::string& q) - : sqlite::query (q) - { - } - - template - explicit - query (sqlite::val_bind v) - : sqlite::query (v) - { - } - - template - explicit - query (sqlite::ref_bind r) - : sqlite::query (r) - { - } - - query (const sqlite::query_base& q) - : sqlite::query (q) - { - } - - template - query (const sqlite::query_column& qc) - : sqlite::query (qc) - { - } - }; -} - -#include -#include - -#include - -#endif // ODB_SQLITE_QUERY_HXX diff --git a/odb/sqlite/query.ixx b/odb/sqlite/query.ixx deleted file mode 100644 index 00e9b66..0000000 --- a/odb/sqlite/query.ixx +++ /dev/null @@ -1,46 +0,0 @@ -// file : odb/sqlite/query.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - inline void query_base:: - init_parameters () const - { - return parameters_->init (); - } - - inline binding& query_base:: - parameters_binding () const - { - return parameters_->binding (); - } - - inline const details::shared_ptr& query_base:: - parameters () const - { - return parameters_; - } - - template - inline void query_base:: - append (val_bind v, const char* conv) - { - append ( - details::shared_ptr ( - new (details::shared) query_param_impl (v)), - conv); - } - - template - inline void query_base:: - append (ref_bind r, const char* conv) - { - append ( - details::shared_ptr ( - new (details::shared) query_param_impl (r)), - conv); - } - } -} diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx deleted file mode 100644 index f381ff0..0000000 --- a/odb/sqlite/query.txx +++ /dev/null @@ -1,168 +0,0 @@ -// file : odb/sqlite/query.txx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - // - // query_base - // - - template - query_base:: - query_base (const query_column& c) - : parameters_ (new (details::shared) query_params) - { - // Cannot use IS TRUE here since database type can be a non- - // integral type. - // - append (c.table (), c.column ()); - append ("="); - append (val_bind (true), c.conversion ()); - } - - // - // query_column - // - - // in - // - template - query_base query_column:: - in (decayed_type v1, decayed_type v2) const - { - query_base q (table_, column_); - q += "IN ("; - q.append (val_bind (v1), conversion_); - q += ","; - q.append (val_bind (v2), conversion_); - q += ")"; - return q; - } - - template - query_base query_column:: - in (decayed_type v1, decayed_type v2, decayed_type v3) const - { - query_base q (table_, column_); - q += "IN ("; - q.append (val_bind (v1), conversion_); - q += ","; - q.append (val_bind (v2), conversion_); - q += ","; - q.append (val_bind (v3), conversion_); - q += ")"; - return q; - } - - template - query_base query_column:: - in (decayed_type v1, decayed_type v2, decayed_type v3, - decayed_type v4) const - { - query_base q (table_, column_); - q += "IN ("; - q.append (val_bind (v1), conversion_); - q += ","; - q.append (val_bind (v2), conversion_); - q += ","; - q.append (val_bind (v3), conversion_); - q += ","; - q.append (val_bind (v4), conversion_); - q += ")"; - return q; - } - - template - query_base query_column:: - in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4, - decayed_type v5) const - { - query_base q (table_, column_); - q += "IN ("; - q.append (val_bind (v1), conversion_); - q += ","; - q.append (val_bind (v2), conversion_); - q += ","; - q.append (val_bind (v3), conversion_); - q += ","; - q.append (val_bind (v4), conversion_); - q += ","; - q.append (val_bind (v5), conversion_); - q += ")"; - return q; - } - - template - template - query_base query_column:: - in_range (I begin, I end) const - { - if (begin != end) - { - query_base q (table_, column_); - q += "IN ("; - - for (I i (begin); i != end; ++i) - { - if (i != begin) - q += ","; - - q.append (val_bind (*i), conversion_); - } - - q += ")"; - return q; - } - else - return query_base (false); - } - - // like - // - template - query_base query_column:: - like (val_bind p) const - { - query_base q (table_, column_); - q += "LIKE"; - q.append (p, conversion_); - return q; - } - - template - query_base query_column:: - like (ref_bind p) const - { - query_base q (table_, column_); - q += "LIKE"; - q.append (p, conversion_); - return q; - } - - template - query_base query_column:: - like (val_bind p, decayed_type e) const - { - query_base q (table_, column_); - q += "LIKE"; - q.append (p, conversion_); - q += "ESCAPE"; - q.append (val_bind (e), conversion_); - return q; - } - - template - query_base query_column:: - like (ref_bind p, decayed_type e) const - { - query_base q (table_, column_); - q += "LIKE"; - q.append (p, conversion_); - q += "ESCAPE"; - q.append (val_bind (e), conversion_); - return q; - } - } -} diff --git a/odb/sqlite/section-statements.hxx b/odb/sqlite/section-statements.hxx deleted file mode 100644 index e6a5da6..0000000 --- a/odb/sqlite/section-statements.hxx +++ /dev/null @@ -1,198 +0,0 @@ -// file : odb/sqlite/section-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_SECTION_STATEMENTS_HXX -#define ODB_SQLITE_SECTION_STATEMENTS_HXX - -#include - -#include // std::size_t - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - class connection; - - // Template argument is the section traits type. - // - template - class section_statements - { - public: - typedef ST traits; - - typedef typename traits::image_type image_type; - typedef typename traits::id_image_type id_image_type; - - typedef sqlite::select_statement select_statement_type; - typedef sqlite::update_statement update_statement_type; - - typedef sqlite::connection connection_type; - - section_statements (connection_type&, - image_type&, id_image_type&, - binding& id, binding& idv); - - connection_type& - connection () {return conn_;} - - const schema_version_migration& - version_migration (const char* name = "") const - { - if (svm_ == 0) - svm_ = &conn_.database ().schema_version_migration (name); - - return *svm_; - } - - image_type& - image () {return image_;} - - const binding& - id_binding () {return id_binding_;} - - // Id and optimistic concurrency version (if any). - // - const binding& - idv_binding () {return idv_binding_;} - - // Select binding. - // - std::size_t - select_image_version () const { return select_image_version_;} - - void - select_image_version (std::size_t v) {select_image_version_ = v;} - - binding& - select_image_binding () {return select_image_binding_;} - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Update binding. - // - std::size_t - update_image_version () const { return update_image_version_;} - - void - update_image_version (std::size_t v) {update_image_version_ = v;} - - std::size_t - update_id_binding_version () const { return update_id_binding_version_;} - - void - update_id_binding_version (std::size_t v) {update_id_binding_version_ = v;} - - binding& - update_image_binding () {return update_image_binding_;} - - // - // Statements. - // - - select_statement_type& - select_statement () - { - if (select_ == 0) - select_.reset ( - new (details::shared) select_statement_type ( - conn_, - traits::select_statement, - traits::versioned, // Process if versioned. - false, // Don't optimize. - id_binding_, - select_image_binding_)); - - return *select_; - } - - update_statement_type& - update_statement () - { - if (update_ == 0) - update_.reset ( - new (details::shared) update_statement_type ( - conn_, - traits::update_statement, - traits::versioned, // Process if versioned. - update_image_binding_)); - - return *update_; - } - - public: - static const std::size_t id_column_count = traits::id_column_count; - static const std::size_t managed_optimistic_load_column_count = - traits::managed_optimistic_load_column_count; - static const std::size_t managed_optimistic_update_column_count = - traits::managed_optimistic_update_column_count; - static const std::size_t select_column_count = traits::load_column_count; - static const std::size_t update_column_count = - traits::update_column_count; - - private: - section_statements (const section_statements&); - section_statements& operator= (const section_statements&); - - protected: - connection_type& conn_; - mutable const schema_version_migration* svm_; - - // These come from object_statements. - // - image_type& image_; - binding& id_binding_; - binding& idv_binding_; - - // Select binding. - // - std::size_t select_image_version_; - - static const std::size_t select_bind_count = - select_column_count != 0 || managed_optimistic_load_column_count != 0 - ? select_column_count + managed_optimistic_load_column_count - : 1; - - binding select_image_binding_; - bind select_image_bind_[select_bind_count]; - bool select_image_truncated_[select_bind_count]; - - // Update binding. - // - std::size_t update_image_version_; - std::size_t update_id_binding_version_; - - static const std::size_t update_bind_count = - update_column_count != 0 || managed_optimistic_update_column_count != 0 - ? update_column_count + id_column_count + - managed_optimistic_update_column_count - : 1; - - binding update_image_binding_; - bind update_image_bind_[update_bind_count]; - - details::shared_ptr select_; - details::shared_ptr update_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_SECTION_STATEMENTS_HXX diff --git a/odb/sqlite/section-statements.txx b/odb/sqlite/section-statements.txx deleted file mode 100644 index ff588b3..0000000 --- a/odb/sqlite/section-statements.txx +++ /dev/null @@ -1,40 +0,0 @@ -// file : odb/sqlite/section-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::memset - -namespace odb -{ - namespace sqlite - { - template - section_statements:: - section_statements (connection_type& conn, - image_type& im, id_image_type&, - binding& id, binding& idv) - : conn_ (conn), - svm_ (0), - image_ (im), - id_binding_ (id), - idv_binding_ (idv), - select_image_binding_ (select_image_bind_, - select_column_count + - managed_optimistic_load_column_count), - update_image_binding_ (update_image_bind_, - update_column_count + id_column_count + - managed_optimistic_update_column_count) - { - select_image_version_ = 0; - update_image_version_ = 0; - update_id_binding_version_ = 0; - - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - - for (std::size_t i (0); i < select_bind_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - } -} diff --git a/odb/sqlite/simple-object-result.hxx b/odb/sqlite/simple-object-result.hxx deleted file mode 100644 index d68af8e..0000000 --- a/odb/sqlite/simple-object-result.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : odb/sqlite/simple-object-result.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX -#define ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include // query_base, query_params -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class object_result_impl: public odb::object_result_impl - { - public: - typedef odb::object_result_impl base_type; - - typedef typename base_type::id_type id_type; - typedef typename base_type::object_type object_type; - typedef typename base_type::pointer_type pointer_type; - - typedef object_traits_impl object_traits; - typedef typename base_type::pointer_traits pointer_traits; - - typedef typename object_traits::statements_type statements_type; - - virtual - ~object_result_impl (); - - object_result_impl (const query_base&, - const details::shared_ptr&, - statements_type&, - const schema_version_migration*); - - virtual void - load (object_type&, bool fetch); - - virtual id_type - load_id (); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - virtual void - invalidate (); - - using base_type::current; - - private: - void - load_image (); - - private: - // We need to hold on to the query parameters because SQLite uses - // the parameter buffers to find each next row. - // - details::shared_ptr params_; - details::shared_ptr statement_; - statements_type& statements_; - object_traits_calls tc_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX diff --git a/odb/sqlite/simple-object-result.txx b/odb/sqlite/simple-object-result.txx deleted file mode 100644 index f27b226..0000000 --- a/odb/sqlite/simple-object-result.txx +++ /dev/null @@ -1,158 +0,0 @@ -// file : odb/sqlite/simple-object-result.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include -#include // result_not_cached - -#include - -namespace odb -{ - namespace sqlite - { - template - object_result_impl:: - ~object_result_impl () - { - if (!this->end_) - statement_->free_result (); - } - - template - void object_result_impl:: - invalidate () - { - if (!this->end_) - { - statement_->free_result (); - this->end_ = true; - } - - params_.reset (); - statement_.reset (); - } - - template - object_result_impl:: - object_result_impl (const query_base& q, - const details::shared_ptr& s, - statements_type& sts, - const schema_version_migration* svm) - : base_type (sts.connection ()), - params_ (q.parameters ()), - statement_ (s), - statements_ (sts), - tc_ (svm) - { - } - - template - void object_result_impl:: - load (object_type& obj, bool fetch) - { - if (fetch) - load_image (); - - // This is a top-level call so the statements cannot be locked. - // - assert (!statements_.locked ()); - typename statements_type::auto_lock l (statements_); - - object_traits::callback (this->db_, obj, callback_event::pre_load); - - typename object_traits::image_type& i (statements_.image ()); - tc_.init (obj, i, &this->db_); - - // Initialize the id image and binding and load the rest of the object - // (containers, etc). - // - typename object_traits::id_image_type& idi (statements_.id_image ()); - object_traits::init (idi, object_traits::id (i)); - - binding& idb (statements_.id_image_binding ()); - if (idi.version != statements_.id_image_version () || idb.version == 0) - { - object_traits::bind (idb.bind, idi); - statements_.id_image_version (idi.version); - idb.version++; - } - - tc_.load_ (statements_, obj, false); - statements_.load_delayed (tc_.version ()); - l.unlock (); - object_traits::callback (this->db_, obj, callback_event::post_load); - } - - template - typename object_result_impl::id_type - object_result_impl:: - load_id () - { - load_image (); - return object_traits::id (statements_.image ()); - } - - template - void object_result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - void object_result_impl:: - load_image () - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename object_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - tc_.bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (tc_.grow (im, statements_.select_image_truncated ())) - im.version++; - - if (im.version != statements_.select_image_version ()) - { - binding& b (statements_.select_image_binding ()); - tc_.bind (b.bind, im, statement_select); - statements_.select_image_version (im.version); - b.version++; - statement_->reload (); - } - } - } - - template - void object_result_impl:: - cache () - { - } - - template - std::size_t object_result_impl:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/simple-object-statements.cxx b/odb/sqlite/simple-object-statements.cxx deleted file mode 100644 index 1eb07db..0000000 --- a/odb/sqlite/simple-object-statements.cxx +++ /dev/null @@ -1,15 +0,0 @@ -// file : odb/sqlite/simple-object-statements.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - namespace sqlite - { - object_statements_base:: - ~object_statements_base () - { - } - } -} diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx deleted file mode 100644 index b60fe6c..0000000 --- a/odb/sqlite/simple-object-statements.hxx +++ /dev/null @@ -1,591 +0,0 @@ -// file : odb/sqlite/simple-object-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX -#define ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX - -#include - -#include -#include -#include // std::size_t - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - // The extra_statement_cache class is only defined (and used) in - // the generated source file. However, object_statements may be - // referenced from another source file in the case of a polymorphic - // hierarchy (though in this case the extra statement cache is - // not used). As a result, we cannot have a by-value member and - // instead will store a pointer and lazily allocate the cache if - // and when needed. We will also need to store a pointer to the - // deleter function which will be initialized during allocation - // (at that point we know that the cache class is defined). - // - template - struct extra_statement_cache_ptr - { - typedef I image_type; - typedef ID id_image_type; - typedef sqlite::connection connection_type; - - extra_statement_cache_ptr (): p_ (0) {} - ~extra_statement_cache_ptr () - { - if (p_ != 0) - (this->*deleter_) (0, 0, 0, 0, 0); - } - - T& - get (connection_type& c, - image_type& im, id_image_type& idim, - binding& id, binding* idv) - { - if (p_ == 0) - allocate (&c, &im, &idim, &id, (idv != 0 ? idv : &id)); - - return *p_; - } - - private: - void - allocate (connection_type*, - image_type*, id_image_type*, - binding*, binding*); - - private: - T* p_; - void (extra_statement_cache_ptr::*deleter_) ( - connection_type*, image_type*, id_image_type*, binding*, binding*); - }; - - template - void extra_statement_cache_ptr:: - allocate (connection_type* c, - image_type* im, id_image_type* idim, - binding* id, binding* idv) - { - // To reduce object code size, this function acts as both allocator - // and deleter. - // - if (p_ == 0) - { - p_ = new T (*c, *im, *idim, *id, *idv); - deleter_ = &extra_statement_cache_ptr::allocate; - } - else - delete p_; - } - - // - // Implementation for objects with object id. - // - - class LIBODB_SQLITE_EXPORT object_statements_base: public statements_base - { - public: - // Locking. - // - void - lock () - { - assert (!locked_); - locked_ = true; - } - - void - unlock () - { - assert (locked_); - locked_ = false; - } - - bool - locked () const - { - return locked_; - } - - struct auto_unlock - { - // Unlocks the statement on construction and re-locks it on - // destruction. - // - auto_unlock (object_statements_base&); - ~auto_unlock (); - - private: - auto_unlock (const auto_unlock&); - auto_unlock& operator= (const auto_unlock&); - - private: - object_statements_base& s_; - }; - - public: - virtual - ~object_statements_base (); - - protected: - object_statements_base (connection_type& conn) - : statements_base (conn), locked_ (false) - { - } - - protected: - bool locked_; - }; - - template - struct optimistic_data; - - template - struct optimistic_data - { - typedef T object_type; - typedef object_traits_impl object_traits; - - optimistic_data (bind*); - - binding* - id_image_binding () {return &id_image_binding_;} - - // The id + optimistic column binding. - // - binding id_image_binding_; - - details::shared_ptr erase_; - }; - - template - struct optimistic_data - { - optimistic_data (bind*) {} - - binding* - id_image_binding () {return 0;} - }; - - template - class object_statements: public object_statements_base - { - public: - typedef T object_type; - typedef object_traits_impl object_traits; - typedef typename object_traits::id_type id_type; - typedef typename object_traits::pointer_type pointer_type; - typedef typename object_traits::image_type image_type; - typedef typename object_traits::id_image_type id_image_type; - - typedef - typename object_traits::pointer_cache_traits - pointer_cache_traits; - - typedef - typename object_traits::extra_statement_cache_type - extra_statement_cache_type; - - typedef sqlite::insert_statement insert_statement_type; - typedef sqlite::select_statement select_statement_type; - typedef sqlite::update_statement update_statement_type; - typedef sqlite::delete_statement delete_statement_type; - - // Automatic lock. - // - struct auto_lock - { - // Lock the statements unless they are already locked in which - // case subsequent calls to locked() will return false. - // - auto_lock (object_statements&); - - // Unlock the statemens if we are holding the lock and clear - // the delayed loads. This should only happen in case an - // exception is thrown. In normal circumstances, the user - // should call unlock() explicitly. - // - ~auto_lock (); - - // Return true if this auto_lock instance holds the lock. - // - bool - locked () const; - - // Unlock the statemens. - // - void - unlock (); - - private: - auto_lock (const auto_lock&); - auto_lock& operator= (const auto_lock&); - - private: - object_statements& s_; - bool locked_; - }; - - - public: - object_statements (connection_type&); - - virtual - ~object_statements (); - - // Delayed loading. - // - typedef void (*loader_function) (odb::database&, - const id_type&, - object_type&, - const schema_version_migration*); - - void - delay_load (const id_type& id, - object_type& obj, - const typename pointer_cache_traits::position_type& p, - loader_function l = 0) - { - delayed_.push_back (delayed_load (id, obj, p, l)); - } - - void - load_delayed (const schema_version_migration* svm) - { - assert (locked ()); - - if (!delayed_.empty ()) - load_delayed_ (svm); - } - - void - clear_delayed () - { - if (!delayed_.empty ()) - clear_delayed_ (); - } - - // Object image. - // - image_type& - image () {return image_;} - - // Insert binding. - // - std::size_t - insert_image_version () const { return insert_image_version_;} - - void - insert_image_version (std::size_t v) {insert_image_version_ = v;} - - binding& - insert_image_binding () {return insert_image_binding_;} - - // Update binding. - // - std::size_t - update_image_version () const { return update_image_version_;} - - void - update_image_version (std::size_t v) {update_image_version_ = v;} - - std::size_t - update_id_image_version () const { return update_id_image_version_;} - - void - update_id_image_version (std::size_t v) {update_id_image_version_ = v;} - - binding& - update_image_binding () {return update_image_binding_;} - - // Select binding. - // - std::size_t - select_image_version () const { return select_image_version_;} - - void - select_image_version (std::size_t v) {select_image_version_ = v;} - - binding& - select_image_binding () {return select_image_binding_;} - - bool* - select_image_truncated () {return select_image_truncated_;} - - // Object id image and binding. - // - id_image_type& - id_image () {return id_image_;} - - std::size_t - id_image_version () const {return id_image_version_;} - - void - id_image_version (std::size_t v) {id_image_version_ = v;} - - binding& - id_image_binding () {return id_image_binding_;} - - // Optimistic id + managed column image binding. It points to - // the same suffix as id binding and they are always updated - // at the same time. - // - binding& - optimistic_id_image_binding () {return od_.id_image_binding_;} - - // Statements. - // - insert_statement_type& - persist_statement () - { - if (persist_ == 0) - { - persist_.reset ( - new (details::shared) insert_statement_type ( - conn_, - object_traits::persist_statement, - object_traits::versioned, // Process if versioned. - insert_image_binding_, - (object_traits::auto_id ? &id_image_binding_ : 0))); - } - - return *persist_; - } - - select_statement_type& - find_statement () - { - if (find_ == 0) - { - find_.reset ( - new (details::shared) select_statement_type ( - conn_, - object_traits::find_statement, - object_traits::versioned, // Process if versioned. - false, // Don't optimize. - id_image_binding_, - select_image_binding_)); - } - - return *find_; - } - - update_statement_type& - update_statement () - { - if (update_ == 0) - { - update_.reset ( - new (details::shared) update_statement_type ( - conn_, - object_traits::update_statement, - object_traits::versioned, // Process if versioned. - update_image_binding_)); - } - - return *update_; - } - - delete_statement_type& - erase_statement () - { - if (erase_ == 0) - { - erase_.reset ( - new (details::shared) delete_statement_type ( - conn_, - object_traits::erase_statement, - id_image_binding_)); - } - - return *erase_; - } - - delete_statement_type& - optimistic_erase_statement () - { - if (od_.erase_ == 0) - { - od_.erase_.reset ( - new (details::shared) delete_statement_type ( - conn_, - object_traits::optimistic_erase_statement, - od_.id_image_binding_)); - } - - return *od_.erase_; - } - - // Extra (container, section) statement cache. - // - extra_statement_cache_type& - extra_statement_cache () - { - return extra_statement_cache_.get ( - conn_, - image_, id_image_, - id_image_binding_, od_.id_image_binding ()); - } - - public: - // select = total - separate_load - // insert = total - inverse - managed_optimistic - // update = total - inverse - managed_optimistic - id - readonly - // - separate_update - // - static const std::size_t id_column_count = - object_traits::id_column_count; - - static const std::size_t managed_optimistic_column_count = - object_traits::managed_optimistic_column_count; - - static const std::size_t select_column_count = - object_traits::column_count - - object_traits::separate_load_column_count; - - static const std::size_t insert_column_count = - object_traits::column_count - - object_traits::inverse_column_count - - object_traits::managed_optimistic_column_count; - - static const std::size_t update_column_count = - insert_column_count - - id_column_count - - object_traits::readonly_column_count - - object_traits::separate_update_column_count; - - private: - object_statements (const object_statements&); - object_statements& operator= (const object_statements&); - - protected: - template - void - load_delayed_ (const schema_version_migration*); - - void - clear_delayed_ (); - - protected: - template - friend class polymorphic_derived_object_statements; - - extra_statement_cache_ptr extra_statement_cache_; - - image_type image_; - - // Select binding. - // - std::size_t select_image_version_; - binding select_image_binding_; - bind select_image_bind_[select_column_count]; - bool select_image_truncated_[select_column_count]; - - // Insert binding. - // - std::size_t insert_image_version_; - binding insert_image_binding_; - bind insert_image_bind_[insert_column_count]; - - // Update binding. Note that the id suffix is bound to id_image_ - // below instead of image_ which makes this binding effectively - // bound to two images. As a result, we have to track versions - // for both of them. If this object uses optimistic concurrency, - // then the binding for the managed column (version, timestamp, - // etc) comes after the id and the image for such a column is - // stored as part of the id image. - // - std::size_t update_image_version_; - std::size_t update_id_image_version_; - binding update_image_binding_; - bind update_image_bind_[update_column_count + id_column_count + - managed_optimistic_column_count]; - - // Id image binding (only used as a parameter). Uses the suffix in - // the update bind. - // - id_image_type id_image_; - std::size_t id_image_version_; - binding id_image_binding_; - - // Extra data for objects with optimistic concurrency support. - // - optimistic_data od_; - - details::shared_ptr persist_; - details::shared_ptr find_; - details::shared_ptr update_; - details::shared_ptr erase_; - - // Delayed loading. - // - struct delayed_load - { - typedef typename pointer_cache_traits::position_type position_type; - - delayed_load () {} - delayed_load (const id_type& i, - object_type& o, - const position_type& p, - loader_function l) - : id (i), obj (&o), pos (p), loader (l) - { - } - - id_type id; - object_type* obj; - position_type pos; - loader_function loader; - }; - - typedef std::vector delayed_loads; - delayed_loads delayed_; - - // Delayed vectors swap guard. See the load_delayed_() function for - // details. - // - struct swap_guard - { - swap_guard (object_statements& os, delayed_loads& dl) - : os_ (os), dl_ (dl) - { - dl_.swap (os_.delayed_); - } - - ~swap_guard () - { - os_.clear_delayed (); - dl_.swap (os_.delayed_); - } - - private: - object_statements& os_; - delayed_loads& dl_; - }; - }; - } -} - -#include -#include - -#include - -#endif // ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX diff --git a/odb/sqlite/simple-object-statements.ixx b/odb/sqlite/simple-object-statements.ixx deleted file mode 100644 index 6756c06..0000000 --- a/odb/sqlite/simple-object-statements.ixx +++ /dev/null @@ -1,68 +0,0 @@ -// file : odb/sqlite/simple-object-statements.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace sqlite - { - // - // auto_unlock - // - inline object_statements_base::auto_unlock:: - auto_unlock (object_statements_base& s) - : s_ (s) - { - s_.unlock (); - } - - inline object_statements_base::auto_unlock:: - ~auto_unlock () - { - s_.lock (); - } - - // - // auto_lock - // - template - inline object_statements::auto_lock:: - auto_lock (object_statements& s) - : s_ (s) - { - if (!s_.locked ()) - { - s_.lock (); - locked_ = true; - } - else - locked_ = false; - } - - template - inline object_statements::auto_lock:: - ~auto_lock () - { - if (locked_) - { - s_.unlock (); - s_.clear_delayed (); - } - } - - template - inline bool object_statements::auto_lock:: - locked () const - { - return locked_; - } - - template - inline void object_statements::auto_lock:: - unlock () - { - assert (locked_); - s_.unlock (); - locked_ = false; - } - } -} diff --git a/odb/sqlite/simple-object-statements.txx b/odb/sqlite/simple-object-statements.txx deleted file mode 100644 index b80944d..0000000 --- a/odb/sqlite/simple-object-statements.txx +++ /dev/null @@ -1,146 +0,0 @@ -// file : odb/sqlite/simple-object-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::memset - -#include -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // optimistic_data - // - - template - optimistic_data:: - optimistic_data (bind* b) - : id_image_binding_ ( - b, - object_traits::id_column_count + - object_traits::managed_optimistic_column_count) - { - } - - // - // object_statements - // - - template - object_statements:: - ~object_statements () - { - } - - template - object_statements:: - object_statements (connection_type& conn) - : object_statements_base (conn), - select_image_binding_ (select_image_bind_, select_column_count), - insert_image_binding_ (insert_image_bind_, insert_column_count), - update_image_binding_ (update_image_bind_, - update_column_count + id_column_count + - managed_optimistic_column_count), - id_image_binding_ (update_image_bind_ + update_column_count, - id_column_count), - od_ (update_image_bind_ + update_column_count) - { - image_.version = 0; - select_image_version_ = 0; - insert_image_version_ = 0; - update_image_version_ = 0; - update_id_image_version_ = 0; - - id_image_.version = 0; - id_image_version_ = 0; - - std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); - std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); - std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); - std::memset ( - select_image_truncated_, 0, sizeof (select_image_truncated_)); - - for (std::size_t i (0); i < select_column_count; ++i) - select_image_bind_[i].truncated = select_image_truncated_ + i; - } - - template - template - void object_statements:: - load_delayed_ (const schema_version_migration* svm) - { - database& db (connection ().database ()); - - delayed_loads dls; - swap_guard sg (*this, dls); - - while (!dls.empty ()) - { - delayed_load l (dls.back ()); - typename pointer_cache_traits::insert_guard ig (l.pos); - dls.pop_back (); - - if (l.loader == 0) - { - object_traits_calls tc (svm); - - if (!tc.find_ (static_cast (*this), &l.id)) - throw object_not_persistent (); - - object_traits::callback (db, *l.obj, callback_event::pre_load); - - // Our calls to init/load below can result in additional delayed - // loads being added to the delayed_ vector. We need to process - // those before we call the post callback. - // - tc.init (*l.obj, image (), &db); - - // Load containers, etc. - // - tc.load_ (static_cast (*this), *l.obj, false); - - if (!delayed_.empty ()) - load_delayed_ (svm); - - // Temporarily unlock the statement for the post_load call so that - // it can load objects of this type recursively. This is safe to do - // because we have completely loaded the current object. Also the - // delayed_ list is clear before the unlock and should be clear on - // re-lock (since a callback can only call public API functions - // which will make sure all the delayed loads are processed before - // returning). - // - { - auto_unlock u (*this); - object_traits::callback (db, *l.obj, callback_event::post_load); - } - } - else - l.loader (db, l.id, *l.obj, svm); - - pointer_cache_traits::load (ig.position ()); - ig.release (); - } - } - - template - void object_statements:: - clear_delayed_ () - { - // Remove the objects from the session cache. - // - for (typename delayed_loads::iterator i (delayed_.begin ()), - e (delayed_.end ()); i != e; ++i) - { - pointer_cache_traits::erase (i->pos); - } - - delayed_.clear (); - } - } -} diff --git a/odb/sqlite/sqlite-types.hxx b/odb/sqlite/sqlite-types.hxx deleted file mode 100644 index b9839bf..0000000 --- a/odb/sqlite/sqlite-types.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : odb/sqlite/sqlite-types.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_SQLITE_TYPES_HXX -#define ODB_SQLITE_SQLITE_TYPES_HXX - -#include - -#include -#include // std::size_t - -namespace odb -{ - namespace sqlite - { - // The SQLite parameter/result binding. This data structures is modelled - // after MYSQL_BIND from MySQL. - // - struct bind - { - enum buffer_type - { - integer, // Buffer is long long; size, capacity, truncated are unused. - real, // Buffer is double; size, capacity, truncated are unused. - text, // Buffer is a UTF-8 char array. - text16, // Buffer is a UTF-16 2-byte char array (sizes in bytes). - blob, // Buffer is a char array. - stream // Buffer is stream_buffers. Size specifies the BLOB size - // (input only). Capacity and truncated unused. - }; - - buffer_type type; - void* buffer; - std::size_t* size; - std::size_t capacity; - bool* is_null; - bool* truncated; - }; - - // The "out" values should be set in set_image() to point to - // variables that will be receiving the data. The "in" values - // are used in set_value() and contain the data that needs to - // be copied over. - // - struct stream_buffers - { - union {std::string* out; const char* in;} db; - union {std::string* out; const char* in;} table; - union {std::string* out; const char* in;} column; - union {long long* out; long long in;} rowid; - }; - } -} - -#include - -#endif // ODB_SQLITE_SQLITE_TYPES_HXX diff --git a/odb/sqlite/statement-cache.hxx b/odb/sqlite/statement-cache.hxx deleted file mode 100644 index 31ca685..0000000 --- a/odb/sqlite/statement-cache.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : odb/sqlite/statement-cache.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_STATEMENT_CACHE_HXX -#define ODB_SQLITE_STATEMENT_CACHE_HXX - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - class LIBODB_SQLITE_EXPORT statement_cache - { - public: - statement_cache (connection& conn) - : conn_ (conn), - version_seq_ (conn_.database ().schema_version_sequence ()) {} - - template - typename object_traits_impl::statements_type& - find_object (); - - template - view_statements& - find_view (); - - private: - typedef std::map, - details::type_info_comparator> map; - - connection& conn_; - unsigned int version_seq_; - map map_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_STATEMENT_CACHE_HXX diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx deleted file mode 100644 index c089e32..0000000 --- a/odb/sqlite/statement-cache.txx +++ /dev/null @@ -1,60 +0,0 @@ -// file : odb/sqlite/statement-cache.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - namespace sqlite - { - template - typename object_traits_impl::statements_type& - statement_cache:: - find_object () - { - typedef - typename object_traits_impl::statements_type - statements_type; - - // Clear the cache if the database version has changed. This - // makes sure we don't re-use statements that correspond to - // the old schema. - // - if (version_seq_ != conn_.database ().schema_version_sequence ()) - { - map_.clear (); - version_seq_ = conn_.database ().schema_version_sequence (); - } - - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast (*i->second); - - details::shared_ptr p ( - new (details::shared) statements_type (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } - - template - view_statements& statement_cache:: - find_view () - { - // We don't cache any statements for views so no need to clear - // the cache. - - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast&> (*i->second); - - details::shared_ptr > p ( - new (details::shared) view_statements (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } - } -} diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx deleted file mode 100644 index b1b0f58..0000000 --- a/odb/sqlite/statement.cxx +++ /dev/null @@ -1,988 +0,0 @@ -// file : odb/sqlite/statement.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include // object_not_persistent - -#include -#include -#include -#include - -#include // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - // LIBODB_SQLITE_HAVE_COLUMN_METADATA -using namespace std; - -namespace odb -{ - namespace sqlite - { - // statement - // - - statement:: - ~statement () - { - if (stmt_ != 0) - { - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->deallocate (conn_, *this); - } - - if (next_ != this) - list_remove (); - - stmt_.reset (); - } - } - - void statement:: - clear () - { - reset (); - } - - void statement:: - init (const char* text, - std::size_t text_size, - statement_kind sk, - const binding* proc, - bool optimize) - { - active_ = false; - - string tmp1; - if (proc != 0) - { - switch (sk) - { - case statement_select: - process_select (tmp1, - text, - &proc->bind->buffer, proc->count, sizeof (bind), - '"', '"', - optimize); - break; - case statement_insert: - process_insert (tmp1, - text, - &proc->bind->buffer, proc->count, sizeof (bind), - '?', - '$'); - break; - case statement_update: - process_update (tmp1, - text, - &proc->bind->buffer, proc->count, sizeof (bind), - '?', - '$'); - break; - case statement_delete: - case statement_generic: - assert (false); - } - - text = tmp1.c_str (); - text_size = tmp1.size (); - } - - string tmp2; - if (conn_.statement_translator_ != 0) - { - conn_.statement_translator_ (tmp2, text, text_size, conn_); - - if (!tmp2.empty ()) - { - text = tmp2.c_str (); - text_size = tmp2.size (); - } - } - -#if SQLITE_VERSION_NUMBER < 3005003 - text_.assign (text, text_size); -#endif - - // Empty statement. - // - if (*text == '\0') - return; - - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - { - // Temporarily store the statement text in prev_ so that - // text() which may be called by the tracer can access it. - // Dirty but efficient. - // -#if SQLITE_VERSION_NUMBER >= 3005003 - prev_ = reinterpret_cast (const_cast (text)); -#endif - t->prepare (conn_, *this); -#if SQLITE_VERSION_NUMBER >= 3005003 - prev_ = 0; -#endif - } - } - - int e; - sqlite3_stmt* stmt (0); - - // sqlite3_prepare_v2() is only available since SQLite 3.3.9 - // but is buggy until 3.3.11. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - while ((e = sqlite3_prepare_v2 (conn_.handle (), - text, - static_cast (text_size), - &stmt, - 0)) == SQLITE_LOCKED) - { - conn_.wait (); - } -#else - e = sqlite3_prepare (conn_.handle (), - text, - static_cast (text_size), - &stmt, - 0); -#endif - - if (e != SQLITE_OK) - translate_error (e, conn_); - - stmt_.reset (stmt); - } - - const char* statement:: - text () const - { - // sqlite3_sql() is only available since 3.5.3. - // -#if SQLITE_VERSION_NUMBER >= 3005003 - if (stmt_ == 0) - // See init() above for details on what's going on here. - // - return prev_ != 0 ? reinterpret_cast (prev_) : ""; - else - return sqlite3_sql (stmt_); -#else - return text_.c_str (); -#endif - } - - bool statement:: - bind_param (const bind* p, size_t n) - { - int e (SQLITE_OK); - bool r (false); - - // SQLite parameters are counted from 1. - // - for (size_t i (0), j (1); e == SQLITE_OK && i < n; ++i) - { - const bind& b (p[i]); - - if (b.buffer == 0) // Skip NULL entries. - continue; - - int c (static_cast (j++)); - - if (b.is_null != 0 && *b.is_null) - { - e = sqlite3_bind_null (stmt_, c); - continue; - } - - switch (b.type) - { - case bind::integer: - { - long long v (*static_cast (b.buffer)); - - e = sqlite3_bind_int64 (stmt_, - c, - // Prior to 3.5.0, sqlite3_int64 was called sqlite_int64. -#if SQLITE_VERSION_NUMBER >= 3005000 - static_cast (v) -#else - static_cast (v) -#endif - ); - break; - } - case bind::real: - { - double v (*static_cast (b.buffer)); - e = sqlite3_bind_double (stmt_, c, v); - break; - } - case bind::text: - { - e = sqlite3_bind_text (stmt_, - c, - static_cast (b.buffer), - static_cast (*b.size), - SQLITE_STATIC); - break; - } - case bind::text16: - { - e = sqlite3_bind_text16 (stmt_, - c, - b.buffer, - static_cast (*b.size), - SQLITE_STATIC); - break; - } - case bind::blob: - { - e = sqlite3_bind_blob (stmt_, - c, - b.buffer, - static_cast (*b.size), - SQLITE_STATIC); - break; - } - case bind::stream: - { -#if SQLITE_VERSION_NUMBER >= 3004000 - e = sqlite3_bind_zeroblob (stmt_, - c, - static_cast (*b.size)); - r = true; -#else - assert (false); -#endif - break; - } - } - } - - if (e != SQLITE_OK) - translate_error (e, conn_); - - return r; - } - - bool statement:: - bind_result (const bind* p, size_t count, bool truncated) - { - bool r (true); - int col_count (sqlite3_data_count (stmt_)); - - int col (0); - for (size_t i (0); i != count && col != col_count; ++i) - { - const bind& b (p[i]); - - if (b.buffer == 0) // Skip NULL entries. - continue; - - int c (col++); - - if (b.type == bind::stream) - col++; // Skip ROWID value that follows. - - if (truncated && (b.truncated == 0 || !*b.truncated)) - continue; - - if (b.truncated != 0) - *b.truncated = false; - - // Check for NULL unless we are reloading a truncated result. - // - if (!truncated) - { - *b.is_null = sqlite3_column_type (stmt_, c) == SQLITE_NULL; - - if (*b.is_null) - continue; - } - - switch (b.type) - { - case bind::integer: - { - *static_cast (b.buffer) = - static_cast (sqlite3_column_int64 (stmt_, c)); - break; - } - case bind::real: - { - *static_cast (b.buffer) = - sqlite3_column_double (stmt_, c); - break; - } - case bind::text: - case bind::text16: - case bind::blob: - { - // SQLite documentation recommends that we first call *_text(), - // *_text16(), or *_blob() function in order to force the type - // conversion, if any. - // - const void* d; - - if (b.type != bind::text16) - { - d = b.type == bind::text - ? sqlite3_column_text (stmt_, c) - : sqlite3_column_blob (stmt_, c); - *b.size = static_cast (sqlite3_column_bytes (stmt_, c)); - } - else - { - d = sqlite3_column_text16 (stmt_, c); - *b.size = static_cast ( - sqlite3_column_bytes16 (stmt_, c)); - } - - if (*b.size > b.capacity) - { - if (b.truncated != 0) - *b.truncated = true; - - r = false; - continue; - } - - memcpy (b.buffer, d, *b.size); - break; - } - case bind::stream: - { - stream_buffers& sb (*static_cast (b.buffer)); - - // SQLite documentation states that these are valid until the - // statement is finalized (or reprepared). For our case, we - // only need it to stay alive until we call set_value() which - // we do while executing the statement (i.e., we don't copy - // images for later processing). - // -#ifdef LIBODB_SQLITE_HAVE_COLUMN_METADATA - sb.db.in = sqlite3_column_database_name (stmt_, c); - sb.table.in = sqlite3_column_table_name (stmt_, c); - sb.column.in = sqlite3_column_origin_name (stmt_, c); -#else - assert (false); -#endif - - // The ROWID comes in the following column. - // - sb.rowid.in = static_cast ( - sqlite3_column_int64 (stmt_, c + 1)); - - break; - } - } - } - - // Make sure that the number of columns in the result returned by - // the database matches the number that we expect. A common cause - // of this assertion is a native view with a number of data members - // not matching the number of columns in the SELECT-list. - // - assert (col == col_count); - - return r; - } - - void statement:: - stream_param (const bind* p, size_t n, const stream_data& d) - { - // Code similar to bind_param(). - // - for (size_t i (0), j (1); i < n; ++i) - { - const bind& b (p[i]); - - if (b.buffer == 0) // Skip NULL entries. - continue; - - int c (static_cast (j++)); - - if ((b.is_null != 0 && *b.is_null) || b.type != bind::stream) - continue; - - // Get column name. - // - const char* col (sqlite3_bind_parameter_name (stmt_, c)); - assert (col != 0); // Statement doesn't contain column name. - - stream_buffers& sb (*static_cast (b.buffer)); - - *sb.db.out = d.db; - *sb.table.out = d.table; - *sb.column.out = col + 1; // Skip '$'. - *sb.rowid.out = d.rowid; - } - } - - inline void - update_hook (void* v, const char* db, const char* table, long long rowid) - { - statement::stream_data& d (*static_cast (v)); - d.db = db; - d.table = table; - d.rowid = rowid; - } - - extern "C" void - odb_sqlite_update_hook (void* v, - int, - const char* db, - const char* table, -#if SQLITE_VERSION_NUMBER >= 3005000 - sqlite3_int64 rowid -#else - sqlite_int64 rowid -#endif - ) - { - update_hook (v, db, table, static_cast (rowid)); - } - - // generic_statement - // - - generic_statement:: - generic_statement (connection_type& conn, const string& text) - : statement (conn, - text, statement_generic, - 0, false), - result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) - { - } - - generic_statement:: - generic_statement (connection_type& conn, const char* text) - : statement (conn, - text, statement_generic, - 0, false), - result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) - { - } - - generic_statement:: - generic_statement (connection_type& conn, - const char* text, - size_t text_size) - : statement (conn, - text, text_size, statement_generic, - 0, false), - result_set_ (stmt_ ? sqlite3_column_count (stmt_) != 0: false) - { - } - - unsigned long long generic_statement:: - execute () - { - if (stmt_ == 0) // Empty statement or comment. - return 0; - - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->execute (conn_, *this); - } - - unsigned long long r (0); - - int e; - sqlite3* h (conn_.handle ()); - -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - // Only the first call to sqlite3_step() can return SQLITE_LOCKED. - // - while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) - { - if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) - break; - - sqlite3_reset (stmt_); - conn_.wait (); - } -#else - e = sqlite3_step (stmt_); -#endif - - for (; e == SQLITE_ROW; e = sqlite3_step (stmt_)) - r++; - - // sqlite3_step() will return a detailed error code only if we used - // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the - // error. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - sqlite3_reset (stmt_); - - if (e != SQLITE_DONE) - translate_error (e, conn_); -#else - e = sqlite3_reset (stmt_); - - if (e != SQLITE_OK) - { - // If the schema has changed, try to re-prepare and re-execute the - // statement. That's what newer versions of SQLite do automatically. - // - if (e == SQLITE_SCHEMA) - { - sqlite3_stmt* stmt (0); - e = sqlite3_prepare (h, - text_.c_str (), - static_cast (text_.size () + 1), - &stmt, - 0); - - if (e != SQLITE_OK) - translate_error (e, conn_); - - stmt_.reset (stmt); - return execute (); // Try again by recursively calling ourselves. - } - else - translate_error (e, conn_); - } -#endif - - if (!result_set_) - r = static_cast (sqlite3_changes (h)); - - return r; - } - - // select_statement - // - - select_statement:: - select_statement (connection_type& conn, - const string& text, - bool process, - bool optimize, - binding& param, - binding& result) - : statement (conn, - text, statement_select, - (process ? &result : 0), optimize), - param_ (¶m), - result_ (result) - { - } - - select_statement:: - select_statement (connection_type& conn, - const char* text, - bool process, - bool optimize, - binding& param, - binding& result) - : statement (conn, - text, statement_select, - (process ? &result : 0), optimize), - param_ (¶m), - result_ (result) - { - } - - select_statement:: - select_statement (connection_type& conn, - const string& text, - bool process, - bool optimize, - binding& result) - : statement (conn, - text, statement_select, - (process ? &result : 0), optimize), - param_ (0), - result_ (result) - { - } - - select_statement:: - select_statement (connection_type& conn, - const char* text, - bool process, - bool optimize, - binding& result) - : statement (conn, - text, statement_select, - (process ? &result : 0), optimize), - param_ (0), - result_ (result) - { - } - - void select_statement:: - execute () - { - if (active ()) - reset (); - - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->execute (conn_, *this); - } - - done_ = false; - - if (param_ != 0) - bind_param (param_->bind, param_->count); - - active (true); - } - - void select_statement:: - free_result () - { - reset (); - done_ = true; - } - - bool select_statement:: - next () - { - if (!done_) - { - int e; - -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - sqlite3* h (conn_.handle ()); - while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) - { - if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) - break; - - sqlite3_reset (stmt_); - conn_.wait (); - } -#else - e = sqlite3_step (stmt_); -#endif - - if (e != SQLITE_ROW) - { - done_ = true; - - // sqlite3_step() will return a detailed error code only if we used - // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the - // error. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - reset (); - - if (e != SQLITE_DONE) -#else - e = reset (); - - if (e != SQLITE_OK) -#endif - translate_error (e, conn_); - } - } - - return !done_; - } - - select_statement::result select_statement:: - load () - { - if (done_) - return no_data; - - return bind_result (result_.bind, result_.count) ? success : truncated; - } - - void select_statement:: - reload () - { - assert (!done_); - - if (!bind_result (result_.bind, result_.count, true)) - assert (false); - } - - // insert_statement - // - - insert_statement:: - insert_statement (connection_type& conn, - const string& text, - bool process, - binding& param, - binding* returning) - : statement (conn, - text, statement_insert, - (process ? ¶m : 0), false), - param_ (param), - returning_ (returning) - { - } - - insert_statement:: - insert_statement (connection_type& conn, - const char* text, - bool process, - binding& param, - binding* returning) - : statement (conn, - text, statement_insert, - (process ? ¶m : 0), false), - param_ (param), - returning_ (returning) - { - } - - bool insert_statement:: - execute () - { - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->execute (conn_, *this); - } - - sqlite3* h (conn_.handle ()); - bool stream (bind_param (param_.bind, param_.count)); - - stream_data sd; - if (stream) - sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); - - int e; - -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) - { - if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) - break; - - sqlite3_reset (stmt_); - conn_.wait (); - } -#else - e = sqlite3_step (stmt_); -#endif - - if (stream) - sqlite3_update_hook (h, 0, 0); // Clear the hook. - - // sqlite3_step() will return a detailed error code only if we used - // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the - // error. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - sqlite3_reset (stmt_); - - if (e != SQLITE_DONE) -#else - e = sqlite3_reset (stmt_); - - if (e != SQLITE_OK) -#endif - { - // SQLITE_CONSTRAINT error code covers more than just a duplicate - // primary key. Unfortunately, there is nothing more precise that - // we can use (even sqlite3_errmsg() returns generic "constraint - // failed"). But an auto-assigned object id should never cause a - // duplicate primary key. - // - if (returning_ == 0 && e == SQLITE_CONSTRAINT) - return false; - else - translate_error (e, conn_); - } - - // Stream parameters, if any. - // - if (stream) - stream_param (param_.bind, param_.count, sd); - - if (returning_ != 0) - { - bind& b (returning_->bind[0]); - - *b.is_null = false; - *static_cast (b.buffer) = - static_cast ( - sqlite3_last_insert_rowid (h)); - } - - return true; - } - - // update_statement - // - - update_statement:: - update_statement (connection_type& conn, - const string& text, - bool process, - binding& param) - : statement (conn, - text, statement_update, - (process ? ¶m : 0), false), - param_ (param) - { - } - - update_statement:: - update_statement (connection_type& conn, - const char* text, - bool process, - binding& param) - : statement (conn, - text, statement_update, - (process ? ¶m : 0), false), - param_ (param) - { - } - - unsigned long long update_statement:: - execute () - { - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->execute (conn_, *this); - } - - sqlite3* h (conn_.handle ()); - bool stream (bind_param (param_.bind, param_.count)); - - stream_data sd; - if (stream) - sqlite3_update_hook (h, &odb_sqlite_update_hook, &sd); - - int e; - -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) - { - if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) - break; - - sqlite3_reset (stmt_); - conn_.wait (); - } -#else - e = sqlite3_step (stmt_); -#endif - - if (stream) - sqlite3_update_hook (h, 0, 0); // Clear the hook. - - // sqlite3_step() will return a detailed error code only if we used - // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the - // error. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - sqlite3_reset (stmt_); - - if (e != SQLITE_DONE) -#else - e = sqlite3_reset (stmt_); - - if (e != SQLITE_OK) -#endif - translate_error (e, conn_); - - int r (sqlite3_changes (h)); - - // Stream parameters, if any. - // - if (stream && r != 0) - stream_param (param_.bind, param_.count, sd); - - return static_cast (r); - } - - // delete_statement - // - - delete_statement:: - delete_statement (connection_type& conn, - const string& text, - binding& param) - : statement (conn, - text, statement_delete, - 0, false), - param_ (param) - { - } - - delete_statement:: - delete_statement (connection_type& conn, - const char* text, - binding& param) - : statement (conn, - text, statement_delete, - 0, false), - param_ (param) - { - } - - unsigned long long delete_statement:: - execute () - { - { - odb::tracer* t; - if ((t = conn_.main_connection ().transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->execute (conn_, *this); - } - - bind_param (param_.bind, param_.count); - - int e; - sqlite3* h (conn_.handle ()); - -#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY - while ((e = sqlite3_step (stmt_)) == SQLITE_LOCKED) - { - if (sqlite3_extended_errcode (h) != SQLITE_LOCKED_SHAREDCACHE) - break; - - sqlite3_reset (stmt_); - conn_.wait (); - } -#else - e = sqlite3_step (stmt_); -#endif - - // sqlite3_step() will return a detailed error code only if we used - // sqlite3_prepare_v2(). Otherwise, sqlite3_reset() returns the - // error. - // -#if SQLITE_VERSION_NUMBER >= 3003011 - sqlite3_reset (stmt_); - - if (e != SQLITE_DONE) -#else - e = sqlite3_reset (stmt_); - - if (e != SQLITE_OK) -#endif - translate_error (e, conn_); - - return static_cast (sqlite3_changes (h)); - } - } -} diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx deleted file mode 100644 index 9eeea7b..0000000 --- a/odb/sqlite/statement.hxx +++ /dev/null @@ -1,392 +0,0 @@ -// file : odb/sqlite/statement.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_STATEMENT_HXX -#define ODB_SQLITE_STATEMENT_HXX - -#include - -#include - -#include -#include // std::size_t -#include // std::strlen, std::memcpy -#include - -#include - -#include -#include -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - class connection; - - class LIBODB_SQLITE_EXPORT statement: public odb::statement, - public active_object - { - public: - typedef sqlite::connection connection_type; - - virtual - ~statement () = 0; - - sqlite3_stmt* - handle () const - { - return stmt_; - } - - virtual const char* - text () const; - - virtual connection_type& - connection () - { - return conn_; - } - - // A statement can be empty. This is used to handle situations - // where a SELECT or UPDATE statement ends up not having any - // columns after processing. An empty statement cannot be - // executed. - // - bool - empty () const - { - return stmt_ == 0; - } - - protected: - // We keep two versions to take advantage of std::string COW. - // - statement (connection_type& conn, - const std::string& text, - statement_kind sk, - const binding* process, - bool optimize) - : active_object (conn) - { - init (text.c_str (), text.size (), sk, process, optimize); - } - - statement (connection_type& conn, - const char* text, - statement_kind sk, - const binding* process, - bool optimize) - : active_object (conn) - { - init (text, std::strlen (text), sk, process, optimize); - } - - statement (connection_type& conn, - const char* text, - std::size_t text_size, - statement_kind sk, - const binding* process, - bool optimize) - : active_object (conn) - { - init (text, text_size, sk, process, optimize); - } - - protected: - // Return true if we bound any stream parameters. - // - bool - bind_param (const bind*, std::size_t count); - - // Extract row columns into the bound buffers. If the truncated - // argument is true, then only truncated columns are extracted. - // Return true if all the data was extracted successfully and - // false if one or more columns were truncated. - // - bool - bind_result (const bind*, std::size_t count, bool truncated = false); - - // Stream (so to speak) parameters. - // - struct stream_data - { - std::string db; - std::string table; - long long rowid; - }; - - void - stream_param (const bind*, std::size_t count, const stream_data&); - - friend void - update_hook (void*, const char*, const char*, long long); - - // Active state. - // - protected: - bool - active () const - { - return active_; - } - - void - active (bool active) - { - assert (active); - - if (!active_) - { - list_add (); - active_ = true; - } - } - - int - reset () - { - int r (SQLITE_OK); - - if (active_) - { - r = sqlite3_reset (stmt_); - list_remove (); - active_ = false; - } - - return r; - } - - // The active_object interface. - // - virtual void - clear (); - - protected: - auto_handle stmt_; - -#if SQLITE_VERSION_NUMBER < 3005003 - std::string text_; -#endif - - bool active_; - - private: - void - init (const char* text, - std::size_t text_size, - statement_kind, - const binding* process, - bool optimize); - }; - - class LIBODB_SQLITE_EXPORT generic_statement: public statement - { - public: - generic_statement (connection_type&, const std::string& text); - generic_statement (connection_type&, const char* text); - generic_statement (connection_type&, - const char* text, - std::size_t text_size); - - unsigned long long - execute (); - - private: - generic_statement (const generic_statement&); - generic_statement& operator= (const generic_statement&); - - private: - bool result_set_; - }; - - class LIBODB_SQLITE_EXPORT select_statement: public statement - { - public: - select_statement (connection_type& conn, - const std::string& text, - bool process_text, - bool optimize_text, - binding& param, - binding& result); - - select_statement (connection_type& conn, - const char* text, - bool process_text, - bool optimize_text, - binding& param, - binding& result); - - select_statement (connection_type& conn, - const std::string& text, - bool process_text, - bool optimize_text, - binding& result); - - select_statement (connection_type& conn, - const char* text, - bool process_text, - bool optimize_text, - binding& result); - - // Common select interface expected by the generated code. - // - public: - enum result - { - success, - no_data, - truncated - }; - - void - execute (); - - // Load next row columns into bound buffers. - // - result - fetch () - { - return next () ? load () : no_data; - } - - // Reload truncated columns into bound buffers. - // - void - refetch () - { - reload (); - } - - // Free the result set. - // - void - free_result (); - - // More fine-grained SQLite-specific interface that splits fetch() - // into next() and load(). - // - public: - // Return false if there is no more rows. You should call next() - // until it returns false or, alternatively, call free_result (). - // Otherwise the statement will remain unfinished. - // - bool - next (); - - result - load (); - - void - reload (); - - private: - select_statement (const select_statement&); - select_statement& operator= (const select_statement&); - - private: - bool done_; - binding* param_; - binding& result_; - }; - - struct auto_result - { - explicit auto_result (select_statement& s): s_ (s) {} - ~auto_result () {s_.free_result ();} - - private: - auto_result (const auto_result&); - auto_result& operator= (const auto_result&); - - private: - select_statement& s_; - }; - - class LIBODB_SQLITE_EXPORT insert_statement: public statement - { - public: - insert_statement (connection_type& conn, - const std::string& text, - bool process_text, - binding& param, - binding* returning); - - insert_statement (connection_type& conn, - const char* text, - bool process_text, - binding& param, - binding* returning); - - // Return true if successful and false if the row is a duplicate. - // All other errors are reported by throwing exceptions. - // - bool - execute (); - - private: - insert_statement (const insert_statement&); - insert_statement& operator= (const insert_statement&); - - private: - binding& param_; - binding* returning_; - }; - - class LIBODB_SQLITE_EXPORT update_statement: public statement - { - public: - update_statement (connection_type& conn, - const std::string& text, - bool process_text, - binding& param); - - update_statement (connection_type& conn, - const char* text, - bool process_text, - binding& param); - - unsigned long long - execute (); - - private: - update_statement (const update_statement&); - update_statement& operator= (const update_statement&); - - private: - binding& param_; - }; - - class LIBODB_SQLITE_EXPORT delete_statement: public statement - { - public: - delete_statement (connection_type& conn, - const std::string& text, - binding& param); - - delete_statement (connection_type& conn, - const char* text, - binding& param); - - unsigned long long - execute (); - - private: - delete_statement (const delete_statement&); - delete_statement& operator= (const delete_statement&); - - private: - binding& param_; - }; - } -} - -#include - -#endif // ODB_SQLITE_STATEMENT_HXX diff --git a/odb/sqlite/statements-base.cxx b/odb/sqlite/statements-base.cxx deleted file mode 100644 index bde8c55..0000000 --- a/odb/sqlite/statements-base.cxx +++ /dev/null @@ -1,15 +0,0 @@ -// file : odb/sqlite/statements-base.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -namespace odb -{ - namespace sqlite - { - statements_base:: - ~statements_base () - { - } - } -} diff --git a/odb/sqlite/statements-base.hxx b/odb/sqlite/statements-base.hxx deleted file mode 100644 index 5851d1b..0000000 --- a/odb/sqlite/statements-base.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// file : odb/sqlite/statements-base.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_STATEMENTS_BASE_HXX -#define ODB_SQLITE_STATEMENTS_BASE_HXX - -#include - -#include -#include - -#include -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - class LIBODB_SQLITE_EXPORT statements_base: public details::shared_base - { - public: - typedef sqlite::connection connection_type; - - connection_type& - connection () - { - return conn_; - } - - // Schema version. database::schema_version_migration() is thread- - // safe which means it is also slow. Cache the result in statements - // so we can avoid the mutex lock. This is thread-safe since if the - // version is updated, then the statements cache will be expired. - // - const schema_version_migration& - version_migration (const char* name = "") const - { - if (svm_ == 0) - svm_ = &conn_.database ().schema_version_migration (name); - - return *svm_; - } - - public: - virtual - ~statements_base (); - - protected: - statements_base (connection_type& conn): conn_ (conn), svm_ (0) {} - - protected: - connection_type& conn_; - mutable const schema_version_migration* svm_; - }; - } -} - -#include - -#endif // ODB_SQLITE_STATEMENTS_BASE_HXX diff --git a/odb/sqlite/stream.cxx b/odb/sqlite/stream.cxx deleted file mode 100644 index 8420ba2..0000000 --- a/odb/sqlite/stream.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// file : odb/sqlite/stream.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#if SQLITE_VERSION_NUMBER >= 3004000 - -#include - -#include // invalid_argument - -#include -#include -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - stream:: - stream (const char* db, - const char* table, - const char* column, - long long rowid, - bool rw) - : active_object (transaction::current ().connection ()) - { - int e (sqlite3_blob_open (conn_.handle (), - db, - table, - column, - static_cast (rowid), - rw, - &h_)); - - if (e != SQLITE_OK) - translate_error (e, conn_); - - list_add (); // Add ourselves to the active objects list. - } - - size_t stream:: - size () const - { - return static_cast (sqlite3_blob_bytes (h_)); - } - - void stream:: - read (void* buf, size_t n, size_t o) - { - int e (sqlite3_blob_read ( - h_, buf, static_cast (n), static_cast (o))); - - if (e != SQLITE_OK) - { - if (e == SQLITE_ERROR) - throw invalid_argument ("read past end"); - else - translate_error (e, conn_); - } - } - - void stream:: - write (const void* buf, size_t n, size_t o) - { - int e (sqlite3_blob_write ( - h_, buf, static_cast (n), static_cast (o))); - - if (e != SQLITE_OK) - { - if (e == SQLITE_ERROR) - throw invalid_argument ("write past end"); - else - translate_error (e, conn_); - } - } - - void stream:: - close (bool check) - { - if (h_ != 0) - { - list_remove (); - - int e (sqlite3_blob_close (h_)); - h_ = 0; // No use trying again. - - if (check && e != SQLITE_OK) - translate_error (e, conn_); - } - } - -#if SQLITE_VERSION_NUMBER >= 3007004 - void stream:: - reopen (long long rowid) - { - int e (sqlite3_blob_reopen (h_, rowid)); - - if (e != SQLITE_OK) - // According to the SQLite documentation, the handle is now - // considered aborted, which means we still need to close it. - // - translate_error (e, conn_); - } -#endif - - void stream:: - clear () - { - // This call can be part of the stack unwinding, so don't check - // for the errors. - // - close (false); - } - } -} - -#endif // SQLITE_VERSION_NUMBER >= 3004000 diff --git a/odb/sqlite/stream.hxx b/odb/sqlite/stream.hxx deleted file mode 100644 index 6ee76cb..0000000 --- a/odb/sqlite/stream.hxx +++ /dev/null @@ -1,85 +0,0 @@ -// file : odb/sqlite/stream.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_STREAM_HXX -#define ODB_SQLITE_STREAM_HXX - -#include - -#include - -#include // std::size_t - -#include -#include - -namespace odb -{ - namespace sqlite - { - // SQLite incremental BLOB/TEXT I/O stream. Available since - // SQLite 3.4.0. - // - class LIBODB_SQLITE_EXPORT stream: public active_object - { - public: - // @@ TODO: db is actually what we now (and SQLite in other places) - // call schema (see database::schema(), ATTACH DATABASE). So we - // should probably rename this at some point for consistency. - // - stream (const char* db, - const char* table, - const char* column, - long long rowid, - bool rw); - - std::size_t - size () const; - - // The following two functions throw std::invalid_argument if - // offset + n is past size(). - // - void - read (void* buf, std::size_t n, std::size_t offset = 0); - - void - write (const void* buf, std::size_t n, std::size_t offset = 0); - - sqlite3_blob* - handle () const {return h_;} - - // Close without reporting errors, if any. - // - virtual - ~stream () {close (false);} - - // Close, by default with reporting errors, if any. - // - void - close (bool check = true); - - // Open the same BLOB but in a different row. Can be faster - // than creating a new stream instance. Note that the stream - // must be in the open state prior to calling this function. - // Only available since SQLite 3.7.4. - // -#if SQLITE_VERSION_NUMBER >= 3007004 - void - reopen (long long rowid); -#endif - - protected: - // The active_object interface. - // - virtual void - clear (); - - private: - sqlite3_blob* h_; - }; - } -} - -#include - -#endif // ODB_SQLITE_STREAM_HXX diff --git a/odb/sqlite/text-stream.hxx b/odb/sqlite/text-stream.hxx deleted file mode 100644 index 7a9b467..0000000 --- a/odb/sqlite/text-stream.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// file : odb/sqlite/text-stream.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TEXT_STREAM_HXX -#define ODB_SQLITE_TEXT_STREAM_HXX - -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - class text_stream: public stream - { - public: - text_stream (const text& b, bool rw) - : stream (b.db ().c_str (), - b.table ().c_str (), - b.column ().c_str (), - b.rowid (), - rw) {} - }; - } -} - -#include - -#endif // ODB_SQLITE_TEXT_STREAM_HXX diff --git a/odb/sqlite/text.hxx b/odb/sqlite/text.hxx deleted file mode 100644 index 3f681fb..0000000 --- a/odb/sqlite/text.hxx +++ /dev/null @@ -1,69 +0,0 @@ -// file : odb/sqlite/text.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TEXT_HXX -#define ODB_SQLITE_TEXT_HXX - -#include - -#include -#include // std::size_t - -// Carefully allow this header to be included into the ODB compilation. -// -#ifndef ODB_COMPILER -# include -# include -#endif - -namespace odb -{ - namespace sqlite - { -#ifdef ODB_COMPILER - #pragma db sqlite:type("TEXT STREAM") - class text -#else - class text -#endif - { - public: - // TEXT size to provision for. Set before calling persist() or update(). - // - explicit - text (std::size_t size = 0): size_ (size) {} - - std::size_t size () const {return size_;} - void size (std::size_t s) {size_ = s;} - - const std::string& db () const {return db_;} - const std::string& table () const {return table_;} - const std::string& column () const {return column_;} - long long rowid () const {return rowid_;} - - void - clear () - { - size_ = 0; - db_.clear (); - table_.clear (); - column_.clear (); - rowid_ = 0; - } - - private: -#ifndef ODB_COMPILER - friend struct default_value_traits; -#endif - std::size_t size_; - mutable std::string db_; - mutable std::string table_; - mutable std::string column_; - mutable long long rowid_; - }; - } -} - -#include - -#endif // ODB_SQLITE_TEXT_HXX diff --git a/odb/sqlite/tracer.cxx b/odb/sqlite/tracer.cxx deleted file mode 100644 index 49f6b00..0000000 --- a/odb/sqlite/tracer.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : odb/sqlite/tracer.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - tracer:: - ~tracer () - { - } - - void tracer:: - prepare (connection&, const statement&) - { - } - - void tracer:: - execute (connection& c, const statement& s) - { - execute (c, s.text ()); - } - - void tracer:: - deallocate (connection&, const statement&) - { - } - - void tracer:: - prepare (odb::connection& c, const odb::statement& s) - { - prepare (static_cast (c), - static_cast (s)); - } - - void tracer:: - execute (odb::connection& c, const odb::statement& s) - { - execute (static_cast (c), - static_cast (s)); - } - - void tracer:: - execute (odb::connection& c, const char* s) - { - execute (static_cast (c), s); - } - - void tracer:: - deallocate (odb::connection& c, const odb::statement& s) - { - deallocate (static_cast (c), - static_cast (s)); - } - } -} diff --git a/odb/sqlite/tracer.hxx b/odb/sqlite/tracer.hxx deleted file mode 100644 index b12573b..0000000 --- a/odb/sqlite/tracer.hxx +++ /dev/null @@ -1,61 +0,0 @@ -// file : odb/sqlite/tracer.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TRACER_HXX -#define ODB_SQLITE_TRACER_HXX - -#include - -#include - -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - class LIBODB_SQLITE_EXPORT tracer: private odb::tracer - { - public: - virtual - ~tracer (); - - virtual void - prepare (connection&, const statement&); - - virtual void - execute (connection&, const statement&); - - virtual void - execute (connection&, const char* statement) = 0; - - virtual void - deallocate (connection&, const statement&); - - private: - // Allow these classes to convert sqlite::tracer to odb::tracer. - // - friend class database; - friend class connection; - friend class transaction; - - virtual void - prepare (odb::connection&, const odb::statement&); - - virtual void - execute (odb::connection&, const odb::statement&); - - virtual void - execute (odb::connection&, const char* statement); - - virtual void - deallocate (odb::connection&, const odb::statement&); - }; - } -} - -#include - -#endif // ODB_SQLITE_TRACER_HXX diff --git a/odb/sqlite/traits-calls.hxx b/odb/sqlite/traits-calls.hxx deleted file mode 100644 index 9d5b59f..0000000 --- a/odb/sqlite/traits-calls.hxx +++ /dev/null @@ -1,214 +0,0 @@ -// file : odb/sqlite/traits-calls.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TRAITS_CALLS_HXX -#define ODB_SQLITE_TRAITS_CALLS_HXX - -#include - -#include // std::size_t - -#include -#include -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // object_traits_calls - // - - template ::versioned> - struct object_traits_calls; - - template - struct object_traits_calls - { - typedef object_traits_impl traits; - typedef typename traits::image_type image_type; - typedef sqlite::bind bind_type; - - object_traits_calls (const schema_version_migration*) {} - - const schema_version_migration* - version () const {return 0;} - - static bool - grow (image_type& i, bool* t) - { - return traits::grow (i, t); - } - - static void - bind (bind_type* b, image_type& i, statement_kind sk) - { - traits::bind (b, i, sk); - } - - // Poly-derived version. - // - static void - bind (bind_type* b, - const bind_type* id, std::size_t id_size, - image_type& i, - statement_kind sk) - { - traits::bind (b, id, id_size, i, sk); - } - - static void - init (T& o, const image_type& i, odb::database* db) - { - traits::init (o, i, db); - } - - static bool - find_ (typename traits::statements_type& sts, - const typename traits::id_type* id) - { - return traits::find_ (sts, id); - } - - static void - load_ (typename traits::statements_type& sts, T& o, bool reload) - { - return traits::load_ (sts, o, reload); - } - }; - - template - struct object_traits_calls - { - typedef object_traits_impl traits; - typedef typename traits::image_type image_type; - typedef sqlite::bind bind_type; - - object_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} - - const schema_version_migration* - version () const {return &svm_;} - - bool - grow (image_type& i, bool* t) const - { - return traits::grow (i, t, svm_); - } - - void - bind (bind_type* b, image_type& i, statement_kind sk) const - { - traits::bind (b, i, sk, svm_); - } - - // Poly-derived version. - // - void - bind (bind_type* b, - const bind_type* id, std::size_t id_size, - image_type& i, - statement_kind sk) const - { - traits::bind (b, id, id_size, i, sk, svm_); - } - - void - init (T& o, const image_type& i, odb::database* db) const - { - traits::init (o, i, db, svm_); - } - - bool - find_ (typename traits::statements_type& sts, - const typename traits::id_type* id) const - { - return traits::find_ (sts, id, svm_); - } - - void - load_ (typename traits::statements_type& sts, T& o, bool reload) const - { - return traits::load_ (sts, o, reload, svm_); - } - - private: - const schema_version_migration& svm_; - }; - - // - // view_traits_calls - // - - template ::versioned> - struct view_traits_calls; - - template - struct view_traits_calls - { - typedef view_traits_impl traits; - typedef typename traits::image_type image_type; - typedef sqlite::bind bind_type; - - view_traits_calls (const schema_version_migration*) {} - - static bool - grow (image_type& i, bool* t) - { - return traits::grow (i, t); - } - - static void - bind (bind_type* b, image_type& i) - { - traits::bind (b, i); - } - - static void - init (T& o, const image_type& i, odb::database* db) - { - traits::init (o, i, db); - } - }; - - template - struct view_traits_calls - { - typedef view_traits_impl traits; - typedef typename traits::image_type image_type; - typedef sqlite::bind bind_type; - - view_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} - - bool - grow (image_type& i, bool* t) const - { - return traits::grow (i, t, svm_); - } - - void - bind (bind_type* b, image_type& i) const - { - traits::bind (b, i, svm_); - } - - void - init (T& o, const image_type& i, odb::database* db) const - { - traits::init (o, i, db, svm_); - } - - private: - const schema_version_migration& svm_; - }; - } -} - -#include - -#endif // ODB_SQLITE_TRAITS_CALLS_HXX diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx deleted file mode 100644 index a47455d..0000000 --- a/odb/sqlite/traits.cxx +++ /dev/null @@ -1,219 +0,0 @@ -// file : odb/sqlite/traits.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -using namespace std; - -namespace odb -{ - namespace sqlite - { - using details::buffer; - - // - // default_value_traits - // - void default_value_traits:: - set_image (buffer& b, size_t& n, bool& is_null, const string& v) - { - is_null = false; - n = v.size (); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v.c_str (), n); - } - - // - // c_string_value_traits - // - void c_string_value_traits:: - set_image (buffer& b, size_t& n, bool& is_null, const char* v) - { - is_null = false; - n = strlen (v); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v, n); - } - - // - // c_array_value_traits_base - // - void c_array_value_traits_base:: - set_value (char* const& v, - const details::buffer& b, - size_t n, - bool is_null, - size_t N) - { - if (!is_null) - { - n = n < N ? n : N; - - if (n != 0) - memcpy (v, b.data (), n); - } - else - n = 0; - - if (n != N) // Append '\0' if there is space. - v[n] = '\0'; - } - - void c_array_value_traits_base:: - set_image (details::buffer& b, - size_t& n, - bool& is_null, - const char* v, - size_t N) - { - is_null = false; - - // Figure out the length. We cannot use strlen since it may - // not be 0-terminated (strnlen is not standard). - // - for (n = 0; n != N && v[n] != '\0'; ++n) ; - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v, n); - } - - // - // default_value_traits - // -#ifdef _WIN32 - void default_value_traits:: - set_image (buffer& b, size_t& n, bool& is_null, const wstring& v) - { - is_null = false; - n = v.size () * 2; - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v.c_str (), n); - } - - // - // c_wstring_value_traits - // - void c_wstring_value_traits:: - set_image (buffer& b, size_t& n, bool& is_null, const wchar_t* v) - { - is_null = false; - n = wcslen (v) * 2; - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v, n); - } - - // - // c_warray_value_traits_base - // - void c_warray_value_traits_base:: - set_value (wchar_t* const& v, - const details::buffer& b, - size_t n, - bool is_null, - size_t N) - { - if (!is_null) - { - n /= 2; - n = n < N ? n : N; - - if (n != 0) - memcpy (v, b.data (), n * sizeof (wchar_t)); - } - else - n = 0; - - if (n != N) // Append '\0' if there is space. - v[n] = L'\0'; - } - - void c_warray_value_traits_base:: - set_image (details::buffer& b, - size_t& n, - bool& is_null, - const wchar_t* v, - size_t N) - { - is_null = false; - - // Figure out the length. We cannot use wcslen since it may - // not be 0-terminated (wcsnlen is not standard). - // - for (n = 0; n != N && v[n] != L'\0'; ++n) ; - - n *= 2; - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - memcpy (b.data (), v, n); - } -#endif // _WIN32 - - // - // default_value_traits, id_blob> - // - // std::vector has to be qualified for Sun CC. - // - void default_value_traits, id_blob>:: - set_image (details::buffer& b, - size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - n = v.size (); - - if (n > b.capacity ()) - b.capacity (n); - - // std::vector::data() may not be available in older compilers. - // - if (n != 0) - memcpy (b.data (), &v.front (), n); - } - - // - // default_value_traits, id_blob> - // - // std::vector has to be qualified for Sun CC. - // - void default_value_traits, id_blob>:: - set_image (details::buffer& b, - size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - n = v.size (); - - if (n > b.capacity ()) - b.capacity (n); - - // std::vector::data() may not be available in older compilers. - // - if (n != 0) - memcpy (b.data (), &v.front (), n); - } - } -} diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx deleted file mode 100644 index a8cf578..0000000 --- a/odb/sqlite/traits.hxx +++ /dev/null @@ -1,1099 +0,0 @@ -// file : odb/sqlite/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TRAITS_HXX -#define ODB_SQLITE_TRAITS_HXX - -#include - -#include // ODB_CXX11 - -#include -#include -#include // std::numeric_limits -#include // std::size_t -#include // std::memcpy, std::memset, std::strlen - -#ifdef ODB_CXX11 -# include -#endif - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -namespace odb -{ - namespace sqlite - { - // - // image_traits - // - - template - struct image_traits; - - template - struct image_traits {typedef long long image_type;}; - - template - struct image_traits {typedef double image_type;}; - - template - struct image_traits - { - typedef details::buffer image_type; - - // By default the text is in UTF-8. - // - static const bind::buffer_type bind_value = bind::text; - }; - - template - struct image_traits {typedef details::buffer image_type;}; - - template - struct image_traits - { - typedef stream_buffers image_type; - }; - - template - struct image_traits - { - typedef stream_buffers image_type; - }; - - // - // value_traits - // - - template - struct wrapped_value_traits; - - template - struct default_value_traits; - - template ::r> - struct select_traits; - - template - struct select_traits - { - typedef default_value_traits type; - }; - - template - struct select_traits - { - typedef - wrapped_value_traits::null_handler> - type; - }; - - template - class value_traits: public select_traits::type - { - }; - - // The wrapped_value_traits specializations should be able to handle - // any value type which means we have to have every possible signature - // of the set_value() and set_image() functions. - // - template - struct wrapped_value_traits - { - typedef wrapper_traits wtraits; - typedef typename wtraits::unrestricted_wrapped_type wrapped_type; - - typedef W value_type; - typedef wrapped_type query_type; - typedef typename image_traits::image_type image_type; - - typedef value_traits vtraits; - - static void - set_value (W& v, const image_type& i, bool is_null) - { - vtraits::set_value (wtraits::set_ref (v), i, is_null); - } - - static void - set_image (image_type& i, bool& is_null, const W& v) - { - vtraits::set_image (i, is_null, wtraits::get_ref (v)); - } - - // TEXT and BLOB. - // - static void - set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) - { - vtraits::set_value (wtraits::set_ref (v), b, n, is_null); - } - - static void - set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) - { - vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); - } - - // TEXT and BLOB STREAM. - // - static void - set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) - { - vtraits::set_value (wtraits::set_ref (v), b, n, is_null); - } - - static void - set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) - { - vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); - } - }; - - template - struct wrapped_value_traits - { - typedef wrapper_traits wtraits; - typedef typename wtraits::unrestricted_wrapped_type wrapped_type; - - typedef W value_type; - typedef wrapped_type query_type; - typedef typename image_traits::image_type image_type; - - typedef value_traits vtraits; - - static void - set_value (W& v, const image_type& i, bool is_null) - { - if (is_null) - wtraits::set_null (v); - else - vtraits::set_value (wtraits::set_ref (v), i, is_null); - } - - static void - set_image (image_type& i, bool& is_null, const W& v) - { - is_null = wtraits::get_null (v); - - if (!is_null) - vtraits::set_image (i, is_null, wtraits::get_ref (v)); - } - - // TEXT and BLOB. - // - static void - set_value (W& v, const details::buffer& b, std::size_t n, bool is_null) - { - if (is_null) - wtraits::set_null (v); - else - vtraits::set_value (wtraits::set_ref (v), b, n, is_null); - } - - static void - set_image (details::buffer& b, std::size_t& n, bool& is_null, const W& v) - { - is_null = wtraits::get_null (v); - - if (!is_null) - vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); - } - - // TEXT and BLOB STREAM. - // - static void - set_value (W& v, const stream_buffers& b, std::size_t n, bool is_null) - { - if (is_null) - wtraits::set_null (v); - else - vtraits::set_value (wtraits::set_ref (v), b, n, is_null); - } - - static void - set_image (stream_buffers& b, std::size_t& n, bool& is_null, const W& v) - { - is_null = wtraits::get_null (v); - - if (!is_null) - vtraits::set_image (b, n, is_null, wtraits::get_ref (v)); - } - }; - - template - struct default_value_traits - { - typedef T value_type; - typedef T query_type; - typedef typename image_traits::image_type image_type; - - static void - set_value (T& v, const image_type& i, bool is_null) - { - if (!is_null) - v = T (i); - else - v = T (); - } - - static void - set_image (image_type& i, bool& is_null, T v) - { - is_null = false; - i = image_type (v); - } - }; - - // Float & double specialization. SQLite converts NaNs to NULLs so - // we convert NULLs to NaNs for consistency. - // - template - struct real_value_traits - { - typedef T value_type; - typedef T query_type; - typedef double image_type; - - static void - set_value (T& v, double i, bool is_null) - { - if (!is_null) - v = T (i); - else - v = std::numeric_limits::quiet_NaN (); - } - - static void - set_image (double& i, bool& is_null, T v) - { - is_null = false; - i = image_type (v); - } - }; - - template <> - struct default_value_traits: real_value_traits {}; - - template <> - struct default_value_traits: real_value_traits {}; - - // std::string specialization. - // - template <> - struct LIBODB_SQLITE_EXPORT default_value_traits - { - typedef std::string value_type; - typedef std::string query_type; - typedef details::buffer image_type; - - static void - set_value (std::string& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - v.assign (b.data (), n); - else - v.erase (); - } - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const std::string&); - }; - - // char*/const char* specialization - // - // Specialization for const char* which only supports initialization - // of an image from the value but not the other way around. This way - // we can pass such values to the queries. - // - struct LIBODB_SQLITE_EXPORT c_string_value_traits - { - typedef const char* value_type; - typedef details::buffer image_type; - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const char*); - }; - - template <> - struct default_value_traits: c_string_value_traits {}; - - template <> - struct default_value_traits: - c_string_value_traits {}; - - // char[N] specialization. - // - struct LIBODB_SQLITE_EXPORT c_array_value_traits_base - { - static void - set_value (char* const& v, - const details::buffer& b, - std::size_t n, - bool is_null, - std::size_t N); - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const char* v, - std::size_t N); - }; - - template - struct default_value_traits - { - typedef char* value_type; - typedef char query_type[N]; - typedef details::buffer image_type; - - static void - set_value (char* const& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_array_value_traits_base::set_value (v, b, n, is_null, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const char* v) - { - c_array_value_traits_base::set_image (b, n, is_null, v, N); - } - }; - - // std::array (string) specialization. - // -#ifdef ODB_CXX11 - template - struct default_value_traits, id_text> - { - typedef std::array value_type; - typedef std::array query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_array_value_traits_base::set_value (v.data (), b, n, is_null, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const value_type& v) - { - c_array_value_traits_base::set_image (b, n, is_null, v.data (), N); - } - }; -#endif - - // char specialization. - // - template <> - struct default_value_traits - { - typedef char value_type; - typedef char query_type; - typedef details::buffer image_type; - - static void - set_value (char& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_array_value_traits_base::set_value (&v, b, n, is_null, 1); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - char v) - { - c_array_value_traits_base::set_image (b, n, is_null, &v, 1); - } - }; - -#ifdef _WIN32 - // std::wstring specialization. Using UTF-16 binding. - // - struct wstring_image_traits - { - typedef details::buffer image_type; - static const bind::buffer_type bind_value = bind::text16; - }; - - template <> - struct image_traits: wstring_image_traits {}; - - template <> - struct LIBODB_SQLITE_EXPORT default_value_traits - { - typedef std::wstring value_type; - typedef std::wstring query_type; - typedef details::buffer image_type; - - static void - set_value (std::wstring& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - v.assign (reinterpret_cast (b.data ()), n / 2); - else - v.erase (); - } - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const std::wstring&); - }; - - // wchar_t*/const wchar_t* specialization. - // - struct LIBODB_SQLITE_EXPORT c_wstring_value_traits - { - typedef const wchar_t* value_type; - typedef details::buffer image_type; - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const wchar_t*); - }; - - template <> - struct image_traits: wstring_image_traits {}; - - template <> - struct default_value_traits: c_wstring_value_traits {}; - - template <> - struct image_traits: wstring_image_traits {}; - - template <> - struct default_value_traits: - c_wstring_value_traits {}; - - // wchar_t[N] specialization. - // - struct LIBODB_SQLITE_EXPORT c_warray_value_traits_base - { - static void - set_value (wchar_t* const& v, - const details::buffer& b, - std::size_t n, - bool is_null, - std::size_t N); - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const wchar_t* v, - std::size_t N); - }; - - template - struct image_traits: wstring_image_traits {}; - - template - struct default_value_traits - { - typedef wchar_t* value_type; - typedef wchar_t query_type[N]; - typedef details::buffer image_type; - - static void - set_value (wchar_t* const& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_warray_value_traits_base::set_value (v, b, n, is_null, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const wchar_t* v) - { - c_warray_value_traits_base::set_image (b, n, is_null, v, N); - } - }; - - // std::array (string) specialization. - // -#ifdef ODB_CXX11 - template - struct image_traits, id_text>: - wstring_image_traits {}; - - template - struct default_value_traits, id_text> - { - typedef std::array value_type; - typedef std::array query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_warray_value_traits_base::set_value (v.data (), b, n, is_null, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const value_type& v) - { - c_warray_value_traits_base::set_image (b, n, is_null, v.data (), N); - } - }; -#endif - - // wchar_t specialization. - // - template <> - struct image_traits: wstring_image_traits {}; - - template <> - struct default_value_traits - { - typedef wchar_t value_type; - typedef wchar_t query_type; - typedef details::buffer image_type; - - static void - set_value (wchar_t& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - c_warray_value_traits_base::set_value (&v, b, n, is_null, 1); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - wchar_t v) - { - c_warray_value_traits_base::set_image (b, n, is_null, &v, 1); - } - }; -#endif // _WIN32 - - // std::vector (buffer) specialization. - // - template <> - struct LIBODB_SQLITE_EXPORT default_value_traits< - std::vector, id_blob> - { - public: - typedef std::vector value_type; - typedef std::vector query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - v.assign (b.data (), b.data () + n); - else - v.clear (); - } - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const value_type&); - }; - - // std::vector (buffer) specialization. - // - template <> - struct LIBODB_SQLITE_EXPORT default_value_traits< - std::vector, id_blob> - { - public: - typedef std::vector value_type; - typedef std::vector query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - { - const unsigned char* d ( - reinterpret_cast (b.data ())); - v.assign (d, d + n); - } - else - v.clear (); - } - - static void - set_image (details::buffer&, - std::size_t& n, - bool& is_null, - const value_type&); - }; - - // char[N] (buffer) specialization. - // - template - struct default_value_traits - { - public: - typedef char* value_type; - typedef char query_type[N]; - typedef details::buffer image_type; - - static void - set_value (char* const& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - std::memcpy (v, b.data (), (n < N ? n : N)); - else - std::memset (v, 0, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const char* v) - { - is_null = false; - n = N; - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), v, n); - } - }; - - // unsigned char[N] (buffer) specialization. - // - template - struct default_value_traits - { - public: - typedef unsigned char* value_type; - typedef unsigned char query_type[N]; - typedef details::buffer image_type; - - static void - set_value (unsigned char* const& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - std::memcpy (v, b.data (), (n < N ? n : N)); - else - std::memset (v, 0, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const unsigned char* v) - { - is_null = false; - n = N; - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), v, n); - } - }; - -#ifdef ODB_CXX11 - // std::array (buffer) specialization. - // - template - struct default_value_traits, id_blob> - { - public: - typedef std::array value_type; - typedef value_type query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - std::memcpy (v.data (), b.data (), (n < N ? n : N)); - else - std::memset (v.data (), 0, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - n = N; - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), v.data (), n); - } - }; - - // std::array (buffer) specialization. - // - template - struct default_value_traits, id_blob> - { - public: - typedef std::array value_type; - typedef value_type query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - std::memcpy (v.data (), b.data (), (n < N ? n : N)); - else - std::memset (v.data (), 0, N); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - n = N; - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), v.data (), n); - } - }; -#endif - - // text (stream) specialization. - // - template <> - struct default_value_traits - { - public: - typedef text value_type; - typedef std::string query_type; - typedef stream_buffers image_type; - - static void - set_value (text& v, const stream_buffers& b, std::size_t, bool is_null) - { - if (!is_null) - { - v.db_ = b.db.in; - v.table_ = b.table.in; - v.column_ = b.column.in; - v.rowid_ = b.rowid.in; - } - } - - static void - set_image (stream_buffers& b, - std::size_t& n, - bool& is_null, - const text& v) - { - is_null = false; - n = v.size_; - - b.db.out = &v.db_; - b.table.out = &v.table_; - b.column.out = &v.column_; - b.rowid.out = &v.rowid_; - } - }; - - // blob (stream) specialization. - // - template <> - struct default_value_traits - { - public: - typedef blob value_type; - typedef std::vector query_type; - typedef stream_buffers image_type; - - static void - set_value (blob& v, const stream_buffers& b, std::size_t, bool is_null) - { - if (!is_null) - { - v.db_ = b.db.in; - v.table_ = b.table.in; - v.column_ = b.column.in; - v.rowid_ = b.rowid.in; - } - } - - static void - set_image (stream_buffers& b, - std::size_t& n, - bool& is_null, - const blob& v) - { - is_null = false; - n = v.size_; - - b.db.out = &v.db_; - b.table.out = &v.table_; - b.column.out = &v.column_; - b.rowid.out = &v.rowid_; - } - }; - - // - // type_traits - // - - template - struct default_type_traits; - - template - class type_traits: public default_type_traits {}; - - // Integral types. - // - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_integer; - }; - - // Float types. - // - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_real; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_real; - }; - - // String types. - // - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_text; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_text; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_text; - }; - - template - struct default_type_traits - { - static const database_type_id db_type_id = id_text; - }; - -#ifdef ODB_CXX11 - template - struct default_type_traits > - { - static const database_type_id db_type_id = id_text; - }; -#endif - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_text; - }; - - // Binary types. - // - template - struct default_type_traits - { - static const database_type_id db_type_id = id_blob; - }; - - template <> - struct default_type_traits > - { - static const database_type_id db_type_id = id_blob; - }; - - template <> - struct default_type_traits > - { - static const database_type_id db_type_id = id_blob; - }; - -#ifdef ODB_CXX11 - template - struct default_type_traits > - { - static const database_type_id db_type_id = id_blob; - }; -#endif - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_text_stream; - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_blob_stream; - }; - } -} - -#include - -#endif // ODB_SQLITE_TRAITS_HXX diff --git a/odb/sqlite/transaction-impl.cxx b/odb/sqlite/transaction-impl.cxx deleted file mode 100644 index 6485f7e..0000000 --- a/odb/sqlite/transaction-impl.cxx +++ /dev/null @@ -1,172 +0,0 @@ -// file : odb/sqlite/transaction-impl.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - transaction_impl:: - transaction_impl (database_type& db, lock l) - : odb::transaction_impl (db), lock_ (l) - { - } - - transaction_impl:: - transaction_impl (connection_ptr c, lock l) - : odb::transaction_impl (c->database (), *c), - connection_ (c), - lock_ (l) - { - } - - transaction_impl:: - ~transaction_impl () - { - } - - void transaction_impl:: - start () - { - // Grab a connection if we don't already have one. - // - if (connection_ == 0) - { - connection_ = static_cast (database_).connection (); - odb::transaction_impl::connection_ = connection_.get (); - } - - connection_type& mc (connection_->main_connection ()); - - switch (lock_) - { - case deferred: - { - mc.begin_statement ().execute (); - break; - } - case immediate: - { - mc.begin_immediate_statement ().execute (); - break; - } - case exclusive: - { - mc.begin_exclusive_statement ().execute (); - break; - } - } - } - - // In SQLite, when a commit fails (e.g., because of the deferred - // foreign key constraint violation), the transaction may not - // be automatically rolled back. So we have to do it ourselves. - // - struct commit_guard - { - commit_guard (connection& c): c_ (&c) {} - void release () {c_ = 0;} - - ~commit_guard () - { - if (c_ != 0 && sqlite3_get_autocommit (c_->handle ()) == 0) - { - // This is happening while another exception is active. - // - try - { - c_->rollback_statement ().execute (); - } - catch (...) {} - } - } - - private: - connection* c_; - }; - - void transaction_impl:: - commit () - { - connection_type& mc (connection_->main_connection ()); - - // Invalidate query results and reset active statements. - // - // Active statements will prevent COMMIT from completing (write - // statements) or releasing the locks (read statements). Normally, a - // statement is automatically reset on completion, however, if an - // exception is thrown, that may not happen. - // - // Note: must be done via the main connection. - // - mc.clear (); - - { - commit_guard cg (mc); - mc.commit_statement ().execute (); - cg.release (); - } - - // Release the connection. - // - connection_.reset (); - } - - void transaction_impl:: - rollback () - { - connection_type& mc (connection_->main_connection ()); - - // Invalidate query results and reset active statements (the same - // reasoning as in commit()). - // - // Note: must be done via the main connection. - // - mc.clear (); - - mc.rollback_statement ().execute (); - - // Release the connection. - // - connection_.reset (); - } - - odb::connection& transaction_impl:: - connection (odb::database* pdb) - { - if (pdb == 0) - return *connection_; - - // Pick the corresponding connection for main/attached database. - // - database_type& db (static_cast (*pdb)); - - assert (&db.main_database () == - &static_cast (database_).main_database ()); - - return db.schema ().empty () - ? connection_->main_connection () - : *static_cast (*db.factory_).attached_connection_; - } - - // Store transaction tracer in the main connection. - // - void transaction_impl:: - tracer (odb::tracer* t) - { - connection_->main_connection ().transaction_tracer_ = t; - } - - odb::tracer* transaction_impl:: - tracer () const - { - return connection_->main_connection ().transaction_tracer_; - } - } -} diff --git a/odb/sqlite/transaction-impl.hxx b/odb/sqlite/transaction-impl.hxx deleted file mode 100644 index d1a310b..0000000 --- a/odb/sqlite/transaction-impl.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : odb/sqlite/transaction-impl.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX -#define ODB_SQLITE_TRANSACTION_IMPL_HXX - -#include - -#include - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - class LIBODB_SQLITE_EXPORT transaction_impl: public odb::transaction_impl - { - public: - typedef sqlite::database database_type; - typedef sqlite::connection connection_type; - - enum lock - { - deferred, - immediate, - exclusive - }; - - transaction_impl (database_type&, lock); - transaction_impl (connection_ptr, lock); - - virtual - ~transaction_impl (); - - virtual void - start (); - - virtual void - commit (); - - virtual void - rollback (); - - virtual odb::connection& - connection (odb::database*); - - virtual void - tracer (odb::tracer*); - - virtual odb::tracer* - tracer () const; - - private: - connection_ptr connection_; - lock lock_; - }; - } -} - -#include - -#endif // ODB_SQLITE_TRANSACTION_IMPL_HXX diff --git a/odb/sqlite/transaction.cxx b/odb/sqlite/transaction.cxx deleted file mode 100644 index 8b4ab23..0000000 --- a/odb/sqlite/transaction.cxx +++ /dev/null @@ -1,26 +0,0 @@ -// file : odb/sqlite/transaction.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include - -namespace odb -{ - namespace sqlite - { - transaction& transaction:: - current () - { - // While the impl type can be of the concrete type, the transaction - // object can be created as either odb:: or odb::sqlite:: type. To - // work around that we are going to hard-cast one two the other - // relying on the fact that they have the same representation and - // no virtual functions. The former is checked in the tests. - // - odb::transaction& b (odb::transaction::current ()); - assert (dynamic_cast (&b.implementation ()) != 0); - return reinterpret_cast (b); - } - } -} diff --git a/odb/sqlite/transaction.hxx b/odb/sqlite/transaction.hxx deleted file mode 100644 index 5e8c141..0000000 --- a/odb/sqlite/transaction.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// file : odb/sqlite/transaction.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_TRANSACTION_HXX -#define ODB_SQLITE_TRANSACTION_HXX - -#include - -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - class transaction_impl; - - class LIBODB_SQLITE_EXPORT transaction: public odb::transaction - { - public: - typedef sqlite::database database_type; - typedef sqlite::connection connection_type; - - explicit - transaction (transaction_impl*, bool make_current = true); - - transaction (); - - // Return the database this transaction is on. - // - database_type& - database (); - - // Return the underlying database connection for this transaction. - // - connection_type& - connection (); - - connection_type& - connection (odb::database&); - - // Return current transaction or throw if there is no transaction - // in effect. - // - static transaction& - current (); - - // Set the current thread's transaction. - // - static void - current (transaction&); - - // SQL statement tracing. - // - public: - typedef sqlite::tracer tracer_type; - - void - tracer (tracer_type& t) - { - odb::transaction::tracer (t); - } - - void - tracer (tracer_type* t) - { - odb::transaction::tracer (t); - } - - using odb::transaction::tracer; - - public: - transaction_impl& - implementation (); - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_TRANSACTION_HXX diff --git a/odb/sqlite/transaction.ixx b/odb/sqlite/transaction.ixx deleted file mode 100644 index de4bd3e..0000000 --- a/odb/sqlite/transaction.ixx +++ /dev/null @@ -1,57 +0,0 @@ -// file : odb/sqlite/transaction.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include - -namespace odb -{ - namespace sqlite - { - inline transaction:: - transaction (transaction_impl* impl, bool make_current) - : odb::transaction (impl, make_current) - { - } - - inline transaction:: - transaction () - : odb::transaction () - { - } - - inline transaction_impl& transaction:: - implementation () - { - // We can use static_cast here since we have an instance of - // sqlite::transaction. - // - return static_cast ( - odb::transaction::implementation ()); - } - - inline transaction::database_type& transaction:: - database () - { - return static_cast (odb::transaction::database ()); - } - - inline transaction::connection_type& transaction:: - connection () - { - return static_cast (odb::transaction::connection ()); - } - - inline transaction::connection_type& transaction:: - connection (odb::database& db) - { - return static_cast (odb::transaction::connection (db)); - } - - inline void transaction:: - current (transaction& t) - { - odb::transaction::current (t); - } - } -} diff --git a/odb/sqlite/version-build2-stub.hxx b/odb/sqlite/version-build2-stub.hxx deleted file mode 100644 index a6bb4d0..0000000 --- a/odb/sqlite/version-build2-stub.hxx +++ /dev/null @@ -1,4 +0,0 @@ -// file : odb/sqlite/version-build2-stub.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include diff --git a/odb/sqlite/version-build2.hxx b/odb/sqlite/version-build2.hxx deleted file mode 100644 index e69de29..0000000 diff --git a/odb/sqlite/version-build2.hxx.in b/odb/sqlite/version-build2.hxx.in deleted file mode 100644 index 50fef2d..0000000 --- a/odb/sqlite/version-build2.hxx.in +++ /dev/null @@ -1,42 +0,0 @@ -// file : odb/sqlite/version-build2.hxx.in -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBODB_SQLITE_VERSION // Note: using the version macro itself. - -// The numeric version format is AAAAABBBBBCCCCCDDDE where: -// -// AAAAA - major version number -// BBBBB - minor version number -// CCCCC - bugfix version number -// DDD - alpha / beta (DDD + 500) version number -// E - final (0) / snapshot (1) -// -// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: -// -// Version AAAAABBBBBCCCCCDDDE -// -// 0.1.0 0000000001000000000 -// 0.1.2 0000000001000020000 -// 1.2.3 0000100002000030000 -// 2.2.0-a.1 0000200001999990010 -// 3.0.0-b.2 0000299999999995020 -// 2.2.0-a.1.z 0000200001999990011 -// -#define LIBODB_SQLITE_VERSION $libodb_sqlite.version.project_number$ULL -#define LIBODB_SQLITE_VERSION_STR "$libodb_sqlite.version.project$" -#define LIBODB_SQLITE_VERSION_ID "$libodb_sqlite.version.project_id$" - -#define LIBODB_SQLITE_VERSION_MAJOR $libodb_sqlite.version.major$ -#define LIBODB_SQLITE_VERSION_MINOR $libodb_sqlite.version.minor$ -#define LIBODB_SQLITE_VERSION_PATCH $libodb_sqlite.version.patch$ - -#define LIBODB_SQLITE_PRE_RELEASE $libodb_sqlite.version.pre_release$ - -#define LIBODB_SQLITE_SNAPSHOT $libodb_sqlite.version.snapshot_sn$ULL -#define LIBODB_SQLITE_SNAPSHOT_ID "$libodb_sqlite.version.snapshot_id$" - -#include - -$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ - -#endif // LIBODB_SQLITE_VERSION diff --git a/odb/sqlite/version.hxx b/odb/sqlite/version.hxx deleted file mode 100644 index ad468de..0000000 --- a/odb/sqlite/version.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// file : odb/sqlite/version.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifdef LIBODB_SQLITE_BUILD2 -# include -#else - -#ifndef ODB_SQLITE_VERSION_HXX -#define ODB_SQLITE_VERSION_HXX - -#include - -#include - -// Version format is AABBCCDD where -// -// AA - major version number -// BB - minor version number -// CC - bugfix version number -// DD - alpha / beta (DD + 50) version number -// -// When DD is not 00, 1 is subtracted from AABBCC. For example: -// -// Version AABBCCDD -// 2.0.0 02000000 -// 2.1.0 02010000 -// 2.1.1 02010100 -// 2.2.0.a1 02019901 -// 3.0.0.b2 02999952 -// - -// Check that we have compatible ODB version. -// -#if ODB_VERSION != 20476 -# error incompatible odb interface version detected -#endif - -// libodb-sqlite version: odb interface version plus the bugfix -// version. -// -#define LIBODB_SQLITE_VERSION 2049976 -#define LIBODB_SQLITE_VERSION_STR "2.5.0-b.26" - -#include - -#endif // ODB_SQLITE_VERSION_HXX -#endif // LIBODB_SQLITE_BUILD2 diff --git a/odb/sqlite/view-result.hxx b/odb/sqlite/view-result.hxx deleted file mode 100644 index ce3d747..0000000 --- a/odb/sqlite/view-result.hxx +++ /dev/null @@ -1,80 +0,0 @@ -// file : odb/sqlite/view-result.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_VIEW_RESULT_HXX -#define ODB_SQLITE_VIEW_RESULT_HXX - -#include - -#include // std::size_t - -#include -#include - -#include - -#include -#include // query_base, query_params -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class view_result_impl: public odb::view_result_impl - { - public: - typedef odb::view_result_impl base_type; - - typedef typename base_type::view_type view_type; - typedef typename base_type::pointer_type pointer_type; - - typedef view_traits_impl view_traits; - typedef typename base_type::pointer_traits pointer_traits; - - typedef view_statements statements_type; - - virtual - ~view_result_impl (); - - view_result_impl (const query_base&, - const details::shared_ptr&, - statements_type&, - const schema_version_migration*); - - virtual void - load (view_type&); - - virtual void - next (); - - virtual void - cache (); - - virtual std::size_t - size (); - - virtual void - invalidate (); - - using base_type::current; - - private: - // We need to hold on to the query parameters because SQLite uses - // the parameter buffers to find each next row. - // - details::shared_ptr params_; - details::shared_ptr statement_; - statements_type& statements_; - view_traits_calls tc_; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_VIEW_RESULT_HXX diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx deleted file mode 100644 index 60efb81..0000000 --- a/odb/sqlite/view-result.txx +++ /dev/null @@ -1,114 +0,0 @@ -// file : odb/sqlite/view-result.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include -#include - -#include - -namespace odb -{ - namespace sqlite - { - template - view_result_impl:: - ~view_result_impl () - { - if (!this->end_) - statement_->free_result (); - } - - template - void view_result_impl:: - invalidate () - { - if (!this->end_) - { - statement_->free_result (); - this->end_ = true; - } - - params_.reset (); - statement_.reset (); - } - - template - view_result_impl:: - view_result_impl (const query_base& q, - const details::shared_ptr& s, - statements_type& sts, - const schema_version_migration* svm) - : base_type (sts.connection ()), - params_ (q.parameters ()), - statement_ (s), - statements_ (sts), - tc_ (svm) - { - } - - template - void view_result_impl:: - load (view_type& view) - { - // The image can grow between calls to load() as a result of other - // statements execution. - // - typename view_traits::image_type& im (statements_.image ()); - - if (im.version != statements_.image_version ()) - { - binding& b (statements_.image_binding ()); - tc_.bind (b.bind, im); - statements_.image_version (im.version); - b.version++; - } - - select_statement::result r (statement_->load ()); - - if (r == select_statement::truncated) - { - if (tc_.grow (im, statements_.image_truncated ())) - im.version++; - - if (im.version != statements_.image_version ()) - { - binding& b (statements_.image_binding ()); - tc_.bind (b.bind, im); - statements_.image_version (im.version); - b.version++; - statement_->reload (); - } - } - - view_traits::callback (this->db_, view, callback_event::pre_load); - tc_.init (view, im, &this->db_); - view_traits::callback (this->db_, view, callback_event::post_load); - } - - template - void view_result_impl:: - next () - { - this->current (pointer_type ()); - - if (!statement_->next ()) - { - statement_->free_result (); - this->end_ = true; - } - } - - template - void view_result_impl:: - cache () - { - } - - template - std::size_t view_result_impl:: - size () - { - throw result_not_cached (); - } - } -} diff --git a/odb/sqlite/view-statements.hxx b/odb/sqlite/view-statements.hxx deleted file mode 100644 index 0bd79ee..0000000 --- a/odb/sqlite/view-statements.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : odb/sqlite/view-statements.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX -#define ODB_SQLITE_VIEW_STATEMENTS_HXX - -#include - -#include // std::size_t - -#include -#include - -#include -#include -#include -#include - -namespace odb -{ - namespace sqlite - { - template - class view_statements: public statements_base - { - public: - typedef T view_type; - typedef view_traits_impl view_traits; - typedef typename view_traits::pointer_type pointer_type; - typedef typename view_traits::image_type image_type; - - public: - view_statements (connection_type&); - - virtual - ~view_statements (); - - // View image. - // - image_type& - image () - { - return image_; - } - - std::size_t - image_version () const - { - return image_version_; - } - - void - image_version (std::size_t v) - { - image_version_ = v; - } - - binding& - image_binding () - { - return image_binding_; - } - - bool* - image_truncated () - { - return image_truncated_; - } - - private: - view_statements (const view_statements&); - view_statements& operator= (const view_statements&); - - private: - image_type image_; - std::size_t image_version_; - binding image_binding_; - bind image_bind_[view_traits::column_count]; - bool image_truncated_[view_traits::column_count]; - }; - } -} - -#include - -#include - -#endif // ODB_SQLITE_VIEW_STATEMENTS_HXX diff --git a/odb/sqlite/view-statements.txx b/odb/sqlite/view-statements.txx deleted file mode 100644 index 0531a92..0000000 --- a/odb/sqlite/view-statements.txx +++ /dev/null @@ -1,33 +0,0 @@ -// file : odb/sqlite/view-statements.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::size_t -#include // std::memset - -namespace odb -{ - namespace sqlite - { - template - view_statements:: - ~view_statements () - { - } - - template - view_statements:: - view_statements (connection_type& conn) - : statements_base (conn), - image_binding_ (image_bind_, view_traits::column_count) - { - image_.version = 0; - image_version_ = 0; - - std::memset (image_bind_, 0, sizeof (image_bind_)); - std::memset (image_truncated_, 0, sizeof (image_truncated_)); - - for (std::size_t i (0); i < view_traits::column_count; ++i) - image_bind_[i].truncated = image_truncated_ + i; - } - } -} diff --git a/repositories.manifest b/repositories.manifest deleted file mode 100644 index fe2f8c0..0000000 --- a/repositories.manifest +++ /dev/null @@ -1,14 +0,0 @@ -: 1 -summary: SQLite ODB runtime library repository - -: -role: prerequisite -location: https://git.build2.org/packaging/sqlite/sqlite.git##HEAD - -: -role: prerequisite -location: ../libodb.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/cli/cli.git##HEAD diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index e54525b..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -driver diff --git a/tests/basics/buildfile b/tests/basics/buildfile deleted file mode 100644 index 5d671d3..0000000 --- a/tests/basics/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : tests/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libs = libodb-sqlite%lib{odb-sqlite} - -exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx deleted file mode 100644 index b998574..0000000 --- a/tests/basics/driver.cxx +++ /dev/null @@ -1,52 +0,0 @@ -// file : tests/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Basic test to make sure the library is usable. Functionality testing -// is done in the odb-tests package. - -#include -#include - -#include -#include -#include - -using namespace odb::sqlite; - -int -main () -{ - { - std::ostringstream os; - database::print_usage (os); - assert (!os.str ().empty ()); - } - - database db (":memory:"); - - { - transaction t (db.begin ()); - db.execute ("CREATE TABLE test (id INTEGER PRIMARY KEY, str TEXT)"); - t.commit (); - } - - { - transaction t (db.begin ()); - db.execute ("INSERT INTO test VALUES (123, 'abc')"); - t.commit (); - } - - try - { - transaction t (db.begin ()); - db.execute ("INSERT INTO test VALUES (123, 'ABC')"); - assert (false); - } - catch (const database_exception&) {} - - { - transaction t (db.begin ()); - db.execute ("DROP TABLE test"); - t.commit (); - } -} diff --git a/tests/build/.gitignore b/tests/build/.gitignore deleted file mode 100644 index 4a730a3..0000000 --- a/tests/build/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -config.build -root/ -bootstrap/ diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build deleted file mode 100644 index 6ee38db..0000000 --- a/tests/build/bootstrap.build +++ /dev/null @@ -1,8 +0,0 @@ -# file : tests/build/bootstrap.build -# license : GNU GPL v2; see accompanying LICENSE file - -project = # Unnamed subproject. - -using config -using dist -using test diff --git a/tests/build/root.build b/tests/build/root.build deleted file mode 100644 index 6c5a90b..0000000 --- a/tests/build/root.build +++ /dev/null @@ -1,23 +0,0 @@ -# file : tests/build/root.build -# license : GNU GPL v2; see accompanying LICENSE file - -cxx.std = latest - -using cxx - -hxx{*}: extension = hxx -cxx{*}: extension = cxx - -if ($cxx.target.system == 'win32-msvc') - cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS - -if ($cxx.class == 'msvc') - cxx.coptions += /wd4251 /wd4275 /wd4800 - -# Every exe{} in this subproject is by default a test. -# -exe{*}: test = true - -# Specify the test target for cross-testing. -# -test.target = $cxx.target diff --git a/tests/buildfile b/tests/buildfile deleted file mode 100644 index 57588a4..0000000 --- a/tests/buildfile +++ /dev/null @@ -1,4 +0,0 @@ -# file : tests/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -./: {*/ -build/} diff --git a/version.txt b/version.txt deleted file mode 100644 index 6bc2f39..0000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -2.5.0-b.26 -- cgit v1.1