Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ if (SQLITE_USE_LEGACY_STRUCT)
target_compile_definitions(SQLiteCpp PUBLIC SQLITE_USE_LEGACY_STRUCT)
endif (SQLITE_USE_LEGACY_STRUCT)

if(BUILD_SHARED_LIBS)
if(WIN32)
add_definitions("-DSQLITECPP_COMPILE_DLL")
target_compile_definitions(SQLiteCpp PRIVATE "SQLITECPP_DLL_EXPORT")
endif()
endif()

option(SQLITE_OMIT_LOAD_EXTENSION "Enable omit load extension" OFF)
if (SQLITE_OMIT_LOAD_EXTENSION)
# Enable the user definition of load_extension().
Expand Down Expand Up @@ -402,8 +409,10 @@ endif (SQLITECPP_RUN_DOXYGEN)

option(SQLITECPP_BUILD_EXAMPLES "Build examples." OFF)
if (SQLITECPP_BUILD_EXAMPLES)

# add the basic example executable
add_executable(SQLiteCpp_example1 ${SQLITECPP_EXAMPLES})

target_link_libraries(SQLiteCpp_example1 SQLiteCpp)
if (MSYS OR MINGW)
target_link_libraries(SQLiteCpp_example1 ssp)
Expand Down
3 changes: 2 additions & 1 deletion include/SQLiteCpp/Backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Database.h>

#include <string>
Expand All @@ -31,7 +32,7 @@ namespace SQLite
* See also the a reference implementation of live backup taken from the official site:
* https://www.sqlite.org/backup.html
*/
class Backup
class SQLITECPP_API Backup
{
public:
/**
Expand Down
15 changes: 8 additions & 7 deletions include/SQLiteCpp/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Statement.h>
#include <SQLiteCpp/Exception.h>

Expand All @@ -22,11 +23,11 @@ struct sqlite3_stmt;
namespace SQLite
{

extern const int INTEGER; ///< SQLITE_INTEGER
extern const int FLOAT; ///< SQLITE_FLOAT
extern const int TEXT; ///< SQLITE_TEXT
extern const int BLOB; ///< SQLITE_BLOB
extern const int Null; ///< SQLITE_NULL
SQLITECPP_API extern const int INTEGER; ///< SQLITE_INTEGER
SQLITECPP_API extern const int FLOAT; ///< SQLITE_FLOAT
SQLITECPP_API extern const int TEXT; ///< SQLITE_TEXT
SQLITECPP_API extern const int BLOB; ///< SQLITE_BLOB
SQLITECPP_API extern const int Null; ///< SQLITE_NULL

/**
* @brief Encapsulation of a Column in a row of the result pointed by the prepared Statement.
Expand All @@ -44,7 +45,7 @@ extern const int Null; ///< SQLITE_NULL
* because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr").
*/
class Column
class SQLITECPP_API Column
{
public:
/**
Expand Down Expand Up @@ -241,7 +242,7 @@ class Column
*
* @return Reference to the stream used
*/
std::ostream& operator<<(std::ostream& aStream, const Column& aColumn);
SQLITECPP_API std::ostream& operator<<(std::ostream& aStream, const Column& aColumn);

#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900) // c++14: Visual Studio 2015

Expand Down
35 changes: 18 additions & 17 deletions include/SQLiteCpp/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Column.h>

// c++17: MinGW GCC version > 8
Expand Down Expand Up @@ -84,37 +85,37 @@ namespace SQLite
// Those public constants enable most usages of SQLiteCpp without including <sqlite3.h> in the client application.

/// The database is opened in read-only mode. If the database does not already exist, an error is returned.
extern const int OPEN_READONLY; // SQLITE_OPEN_READONLY
SQLITECPP_API extern const int OPEN_READONLY; // SQLITE_OPEN_READONLY
/// The database is opened for reading and writing if possible, or reading only if the file is write protected
/// by the operating system. In either case the database must already exist, otherwise an error is returned.
extern const int OPEN_READWRITE; // SQLITE_OPEN_READWRITE
SQLITECPP_API extern const int OPEN_READWRITE; // SQLITE_OPEN_READWRITE
/// With OPEN_READWRITE: The database is opened for reading and writing, and is created if it does not already exist.
extern const int OPEN_CREATE; // SQLITE_OPEN_CREATE
SQLITECPP_API extern const int OPEN_CREATE; // SQLITE_OPEN_CREATE
/// Enable URI filename interpretation, parsed according to RFC 3986 (ex. "file:data.db?mode=ro&cache=private")
extern const int OPEN_URI; // SQLITE_OPEN_URI
SQLITECPP_API extern const int OPEN_URI; // SQLITE_OPEN_URI
/// Open in memory database
extern const int OPEN_MEMORY; // SQLITE_OPEN_MEMORY
SQLITECPP_API extern const int OPEN_MEMORY; // SQLITE_OPEN_MEMORY
/// Open database in multi-thread threading mode
extern const int OPEN_NOMUTEX; // SQLITE_OPEN_NOMUTEX
SQLITECPP_API extern const int OPEN_NOMUTEX; // SQLITE_OPEN_NOMUTEX
/// Open database with thread-safety in serialized threading mode
extern const int OPEN_FULLMUTEX; // SQLITE_OPEN_FULLMUTEX
SQLITECPP_API extern const int OPEN_FULLMUTEX; // SQLITE_OPEN_FULLMUTEX
/// Open database with shared cache enabled
extern const int OPEN_SHAREDCACHE; // SQLITE_OPEN_SHAREDCACHE
SQLITECPP_API extern const int OPEN_SHAREDCACHE; // SQLITE_OPEN_SHAREDCACHE
/// Open database with shared cache disabled
extern const int OPEN_PRIVATECACHE; // SQLITE_OPEN_PRIVATECACHE
SQLITECPP_API extern const int OPEN_PRIVATECACHE; // SQLITE_OPEN_PRIVATECACHE
/// Database filename is not allowed to be a symbolic link (Note: only since SQlite 3.31.0 from 2020-01-22)
extern const int OPEN_NOFOLLOW; // SQLITE_OPEN_NOFOLLOW
SQLITECPP_API extern const int OPEN_NOFOLLOW; // SQLITE_OPEN_NOFOLLOW


extern const int OK; ///< SQLITE_OK (used by check() bellow)
SQLITECPP_API extern const int OK; ///< SQLITE_OK (used by check() bellow)

extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time
extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time
SQLITECPP_API extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time
SQLITECPP_API extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time

/// Return SQLite version string using runtime call to the compiled library
const char* getLibVersion() noexcept;
SQLITECPP_API const char* getLibVersion() noexcept;
/// Return SQLite version number using runtime call to the compiled library
int getLibVersionNumber() noexcept;
SQLITECPP_API int getLibVersionNumber() noexcept;

// Public structure for representing all fields contained within the SQLite header.
// Official documentation for fields: https://www.sqlite.org/fileformat.html#the_database_header
Expand Down Expand Up @@ -160,7 +161,7 @@ struct Header {
* because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr").
*/
class Database
class SQLITECPP_API Database
{
friend class Statement; // Give Statement constructor access to the mSQLitePtr Connection Handle

Expand Down Expand Up @@ -265,7 +266,7 @@ class Database
// Deleter functor to use with smart pointers to close the SQLite database connection in an RAII fashion.
struct Deleter
{
void operator()(sqlite3* apSQLite);
SQLITECPP_API void operator()(sqlite3* apSQLite);
};

/**
Expand Down
3 changes: 2 additions & 1 deletion include/SQLiteCpp/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <stdexcept>
#include <string>

Expand All @@ -23,7 +24,7 @@ namespace SQLite
/**
* @brief Encapsulation of the error message from SQLite3, based on std::runtime_error.
*/
class Exception : public std::runtime_error
class SQLITECPP_API Exception : public std::runtime_error
{
public:
/**
Expand Down
3 changes: 3 additions & 0 deletions include/SQLiteCpp/SQLiteCpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


// Include useful headers of SQLiteC++
#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Assertion.h>
#include <SQLiteCpp/Exception.h>
#include <SQLiteCpp/Database.h>
Expand All @@ -42,3 +43,5 @@
*/
#define SQLITECPP_VERSION "3.02.01" // 3.2.1
#define SQLITECPP_VERSION_NUMBER 3002001 // 3.2.1


40 changes: 40 additions & 0 deletions include/SQLiteCpp/SQLiteCppExport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @file SQLiteCppExport.h
* @ingroup SQLiteCpp
* @brief File with macros needed in the generation of Windows DLLs
*
*
* Copyright (c) 2012-2022 Sebastien Rombauts ([email protected])
*
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
* or copy at http://opensource.org/licenses/MIT)
*/

#pragma once

/*
* #define SQLITECPP_COMPILE_DLL to compile a DLL under Windows
* #define SQLITECPP_EXPORT to export symbols when creating the DLL, otherwise it defaults to importing symbols
*/

/* Windows DLL export/import */
#if defined(_WIN32)&& !defined(__GNUC__) && defined(SQLITECPP_COMPILE_DLL)
#if SQLITECPP_DLL_EXPORT
#define SQLITECPP_API __declspec(dllexport)
#pragma message("Exporting symbols")
#else
#define SQLITECPP_API __declspec(dllimport)
#pragma message("Importing symbols")
#endif
#else
#if __GNUC__ >= 4
#define SQLITECPP_API __attribute__ ((visibility ("default")))
#else
#define SQLITECPP_API
#endif
#endif

#if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL)
#pragma warning( disable : 4251 )
#pragma warning( disable : 4275 )
#endif
3 changes: 2 additions & 1 deletion include/SQLiteCpp/Savepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Exception.h>

namespace SQLite
Expand Down Expand Up @@ -53,7 +54,7 @@ class Database;
* because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr").
*/
class Savepoint
class SQLITECPP_API Savepoint
{
public:
/**
Expand Down
5 changes: 3 additions & 2 deletions include/SQLiteCpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Exception.h>
#include <SQLiteCpp/Utils.h> // SQLITECPP_PURE_FUNC

Expand All @@ -30,7 +31,7 @@ namespace SQLite
class Database;
class Column;

extern const int OK; ///< SQLITE_OK
SQLITECPP_API extern const int OK; ///< SQLITE_OK

/**
* @brief RAII encapsulation of a prepared SQLite Statement.
Expand All @@ -49,7 +50,7 @@ extern const int OK; ///< SQLITE_OK
* because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr").
*/
class Statement
class SQLITECPP_API Statement
{
public:
/**
Expand Down
3 changes: 2 additions & 1 deletion include/SQLiteCpp/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
#pragma once

#include <SQLiteCpp/SQLiteCppExport.h>
#include <SQLiteCpp/Exception.h>


Expand Down Expand Up @@ -50,7 +51,7 @@ enum class TransactionBehavior {
* because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr").
*/
class Transaction
class SQLITECPP_API Transaction
{
public:
/**
Expand Down
Loading