restructure external code and handle 3rd party licenses correctly
This commit is contained in:
@@ -46,15 +46,27 @@ after_build:
|
|||||||
- cd artifacts_core
|
- cd artifacts_core
|
||||||
- mkdir lib
|
- mkdir lib
|
||||||
- mkdir include
|
- mkdir include
|
||||||
|
- mkdir license
|
||||||
- cd ..
|
- cd ..
|
||||||
- ps: |
|
- ps: |
|
||||||
copy build/core/release/sourcetraildb.lib artifacts_core/lib/
|
copy build/core/release/sourcetraildb.lib artifacts_core/lib/
|
||||||
copy build/core/include/version.h artifacts_core/include/
|
copy build/core/include/version.h artifacts_core/include/
|
||||||
copy core/include/* artifacts_core/include/
|
copy core/include/* artifacts_core/include/
|
||||||
|
copy LICENSE.txt artifacts_core/license/license_sourcetraildb.txt
|
||||||
|
copy external/catch/license_catch.txt artifacts_core/license/
|
||||||
|
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_core/license/
|
||||||
|
copy external/json/license_json.txt artifacts_core/license/
|
||||||
- mkdir artifacts_bindings_python
|
- mkdir artifacts_bindings_python
|
||||||
|
- cd artifacts_bindings_python
|
||||||
|
- mkdir license
|
||||||
|
- cd ..
|
||||||
- ps: |
|
- ps: |
|
||||||
copy build/bindings_python/release/_sourcetraildb.pyd artifacts_bindings_python/
|
copy build/bindings_python/release/_sourcetraildb.pyd artifacts_bindings_python/
|
||||||
copy build/bindings_python/release/sourcetraildb.py artifacts_bindings_python/
|
copy build/bindings_python/release/sourcetraildb.py artifacts_bindings_python/
|
||||||
|
copy LICENSE.txt artifacts_bindings_python/license/license_sourcetraildb.txt
|
||||||
|
copy external/catch/license_catch.txt artifacts_bindings_python/license/
|
||||||
|
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_bindings_python/license/
|
||||||
|
copy external/json/license_json.txt artifacts_bindings_python/license/
|
||||||
|
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
|
|||||||
+10
-7
@@ -16,8 +16,8 @@ configure_file(
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(LIB_SRC_FILES
|
set(LIB_SRC_FILES
|
||||||
external/sqlite/CppSQLite3.cpp
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/src/CppSQLite3.cpp"
|
||||||
external/sqlite/sqlite3.c
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/src/sqlite3.c"
|
||||||
src/DatabaseStorage.cpp
|
src/DatabaseStorage.cpp
|
||||||
src/DefinitionKind.cpp
|
src/DefinitionKind.cpp
|
||||||
src/EdgeKind.cpp
|
src/EdgeKind.cpp
|
||||||
@@ -31,9 +31,9 @@ set(LIB_SRC_FILES
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(LIB_HDR_FILES
|
set(LIB_HDR_FILES
|
||||||
external/json/json.hpp
|
"${CMAKE_SOURCE_DIR}/external/json/include/json.hpp"
|
||||||
external/sqlite/CppSQLite3.h
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include/CppSQLite3.h"
|
||||||
external/sqlite/sqlite3.h
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include/sqlite3.h"
|
||||||
include/DatabaseStorage.h
|
include/DatabaseStorage.h
|
||||||
include/DefinitionKind.h
|
include/DefinitionKind.h
|
||||||
include/EdgeKind.h
|
include/EdgeKind.h
|
||||||
@@ -65,7 +65,8 @@ set_target_properties(${LIB_CORE} PROPERTIES OUTPUT_NAME "sourcetraildb")
|
|||||||
|
|
||||||
target_include_directories(${LIB_CORE} PUBLIC
|
target_include_directories(${LIB_CORE} PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/external"
|
"${CMAKE_SOURCE_DIR}/external/json/include"
|
||||||
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include"
|
||||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -78,7 +79,9 @@ add_executable(${TEST_CORE} ${TEST_SRC_FILES})
|
|||||||
|
|
||||||
target_include_directories(${TEST_CORE} PUBLIC
|
target_include_directories(${TEST_CORE} PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/external"
|
"${CMAKE_SOURCE_DIR}/external/catch/include"
|
||||||
|
"${CMAKE_SOURCE_DIR}/external/json/include"
|
||||||
|
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include"
|
||||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sqlite/CppSQLite3.h"
|
#include "CppSQLite3.h"
|
||||||
|
|
||||||
#include "StorageEdge.h"
|
#include "StorageEdge.h"
|
||||||
#include "StorageError.h"
|
#include "StorageError.h"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "NameHierarchy.h"
|
#include "NameHierarchy.h"
|
||||||
|
|
||||||
#include "json/json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
namespace sourcetrail
|
namespace sourcetrail
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sqlite/CppSQLite3.h"
|
#include "CppSQLite3.h"
|
||||||
|
|
||||||
#include "DatabaseStorage.h"
|
#include "DatabaseStorage.h"
|
||||||
#include "DefinitionKind.h"
|
#include "DefinitionKind.h"
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() function
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() function
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
#include "DatabaseStorage.h"
|
#include "DatabaseStorage.h"
|
||||||
#include "NodeKind.h"
|
#include "NodeKind.h"
|
||||||
|
|||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
+73
@@ -0,0 +1,73 @@
|
|||||||
|
The Code Project Open License (CPOL) 1.02
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
========
|
||||||
|
|
||||||
|
This License governs Your use of the Work. This License is intended to allow developers to use the Source Code and Executable Files provided as part of the Work in any application in any form.
|
||||||
|
|
||||||
|
The main points subject to the terms of the License are:
|
||||||
|
|
||||||
|
* Source Code and Executable Files can be used in commercial applications;
|
||||||
|
* Source Code and Executable Files can be redistributed; and
|
||||||
|
* Source Code can be modified to create derivative works.
|
||||||
|
* No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is provided "as-is".
|
||||||
|
* The Article accompanying the Work may not be distributed or republished without the Author's consent
|
||||||
|
|
||||||
|
This License is entered between You, the individual or other entity reading or otherwise making use of the Work licensed pursuant to this License and the individual or other entity which offers the Work under the terms of this License ("Author").
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT OPEN LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||||
|
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS CONTAINED HEREIN IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. IF YOU DO NOT AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS LICENSE, YOU CANNOT MAKE ANY USE OF THE WORK.
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
a. "Articles" means, collectively, all articles written by Author which describes how the Source Code and Executable Files for the Work may be used by a user.
|
||||||
|
b. "Author" means the individual or entity that offers the Work under the terms of this License.
|
||||||
|
c. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works.
|
||||||
|
d. "Executable Files" refer to the executables, binary files, configuration and any required data files included in the Work.
|
||||||
|
e. "Publisher" means the provider of the website, magazine, CD-ROM, DVD or other medium from or by which the Work is obtained by You.
|
||||||
|
f. "Source Code" refers to the collection of source code and configuration files used to create the Executable Files.
|
||||||
|
g. "Standard Version" refers to such a Work if it has not been modified, or has been modified in accordance with the consent of the Author, such consent being in the full discretion of the Author.
|
||||||
|
h. "Work" refers to the collection of files distributed by the Publisher, including the Source Code, Executable Files, binaries, data files, documentation, whitepapers and the Articles.
|
||||||
|
i. "You" is you, an individual or entity wishing to use the Work and exercise your rights under this License.
|
||||||
|
|
||||||
|
2. Fair Use/Fair Use Rights. Nothing in this License is intended to reduce, limit, or restrict any rights arising from fair use, fair dealing, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.
|
||||||
|
|
||||||
|
3. License Grant. Subject to the terms and conditions of this License, the Author hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
|
||||||
|
|
||||||
|
a. You may use the standard version of the Source Code or Executable Files in Your own applications.
|
||||||
|
b. You may apply bug fixes, portability fixes and other modifications obtained from the Public Domain or from the Author. A Work modified in such a way shall still be considered the standard version and will be subject to this License.
|
||||||
|
c. You may otherwise modify Your copy of this Work (excluding the Articles) in any way to create a Derivative Work, provided that You insert a prominent notice in each changed file stating how, when and where You changed that file.
|
||||||
|
d. You may distribute the standard version of the Executable Files and Source Code or Derivative Work in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution.
|
||||||
|
e. The Articles discussing the Work published in any form by the author may not be distributed or republished without the Author's consent. The author retains copyright to any such Articles. You may use the Executable Files and Source Code pursuant to this License but you may not repost or republish or otherwise distribute or make available the Articles, without the prior written consent of the Author.
|
||||||
|
Any subroutines or modules supplied by You and linked into the Source Code or Executable Files of this Work shall not be considered part of this Work and will not be subject to the terms of this License.
|
||||||
|
|
||||||
|
4. Patent License. Subject to the terms and conditions of this License, each Author hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, import, and otherwise transfer the Work.
|
||||||
|
|
||||||
|
5. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
|
||||||
|
a. You agree not to remove any of the original copyright, patent, trademark, and attribution notices and associated disclaimers that may appear in the Source Code or Executable Files.
|
||||||
|
b. You agree not to advertise or in any way imply that this Work is a product of Your own.
|
||||||
|
c. The name of the Author may not be used to endorse or promote products derived from the Work without the prior written consent of the Author.
|
||||||
|
d. You agree not to sell, lease, or rent any part of the Work. This does not restrict you from including the Work or any part of the Work inside a larger software distribution that itself is being sold. The Work by itself, though, cannot be sold, leased or rented.
|
||||||
|
e. You may distribute the Executable Files and Source Code only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy of the Executable Files or Source Code You distribute and ensure that anyone receiving such Executable Files and Source Code agrees that the terms of this License apply to such Executable Files and/or Source Code. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute the Executable Files or Source Code with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License.
|
||||||
|
f. You agree not to use the Work for illegal, immoral or improper purposes, or on pages containing illegal, immoral or improper material. The Work is subject to applicable export laws. You agree to comply with all such laws and regulations that may apply to the Work after Your receipt of the Work.
|
||||||
|
|
||||||
|
6. Representations, Warranties and Disclaimer. THIS WORK IS PROVIDED "AS IS", "WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OR CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, INCLUDING COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. AUTHOR EXPRESSLY DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES OR CONDITIONS, INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, MERCHANTABLE QUALITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT, OR THAT THE WORK (OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF VIRUSES. YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE WORKS.
|
||||||
|
|
||||||
|
7. Indemnity. You agree to defend, indemnify and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys� fees) resulting from or relating to any use of the Work by You.
|
||||||
|
|
||||||
|
8. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, EVEN IF THE AUTHOR OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
9. Termination.
|
||||||
|
a. This License and the rights granted hereunder will terminate automatically upon any breach by You of any term of this License. Individuals or entities who have received Derivative Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination of this License.
|
||||||
|
b. If You bring a copyright, trademark, patent or any other infringement claim against any contributor over infringements You claim are made by the Work, your License from such contributor to the Work ends automatically.
|
||||||
|
c. Subject to the above terms and conditions, this License is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, the Author reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
|
||||||
|
|
||||||
|
10. Publisher. The parties hereby confirm that the Publisher shall not, under any circumstances, be responsible for and shall not have any liability in respect of the subject matter of this License. The Publisher makes no warranty whatsoever in connection with the Work and shall not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. The Publisher reserves the right to cease making the Work available to You at any time without notice
|
||||||
|
|
||||||
|
11. Miscellaneous
|
||||||
|
a. This License shall be governed by the laws of the location of the head office of the Author or if the Author is an individual, the laws of location of the principal place of residence of the Author.
|
||||||
|
b. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this License, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
||||||
|
c. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
|
||||||
|
d. This License constitutes the entire agreement between the parties with respect to the Work licensed herein. There are no understandings, agreements or representations with respect to the Work not specified herein. The Author shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Author and You.
|
||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2013-2018 Niels Lohmann
|
||||||
|
|
||||||
|
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.
|
||||||
Vendored
+326
@@ -0,0 +1,326 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CppSQLite3 - A C++ wrapper around the SQLite3 embedded database library.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004..2007 Rob Groves. All Rights Reserved. rob.groves@btinternet.com
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and distribute this software and its
|
||||||
|
// documentation for any purpose, without fee, and without a written
|
||||||
|
// agreement, is hereby granted, provided that the above copyright notice,
|
||||||
|
// this paragraph and the following two paragraphs appear in all copies,
|
||||||
|
// modifications, and distributions.
|
||||||
|
//
|
||||||
|
// IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||||
|
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
|
||||||
|
// PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
|
||||||
|
// EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
// PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
|
||||||
|
// ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION
|
||||||
|
// TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||||
|
//
|
||||||
|
// V3.0 03/08/2004 -Initial Version for sqlite3
|
||||||
|
//
|
||||||
|
// V3.1 16/09/2004 -Implemented getXXXXField using sqlite3 functions
|
||||||
|
// -Added CppSQLiteDB3::tableExists()
|
||||||
|
//
|
||||||
|
// V3.2 01/07/2005 -Fixed execScalar to handle a NULL result
|
||||||
|
// 12/07/2007 -Added CppSQLiteDB::IsAutoCommitOn()
|
||||||
|
// -Added int64 functions to CppSQLite3Query
|
||||||
|
// -Added Name based parameter binding to CppSQLite3Statement.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef _CppSQLite3_H_
|
||||||
|
#define _CppSQLite3_H_
|
||||||
|
|
||||||
|
#include "sqlite3.h"
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#define CPPSQLITE_ERROR 1000
|
||||||
|
|
||||||
|
class CppSQLite3Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Exception(const int nErrCode,
|
||||||
|
char* szErrMess,
|
||||||
|
bool bDeleteMsg=true);
|
||||||
|
|
||||||
|
CppSQLite3Exception(const CppSQLite3Exception& e);
|
||||||
|
|
||||||
|
virtual ~CppSQLite3Exception();
|
||||||
|
|
||||||
|
const int errorCode() { return mnErrCode; }
|
||||||
|
|
||||||
|
const char* errorMessage() { return mpszErrMess; }
|
||||||
|
|
||||||
|
static const char* errorCodeAsString(int nErrCode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int mnErrCode;
|
||||||
|
char* mpszErrMess;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3Buffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Buffer();
|
||||||
|
|
||||||
|
~CppSQLite3Buffer();
|
||||||
|
|
||||||
|
const char* format(const char* szFormat, ...);
|
||||||
|
|
||||||
|
operator const char*() { return mpBuf; }
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
char* mpBuf;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3Binary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Binary();
|
||||||
|
|
||||||
|
~CppSQLite3Binary();
|
||||||
|
|
||||||
|
void setBinary(const unsigned char* pBuf, int nLen);
|
||||||
|
void setEncoded(const unsigned char* pBuf);
|
||||||
|
|
||||||
|
const unsigned char* getEncoded();
|
||||||
|
const unsigned char* getBinary();
|
||||||
|
|
||||||
|
int getBinaryLength();
|
||||||
|
|
||||||
|
unsigned char* allocBuffer(int nLen);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
unsigned char* mpBuf;
|
||||||
|
int mnBinaryLen;
|
||||||
|
int mnBufferLen;
|
||||||
|
int mnEncodedLen;
|
||||||
|
bool mbEncoded;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3Query
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Query();
|
||||||
|
|
||||||
|
CppSQLite3Query(const CppSQLite3Query& rQuery);
|
||||||
|
|
||||||
|
CppSQLite3Query(sqlite3* pDB,
|
||||||
|
sqlite3_stmt* pVM,
|
||||||
|
bool bEof,
|
||||||
|
bool bOwnVM=true);
|
||||||
|
|
||||||
|
CppSQLite3Query& operator=(const CppSQLite3Query& rQuery);
|
||||||
|
|
||||||
|
virtual ~CppSQLite3Query();
|
||||||
|
|
||||||
|
int numFields();
|
||||||
|
|
||||||
|
int fieldIndex(const char* szField);
|
||||||
|
const char* fieldName(int nCol);
|
||||||
|
|
||||||
|
const char* fieldDeclType(int nCol);
|
||||||
|
int fieldDataType(int nCol);
|
||||||
|
|
||||||
|
const char* fieldValue(int nField);
|
||||||
|
const char* fieldValue(const char* szField);
|
||||||
|
|
||||||
|
int getIntField(int nField, int nNullValue=0);
|
||||||
|
int getIntField(const char* szField, int nNullValue=0);
|
||||||
|
|
||||||
|
sqlite_int64 getInt64Field(int nField, sqlite_int64 nNullValue=0);
|
||||||
|
sqlite_int64 getInt64Field(const char* szField, sqlite_int64 nNullValue=0);
|
||||||
|
|
||||||
|
double getFloatField(int nField, double fNullValue=0.0);
|
||||||
|
double getFloatField(const char* szField, double fNullValue=0.0);
|
||||||
|
|
||||||
|
const char* getStringField(int nField, const char* szNullValue="");
|
||||||
|
const char* getStringField(const char* szField, const char* szNullValue="");
|
||||||
|
|
||||||
|
const unsigned char* getBlobField(int nField, int& nLen);
|
||||||
|
const unsigned char* getBlobField(const char* szField, int& nLen);
|
||||||
|
|
||||||
|
bool fieldIsNull(int nField);
|
||||||
|
bool fieldIsNull(const char* szField);
|
||||||
|
|
||||||
|
bool eof();
|
||||||
|
|
||||||
|
void nextRow();
|
||||||
|
|
||||||
|
void finalize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void checkVM();
|
||||||
|
|
||||||
|
sqlite3* mpDB;
|
||||||
|
sqlite3_stmt* mpVM;
|
||||||
|
bool mbEof;
|
||||||
|
int mnCols;
|
||||||
|
bool mbOwnVM;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3Table
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Table();
|
||||||
|
|
||||||
|
CppSQLite3Table(const CppSQLite3Table& rTable);
|
||||||
|
|
||||||
|
CppSQLite3Table(char** paszResults, int nRows, int nCols);
|
||||||
|
|
||||||
|
virtual ~CppSQLite3Table();
|
||||||
|
|
||||||
|
CppSQLite3Table& operator=(const CppSQLite3Table& rTable);
|
||||||
|
|
||||||
|
int numFields();
|
||||||
|
|
||||||
|
int numRows();
|
||||||
|
|
||||||
|
const char* fieldName(int nCol);
|
||||||
|
|
||||||
|
const char* fieldValue(int nField);
|
||||||
|
const char* fieldValue(const char* szField);
|
||||||
|
|
||||||
|
int getIntField(int nField, int nNullValue=0);
|
||||||
|
int getIntField(const char* szField, int nNullValue=0);
|
||||||
|
|
||||||
|
double getFloatField(int nField, double fNullValue=0.0);
|
||||||
|
double getFloatField(const char* szField, double fNullValue=0.0);
|
||||||
|
|
||||||
|
const char* getStringField(int nField, const char* szNullValue="");
|
||||||
|
const char* getStringField(const char* szField, const char* szNullValue="");
|
||||||
|
|
||||||
|
bool fieldIsNull(int nField);
|
||||||
|
bool fieldIsNull(const char* szField);
|
||||||
|
|
||||||
|
void setRow(int nRow);
|
||||||
|
|
||||||
|
void finalize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void checkResults();
|
||||||
|
|
||||||
|
int mnCols;
|
||||||
|
int mnRows;
|
||||||
|
int mnCurrentRow;
|
||||||
|
char** mpaszResults;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3Statement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3Statement();
|
||||||
|
|
||||||
|
CppSQLite3Statement(const CppSQLite3Statement& rStatement);
|
||||||
|
|
||||||
|
CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM);
|
||||||
|
|
||||||
|
virtual ~CppSQLite3Statement();
|
||||||
|
|
||||||
|
CppSQLite3Statement& operator=(const CppSQLite3Statement& rStatement);
|
||||||
|
|
||||||
|
int execDML();
|
||||||
|
|
||||||
|
CppSQLite3Query execQuery();
|
||||||
|
|
||||||
|
void bind(int nParam, const char* szValue);
|
||||||
|
void bind(int nParam, const int nValue);
|
||||||
|
void bind(int nParam, const double dwValue);
|
||||||
|
void bind(int nParam, const unsigned char* blobValue, int nLen);
|
||||||
|
void bindNull(int nParam);
|
||||||
|
|
||||||
|
int bindParameterIndex(const char* szParam);
|
||||||
|
void bind(const char* szParam, const char* szValue);
|
||||||
|
void bind(const char* szParam, const int nValue);
|
||||||
|
void bind(const char* szParam, const double dwValue);
|
||||||
|
void bind(const char* szParam, const unsigned char* blobValue, int nLen);
|
||||||
|
void bindNull(const char* szParam);
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void finalize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void checkDB();
|
||||||
|
void checkVM();
|
||||||
|
|
||||||
|
sqlite3* mpDB;
|
||||||
|
sqlite3_stmt* mpVM;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CppSQLite3DB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
CppSQLite3DB();
|
||||||
|
|
||||||
|
virtual ~CppSQLite3DB();
|
||||||
|
|
||||||
|
void open(const char* szFile);
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
bool tableExists(const char* szTable);
|
||||||
|
|
||||||
|
int execDML(const char* szSQL);
|
||||||
|
|
||||||
|
CppSQLite3Query execQuery(const char* szSQL);
|
||||||
|
|
||||||
|
int execScalar(const char* szSQL, int nNullValue=0);
|
||||||
|
|
||||||
|
CppSQLite3Table getTable(const char* szSQL);
|
||||||
|
|
||||||
|
CppSQLite3Statement compileStatement(const char* szSQL);
|
||||||
|
|
||||||
|
sqlite_int64 lastRowId();
|
||||||
|
|
||||||
|
void interrupt() { sqlite3_interrupt(mpDB); }
|
||||||
|
|
||||||
|
void setBusyTimeout(int nMillisecs);
|
||||||
|
|
||||||
|
static const char* SQLiteVersion() { return SQLITE_VERSION; }
|
||||||
|
static const char* SQLiteHeaderVersion() { return SQLITE_VERSION; }
|
||||||
|
static const char* SQLiteLibraryVersion() { return sqlite3_libversion(); }
|
||||||
|
static int SQLiteLibraryVersionNumber() { return sqlite3_libversion_number(); }
|
||||||
|
|
||||||
|
bool IsAutoCommitOn();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CppSQLite3DB(const CppSQLite3DB& db);
|
||||||
|
CppSQLite3DB& operator=(const CppSQLite3DB& db);
|
||||||
|
|
||||||
|
sqlite3_stmt* compile(const char* szSQL);
|
||||||
|
|
||||||
|
void checkDB();
|
||||||
|
|
||||||
|
sqlite3* mpDB;
|
||||||
|
int mnBusyTimeoutMs;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Vendored
+7831
File diff suppressed because it is too large
Load Diff
Vendored
+1587
File diff suppressed because it is too large
Load Diff
Vendored
+155866
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user