soci-3.2.3/ 0000755 0000000 0000000 00000000000 12511402516 011147 5 ustar root root soci-3.2.3/cmake/ 0000755 0000000 0000000 00000000000 12511362240 012226 5 ustar root root soci-3.2.3/cmake/resources/ 0000755 0000000 0000000 00000000000 12511362240 014240 5 ustar root root soci-3.2.3/cmake/resources/vs2010-test-cmd-args.vcxproj.user.in 0000644 0000000 0000000 00000000616 12511362240 022645 0 ustar root root
@SOCI_TEST_CMD_ARGS@
WindowsLocalDebugger
soci-3.2.3/cmake/modules/ 0000755 0000000 0000000 00000000000 12511401144 013673 5 ustar root root soci-3.2.3/cmake/modules/FindFirebird.cmake 0000644 0000000 0000000 00000001653 12511362240 017234 0 ustar root root ##############################################################
# Copyright (c) 2008 Daniel Pfeifer #
# #
# Distributed under the Boost Software License, Version 1.0. #
##############################################################
# This module defines
# FIREBIRD_INCLUDE_DIR - where to find ibase.h
# FIREBIRD_LIBRARIES - the libraries to link against to use FIREBIRD
# FIREBIRD_FOUND - true if FIREBIRD was found
find_path(FIREBIRD_INCLUDE_DIR ibase.h
/usr/include
$ENV{ProgramFiles}/Firebird/*/include
)
find_library(FIREBIRD_LIBRARIES
NAMES
fbclient
fbclient_ms
PATHS
/usr/lib
$ENV{ProgramFiles}/Firebird/*/lib
)
# fbembed ?
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Firebird
DEFAULT_MSG FIREBIRD_LIBRARIES FIREBIRD_INCLUDE_DIR)
mark_as_advanced(FIREBIRD_INCLUDE_DIR FIREBIRD_LIBRARIES)
soci-3.2.3/cmake/modules/FindMySQL.cmake 0000644 0000000 0000000 00000010555 12511362240 016454 0 ustar root root # - Try to find MySQL / MySQL Embedded library
# Find the MySQL includes and client library
# This module defines
# MYSQL_INCLUDE_DIR, where to find mysql.h
# MYSQL_LIBRARIES, the libraries needed to use MySQL.
# MYSQL_LIB_DIR, path to the MYSQL_LIBRARIES
# MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded.
# MYSQL_EMBEDDED_LIB_DIR, path to the MYSQL_EMBEDDED_LIBRARIES
# MYSQL_FOUND, If false, do not try to use MySQL.
# MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded.
# Copyright (c) 2006-2008, Jarosław Staniek
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckCXXSourceCompiles)
if(WIN32)
find_path(MYSQL_INCLUDE_DIR mysql.h
PATHS
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
$ENV{ProgramFiles}/MySQL/*/include
$ENV{SystemDrive}/MySQL/*/include
)
else(WIN32)
find_path(MYSQL_INCLUDE_DIR mysql.h
PATHS
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
/usr/local/mysql/include
/opt/mysql/mysql/include
PATH_SUFFIXES
mysql
)
endif(WIN32)
if(WIN32)
if (${CMAKE_BUILD_TYPE})
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
endif()
# path suffix for debug/release mode
# binary_dist: mysql binary distribution
# build_dist: custom build
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
set(binary_dist debug)
set(build_dist Debug)
else(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
ADD_DEFINITIONS(-DDBUG_OFF)
set(binary_dist opt)
set(build_dist Release)
endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
# find_library(MYSQL_LIBRARIES NAMES mysqlclient
find_library(MYSQL_LIBRARIES NAMES libmysql
PATHS
$ENV{MYSQL_DIR}/lib/${binary_dist}
$ENV{MYSQL_DIR}/libmysql/${build_dist}
$ENV{MYSQL_DIR}/client/${build_dist}
$ENV{ProgramFiles}/MySQL/*/lib/${binary_dist}
$ENV{SystemDrive}/MySQL/*/lib/${binary_dist}
)
else(WIN32)
# find_library(MYSQL_LIBRARIES NAMES mysqlclient
find_library(MYSQL_LIBRARIES NAMES libmysql
PATHS
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
/usr/local/mysql/lib
/opt/mysql/mysql/lib
PATH_SUFFIXES
mysql
)
endif(WIN32)
if(WIN32)
set(MYSQL_LIB_PATHS
$ENV{MYSQL_DIR}/lib/opt
$ENV{MYSQL_DIR}/client/release
$ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt
)
find_library(MYSQL_LIBRARIES NAMES mysqlclient
PATHS
${MYSQL_LIB_PATHS}
)
else(WIN32)
set(MYSQL_LIB_PATHS
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
/usr/local/mysql/lib
/opt/mysql/mysql/lib
PATH_SUFFIXES
mysql
)
find_library(MYSQL_LIBRARIES NAMES mysqlclient
PATHS
${MYSQL_LIB_PATHS}
)
endif(WIN32)
find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld
PATHS
${MYSQL_LIB_PATHS}
)
if(MYSQL_LIBRARIES)
get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIBRARIES} PATH)
endif(MYSQL_LIBRARIES)
if(MYSQL_EMBEDDED_LIBRARIES)
get_filename_component(MYSQL_EMBEDDED_LIB_DIR ${MYSQL_EMBEDDED_LIBRARIES} PATH)
endif(MYSQL_EMBEDDED_LIBRARIES)
set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
check_cxx_source_compiles( "#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
set(MYSQL_FOUND TRUE)
message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
set(MYSQL_FOUND FALSE)
message(STATUS "MySQL not found.")
endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
set(MYSQL_EMBEDDED_FOUND TRUE)
message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}")
else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
set(MYSQL_EMBEDDED_FOUND FALSE)
message(STATUS "MySQL Embedded not found.")
endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES)
soci-3.2.3/cmake/modules/FindDL.cmake 0000644 0000000 0000000 00000001064 12511362240 016001 0 ustar root root if(DL_INCLUDE_DIR)
set(DL_FIND_QUIETLY TRUE)
endif()
find_path(DL_INCLUDE_DIR dlfcn.h)
find_library(DL_LIBRARY NAMES dl)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DL DEFAULT_MSG DL_LIBRARY DL_INCLUDE_DIR)
if(NOT DL_FOUND)
# if dlopen can be found without linking in dl then,
# dlopen is part of libc, so don't need to link extra libs.
include(CheckFunctionExists)
check_function_exists(dlopen DL_FOUND)
set(DL_LIBRARY "")
endif()
set(DL_LIBRARIES ${DL_LIBRARY})
mark_as_advanced(DL_LIBRARY DL_INCLUDE_DIR)
soci-3.2.3/cmake/modules/FindDB2.cmake 0000644 0000000 0000000 00000006035 12511362240 016054 0 ustar root root ###############################################################################
# CMake module to search for DB2 client library
#
# On success, the macro sets the following variables:
# DB2_FOUND = if the library found
# DB2_LIBRARY = full path to the library
# DB2_LIBRARIES = full path to the library
# DB2_INCLUDE_DIR = where to find the library headers
#
# Copyright (c) 2013 Denis Chapligin
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
if(UNIX)
set(DB2_INSTALL_PATHS
/opt/ibm/db2/V10.1
/opt/ibm/db2/V9.7
/opt/ibm/db2/V9.5
/opt/ibm/db2/V9.1)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(DB2_LIBDIRS "lib32" "lib")
else()
set(DB2_LIBDIRS "lib64")
endif()
set(DB2_FIND_INCLUDE_PATHS)
set(DB2_FIND_LIB_PATHS)
foreach(db2_install_path ${DB2_INSTALL_PATHS})
if (IS_DIRECTORY ${db2_install_path}/include)
set(DB2_FIND_INCLUDE_PATHS
${DB2_FIND_INCLUDE_PATHS}
${db2_install_path}/include)
endif()
foreach(db2_libdir ${DB2_LIBDIRS})
if (IS_DIRECTORY ${db2_install_path}/${db2_libdir})
set(DB2_FIND_LIB_PATHS
${DB2_FIND_LIB_PATHS}
${db2_install_path}/${db2_libdir})
endif()
endforeach(db2_libdir)
endforeach(db2_install_path)
elseif(WIN32)
if (CMAKE_CL_64) # 64-bit build, DB2 64-bit installed
set(DB2_FIND_INCLUDE_PATHS $ENV{ProgramW6432}/IBM/SQLLIB/include)
set(DB2_FIND_LIB_PATHS $ENV{ProgramW6432}/IBM/SQLLIB/lib)
else() # 32-bit build, DB2 64-bit or DB2 32-bit installed
if(EXISTS "$ENV{ProgramW6432}/IBM/SQLLIB/lib")
# On 64-bit Windows with DB2 64-bit installed:
# LIB environment points to {DB2}/IBM/SQLLIB/lib with64-bit db2api.lib,
# this flag prevents checking paths in LIB, so Win32 version can be detected
set(DB2_FIND_LIB_NO_LIB NO_SYSTEM_ENVIRONMENT_PATH)
endif()
set(DB2_FIND_INCLUDE_PATHS
$ENV{ProgramW6432}/IBM/SQLLIB/include
$ENV{ProgramFiles}/IBM/SQLLIB/include)
set(DB2_FIND_LIB_PATHS
$ENV{ProgramFiles}/IBM/SQLLIB/lib
$ENV{ProgramFiles}/IBM/SQLLIB/lib/win32
$ENV{ProgramW6432}/IBM/SQLLIB/lib/win32)
endif()
endif()
find_path(DB2_INCLUDE_DIR sqlcli1.h
$ENV{DB2_INCLUDE_DIR}
$ENV{DB2_DIR}/include
${DB2_FIND_INCLUDE_PATHS})
find_library(DB2_LIBRARY
NAMES db2 db2api
PATHS
${DB2_FIND_LIB_PATHS}
${DB2_FIND_LIB_NO_LIB})
if(DB2_LIBRARY)
get_filename_component(DB2_LIBRARY_DIR ${DB2_LIBRARY} PATH)
endif()
if(DB2_INCLUDE_DIR AND DB2_LIBRARY_DIR)
set(DB2_FOUND TRUE)
include_directories(${DB2_INCLUDE_DIR})
link_directories(${DB2_LIBRARY_DIR})
endif()
set(DB2_LIBRARIES ${DB2_LIBRARY})
# Handle the QUIETLY and REQUIRED arguments and set DB2_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DB2
DEFAULT_MSG
DB2_INCLUDE_DIR
DB2_LIBRARIES)
mark_as_advanced(DB2_INCLUDE_DIR DB2_LIBRARIES)
soci-3.2.3/cmake/modules/FindSQLite3.cmake 0000644 0000000 0000000 00000003544 12511362240 016733 0 ustar root root ###############################################################################
# CMake module to search for SQLite 3 library
#
# On success, the macro sets the following variables:
# SQLITE3_FOUND = if the library found
# SQLITE3_LIBRARY = full path to the library
# SQLITE3_LIBRARIES = full path to the library
# SSQLITE3_INCLUDE_DIR = where to find the library headers
#
# Copyright (c) 2009 Mateusz Loskot
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
find_path(SQLITE3_INCLUDE_DIR
NAMES sqlite3.h
PATH_PREFIXES sqlite sqlite3
PATHS
/usr/include
/usr/local/include
$ENV{LIB_DIR}/include
$ENV{LIB_DIR}/include/sqlite
$ENV{LIB_DIR}/include/sqlite3
$ENV{ProgramFiles}/SQLite/*/include
$ENV{ProgramFiles}/SQLite3/*/include
$ENV{SystemDrive}/SQLite/*/include
$ENV{SystemDrive}/SQLite3/*/include
$ENV{SQLITE_ROOT}/include
${SQLITE_ROOT_DIR}/include
$ENV{OSGEO4W_ROOT}/include)
set(SQLITE3_NAMES sqlite3_i sqlite3)
find_library(SQLITE3_LIBRARY
NAMES ${SQLITE3_NAMES}
PATHS
/usr/lib
/usr/local/lib
$ENV{LIB_DIR}/lib
$ENV{ProgramFiles}/SQLite/*/lib
$ENV{ProgramFiles}/SQLite3/*/lib
$ENV{SystemDrive}/SQLite/*/lib
$ENV{SystemDrive}/SQLite3/*/lib
$ENV{SQLITE_ROOT}/lib
${SQLITE_ROOT_DIR}/lib
$ENV{OSGEO4W_ROOT}/lib)
set(SQLITE3_LIBRARIES
${SQLITE3_LIBRARIES}
${SQLITE3_LIBRARY})
#message(STATUS ${SQLITE3_LIBRARY})
# Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLITE3
DEFAULT_MSG
SQLITE3_LIBRARIES
SQLITE3_INCLUDE_DIR)
mark_as_advanced(SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR SQLITE3_LIBRARIES)
soci-3.2.3/cmake/modules/FindSoci.cmake 0000644 0000000 0000000 00000005667 12511362240 016414 0 ustar root root ###############################################################################
# CMake module to search for SOCI library
#
# WARNING: This module is experimental work in progress.
#
# This module defines:
# SOCI_INCLUDE_DIRS = include dirs to be used when using the soci library
# SOCI_LIBRARY = full path to the soci library
# SOCI_VERSION = the soci version found (not yet. soci does not provide that info.)
# SOCI_FOUND = true if soci was found
#
# This module respects:
# LIB_SUFFIX = (64|32|"") Specifies the suffix for the lib directory
#
# For each component you specify in find_package(), the following variables are set.
#
# SOCI_${COMPONENT}_PLUGIN = full path to the soci plugin
# SOCI_${COMPONENT}_FOUND
#
# Copyright (c) 2011 Michael Jansen
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
#
### Global Configuration Section
#
SET(_SOCI_ALL_PLUGINS mysql odbc postgresql sqlite3)
SET(_SOCI_REQUIRED_VARS SOCI_INCLUDE_DIR SOCI_LIBRARY)
#
### FIRST STEP: Find the soci headers.
#
FIND_PATH(
SOCI_INCLUDE_DIR soci.h
PATH "/usr/local"
PATH_SUFFIXES "" "soci"
DOC "Soci (http://soci.sourceforge.net) include directory")
MARK_AS_ADVANCED(SOCI_INCLUDE_DIR)
SET(SOCI_INCLUDE_DIRS ${SOCI_INCLUDE_DIR})
#
### SECOND STEP: Find the soci core library. Respect LIB_SUFFIX
#
FIND_LIBRARY(
SOCI_LIBRARY
NAMES soci_core
HINTS ${SOCI_INCLUDE_DIR}/..
PATH_SUFFIXES lib${LIB_SUFFIX})
MARK_AS_ADVANCED(SOCI_LIBRARY)
GET_FILENAME_COMPONENT(SOCI_LIBRARY_DIR ${SOCI_LIBRARY} PATH)
MARK_AS_ADVANCED(SOCI_LIBRARY_DIR)
#
### THIRD STEP: Find all installed plugins if the library was found
#
IF(SOCI_INCLUDE_DIR AND SOCI_LIBRARY)
MESSAGE(STATUS "Soci found: Looking for plugins")
FOREACH(plugin IN LISTS _SOCI_ALL_PLUGINS)
FIND_LIBRARY(
SOCI_${plugin}_PLUGIN
NAMES soci_${plugin}
HINTS ${SOCI_INCLUDE_DIR}/..
PATH_SUFFIXES lib${LIB_SUFFIX})
MARK_AS_ADVANCED(SOCI_${plugin}_PLUGIN)
IF(SOCI_${plugin}_PLUGIN)
MESSAGE(STATUS " * Plugin ${plugin} found ${SOCI_${plugin}_PLUGIN}.")
SET(SOCI_${plugin}_FOUND True)
ELSE()
MESSAGE(STATUS " * Plugin ${plugin} not found.")
SET(SOCI_${plugin}_FOUND False)
ENDIF()
ENDFOREACH()
#
### FOURTH CHECK: Check if the required components were all found
#
FOREACH(component ${Soci_FIND_COMPONENTS})
IF(NOT SOCI_${component}_FOUND)
MESSAGE(SEND_ERROR "Required component ${component} not found.")
ENDIF()
ENDFOREACH()
ENDIF()
#
### ADHERE TO STANDARDS
#
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Soci DEFAULT_MSG ${_SOCI_REQUIRED_VARS})
soci-3.2.3/cmake/modules/FindPostgreSQL.cmake 0000644 0000000 0000000 00000004555 12511362240 017515 0 ustar root root # - Find PostgreSQL
# Find the PostgreSQL includes and client library
# This module defines
# POSTGRESQL_INCLUDE_DIR, where to find libpq-fe.h
# POSTGRESQL_LIBRARIES, libraries needed to use PostgreSQL
# POSTGRESQL_VERSION, if found, version of PostgreSQL
# POSTGRESQL_FOUND, if false, do not try to use PostgreSQL
#
# Copyright (c) 2010, Mateusz Loskot,
# Copyright (c) 2006, Jaroslaw Staniek,
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
find_program(PG_CONFIG NAMES pg_config
PATHS
/usr/bin
/usr/local/bin
$ENV{ProgramFiles}/PostgreSQL/*/bin
$ENV{SystemDrive}/PostgreSQL/*/bin
DOC "Path to pg_config utility")
if(PG_CONFIG)
exec_program(${PG_CONFIG}
ARGS "--version"
OUTPUT_VARIABLE PG_CONFIG_VERSION)
if(${PG_CONFIG_VERSION} MATCHES "^[A-Za-z]+[ ](.*)$")
string(REGEX REPLACE "^[A-Za-z]+[ ](.*)$" "\\1" POSTGRESQL_VERSION "${PG_CONFIG_VERSION}")
endif()
exec_program(${PG_CONFIG}
ARGS "--includedir"
OUTPUT_VARIABLE PG_CONFIG_INCLUDEDIR)
exec_program(${PG_CONFIG}
ARGS "--libdir"
OUTPUT_VARIABLE PG_CONFIG_LIBDIR)
else()
set(POSTGRESQL_VERSION "unknown")
endif()
find_path(POSTGRESQL_INCLUDE_DIR libpq-fe.h
${PG_CONFIG_INCLUDEDIR}
/usr/include/server
/usr/include/pgsql/server
/usr/local/include/pgsql/server
/usr/include/postgresql
/usr/include/postgresql/server
/usr/include/postgresql/*/server
$ENV{ProgramFiles}/PostgreSQL/*/include
$ENV{SystemDrive}/PostgreSQL/*/include)
find_library(POSTGRESQL_LIBRARIES NAMES pq libpq
PATHS
${PG_CONFIG_LIBDIR}
/usr/lib
/usr/local/lib
/usr/lib/postgresql
/usr/lib64
/usr/local/lib64
/usr/lib64/postgresql
$ENV{ProgramFiles}/PostgreSQL/*/lib
$ENV{SystemDrive}/PostgreSQL/*/lib
$ENV{ProgramFiles}/PostgreSQL/*/lib/ms
$ENV{SystemDrive}/PostgreSQL/*/lib/ms)
if(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
set(POSTGRESQL_FOUND TRUE)
else()
set(POSTGRESQL_FOUND FALSE)
endif()
# Handle the QUIETLY and REQUIRED arguments and set POSTGRESQL_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PostgreSQL
DEFAULT_MSG
POSTGRESQL_INCLUDE_DIR
POSTGRESQL_LIBRARIES
POSTGRESQL_VERSION)
mark_as_advanced(POSTGRESQL_INCLUDE_DIR POSTGRESQL_LIBRARIES)
soci-3.2.3/cmake/modules/FindOracle.cmake 0000644 0000000 0000000 00000005177 12511362240 016720 0 ustar root root ###############################################################################
#
# CMake module to search for Oracle client library (OCI)
#
# On success, the macro sets the following variables:
# ORACLE_FOUND = if the library found
# ORACLE_LIBRARY = full path to the library
# ORACLE_LIBRARIES = full path to the library
# ORACLE_INCLUDE_DIR = where to find the library headers also defined,
# but not for general use are
# ORACLE_VERSION = version of library which was found, e.g. "1.2.5"
#
# Copyright (c) 2009-2013 Mateusz Loskot
#
# Developed with inspiration from Petr Vanek
# who wrote similar macro for TOra - http://torasql.com/
#
# Module source: http://github.com/mloskot/workshop/tree/master/cmake/
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
# If ORACLE_HOME not defined, assume Oracle libraries not available
if(DEFINED ENV{ORACLE_HOME})
set(ORACLE_HOME $ENV{ORACLE_HOME})
message(STATUS "ORACLE_HOME=${ORACLE_HOME}")
find_path(ORACLE_INCLUDE_DIR
NAMES oci.h
PATHS
${ORACLE_HOME}/rdbms/public
${ORACLE_HOME}/include
${ORACLE_HOME}/sdk/include # Oracle SDK
${ORACLE_HOME}/OCI/include) # Oracle XE on Windows
set(ORACLE_OCI_NAMES clntsh libclntsh oci) # Dirty trick might help on OSX, see issues/89
set(ORACLE_OCCI_NAMES libocci occi oraocci10 oraocci11)
set(ORACLE_NNZ_NAMES nnz10 libnnz10 nnz11 libnnz11 nnz12 libnnz12 ociw32)
set(ORACLE_LIB_DIR
${ORACLE_HOME}
${ORACLE_HOME}/lib
${ORACLE_HOME}/sdk/lib # Oracle SDK
${ORACLE_HOME}/sdk/lib/msvc
${ORACLE_HOME}/OCI/lib/msvc) # Oracle XE on Windows
find_library(ORACLE_OCI_LIBRARY
NAMES ${ORACLE_OCI_NAMES} PATHS ${ORACLE_LIB_DIR})
find_library(ORACLE_OCCI_LIBRARY
NAMES ${ORACLE_OCCI_NAMES} PATHS ${ORACLE_LIB_DIR})
find_library(ORACLE_NNZ_LIBRARY
NAMES ${ORACLE_NNZ_NAMES} PATHS ${ORACLE_LIB_DIR})
set(ORACLE_LIBRARY
${ORACLE_OCI_LIBRARY}
${ORACLE_OCCI_LIBRARY}
${ORACLE_NNZ_LIBRARY})
if(NOT WIN32)
set(ORACLE_LIBRARY ${ORACLE_LIBRARY} ${ORACLE_CLNTSH_LIBRARY})
endif(NOT WIN32)
set(ORACLE_LIBRARIES ${ORACLE_LIBRARY})
endif(DEFINED ENV{ORACLE_HOME})
# Handle the QUIETLY and REQUIRED arguments and set ORACLE_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ORACLE DEFAULT_MSG ORACLE_LIBRARY ORACLE_INCLUDE_DIR)
mark_as_advanced(ORACLE_INCLUDE_DIR ORACLE_LIBRARY)
soci-3.2.3/cmake/modules/FindODBC.cmake 0000644 0000000 0000000 00000003725 12511401144 016214 0 ustar root root #
# Find the ODBC driver manager includes and library.
#
# ODBC is an open standard for connecting to different databases in a
# semi-vendor-independent fashion. First you install the ODBC driver
# manager. Then you need a driver for each separate database you want
# to connect to (unless a generic one works). VTK includes neither
# the driver manager nor the vendor-specific drivers: you have to find
# those yourself.
#
# This module defines
# ODBC_INCLUDE_DIR, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires MySQL.
# also defined, but not for general use is
# ODBC_LIBRARY, where to find the ODBC driver manager library.
set(ODBC_FOUND FALSE)
find_path(ODBC_INCLUDE_DIR sql.h
/usr/include
/usr/include/odbc
/usr/local/include
/usr/local/include/odbc
/usr/local/odbc/include
"C:/Program Files (x86)/Windows Kits/8.0/include/um"
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include"
"C:/Program Files/ODBC/include"
"C:/Program Files/Microsoft SDKs/Windows/v7.0/include"
"C:/Program Files/Microsoft SDKs/Windows/v6.0a/include"
"C:/ODBC/include"
DOC "Specify the directory containing sql.h."
)
if(MSVC)
# msvc knows where to find sdk libs
set(ODBC_LIBRARY odbc32)
else()
find_library(ODBC_LIBRARY
NAMES iodbc odbc odbcinst odbc32
PATHS
/usr/lib
/usr/lib/odbc
/usr/local/lib
/usr/local/lib/odbc
/usr/local/odbc/lib
"C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86/"
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib"
"C:/Program Files/ODBC/lib"
"C:/ODBC/lib/debug"
DOC "Specify the ODBC driver manager library here."
)
endif()
if(ODBC_LIBRARY)
if(ODBC_INCLUDE_DIR)
set( ODBC_FOUND 1 )
endif()
endif()
set(ODBC_LIBRARIES ${ODBC_LIBRARY})
mark_as_advanced(ODBC_FOUND ODBC_LIBRARY ODBC_EXTRA_LIBRARIES ODBC_INCLUDE_DIR)
soci-3.2.3/cmake/SociUtilities.cmake 0000644 0000000 0000000 00000033502 12511362240 016024 0 ustar root root ################################################################################
# SociUtilities.cmake - part of CMake configuration of SOCI library
#
# Based on BoostUtilities.cmake from CMake configuration for Boost
################################################################################
# Copyright (C) 2007 Douglas Gregor
# Copyright (C) 2007 Troy Straszheim
# Copyright (C) 2010 Mateusz Loskot
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
################################################################################
# Macros in this module:
#
# list_contains: Determine whether a string value is in a list.
#
# car: Return the first element in a list
#
# cdr: Return all but the first element in a list
#
# parse_arguments: Parse keyword arguments for use in other macros.
#
# soci_check_package_found: Test varname-FOUND for case-insensitive varname
#
################################################################################
# This utility macro determines whether a particular string value
# occurs within a list of strings:
#
# list_contains(result string_to_find arg1 arg2 arg3 ... argn)
#
# This macro sets the variable named by result equal to TRUE if
# string_to_find is found anywhere in the following arguments.
macro(list_contains var value)
set(${var})
foreach (value2 ${ARGN})
if (${value} STREQUAL ${value2})
set(${var} TRUE)
endif (${value} STREQUAL ${value2})
endforeach (value2)
endmacro(list_contains)
# This utility macro extracts the first argument from the list of
# arguments given, and places it into the variable named var.
#
# car(var arg1 arg2 ...)
macro(car var)
set(${var} ${ARGV1})
endmacro(car)
# This utility macro extracts all of the arguments given except the
# first, and places them into the variable named var.
#
# car(var arg1 arg2 ...)
macro(cdr var junk)
set(${var} ${ARGN})
endmacro(cdr)
# The parse_arguments macro will take the arguments of another macro and
# define several variables. The first argument to parse_arguments is a
# prefix to put on all variables it creates. The second argument is a
# list of names, and the third argument is a list of options. Both of
# these lists should be quoted. The rest of parse_arguments are
# arguments from another macro to be parsed.
#
# parse_arguments(prefix arg_names options arg1 arg2...)
#
# For each item in options, parse_arguments will create a variable with
# that name, prefixed with prefix_. So, for example, if prefix is
# MY_MACRO and options is OPTION1;OPTION2, then parse_arguments will
# create the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These
# variables will be set to true if the option exists in the command line
# or false otherwise.
#
# For each item in arg_names, parse_arguments will create a variable
# with that name, prefixed with prefix_. Each variable will be filled
# with the arguments that occur after the given arg_name is encountered
# up to the next arg_name or the end of the arguments. All options are
# removed from these lists. parse_arguments also creates a
# prefix_DEFAULT_ARGS variable containing the list of all arguments up
# to the first arg_name encountered.
macro(parse_arguments prefix arg_names option_names)
set(DEFAULT_ARGS)
foreach(arg_name ${arg_names})
set(${prefix}_${arg_name})
endforeach(arg_name)
foreach(option ${option_names})
set(${prefix}_${option} FALSE)
endforeach(option)
set(current_arg_name DEFAULT_ARGS)
set(current_arg_list)
foreach(arg ${ARGN})
list_contains(is_arg_name ${arg} ${arg_names})
if (is_arg_name)
set(${prefix}_${current_arg_name} ${current_arg_list})
set(current_arg_name ${arg})
set(current_arg_list)
else (is_arg_name)
list_contains(is_option ${arg} ${option_names})
if (is_option)
set(${prefix}_${arg} TRUE)
else (is_option)
set(current_arg_list ${current_arg_list} ${arg})
endif (is_option)
endif (is_arg_name)
endforeach(arg)
set(${prefix}_${current_arg_name} ${current_arg_list})
endmacro(parse_arguments)
# Perform a reverse topological sort on the given LIST.
#
# topological_sort(my_list "MY_" "_EDGES")
#
# LIST is the name of a variable containing a list of elements to be
# sorted in reverse topological order. Each element in the list has a
# set of outgoing edges (for example, those other list elements that
# it depends on). In the resulting reverse topological ordering
# (written back into the variable named LIST), an element will come
# later in the list than any of the elements that can be reached by
# following its outgoing edges and the outgoing edges of any vertices
# they target, recursively. Thus, if the edges represent dependencies
# on build targets, for example, the reverse topological ordering is
# the order in which one would build those targets.
#
# For each element E in this list, the edges for E are contained in
# the variable named ${PREFIX}${E}${SUFFIX}, where E is the
# upper-cased version of the element in the list. If no such variable
# exists, then it is assumed that there are no edges. For example, if
# my_list contains a, b, and c, one could provide a dependency graph
# using the following variables:
#
# MY_A_EDGES b
# MY_B_EDGES
# MY_C_EDGES a b
#
# With the involcation of topological_sort shown above and these
# variables, the resulting reverse topological ordering will be b, a,
# c.
function(topological_sort LIST PREFIX SUFFIX)
# Clear the stack and output variable
set(VERTICES "${${LIST}}")
set(STACK)
set(${LIST})
# Loop over all of the vertices, starting the topological sort from
# each one.
foreach(VERTEX ${VERTICES})
string(TOUPPER ${VERTEX} UPPER_VERTEX)
# If we haven't already processed this vertex, start a depth-first
# search from where.
if (NOT FOUND_${UPPER_VERTEX})
# Push this vertex onto the stack with all of its outgoing edges
string(REPLACE ";" " " NEW_ELEMENT
"${VERTEX};${${PREFIX}${UPPER_VERTEX}${SUFFIX}}")
list(APPEND STACK ${NEW_ELEMENT})
# We've now seen this vertex
set(FOUND_${UPPER_VERTEX} TRUE)
# While the depth-first search stack is not empty
list(LENGTH STACK STACK_LENGTH)
while(STACK_LENGTH GREATER 0)
# Remove the vertex and its remaining out-edges from the top
# of the stack
list(GET STACK -1 OUT_EDGES)
list(REMOVE_AT STACK -1)
# Get the source vertex and the list of out-edges
separate_arguments(OUT_EDGES)
list(GET OUT_EDGES 0 SOURCE)
list(REMOVE_AT OUT_EDGES 0)
# While there are still out-edges remaining
list(LENGTH OUT_EDGES OUT_DEGREE)
while (OUT_DEGREE GREATER 0)
# Pull off the first outgoing edge
list(GET OUT_EDGES 0 TARGET)
list(REMOVE_AT OUT_EDGES 0)
string(TOUPPER ${TARGET} UPPER_TARGET)
if (NOT FOUND_${UPPER_TARGET})
# We have not seen the target before, so we will traverse
# its outgoing edges before coming back to our
# source. This is the key to the depth-first traversal.
# We've now seen this vertex
set(FOUND_${UPPER_TARGET} TRUE)
# Push the remaining edges for the current vertex onto the
# stack
string(REPLACE ";" " " NEW_ELEMENT
"${SOURCE};${OUT_EDGES}")
list(APPEND STACK ${NEW_ELEMENT})
# Setup the new source and outgoing edges
set(SOURCE ${TARGET})
string(TOUPPER ${SOURCE} UPPER_SOURCE)
set(OUT_EDGES
${${PREFIX}${UPPER_SOURCE}${SUFFIX}})
endif(NOT FOUND_${UPPER_TARGET})
list(LENGTH OUT_EDGES OUT_DEGREE)
endwhile (OUT_DEGREE GREATER 0)
# We have finished all of the outgoing edges for
# SOURCE; add it to the resulting list.
list(APPEND ${LIST} ${SOURCE})
# Check the length of the stack
list(LENGTH STACK STACK_LENGTH)
endwhile(STACK_LENGTH GREATER 0)
endif (NOT FOUND_${UPPER_VERTEX})
endforeach(VERTEX)
set(${LIST} ${${LIST}} PARENT_SCOPE)
endfunction(topological_sort)
# Small little hack that tweaks a component name (as used for CPack)
# to make sure to avoid certain names that cause problems. Sets the
# variable named varname to the "sanitized" name.
#
# FIXME: This is a complete hack. We probably need to fix the CPack
# generators (NSIS in particular) to get rid of the need for this.
macro(fix_cpack_component_name varname name)
if (${name} STREQUAL "foreach")
set(${varname} "boost_foreach")
else()
set(${varname} ${name})
endif()
endmacro()
#
# A big shout out to the cmake gurus @ compiz
#
function (colormsg)
string (ASCII 27 _escape)
set(WHITE "29")
set(GRAY "30")
set(RED "31")
set(GREEN "32")
set(YELLOW "33")
set(BLUE "34")
set(MAG "35")
set(CYAN "36")
foreach (color WHITE GRAY RED GREEN YELLOW BLUE MAG CYAN)
set(HI${color} "1\;${${color}}")
set(LO${color} "2\;${${color}}")
set(_${color}_ "4\;${${color}}")
set(_HI${color}_ "1\;4\;${${color}}")
set(_LO${color}_ "2\;4\;${${color}}")
endforeach()
set(str "")
set(coloron FALSE)
foreach(arg ${ARGV})
if (NOT ${${arg}} STREQUAL "")
if (CMAKE_COLOR_MAKEFILE)
set(str "${str}${_escape}[${${arg}}m")
set(coloron TRUE)
endif()
else()
set(str "${str}${arg}")
if (coloron)
set(str "${str}${_escape}[0m")
set(coloron FALSE)
endif()
set(str "${str} ")
endif()
endforeach()
message(STATUS ${str})
endfunction()
# colormsg("Colors:"
# WHITE "white" GRAY "gray" GREEN "green"
# RED "red" YELLOW "yellow" BLUE "blue" MAG "mag" CYAN "cyan"
# _WHITE_ "white" _GRAY_ "gray" _GREEN_ "green"
# _RED_ "red" _YELLOW_ "yellow" _BLUE_ "blue" _MAG_ "mag" _CYAN_ "cyan"
# _HIWHITE_ "white" _HIGRAY_ "gray" _HIGREEN_ "green"
# _HIRED_ "red" _HIYELLOW_ "yellow" _HIBLUE_ "blue" _HIMAG_ "mag" _HICYAN_ "cyan"
# HIWHITE "white" HIGRAY "gray" HIGREEN "green"
# HIRED "red" HIYELLOW "yellow" HIBLUE "blue" HIMAG "mag" HICYAN "cyan"
# "right?")
#
# pretty-prints the value of a variable so that the
# equals signs align
#
function(boost_report_value NAME)
string(LENGTH "${NAME}" varlen)
# LOG
#message(STATUS "boost_report_value: NAME=${NAME} (${varlen})")
#message(STATUS "boost_report_value: \${NAME}=${${NAME}}")
math(EXPR padding_len 40-${varlen})
string(SUBSTRING " "
0 ${padding_len} varpadding)
colormsg("${NAME}${varpadding} = ${${NAME}}")
endfunction()
function(trace NAME)
if(BOOST_CMAKE_TRACE)
string(LENGTH "${NAME}" varlen)
math(EXPR padding_len 40-${varlen})
string(SUBSTRING "........................................"
0 ${padding_len} varpadding)
message("${NAME} ${varpadding} ${${NAME}}")
endif()
endfunction()
#
# pretty-prints the value of a variable so that the
# equals signs align
#
function(boost_report_pretty PRETTYNAME VARNAME)
string(LENGTH "${PRETTYNAME}" varlen)
math(EXPR padding_len 30-${varlen})
string(SUBSTRING " "
0 ${padding_len} varpadding)
message(STATUS "${PRETTYNAME}${varpadding} = ${${VARNAME}}")
endfunction()
#
# assert that ARG is actually a library target
#
macro(dependency_check ARG)
trace(ARG)
if (NOT "${ARG}" STREQUAL "")
get_target_property(deptype ${ARG} TYPE)
if(NOT deptype MATCHES ".*_LIBRARY$")
set(DEPENDENCY_OKAY FALSE)
list(APPEND DEPENDENCY_FAILURES ${ARG})
endif()
endif()
endmacro()
#
# Tests package-FOUND for varname in three cases as given, lowercase and
# uppercase.
#
macro(soci_check_package_found NAME SUCCESS)
set(${SUCCESS} FALSE)
set(VARNAME ${NAME})
set(VARNAME_SUCCESS ${${VARNAME}_FOUND})
# Test both, given original name and uppercase version too
if(VARNAME_SUCCESS)
set(${SUCCESS} TRUE)
else()
string(TOUPPER ${NAME} VARNAME)
set(VARNAME_SUCCESS ${${VARNAME}_FOUND})
if(VARNAME_SUCCESS)
set(${SUCCESS} TRUE)
endif()
endif()
endmacro()
#
# Pretty-print of given property of current directory.
#
macro(soci_report_directory_property PROPNAME)
get_directory_property(${PROPNAME} ${PROPNAME})
boost_report_value(${PROPNAME})
endmacro()
#
# Scans the current directory and returns a list of subdirectories.
# Author: Robert Fleming
# Source: http://www.cmake.org/pipermail/cmake/2008-February/020114.html
#
# Third parameter is 1 if you want relative paths returned.
# Usage: list_subdirectories(the_list_is_returned_here /path/to/project TRUE)
#
macro(list_subdirectories retval curdir return_relative)
file(GLOB sub-dir RELATIVE ${curdir} *)
set(list_of_dirs "")
foreach(dir ${sub-dir})
if(IS_DIRECTORY ${curdir}/${dir})
if (${return_relative})
set(list_of_dirs ${list_of_dirs} ${dir})
else()
set(list_of_dirs ${list_of_dirs} ${curdir}/${dir})
endif()
endif()
endforeach()
set(${retval} ${list_of_dirs})
endmacro()
#
# Generates output name for given target depending on platform and version.
# For instance, on Windows, libraries get ABI version suffix soci_coreXY.{dll|lib}.
#
function(soci_target_output_name TARGET_NAME OUTPUT_NAME)
if(NOT DEFINED TARGET_NAME)
message(SEND_ERROR "Error, the variable TARGET_NAME is not defined!")
endif()
if(NOT DEFINED ${PROJECT_NAME}_VERSION)
message(SEND_ERROR "Error, the variable ${${PROJECT_NAME}_VERSION} is not defined!")
endif()
# On Windows, ABI version is specified using binary file name suffix.
# On Unix, suffix is empty and SOVERSION is used instead.
if (WIN32)
string(LENGTH "${${PROJECT_NAME}_ABI_VERSION}" abilen)
if(abilen GREATER 0)
set(SUFFIX "_${${PROJECT_NAME}_ABI_VERSION}")
endif()
endif()
set(${OUTPUT_NAME} ${TARGET_NAME}${SUFFIX} PARENT_SCOPE)
endfunction()
soci-3.2.3/cmake/SociDependencies.cmake 0000644 0000000 0000000 00000004471 12511362240 016442 0 ustar root root ################################################################################
# SociDependencies.cmake - part of CMake configuration of SOCI library
#
# Based on BoostExternals.cmake from CMake configuration for Boost
################################################################################
# Copyright (C) 2010 Mateusz Loskot
# Copyright (C) 2009 Troy Straszheim
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_backend - defines a database backend for SOCI library
#
################################################################################
#
# List of SOCI dependncies
#
set(SOCI_BACKENDS_DB_DEPENDENCIES
MySQL
ODBC
Oracle
PostgreSQL
SQLite3
Firebird
DB2)
set(SOCI_BACKENDS_ALL_DEPENDENCIES
Boost
${SOCI_BACKENDS_DB_DEPENDENCIES})
#
# Perform checks
#
colormsg(_HIBLUE_ "Looking for SOCI dependencies:")
macro(boost_external_report NAME)
set(VARNAME ${NAME})
set(SUCCESS ${${VARNAME}_FOUND})
set(VARNAMES ${ARGV})
list(REMOVE_AT VARNAMES 0)
# Test both, given original name and uppercase version too
if(NOT SUCCESS)
string(TOUPPER ${NAME} VARNAME)
set(SUCCESS ${${VARNAME}_FOUND})
if(NOT SUCCESS)
colormsg(_RED_ "WARNING:")
colormsg(RED "${NAME} not found, some libraries or features will be disabled.")
colormsg(RED "See the documentation for ${NAME} or manually set these variables:")
endif()
endif()
foreach(variable ${VARNAMES})
boost_report_value(${VARNAME}_${variable})
endforeach()
endmacro()
#
# Some externals default to OFF
#
option(WITH_VALGRIND "Run tests under valgrind" OFF)
#
# Detect available dependencies
#
foreach(external ${SOCI_BACKENDS_ALL_DEPENDENCIES})
string(TOUPPER "${external}" EXTERNAL)
option(WITH_${EXTERNAL} "Attempt to find and configure ${external}" ON)
if(WITH_${EXTERNAL})
colormsg(HICYAN "${external}:")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies/${external}.cmake)
else()
set(${EXTERNAL}_FOUND FALSE CACHE BOOL "${external} found" FORCE)
colormsg(HIRED "${external}:" RED "disabled, since WITH_${EXTERNAL}=OFF")
endif()
endforeach()
soci-3.2.3/cmake/SociConfig.cmake 0000644 0000000 0000000 00000003533 12511362240 015257 0 ustar root root ################################################################################
# SociConfig.cmake - CMake build configuration of SOCI library
################################################################################
# Copyright (C) 2010 Mateusz Loskot
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
#
# Force compilation flags and set desired warnings level
#
if (MSVC)
if (MSVC80 OR MSVC90 OR MSVC10)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNING)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
else()
set(SOCI_GCC_CLANG_COMMON_FLAGS
"-pedantic -ansi -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ${SOCI_GCC_CLANG_COMMON_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
endif()
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_GCC_CLANG_COMMON_FLAGS}")
else()
message(FATAL_ERROR "CMake is unable to recognize compilation toolset to build SOCI for you!")
endif()
endif()
soci-3.2.3/cmake/.gitignore 0000644 0000000 0000000 00000000277 12511362240 014224 0 ustar root root *~
*.kdev[0-9]
*.swp
aclocal.m4
autom4te.cache
confdefs.h
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
m4
missing
Makefile
Makefile.in
tmp
soci-3.2.3/cmake/SociSystemInfo.cmake 0000644 0000000 0000000 00000005257 12511362240 016157 0 ustar root root ################################################################################
# SociSystemInfo.cmake - part of CMake configuration of SOCI library
#
# Based on idea taken from http://code.google.com/p/softart/ project
################################################################################
# Copyright (C) 2010 Mateusz Loskot
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# The following variables are defined:
# SOCI_COMPILER_NAME - name of compiler toolset, follows Boost toolset naming.
# SOCI_PLATFORM_NAME - target platform name: x64, x86 or win32
#
# Based on the Pre-defined Compiler Macros
# http://sourceforge.net/p/predef/wiki/Compilers/
################################################################################
set(SOCI_COMPILER_NAME)
set(SOCI_PLATFORM_NAME)
if(MINGW OR UNIX)
exec_program(${CMAKE_C_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE GCC_VERSION)
string(REPLACE "." "" GCC_VERSION_STR_FULL ${GCC_VERSION})
string(REGEX MATCH "[0-9]+\\.[0-9]+" GCC_VERSION_MAJOR_MINOR ${GCC_VERSION})
endif()
if(WIN32)
if(MSVC)
if(MSVC_VERSION EQUAL 1200)
set(SOCI_COMPILER_NAME "msvc-6.0")
endif()
if(MSVC_VERSION EQUAL 1300)
set(SOCI_COMPILER_NAME "msvc-7.0")
endif()
if(MSVC_VERSION EQUAL 1310)
set(SOCI_COMPILER_NAME "msvc-7.1") # Visual Studio 2003
endif()
if(MSVC_VERSION EQUAL 1400)
set(SOCI_COMPILER_NAME "msvc-8.0") # Visual Studio 2005
endif()
if(MSVC_VERSION EQUAL 1500)
set(SOCI_COMPILER_NAME "msvc-9.0") # Visual Studio 2008
endif()
if(MSVC_VERSION EQUAL 1600)
set(SOCI_COMPILER_NAME "msvc-10.0") # Visual Studio 2010
endif()
if(MSVC_VERSION EQUAL 1700)
set(SOCI_COMPILER_NAME "msvc-11.0") # Visual Studio 2012
endif()
endif(MSVC)
if(MINGW)
set(SOCI_COMPILER_NAME "mingw-${GCC_VERSION}")
endif( MINGW )
if(CMAKE_GENERATOR MATCHES "Win64")
set(SOCI_PLATFORM_NAME "x64")
else()
set(SOCI_PLATFORM_NAME "win32")
endif()
endif(WIN32)
if(UNIX)
set(SOCI_COMPILER_NAME "gcc-${GCC_VERSION}")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(SOCI_PLATFORM_NAME "x64")
else()
set(SOCI_PLATFORM_NAME "x86")
endif()
endif(UNIX)
if(NOT SOCI_COMPILER_NAME)
colormsg(_RED_ "WARNING:")
colormsg(RED "Could not determine compiler toolset name to set SOCI_COMPILER_NAME variable.")
endif()
if(NOT SOCI_PLATFORM_NAME)
colormsg(_RED_ "WARNING:")
colormsg(RED "Could not determine platform name to set SOCI_PLATFORM_NAME variable.")
endif()
soci-3.2.3/cmake/SociBackend.cmake 0000644 0000000 0000000 00000026352 12511362240 015405 0 ustar root root ################################################################################
# SociBackend.cmake - part of CMake configuration of SOCI library
################################################################################
# Copyright (C) 2010 Mateusz Loskot
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_backend
# - defines project of a database backend for SOCI library
#
# soci_backend_test
# - defines test project of a database backend for SOCI library
################################################################################
# Defines project of a database backend for SOCI library
#
# soci_backend(backendname
# HEADERS header1 header2
# DEPENDS dependency1 dependency2
# DESCRIPTION description
# AUTHORS author1 author2
# MAINTAINERS maintainer1 maintainer2)
#
macro(soci_backend NAME)
parse_arguments(THIS_BACKEND
"HEADERS;DEPENDS;DESCRIPTION;AUTHORS;MAINTAINERS;"
""
${ARGN})
colormsg(HIGREEN "${NAME} - ${THIS_BACKEND_DESCRIPTION}")
# Backend name variants utils
string(TOLOWER "${PROJECT_NAME}" PROJECTNAMEL)
string(TOLOWER "${NAME}" NAMEL)
string(TOUPPER "${NAME}" NAMEU)
# Backend option available to user
set(THIS_BACKEND_OPTION SOCI_${NAMEU})
option(${THIS_BACKEND_OPTION}
"Attempt to build ${PROJECT_NAME} backend for ${NAME}" ON)
# Determine required dependencies
set(THIS_BACKEND_DEPENDS_INCLUDE_DIRS)
set(THIS_BACKEND_DEPENDS_LIBRARIES)
set(THIS_BACKEND_DEPENDS_DEFS)
set(DEPENDS_NOT_FOUND)
# CMake 2.8+ syntax only:
#foreach(dep IN LISTS THIS_BACKEND_DEPENDS)
foreach(dep ${THIS_BACKEND_DEPENDS})
soci_check_package_found(${dep} DEPEND_FOUND)
if(NOT DEPEND_FOUND)
list(APPEND DEPENDS_NOT_FOUND ${dep})
else()
string(TOUPPER "${dep}" DEPU)
list(APPEND THIS_BACKEND_DEPENDS_INCLUDE_DIRS ${${DEPU}_INCLUDE_DIR})
list(APPEND THIS_BACKEND_DEPENDS_INCLUDE_DIRS ${${DEPU}_INCLUDE_DIRS})
list(APPEND THIS_BACKEND_DEPENDS_LIBRARIES ${${DEPU}_LIBRARIES})
list(APPEND THIS_BACKEND_DEPENDS_DEFS -DHAVE_${DEPU}=1)
endif()
endforeach()
list(LENGTH DEPENDS_NOT_FOUND NOT_FOUND_COUNT)
if (NOT_FOUND_COUNT GREATER 0)
colormsg(_RED_ "WARNING:")
colormsg(RED "Some required dependencies of ${NAME} backend not found:")
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
foreach(dep ${DEPENDS_NOT_FOUND})
colormsg(RED " ${dep}")
endforeach()
else()
foreach(dep IN LISTS DEPENDS_NOT_FOUND)
colormsg(RED " ${dep}")
endforeach()
endif()
# TODO: Abort or warn compilation may fail? --mloskot
colormsg(RED "Skipping")
set(${THIS_BACKEND_OPTION} OFF)
else(NOT_FOUND_COUNT GREATER 0)
if(${THIS_BACKEND_OPTION})
# Backend-specific include directories
list(APPEND THIS_BACKEND_DEPENDS_INCLUDE_DIRS ${SOCI_SOURCE_DIR}/core)
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES
"${THIS_BACKEND_DEPENDS_INCLUDE_DIRS}")
# Backend-specific preprocessor definitions
add_definitions(${THIS_BACKEND_DEPENDS_DEFS})
# Backend installable headers and sources
if (NOT THIS_BACKEND_HEADERS)
file(GLOB THIS_BACKEND_HEADERS *.h)
endif()
file(GLOB THIS_BACKEND_SOURCES *.cpp)
set(THIS_BACKEND_HEADERS_VAR SOCI_${NAMEU}_HEADERS)
set(${THIS_BACKEND_HEADERS_VAR} ${THIS_BACKEND_HEADERS})
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Header Files" FILES ${THIS_BACKEND_HEADERS})
source_group("Source Files" FILES ${THIS_BACKEND_SOURCES})
source_group("CMake Files" FILES CMakeLists.txt)
# Backend target
set(THIS_BACKEND_TARGET ${PROJECTNAMEL}_${NAMEL})
set(THIS_BACKEND_TARGET_VAR SOCI_${NAMEU}_TARGET)
set(${THIS_BACKEND_TARGET_VAR} ${THIS_BACKEND_TARGET})
soci_target_output_name(${THIS_BACKEND_TARGET} ${THIS_BACKEND_TARGET_VAR}_OUTPUT_NAME)
set(THIS_BACKEND_TARGET_OUTPUT_NAME ${${THIS_BACKEND_TARGET_VAR}_OUTPUT_NAME})
set(THIS_BACKEND_TARGET_OUTPUT_NAME_VAR ${THIS_BACKEND_TARGET_VAR}_OUTPUT_NAME)
# TODO: Extract as macros: soci_shared_lib_target and soci_static_lib_target --mloskot
# Shared library target
if (SOCI_SHARED)
add_library(${THIS_BACKEND_TARGET}
SHARED
${THIS_BACKEND_SOURCES}
${THIS_BACKEND_HEADERS})
target_link_libraries(${THIS_BACKEND_TARGET}
${SOCI_CORE_TARGET}
${THIS_BACKEND_DEPENDS_LIBRARIES})
if(WIN32)
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
OUTPUT_NAME ${THIS_BACKEND_TARGET_OUTPUT_NAME}
DEFINE_SYMBOL SOCI_DLL)
else()
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
endif()
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
VERSION ${${PROJECT_NAME}_VERSION}
CLEAN_DIRECT_OUTPUT 1)
endif()
# Static library target
if (SOCI_STATIC)
set(THIS_BACKEND_TARGET_STATIC ${THIS_BACKEND_TARGET}_static)
add_library(${THIS_BACKEND_TARGET_STATIC}
STATIC
${THIS_BACKEND_SOURCES}
${THIS_BACKEND_HEADERS})
set_target_properties(${THIS_BACKEND_TARGET_STATIC}
PROPERTIES
OUTPUT_NAME ${THIS_BACKEND_TARGET_OUTPUT_NAME}
PREFIX "lib"
CLEAN_DIRECT_OUTPUT 1)
endif()
# Backend installation
install(FILES ${THIS_BACKEND_HEADERS}
DESTINATION
${INCLUDEDIR}/${PROJECTNAMEL}/${NAMEL})
if (SOCI_SHARED)
install(TARGETS ${THIS_BACKEND_TARGET}
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${LIBDIR}
ARCHIVE DESTINATION ${LIBDIR})
endif()
if (SOCI_SHARED)
install(TARGETS ${THIS_BACKEND_TARGET_STATIC}
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${LIBDIR}
ARCHIVE DESTINATION ${LIBDIR})
endif()
else()
colormsg(HIRED "${NAME}" RED "backend disabled, since")
endif()
endif(NOT_FOUND_COUNT GREATER 0)
boost_report_value(${THIS_BACKEND_OPTION})
if(${THIS_BACKEND_OPTION})
boost_report_value(${THIS_BACKEND_TARGET_VAR})
boost_report_value(${THIS_BACKEND_TARGET_OUTPUT_NAME_VAR})
boost_report_value(${THIS_BACKEND_HEADERS_VAR})
soci_report_directory_property(COMPILE_DEFINITIONS)
endif()
# LOG
#message("soci_backend:")
#message("NAME: ${NAME}")
#message("${THIS_BACKEND_OPTION} = ${SOCI_BACKEND_SQLITE3}")
#message("DEPENDS: ${THIS_BACKEND_DEPENDS}")
#message("DESCRIPTION: ${THIS_BACKEND_DESCRIPTION}")
#message("AUTHORS: ${THIS_BACKEND_AUTHORS}")
#message("MAINTAINERS: ${THIS_BACKEND_MAINTAINERS}")
#message("HEADERS: ${THIS_BACKEND_HEADERS}")
#message("SOURCES: ${THIS_BACKEND_SOURCES}")
#message("DEPENDS_LIBRARIES: ${THIS_BACKEND_DEPENDS_LIBRARIES}")
#message("DEPENDS_INCLUDE_DIRS: ${THIS_BACKEND_DEPENDS_INCLUDE_DIRS}")
endmacro()
# Generates .vcxproj.user for target of each test.
#
# soci_backend_test_create_vcxproj_user(
# PostgreSQLTest
# "host=localhost dbname=soci_test user=mloskot")
#
function(soci_backend_test_create_vcxproj_user TARGET_NAME TEST_CMD_ARGS)
if(MSVC)
set(SYSTEM_NAME $ENV{USERDOMAIN})
set(USER_NAME $ENV{USERNAME})
set(SOCI_TEST_CMD_ARGS ${TEST_CMD_ARGS})
if(MSVC_VERSION EQUAL 1600)
configure_file(
${SOCI_SOURCE_DIR}/cmake/resources/vs2010-test-cmd-args.vcxproj.user.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.vcxproj.user
@ONLY)
endif()
endif()
endfunction(soci_backend_test_create_vcxproj_user)
# Defines test project of a database backend for SOCI library
#
# soci_backend_test(BACKEND mybackend SOURCE mytest1.cpp
# NAME mytest1
# CONNSTR "my test connection"
# DEPENDS library1 library2)
#
macro(soci_backend_test)
parse_arguments(THIS_TEST
"BACKEND;SOURCE;CONNSTR;NAME;DEPENDS;"
""
${ARGN})
# Test backend name
string(TOUPPER "${THIS_TEST_BACKEND}" BACKENDU)
string(TOLOWER "${THIS_TEST_BACKEND}" BACKENDL)
if(SOCI_TESTS AND SOCI_${BACKENDU} AND NOT SOCI_${BACKENDU}_DO_NOT_TEST)
# Test name
if(THIS_TEST_NAME)
string(TOUPPER "${THIS_TEST_NAME}" NAMEU)
set(TEST_FULL_NAME SOCI_${BACKENDU}_TEST_${NAMEU})
else()
set(TEST_FULL_NAME SOCI_${BACKENDU}_TEST)
endif()
set(TEST_CONNSTR_VAR ${TEST_FULL_NAME}_CONNSTR)
set(${TEST_CONNSTR_VAR} ""
CACHE STRING "Connection string for ${BACKENDU} test")
if(NOT ${TEST_CONNSTR_VAR} AND THIS_TEST_CONNSTR)
set(${TEST_CONNSTR_VAR} ${THIS_TEST_CONNSTR})
endif()
boost_report_value(${TEST_CONNSTR_VAR})
include_directories(${SOCI_SOURCE_DIR}/core/test)
include_directories(${SOCI_SOURCE_DIR}/backends/${BACKENDL})
# TODO: Find more generic way of adding Boost to core and backend tests only.
# Ideally, from within Boost.cmake.
set(SOCI_TEST_DEPENDENCIES)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
if(Boost_DATE_TIME_FOUND)
set(SOCI_TEST_DEPENDENCIES ${Boost_DATE_TIME_LIBRARY})
add_definitions(-DHAVE_BOOST_DATE_TIME=1)
endif()
endif()
string(TOLOWER "${TEST_FULL_NAME}" TEST_TARGET)
set(TEST_HEADERS ${PROJECT_SOURCE_DIR}/core/test/common-tests.h)
# Shared libraries test
add_executable(${TEST_TARGET} ${TEST_HEADERS} ${THIS_TEST_SOURCE})
target_link_libraries(${TEST_TARGET}
${SOCI_CORE_TARGET}
${SOCI_${BACKENDU}_TARGET}
${${BACKENDU}_LIBRARIES}
${SOCI_TEST_DEPENDENCIES})
add_test(${TEST_TARGET}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_TARGET}
${${TEST_CONNSTR_VAR}})
soci_backend_test_create_vcxproj_user(${TEST_TARGET} "\"${${TEST_CONNSTR_VAR}}\"")
# Static libraries test
if(SOCI_STATIC)
set(TEST_TARGET_STATIC ${TEST_TARGET}_static)
add_executable(${TEST_TARGET_STATIC} ${TEST_HEADERS} ${THIS_TEST_SOURCE})
target_link_libraries(${TEST_TARGET_STATIC}
${SOCI_CORE_TARGET_STATIC}
${SOCI_${BACKENDU}_TARGET}_static
${${BACKENDU}_LIBRARIES}
${SOCI_CORE_STATIC_DEPENDENCIES}
${SOCI_TEST_DEPENDENCIES})
add_test(${TEST_TARGET_STATIC}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_TARGET_STATIC}
${${TEST_CONNSTR_VAR}})
soci_backend_test_create_vcxproj_user(${TEST_TARGET_STATIC} "\"${${TEST_CONNSTR_VAR}}\"")
endif(SOCI_STATIC)
# Ask make check to try to build tests first before executing them
add_dependencies(check ${TEST_TARGET} ${TEST_TARGET_STATIC})
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Header Files" FILES ${TEST_HEADERS})
source_group("Source Files" FILES ${THIS_TEST_SOURCE})
source_group("CMake Files" FILES CMakeLists.txt)
endif()
# LOG
#message("NAME=${NAME}")
#message("THIS_TEST_NAME=${THIS_TEST_NAME}")
#message("THIS_TEST_BACKEND=${THIS_TEST_BACKEND}")
#message("THIS_TEST_CONNSTR=${THIS_TEST_CONNSTR}")
#message("THIS_TEST_SOURCE=${THIS_TEST_SOURCE}")
#message("THIS_TEST_OPTION=${THIS_TEST_OPTION}")
endmacro()
soci-3.2.3/cmake/SociVersion.cmake 0000644 0000000 0000000 00000004242 12511362240 015475 0 ustar root root ################################################################################
# SociVersion.cmake - part of CMake configuration of SOCI library
################################################################################
# Copyright (C) 2010 Mateusz Loskot
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_version - defines version information for SOCI library
#
################################################################################
# Defines version information for SOCI library
#
# soci_version(MAJOR major_version MINOR minor_version PATCH patch_level)
#
# MAJOR.MINOR version is used to set SOVERSION
#
macro(soci_version)
parse_arguments(THIS_VERSION "MAJOR;MINOR;PATCH;"
""
${ARGN})
# Set version components
set(${PROJECT_NAME}_VERSION_MAJOR ${THIS_VERSION_MAJOR})
set(${PROJECT_NAME}_VERSION_MINOR ${THIS_VERSION_MINOR})
set(${PROJECT_NAME}_VERSION_PATCH ${THIS_VERSION_PATCH})
# Set VERSION string
set(${PROJECT_NAME}_VERSION
"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}")
# Set SOVERSION based on major and minor
set(${PROJECT_NAME}_SOVERSION
"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}")
# Set ABI version string used to name binary output and, by SOCI loader, to find binaries.
# On Windows, ABI version is specified using binary file name suffix.
# On Unix, suffix ix empty and SOVERSION is used instead.
if (UNIX)
set(${PROJECT_NAME}_ABI_VERSION ${${PROJECT_NAME}_SOVERSION})
elseif(WIN32)
set(${PROJECT_NAME}_ABI_VERSION
"${${PROJECT_NAME}_VERSION_MAJOR}_${${PROJECT_NAME}_VERSION_MINOR}")
else()
message(FATAL_ERROR "Ambiguous target platform with unknown ABI version scheme. Giving up.")
endif()
boost_report_value(${PROJECT_NAME}_VERSION)
boost_report_value(${PROJECT_NAME}_ABI_VERSION)
add_definitions(-DSOCI_ABI_VERSION="${${PROJECT_NAME}_ABI_VERSION}")
endmacro()
soci-3.2.3/cmake/CMakeLists.txt 0000644 0000000 0000000 00000000776 12511362240 015000 0 ustar root root ###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2009 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
# install the cmake modules
file(GLOB SOCI_CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")
soci-3.2.3/cmake/dependencies/ 0000755 0000000 0000000 00000000000 12511362240 014654 5 ustar root root soci-3.2.3/cmake/dependencies/SQLite3.cmake 0000644 0000000 0000000 00000000154 12511362240 017102 0 ustar root root set(SQLITE3_FIND_QUIETLY TRUE)
find_package(SQLite3)
boost_external_report(SQLite3 INCLUDE_DIR LIBRARIES)
soci-3.2.3/cmake/dependencies/Threads.cmake 0000644 0000000 0000000 00000000205 12511362240 017245 0 ustar root root set(Threads_FIND_QUIETLY TRUE)
find_package(Threads)
message(STATUS "X: ${Threads_FOUND}")
boost_external_report(Threads LIBRARIES)
soci-3.2.3/cmake/dependencies/PostgreSQL.cmake 0000644 0000000 0000000 00000000174 12511362240 017663 0 ustar root root set(PostgreSQL_FIND_QUIETLY TRUE)
find_package(PostgreSQL)
boost_external_report(PostgreSQL INCLUDE_DIR LIBRARIES VERSION) soci-3.2.3/cmake/dependencies/MySQL.cmake 0000644 0000000 0000000 00000000316 12511362240 016623 0 ustar root root set(MySQL_FIND_QUIETLY TRUE)
find_package(MySQL)
boost_external_report(MySQL INCLUDE_DIR LIBRARIES)
#if(MYSQL_FOUND)
# include_directories(${MYSQL_INCLUDE_DIR})
# add_definitions(-DHAVE_MYSQL)
#endif() soci-3.2.3/cmake/dependencies/Boost.cmake 0000644 0000000 0000000 00000000575 12511362240 016753 0 ustar root root set(Boost_FIND_QUIETLY TRUE)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.33.1 COMPONENTS date_time)
if (NOT Boost_date_time_FOUND)
find_package(Boost 1.33.1)
endif()
set(Boost_RELEASE_VERSION
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
boost_external_report(Boost RELEASE_VERSION INCLUDE_DIR LIBRARIES)
soci-3.2.3/cmake/dependencies/Firebird.cmake 0000644 0000000 0000000 00000000170 12511362240 017402 0 ustar root root set(Firebird_FIND_QUIETLY TRUE)
find_package(Firebird)
boost_external_report(Firebird INCLUDE_DIR LIBRARIES VERSION)
soci-3.2.3/cmake/dependencies/ODBC.cmake 0000644 0000000 0000000 00000000143 12511362240 016363 0 ustar root root set(ODBC_FIND_QUIETLY TRUE)
find_package(ODBC)
boost_external_report(ODBC INCLUDE_DIR LIBRARIES)
soci-3.2.3/cmake/dependencies/Oracle.cmake 0000644 0000000 0000000 00000000151 12511362240 017060 0 ustar root root set(ORACLE_FIND_QUIETLY TRUE)
find_package(Oracle)
boost_external_report(Oracle INCLUDE_DIR LIBRARIES)
soci-3.2.3/cmake/dependencies/DB2.cmake 0000644 0000000 0000000 00000000140 12511362240 016220 0 ustar root root set(DB2_FIND_QUIETLY TRUE)
find_package(DB2)
boost_external_report(DB2 INCLUDE_DIR LIBRARIES)
soci-3.2.3/backends/ 0000755 0000000 0000000 00000000000 12511362240 012720 5 ustar root root soci-3.2.3/backends/oracle/ 0000755 0000000 0000000 00000000000 12511362240 014165 5 ustar root root soci-3.2.3/backends/oracle/error.h 0000644 0000000 0000000 00000001133 12511361676 015501 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_ORACLE_ERROR_H_INCLUDED
#define SOCI_ORACLE_ERROR_H_INCLUDED
#include "soci-oracle.h"
namespace soci
{
namespace details
{
namespace oracle
{
void throw_oracle_soci_error(sword res, OCIError *errhp);
void get_error_details(sword res, OCIError *errhp,
std::string &msg, int &errNum);
} // namespace oracle
} // namespace details
} // namespace soci
#endif
soci-3.2.3/backends/oracle/blob.cpp 0000644 0000000 0000000 00000005460 12511361676 015630 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include "soci-oracle.h"
#include "error.h"
#include "statement.h"
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
oracle_blob_backend::oracle_blob_backend(oracle_session_backend &session)
: session_(session)
{
sword res = OCIDescriptorAlloc(session.envhp_,
reinterpret_cast(&lobp_), OCI_DTYPE_LOB, 0, 0);
if (res != OCI_SUCCESS)
{
throw soci_error("Cannot allocate the LOB locator");
}
}
oracle_blob_backend::~oracle_blob_backend()
{
OCIDescriptorFree(lobp_, OCI_DTYPE_LOB);
}
std::size_t oracle_blob_backend::get_len()
{
ub4 len;
sword res = OCILobGetLength(session_.svchp_, session_.errhp_,
lobp_, &len);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return static_cast(len);
}
std::size_t oracle_blob_backend::read(
std::size_t offset, char *buf, std::size_t toRead)
{
ub4 amt = static_cast(toRead);
sword res = OCILobRead(session_.svchp_, session_.errhp_, lobp_, &amt,
static_cast(offset), reinterpret_cast(buf),
amt, 0, 0, 0, 0);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return static_cast(amt);
}
std::size_t oracle_blob_backend::write(
std::size_t offset, char const *buf, std::size_t toWrite)
{
ub4 amt = static_cast(toWrite);
sword res = OCILobWrite(session_.svchp_, session_.errhp_, lobp_, &amt,
static_cast(offset),
reinterpret_cast(const_cast(buf)),
amt, OCI_ONE_PIECE, 0, 0, 0, 0);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return static_cast(amt);
}
std::size_t oracle_blob_backend::append(char const *buf, std::size_t toWrite)
{
ub4 amt = static_cast(toWrite);
sword res = OCILobWriteAppend(session_.svchp_, session_.errhp_, lobp_,
&amt, reinterpret_cast(const_cast(buf)),
amt, OCI_ONE_PIECE, 0, 0, 0, 0);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return static_cast(amt);
}
void oracle_blob_backend::trim(std::size_t newLen)
{
sword res = OCILobTrim(session_.svchp_, session_.errhp_, lobp_,
static_cast(newLen));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
}
soci-3.2.3/backends/oracle/statement.cpp 0000644 0000000 0000000 00000021470 12511361676 016715 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define soci_ORACLE_SOURCE
#include "soci-oracle.h"
#include "error.h"
#include
#include
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
oracle_statement_backend::oracle_statement_backend(oracle_session_backend &session)
: session_(session), stmtp_(NULL), boundByName_(false), boundByPos_(false),
noData_(false)
{
}
void oracle_statement_backend::alloc()
{
sword res = OCIHandleAlloc(session_.envhp_,
reinterpret_cast(&stmtp_),
OCI_HTYPE_STMT, 0, 0);
if (res != OCI_SUCCESS)
{
throw soci_error("Cannot allocate statement handle");
}
}
void oracle_statement_backend::clean_up()
{
// deallocate statement handle
if (stmtp_ != NULL)
{
OCIHandleFree(stmtp_, OCI_HTYPE_STMT);
stmtp_ = NULL;
}
boundByName_ = false;
boundByPos_ = false;
}
void oracle_statement_backend::prepare(std::string const &query,
statement_type /* eType */)
{
sb4 stmtLen = static_cast(query.size());
sword res = OCIStmtPrepare(stmtp_,
session_.errhp_,
reinterpret_cast(const_cast(query.c_str())),
stmtLen, OCI_V7_SYNTAX, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
}
statement_backend::exec_fetch_result oracle_statement_backend::execute(int number)
{
sword res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_,
static_cast(number), 0, 0, 0, OCI_DEFAULT);
if (res == OCI_SUCCESS || res == OCI_SUCCESS_WITH_INFO)
{
noData_ = false;
return ef_success;
}
else if (res == OCI_NO_DATA)
{
noData_ = true;
return ef_no_data;
}
else
{
throw_oracle_soci_error(res, session_.errhp_);
return ef_no_data; // unreachable dummy return to please the compiler
}
}
statement_backend::exec_fetch_result oracle_statement_backend::fetch(int number)
{
if (noData_)
{
return ef_no_data;
}
sword res = OCIStmtFetch(stmtp_, session_.errhp_,
static_cast(number), OCI_FETCH_NEXT, OCI_DEFAULT);
if (res == OCI_SUCCESS || res == OCI_SUCCESS_WITH_INFO)
{
return ef_success;
}
else if (res == OCI_NO_DATA)
{
noData_ = true;
return ef_no_data;
}
else
{
throw_oracle_soci_error(res, session_.errhp_);
return ef_no_data; // unreachable dummy return to please the compiler
}
}
long long oracle_statement_backend::get_affected_rows()
{
ub4 row_count;
sword res = OCIAttrGet(static_cast(stmtp_),
OCI_HTYPE_STMT, &row_count,
0, OCI_ATTR_ROW_COUNT, session_.errhp_);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return row_count;
}
int oracle_statement_backend::get_number_of_rows()
{
int rows;
sword res = OCIAttrGet(static_cast(stmtp_),
OCI_HTYPE_STMT, static_cast(&rows),
0, OCI_ATTR_ROWS_FETCHED, session_.errhp_);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return rows;
}
std::string oracle_statement_backend::rewrite_for_procedure_call(
std::string const &query)
{
std::string newQuery("begin ");
newQuery += query;
newQuery += "; end;";
return newQuery;
}
int oracle_statement_backend::prepare_for_describe()
{
sword res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_,
1, 0, 0, 0, OCI_DESCRIBE_ONLY);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
int cols;
res = OCIAttrGet(static_cast(stmtp_),
static_cast(OCI_HTYPE_STMT), static_cast(&cols),
0, static_cast(OCI_ATTR_PARAM_COUNT), session_.errhp_);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return cols;
}
void oracle_statement_backend::describe_column(int colNum, data_type &type,
std::string &columnName)
{
int size;
int precision;
int scale;
ub2 dbtype;
text* dbname;
ub4 nameLength;
ub2 dbsize;
sb2 dbprec;
ub1 dbscale; //sb2 in some versions of Oracle?
// Get the column handle
OCIParam* colhd;
sword res = OCIParamGet(reinterpret_cast(stmtp_),
static_cast(OCI_HTYPE_STMT),
reinterpret_cast(session_.errhp_),
reinterpret_cast(&colhd),
static_cast(colNum));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// Get the column name
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&dbname),
reinterpret_cast(&nameLength),
static_cast(OCI_ATTR_NAME),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// Get the column type
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&dbtype),
0,
static_cast(OCI_ATTR_DATA_TYPE),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// get the data size
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&dbsize),
0,
static_cast(OCI_ATTR_DATA_SIZE),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// get the precision
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&dbprec),
0,
static_cast(OCI_ATTR_PRECISION),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// get the scale
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&dbscale),
0,
static_cast(OCI_ATTR_SCALE),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
columnName.assign(dbname, dbname + nameLength);
size = static_cast(dbsize);
precision = static_cast(dbprec);
scale = static_cast(dbscale);
switch (dbtype)
{
case SQLT_CHR:
case SQLT_AFC:
type = dt_string;
break;
case SQLT_NUM:
if (scale > 0)
{
if (session_.get_option_decimals_as_strings())
type = dt_string;
else
type = dt_double;
}
else if (precision <= std::numeric_limits::digits10)
{
type = dt_integer;
}
else
{
type = dt_long_long;
}
break;
case SQLT_DAT:
type = dt_date;
break;
}
}
std::size_t oracle_statement_backend::column_size(int position)
{
// Note: we may want to optimize so that the OCI_DESCRIBE_ONLY call
// happens only once per statement.
// Possibly use existing statement::describe() / make column prop
// access lazy at same time
int colSize(0);
sword res = OCIStmtExecute(session_.svchp_, stmtp_,
session_.errhp_, 1, 0, 0, 0, OCI_DESCRIBE_ONLY);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// Get The Column Handle
OCIParam* colhd;
res = OCIParamGet(reinterpret_cast(stmtp_),
static_cast(OCI_HTYPE_STMT),
reinterpret_cast(session_.errhp_),
reinterpret_cast(&colhd),
static_cast(position));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
// Get The Data Size
res = OCIAttrGet(reinterpret_cast(colhd),
static_cast(OCI_DTYPE_PARAM),
reinterpret_cast(&colSize),
0,
static_cast(OCI_ATTR_DATA_SIZE),
reinterpret_cast(session_.errhp_));
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
return static_cast(colSize);
}
soci-3.2.3/backends/oracle/vector-use-type.cpp 0000644 0000000 0000000 00000025556 12511361676 017775 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define soci_ORACLE_SOURCE
#include "soci-oracle.h"
#include "error.h"
#include
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#define snprintf _snprintf
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
void oracle_vector_use_type_backend::prepare_indicators(std::size_t size)
{
if (size == 0)
{
throw soci_error("Vectors of size 0 are not allowed.");
}
indOCIHolderVec_.resize(size);
indOCIHolders_ = &indOCIHolderVec_[0];
}
void oracle_vector_use_type_backend::prepare_for_bind(
void *&data, sb4 &size, ub2 &oracleType)
{
switch (type_)
{
// simple cases
case x_char:
{
oracleType = SQLT_AFC;
size = sizeof(char);
std::vector *vp = static_cast *>(data);
std::vector &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_short:
{
oracleType = SQLT_INT;
size = sizeof(short);
std::vector *vp = static_cast *>(data);
std::vector &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_integer:
{
oracleType = SQLT_INT;
size = sizeof(int);
std::vector *vp = static_cast *>(data);
std::vector &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_double:
{
oracleType = SQLT_FLT;
size = sizeof(double);
std::vector *vp = static_cast *>(data);
std::vector &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
// cases that require adjustments and buffer management
case x_long_long:
{
std::vector *vp
= static_cast *>(data);
std::vector &v(*vp);
std::size_t const vecSize = v.size();
std::size_t const entrySize = 100; // arbitrary
std::size_t const bufSize = entrySize * vecSize;
buf_ = new char[bufSize];
oracleType = SQLT_STR;
data = buf_;
size = entrySize;
prepare_indicators(vecSize);
}
break;
case x_unsigned_long_long:
{
std::vector *vp
= static_cast *>(data);
std::vector &v(*vp);
std::size_t const vecSize = v.size();
std::size_t const entrySize = 100; // arbitrary
std::size_t const bufSize = entrySize * vecSize;
buf_ = new char[bufSize];
oracleType = SQLT_STR;
data = buf_;
size = entrySize;
prepare_indicators(vecSize);
}
break;
case x_stdstring:
{
std::vector *vp
= static_cast *>(data);
std::vector &v(*vp);
std::size_t maxSize = 0;
std::size_t const vecSize = v.size();
prepare_indicators(vecSize);
for (std::size_t i = 0; i != vecSize; ++i)
{
std::size_t sz = v[i].length();
sizes_.push_back(static_cast(sz));
maxSize = sz > maxSize ? sz : maxSize;
}
buf_ = new char[maxSize * vecSize];
char *pos = buf_;
for (std::size_t i = 0; i != vecSize; ++i)
{
strncpy(pos, v[i].c_str(), v[i].length());
pos += maxSize;
}
oracleType = SQLT_CHR;
data = buf_;
size = static_cast(maxSize);
}
break;
case x_stdtm:
{
std::vector *vp
= static_cast *>(data);
prepare_indicators(vp->size());
sb4 const dlen = 7; // size of SQLT_DAT
buf_ = new char[dlen * vp->size()];
oracleType = SQLT_DAT;
data = buf_;
size = dlen;
}
break;
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
}
}
void oracle_vector_use_type_backend::bind_by_pos(int &position,
void *data, exchange_type type)
{
data_ = data; // for future reference
type_ = type; // for future reference
ub2 oracleType;
sb4 size;
prepare_for_bind(data, size, oracleType);
ub2 *sizesP = 0; // used only for std::string
if (type == x_stdstring)
{
sizesP = &sizes_[0];
}
sword res = OCIBindByPos(statement_.stmtp_, &bindp_,
statement_.session_.errhp_,
position++, data, size, oracleType,
indOCIHolders_, sizesP, 0, 0, 0, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, statement_.session_.errhp_);
}
}
void oracle_vector_use_type_backend::bind_by_name(
std::string const &name, void *data, exchange_type type)
{
data_ = data; // for future reference
type_ = type; // for future reference
ub2 oracleType;
sb4 size;
prepare_for_bind(data, size, oracleType);
ub2 *sizesP = 0; // used only for std::string
if (type == x_stdstring)
{
sizesP = &sizes_[0];
}
sword res = OCIBindByName(statement_.stmtp_, &bindp_,
statement_.session_.errhp_,
reinterpret_cast(const_cast(name.c_str())),
static_cast(name.size()),
data, size, oracleType,
indOCIHolders_, sizesP, 0, 0, 0, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, statement_.session_.errhp_);
}
}
void oracle_vector_use_type_backend::pre_use(indicator const *ind)
{
// first deal with data
if (type_ == x_stdstring)
{
// nothing to do - it's already done during bind
// (and it's probably impossible to separate them, because
// changes in the string size could not be handled here)
}
else if (type_ == x_long_long)
{
std::vector *vp
= static_cast *>(data_);
std::vector &v(*vp);
char *pos = buf_;
std::size_t const entrySize = 100; // arbitrary, but consistent
std::size_t const vecSize = v.size();
for (std::size_t i = 0; i != vecSize; ++i)
{
snprintf(pos, entrySize, "%" LL_FMT_FLAGS "d", v[i]);
pos += entrySize;
}
}
else if (type_ == x_unsigned_long_long)
{
std::vector *vp
= static_cast *>(data_);
std::vector &v(*vp);
char *pos = buf_;
std::size_t const entrySize = 100; // arbitrary, but consistent
std::size_t const vecSize = v.size();
for (std::size_t i = 0; i != vecSize; ++i)
{
snprintf(pos, entrySize, "%" LL_FMT_FLAGS "u", v[i]);
pos += entrySize;
}
}
else if (type_ == x_stdtm)
{
std::vector *vp
= static_cast *>(data_);
std::vector &v(*vp);
ub1* pos = reinterpret_cast(buf_);
std::size_t const vsize = v.size();
for (std::size_t i = 0; i != vsize; ++i)
{
*pos++ = static_cast(100 + (1900 + v[i].tm_year) / 100);
*pos++ = static_cast(100 + v[i].tm_year % 100);
*pos++ = static_cast(v[i].tm_mon + 1);
*pos++ = static_cast(v[i].tm_mday);
*pos++ = static_cast(v[i].tm_hour + 1);
*pos++ = static_cast(v[i].tm_min + 1);
*pos++ = static_cast(v[i].tm_sec + 1);
}
}
// then handle indicators
if (ind != NULL)
{
std::size_t const vsize = size();
for (std::size_t i = 0; i != vsize; ++i, ++ind)
{
if (*ind == i_null)
{
indOCIHolderVec_[i] = -1; // null
}
else
{
indOCIHolderVec_[i] = 0; // value is OK
}
}
}
else
{
// no indicators - treat all fields as OK
std::size_t const vsize = size();
for (std::size_t i = 0; i != vsize; ++i, ++ind)
{
indOCIHolderVec_[i] = 0; // value is OK
}
}
}
std::size_t oracle_vector_use_type_backend::size()
{
std::size_t sz = 0; // dummy initialization to please the compiler
switch (type_)
{
// simple cases
case x_char:
{
std::vector *vp = static_cast *>(data_);
sz = vp->size();
}
break;
case x_short:
{
std::vector *vp = static_cast *>(data_);
sz = vp->size();
}
break;
case x_integer:
{
std::vector *vp = static_cast *>(data_);
sz = vp->size();
}
break;
case x_long_long:
{
std::vector *vp
= static_cast *>(data_);
sz = vp->size();
}
break;
case x_unsigned_long_long:
{
std::vector *vp
= static_cast *>(data_);
sz = vp->size();
}
break;
case x_double:
{
std::vector *vp
= static_cast *>(data_);
sz = vp->size();
}
break;
case x_stdstring:
{
std::vector *vp
= static_cast *>(data_);
sz = vp->size();
}
break;
case x_stdtm:
{
std::vector *vp
= static_cast *>(data_);
sz = vp->size();
}
break;
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
}
return sz;
}
void oracle_vector_use_type_backend::clean_up()
{
if (buf_ != NULL)
{
delete [] buf_;
buf_ = NULL;
}
if (bindp_ != NULL)
{
OCIHandleFree(bindp_, OCI_HTYPE_DEFINE);
bindp_ = NULL;
}
}
soci-3.2.3/backends/oracle/standard-use-type.cpp 0000644 0000000 0000000 00000031720 12511361676 020261 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define soci_ORACLE_SOURCE
#include "soci-oracle.h"
#include "blob.h"
#include "error.h"
#include "rowid.h"
#include "statement.h"
#include
#include
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#define snprintf _snprintf
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
void oracle_standard_use_type_backend::prepare_for_bind(
void *&data, sb4 &size, ub2 &oracleType, bool readOnly)
{
readOnly_ = readOnly;
switch (type_)
{
// simple cases
case x_char:
oracleType = SQLT_AFC;
size = sizeof(char);
if (readOnly)
{
buf_ = new char[size];
data = buf_;
}
break;
case x_short:
oracleType = SQLT_INT;
size = sizeof(short);
if (readOnly)
{
buf_ = new char[size];
data = buf_;
}
break;
case x_integer:
oracleType = SQLT_INT;
size = sizeof(int);
if (readOnly)
{
buf_ = new char[size];
data = buf_;
}
break;
case x_double:
oracleType = SQLT_FLT;
size = sizeof(double);
if (readOnly)
{
buf_ = new char[size];
data = buf_;
}
break;
// cases that require adjustments and buffer management
case x_long_long:
case x_unsigned_long_long:
oracleType = SQLT_STR;
size = 100; // arbitrary buffer length
buf_ = new char[size];
data = buf_;
break;
case x_stdstring:
oracleType = SQLT_STR;
// 4000 is Oracle max VARCHAR2 size; 32768 is max LONG size
size = 32769;
buf_ = new char[size];
data = buf_;
break;
case x_stdtm:
oracleType = SQLT_DAT;
size = 7 * sizeof(ub1);
buf_ = new char[size];
data = buf_;
break;
// cases that require special handling
case x_statement:
{
oracleType = SQLT_RSET;
statement *st = static_cast(data);
st->alloc();
oracle_statement_backend *stbe
= static_cast(st->get_backend());
size = 0;
data = &stbe->stmtp_;
}
break;
case x_rowid:
{
oracleType = SQLT_RDD;
rowid *rid = static_cast(data);
oracle_rowid_backend *rbe
= static_cast(rid->get_backend());
size = 0;
data = &rbe->rowidp_;
}
break;
case x_blob:
{
oracleType = SQLT_BLOB;
blob *b = static_cast(data);
oracle_blob_backend *bbe
= static_cast(b->get_backend());
size = 0;
data = &bbe->lobp_;
}
break;
}
}
void oracle_standard_use_type_backend::bind_by_pos(
int &position, void *data, exchange_type type, bool readOnly)
{
if (statement_.boundByName_)
{
throw soci_error(
"Binding for use elements must be either by position or by name.");
}
data_ = data; // for future reference
type_ = type; // for future reference
ub2 oracleType;
sb4 size;
prepare_for_bind(data, size, oracleType, readOnly);
sword res = OCIBindByPos(statement_.stmtp_, &bindp_,
statement_.session_.errhp_,
position++, data, size, oracleType,
&indOCIHolder_, 0, 0, 0, 0, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, statement_.session_.errhp_);
}
statement_.boundByPos_ = true;
}
void oracle_standard_use_type_backend::bind_by_name(
std::string const &name, void *data, exchange_type type, bool readOnly)
{
if (statement_.boundByPos_)
{
throw soci_error(
"Binding for use elements must be either by position or by name.");
}
data_ = data; // for future reference
type_ = type; // for future reference
ub2 oracleType;
sb4 size;
prepare_for_bind(data, size, oracleType, readOnly);
sword res = OCIBindByName(statement_.stmtp_, &bindp_,
statement_.session_.errhp_,
reinterpret_cast(const_cast(name.c_str())),
static_cast(name.size()),
data, size, oracleType,
&indOCIHolder_, 0, 0, 0, 0, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, statement_.session_.errhp_);
}
statement_.boundByName_ = true;
}
void oracle_standard_use_type_backend::pre_use(indicator const *ind)
{
// first deal with data
switch (type_)
{
case x_char:
if (readOnly_)
{
buf_[0] = *static_cast(data_);
}
break;
case x_short:
if (readOnly_)
{
*static_cast(static_cast(buf_)) = *static_cast(data_);
}
break;
case x_integer:
if (readOnly_)
{
*static_cast(static_cast(buf_)) = *static_cast(data_);
}
break;
case x_long_long:
{
size_t const size = 100; // arbitrary, but consistent with prepare_for_bind
snprintf(buf_, size, "%" LL_FMT_FLAGS "d", *static_cast(data_));
}
break;
case x_unsigned_long_long:
{
size_t const size = 100; // arbitrary, but consistent with prepare_for_bind
snprintf(buf_, size, "%" LL_FMT_FLAGS "u", *static_cast(data_));
}
break;
case x_double:
if (readOnly_)
{
*static_cast(static_cast(buf_)) = *static_cast(data_);
}
break;
case x_stdstring:
{
std::string *s = static_cast(data_);
// 4000 is Oracle max VARCHAR2 size; 32768 is max LONG size
std::size_t const bufSize = 32769;
std::size_t const sSize = s->size();
std::size_t const toCopy =
sSize < bufSize -1 ? sSize + 1 : bufSize - 1;
strncpy(buf_, s->c_str(), toCopy);
buf_[toCopy] = '\0';
}
break;
case x_stdtm:
{
std::tm *t = static_cast(data_);
ub1* pos = reinterpret_cast(buf_);
*pos++ = static_cast(100 + (1900 + t->tm_year) / 100);
*pos++ = static_cast(100 + t->tm_year % 100);
*pos++ = static_cast(t->tm_mon + 1);
*pos++ = static_cast(t->tm_mday);
*pos++ = static_cast(t->tm_hour + 1);
*pos++ = static_cast(t->tm_min + 1);
*pos = static_cast(t->tm_sec + 1);
}
break;
case x_statement:
{
statement *s = static_cast(data_);
s->undefine_and_bind();
}
break;
case x_rowid:
case x_blob:
// nothing to do
break;
}
// then handle indicators
if (ind != NULL && *ind == i_null)
{
indOCIHolder_ = -1; // null
}
else
{
indOCIHolder_ = 0; // value is OK
}
}
void oracle_standard_use_type_backend::post_use(bool gotData, indicator *ind)
{
// It is possible to have the bound element being overwritten
// by the database.
//
// With readOnly_ == true the propagation of modification should *not*
// take place and in addition the attempt of modification should be detected and reported.
// first, deal with data
if (gotData)
{
switch (type_)
{
case x_char:
if (readOnly_)
{
const char original = *static_cast(data_);
const char bound = buf_[0];
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_short:
if (readOnly_)
{
const short original = *static_cast(data_);
const short bound = *static_cast(static_cast(buf_));
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_integer:
if (readOnly_)
{
const int original = *static_cast(data_);
const int bound = *static_cast(static_cast(buf_));
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_long_long:
if (readOnly_)
{
long long const original = *static_cast(data_);
long long const bound = std::strtoll(buf_, NULL, 10);
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_unsigned_long_long:
if (readOnly_)
{
unsigned long long const original = *static_cast(data_);
unsigned long long const bound = std::strtoull(buf_, NULL, 10);
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_double:
if (readOnly_)
{
const double original = *static_cast(data_);
const double bound = *static_cast(static_cast(buf_));
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_stdstring:
{
std::string & original = *static_cast(data_);
if (original != buf_)
{
if (readOnly_)
{
throw soci_error("Attempted modification of const use element");
}
else
{
original = buf_;
}
}
}
break;
case x_stdtm:
{
std::tm & original = *static_cast(data_);
std::tm bound;
ub1 *pos = reinterpret_cast(buf_);
bound.tm_isdst = -1;
bound.tm_year = (*pos++ - 100) * 100;
bound.tm_year += *pos++ - 2000;
bound.tm_mon = *pos++ - 1;
bound.tm_mday = *pos++;
bound.tm_hour = *pos++ - 1;
bound.tm_min = *pos++ - 1;
bound.tm_sec = *pos++ - 1;
if (original.tm_year != bound.tm_year ||
original.tm_mon != bound.tm_mon ||
original.tm_mday != bound.tm_mday ||
original.tm_hour != bound.tm_hour ||
original.tm_min != bound.tm_min ||
original.tm_sec != bound.tm_sec)
{
if (readOnly_)
{
throw soci_error("Attempted modification of const use element");
}
else
{
original = bound;
// normalize and compute the remaining fields
std::mktime(&original);
}
}
}
break;
case x_statement:
{
statement *s = static_cast(data_);
s->define_and_bind();
}
break;
case x_rowid:
case x_blob:
// nothing to do here
break;
}
}
if (ind != NULL)
{
if (gotData)
{
if (indOCIHolder_ == 0)
{
*ind = i_ok;
}
else if (indOCIHolder_ == -1)
{
*ind = i_null;
}
else
{
*ind = i_truncated;
}
}
}
}
void oracle_standard_use_type_backend::clean_up()
{
if (bindp_ != NULL)
{
OCIHandleFree(bindp_, OCI_HTYPE_DEFINE);
bindp_ = NULL;
}
if (buf_ != NULL)
{
delete [] buf_;
buf_ = NULL;
}
}
soci-3.2.3/backends/oracle/session.cpp 0000644 0000000 0000000 00000013736 12511361676 016402 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_ORACLE_SOURCE
#include "soci-oracle.h"
#include "error.h"
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
oracle_session_backend::oracle_session_backend(std::string const & serviceName,
std::string const & userName, std::string const & password, int mode,
bool decimals_as_strings)
: envhp_(NULL), srvhp_(NULL), errhp_(NULL), svchp_(NULL), usrhp_(NULL)
, decimals_as_strings_(decimals_as_strings)
{
sword res;
// create the environment
res = OCIEnvCreate(&envhp_, OCI_THREADED | OCI_ENV_NO_MUTEX,
0, 0, 0, 0, 0, 0);
if (res != OCI_SUCCESS)
{
throw soci_error("Cannot create environment");
}
// create the server handle
res = OCIHandleAlloc(envhp_, reinterpret_cast(&srvhp_),
OCI_HTYPE_SERVER, 0, 0);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot create server handle");
}
// create the error handle
res = OCIHandleAlloc(envhp_, reinterpret_cast(&errhp_),
OCI_HTYPE_ERROR, 0, 0);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot create error handle");
}
// create the server context
sb4 serviceNameLen = static_cast(serviceName.size());
res = OCIServerAttach(srvhp_, errhp_,
reinterpret_cast(const_cast(serviceName.c_str())),
serviceNameLen, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
std::string msg;
int errNum;
get_error_details(res, errhp_, msg, errNum);
clean_up();
throw oracle_soci_error(msg, errNum);
}
// create service context handle
res = OCIHandleAlloc(envhp_, reinterpret_cast(&svchp_),
OCI_HTYPE_SVCCTX, 0, 0);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot create service context");
}
// set the server attribute in the context handle
res = OCIAttrSet(svchp_, OCI_HTYPE_SVCCTX, srvhp_, 0,
OCI_ATTR_SERVER, errhp_);
if (res != OCI_SUCCESS)
{
std::string msg;
int errNum;
get_error_details(res, errhp_, msg, errNum);
clean_up();
throw oracle_soci_error(msg, errNum);
}
// allocate user session handle
res = OCIHandleAlloc(envhp_, reinterpret_cast(&usrhp_),
OCI_HTYPE_SESSION, 0, 0);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot allocate user session handle");
}
// set username attribute in the user session handle
sb4 userNameLen = static_cast(userName.size());
res = OCIAttrSet(usrhp_, OCI_HTYPE_SESSION,
reinterpret_cast(const_cast(userName.c_str())),
userNameLen, OCI_ATTR_USERNAME, errhp_);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot set username");
}
// set password attribute
sb4 passwordLen = static_cast(password.size());
res = OCIAttrSet(usrhp_, OCI_HTYPE_SESSION,
reinterpret_cast(const_cast(password.c_str())),
passwordLen, OCI_ATTR_PASSWORD, errhp_);
if (res != OCI_SUCCESS)
{
clean_up();
throw soci_error("Cannot set password");
}
// begin the session
res = OCISessionBegin(svchp_, errhp_, usrhp_,
OCI_CRED_RDBMS, mode);
if (res != OCI_SUCCESS)
{
std::string msg;
int errNum;
get_error_details(res, errhp_, msg, errNum);
clean_up();
throw oracle_soci_error(msg, errNum);
}
// set the session in the context handle
res = OCIAttrSet(svchp_, OCI_HTYPE_SVCCTX, usrhp_,
0, OCI_ATTR_SESSION, errhp_);
if (res != OCI_SUCCESS)
{
std::string msg;
int errNum;
get_error_details(res, errhp_, msg, errNum);
clean_up();
throw oracle_soci_error(msg, errNum);
}
}
oracle_session_backend::~oracle_session_backend()
{
clean_up();
}
void oracle_session_backend::begin()
{
// This code is commented out because it causes one of the transaction
// tests in common_tests::test10() to fail with error 'Invalid handle'
// With the code commented out, all tests pass.
// sword res = OCITransStart(svchp_, errhp_, 0, OCI_TRANS_NEW);
// if (res != OCI_SUCCESS)
// {
// throworacle_soci_error(res, errhp_);
// }
}
void oracle_session_backend::commit()
{
sword res = OCITransCommit(svchp_, errhp_, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, errhp_);
}
}
void oracle_session_backend::rollback()
{
sword res = OCITransRollback(svchp_, errhp_, OCI_DEFAULT);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, errhp_);
}
}
void oracle_session_backend::clean_up()
{
if (svchp_ != NULL && errhp_ != NULL && usrhp_ != NULL)
{
OCISessionEnd(svchp_, errhp_, usrhp_, OCI_DEFAULT);
}
if (usrhp_) { OCIHandleFree(usrhp_, OCI_HTYPE_SESSION); }
if (svchp_) { OCIHandleFree(svchp_, OCI_HTYPE_SVCCTX); }
if (srvhp_)
{
OCIServerDetach(srvhp_, errhp_, OCI_DEFAULT);
OCIHandleFree(srvhp_, OCI_HTYPE_SERVER);
}
if (errhp_) { OCIHandleFree(errhp_, OCI_HTYPE_ERROR); }
if (envhp_) { OCIHandleFree(envhp_, OCI_HTYPE_ENV); }
}
oracle_statement_backend * oracle_session_backend::make_statement_backend()
{
return new oracle_statement_backend(*this);
}
oracle_rowid_backend * oracle_session_backend::make_rowid_backend()
{
return new oracle_rowid_backend(*this);
}
oracle_blob_backend * oracle_session_backend::make_blob_backend()
{
return new oracle_blob_backend(*this);
}
soci-3.2.3/backends/oracle/Makefile.basic 0000644 0000000 0000000 00000005207 12511361676 016725 0 ustar root root # The following variable is specific to this backend and its correct
# values might depend on your environment - feel free to set it accordingly.
ORACLEINCLUDEDIR = -I/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/public
# The rest of the Makefile is indepentent of the target environment.
COMPILER = g++
CXXFLAGS = -Wall -pedantic -Wno-long-long
CXXFLAGSSO = ${CXXFLAGS} -fPIC
INCLUDEDIRS = -I../../core ${ORACLEINCLUDEDIR}
OBJECTS = blob.o factory.o row-id.o session.o standard-into-type.o \
standard-use-type.o statement.o vector-into-type.o vector-use-type.o \
error.o
OBJECTSSO = blob-s.o factory-s.o row-id-s.o session-s.o \
standard-into-type-s.o standard-use-type-s.o statement-s.o \
vector-into-type-s.o vector-use-type-s.o error-s.o
libsoci_oracle.a : ${OBJECTS}
ar rv $@ $?
rm *.o
soci-oracle.o : soci-oracle.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
blob.o : blob.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
error.o : error.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
factory.o : factory.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
row-id.o : row-id.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
session.o : session.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
standard-into-type.o : standard-into-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
standard-use-type.o : standard-use-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
statement.o : statement.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
vector-into-type.o : vector-into-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
vector-use-type.o : vector-use-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
shared : ${OBJECTSSO}
${COMPILER} -shared -o libsoci_oracle.so ${OBJECTSSO}
rm *.o
blob-s.o : blob.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
error-s.o : error.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
factory-s.o : factory.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
row-id-s.o : row-id.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
session-s.o : session.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
standard-into-type-s.o : standard-into-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
standard-use-type-s.o : standard-use-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
statement-s.o : statement.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
vector-into-type-s.o : vector-into-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
vector-use-type-s.o : vector-use-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
clean :
rm -f *.o libsoci_oracle.a libsoci_oracle.so
soci-3.2.3/backends/oracle/soci-oracle.h 0000644 0000000 0000000 00000017702 12511362240 016545 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_ORACLE_H_INCLUDED
#define SOCI_ORACLE_H_INCLUDED
#ifdef _WIN32
# ifdef SOCI_DLL
# ifdef SOCI_ORACLE_SOURCE
# define SOCI_ORACLE_DECL __declspec(dllexport)
# else
# define SOCI_ORACLE_DECL __declspec(dllimport)
# endif // SOCI_ORACLE_SOURCE
# endif // SOCI_DLL
#endif // _WIN32
//
// If SOCI_ORACLE_DECL isn't defined yet define it now
#ifndef SOCI_ORACLE_DECL
# define SOCI_ORACLE_DECL
#endif
#include
#include // OCI
#include
#ifdef _MSC_VER
#pragma warning(disable:4512 4511)
#endif
namespace soci
{
class SOCI_ORACLE_DECL oracle_soci_error : public soci_error
{
public:
oracle_soci_error(std::string const & msg, int errNum = 0);
int err_num_;
};
struct oracle_statement_backend;
struct oracle_standard_into_type_backend : details::standard_into_type_backend
{
oracle_standard_into_type_backend(oracle_statement_backend &st)
: statement_(st), defnp_(NULL), indOCIHolder_(0),
data_(NULL), buf_(NULL) {}
virtual void define_by_pos(int &position,
void *data, details::exchange_type type);
virtual void pre_fetch();
virtual void post_fetch(bool gotData, bool calledFromFetch,
indicator *ind);
virtual void clean_up();
oracle_statement_backend &statement_;
OCIDefine *defnp_;
sb2 indOCIHolder_;
void *data_;
char *buf_; // generic buffer
details::exchange_type type_;
ub2 rCode_;
};
struct oracle_vector_into_type_backend : details::vector_into_type_backend
{
oracle_vector_into_type_backend(oracle_statement_backend &st)
: statement_(st), defnp_(NULL), indOCIHolders_(NULL),
data_(NULL), buf_(NULL) {}
virtual void define_by_pos(int &position,
void *data, details::exchange_type type);
virtual void pre_fetch();
virtual void post_fetch(bool gotData, indicator *ind);
virtual void resize(std::size_t sz);
virtual std::size_t size();
virtual void clean_up();
// helper function for preparing indicators and sizes_ vectors
// (as part of the define_by_pos)
void prepare_indicators(std::size_t size);
oracle_statement_backend &statement_;
OCIDefine *defnp_;
sb2 *indOCIHolders_;
std::vector indOCIHolderVec_;
void *data_;
char *buf_; // generic buffer
details::exchange_type type_;
std::size_t colSize_; // size of the string column (used for strings)
std::vector sizes_; // sizes of data fetched (used for strings)
std::vector rCodes_;
};
struct oracle_standard_use_type_backend : details::standard_use_type_backend
{
oracle_standard_use_type_backend(oracle_statement_backend &st)
: statement_(st), bindp_(NULL), indOCIHolder_(0),
data_(NULL), buf_(NULL) {}
virtual void bind_by_pos(int &position,
void *data, details::exchange_type type, bool readOnly);
virtual void bind_by_name(std::string const &name,
void *data, details::exchange_type type, bool readOnly);
// common part for bind_by_pos and bind_by_name
void prepare_for_bind(void *&data, sb4 &size, ub2 &oracleType, bool readOnly);
virtual void pre_use(indicator const *ind);
virtual void post_use(bool gotData, indicator *ind);
virtual void clean_up();
oracle_statement_backend &statement_;
OCIBind *bindp_;
sb2 indOCIHolder_;
void *data_;
bool readOnly_;
char *buf_; // generic buffer
details::exchange_type type_;
};
struct oracle_vector_use_type_backend : details::vector_use_type_backend
{
oracle_vector_use_type_backend(oracle_statement_backend &st)
: statement_(st), bindp_(NULL), indOCIHolders_(NULL),
data_(NULL), buf_(NULL) {}
virtual void bind_by_pos(int &position,
void *data, details::exchange_type type);
virtual void bind_by_name(std::string const &name,
void *data, details::exchange_type type);
// common part for bind_by_pos and bind_by_name
void prepare_for_bind(void *&data, sb4 &size, ub2 &oracleType);
// helper function for preparing indicators and sizes_ vectors
// (as part of the bind_by_pos and bind_by_name)
void prepare_indicators(std::size_t size);
virtual void pre_use(indicator const *ind);
virtual std::size_t size();
virtual void clean_up();
oracle_statement_backend &statement_;
OCIBind *bindp_;
std::vector indOCIHolderVec_;
sb2 *indOCIHolders_;
void *data_;
char *buf_; // generic buffer
details::exchange_type type_;
// used for strings only
std::vector sizes_;
std::size_t maxSize_;
};
struct oracle_session_backend;
struct oracle_statement_backend : details::statement_backend
{
oracle_statement_backend(oracle_session_backend &session);
virtual void alloc();
virtual void clean_up();
virtual void prepare(std::string const &query,
details::statement_type eType);
virtual exec_fetch_result execute(int number);
virtual exec_fetch_result fetch(int number);
virtual long long get_affected_rows();
virtual int get_number_of_rows();
virtual std::string rewrite_for_procedure_call(std::string const &query);
virtual int prepare_for_describe();
virtual void describe_column(int colNum, data_type &dtype,
std::string &columnName);
// helper for defining into vector
std::size_t column_size(int position);
virtual oracle_standard_into_type_backend * make_into_type_backend();
virtual oracle_standard_use_type_backend * make_use_type_backend();
virtual oracle_vector_into_type_backend * make_vector_into_type_backend();
virtual oracle_vector_use_type_backend * make_vector_use_type_backend();
oracle_session_backend &session_;
OCIStmt *stmtp_;
bool boundByName_;
bool boundByPos_;
bool noData_;
};
struct oracle_rowid_backend : details::rowid_backend
{
oracle_rowid_backend(oracle_session_backend &session);
~oracle_rowid_backend();
OCIRowid *rowidp_;
};
struct oracle_blob_backend : details::blob_backend
{
oracle_blob_backend(oracle_session_backend &session);
~oracle_blob_backend();
virtual std::size_t get_len();
virtual std::size_t read(std::size_t offset, char *buf,
std::size_t toRead);
virtual std::size_t write(std::size_t offset, char const *buf,
std::size_t toWrite);
virtual std::size_t append(char const *buf, std::size_t toWrite);
virtual void trim(std::size_t newLen);
oracle_session_backend &session_;
OCILobLocator *lobp_;
};
struct oracle_session_backend : details::session_backend
{
oracle_session_backend(std::string const & serviceName,
std::string const & userName,
std::string const & password,
int mode,
bool decimals_as_strings = false);
~oracle_session_backend();
virtual void begin();
virtual void commit();
virtual void rollback();
virtual std::string get_backend_name() const { return "oracle"; }
void clean_up();
virtual oracle_statement_backend * make_statement_backend();
virtual oracle_rowid_backend * make_rowid_backend();
virtual oracle_blob_backend * make_blob_backend();
bool get_option_decimals_as_strings() { return decimals_as_strings_; }
OCIEnv *envhp_;
OCIServer *srvhp_;
OCIError *errhp_;
OCISvcCtx *svchp_;
OCISession *usrhp_;
bool decimals_as_strings_;
};
struct oracle_backend_factory : backend_factory
{
oracle_backend_factory() {}
virtual oracle_session_backend * make_session(
connection_parameters const & parameters) const;
};
extern SOCI_ORACLE_DECL oracle_backend_factory const oracle;
extern "C"
{
// for dynamic backend loading
SOCI_ORACLE_DECL backend_factory const * factory_oracle();
SOCI_ORACLE_DECL void register_factory_oracle();
} // extern "C"
} // namespace soci
#endif
soci-3.2.3/backends/oracle/error.cpp 0000644 0000000 0000000 00000002656 12511361676 016047 0 ustar root root //
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_ORACLE_SOURCE
#include "soci-oracle.h"
#include "error.h"
#include
#include
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;
oracle_soci_error::oracle_soci_error(std::string const & msg, int errNum)
: soci_error(msg), err_num_(errNum)
{
}
void soci::details::oracle::get_error_details(sword res, OCIError *errhp,
std::string &msg, int &errNum)
{
text errbuf[512];
sb4 errcode;
errNum = 0;
switch (res)
{
case OCI_NO_DATA:
msg = "soci error: No data";
break;
case OCI_ERROR:
OCIErrorGet(errhp, 1, 0, &errcode,
errbuf, sizeof(errbuf), OCI_HTYPE_ERROR);
msg = reinterpret_cast(errbuf);
errNum = static_cast