libtabula

Check-in [dd77d4c60e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a test for C++11's "long long" data type, which we use in defining sql_* data types. Previously, we blindly assumed the C++ compiler also supported C99's "long long" even though C++98 and C++03 don't require it, which in turn required a couple of levels of fall-back for the cases where the C++ compiler didn't have that extension. Now that it's finally part of C++, we can just check for it.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dd77d4c60eb05078d3850321a6108c63f6683e3d
User & Date: etr 2015-09-11 18:30:02
Context
2015-09-11
18:41
Added another C++11 test using the same mechanism from the previous one, this time for the cbegin/cend iterators, required on EL7, but which break the build on EL5's default GCC 4.1.2 compiler. Now we use them if present, and not if not. check-in: 9069ab8ffb user: etr tags: trunk
18:30
Added a test for C++11's "long long" data type, which we use in defining sql_* data types. Previously, we blindly assumed the C++ compiler also supported C99's "long long" even though C++98 and C++03 don't require it, which in turn required a couple of levels of fall-back for the cases where the C++ compiler didn't have that extension. Now that it's finally part of C++, we can just check for it. check-in: dd77d4c60e user: etr tags: trunk
2015-09-03
14:37
. check-in: 22689bd7dc user: etr tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CMakeLists.txt.

1
2
3
4
5
6

7

8
9
10
11
12
13
14
...
134
135
136
137
138
139
140

141
142
143
144
145




146
147
148
149
150
151
152
# CMakeLists.txt - Tells CMake how to build the libtabula system on 
#      supported platforms.  See */CMakeLists.txt for build details of
#      each element of the system.
#
# Created 2014.08.21 by Warren Young
#

# Copyright © 2014-2015 by Warren Young

#
# Others may also hold copyrights on code in this file.  See the
# CREDITS.md file in the top directory of the distribution for details.
#
# This file is part of libtabula.
#
# libtabula is free software; you can redistribute it and/or modify it
................................................................................
configure_file(src/libtabula.h.in src/libtabula.h)
configure_file(src/ssx/Doxyfile.in src/ssx/Doxyfile)

include_directories(src ${PROJECT_BINARY_DIR}/src ${MYSQL_INCLUDE_DIR})
get_filename_component(MYSQL_LIBRARY_DIR "${MYSQL_LIBRARY}" PATH)
link_directories(${MYSQL_LIBRARY_DIR})


add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(src/ssx)
add_subdirectory(test)
add_subdirectory(examples)





# Two testing targets based on the dtest script, one running it
# standalone, one under CTest.  The latter suppresses output and 
# only reports pass/fail.  The dtest target can't depend on "all"
# due to a CMake design weakness, while "test" does implicitly,
# since it's integrated into the CMake design.
add_custom_target(dtest






>
|
>







 







>





>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# CMakeLists.txt - Tells CMake how to build the libtabula system on 
#      supported platforms.  See */CMakeLists.txt for build details of
#      each element of the system.
#
# Created 2014.08.21 by Warren Young
#
# Copyright
#   © 2014-2015 by Warren Young
#   © 2015 by Educational Technology Resources, Inc.
#
# Others may also hold copyrights on code in this file.  See the
# CREDITS.md file in the top directory of the distribution for details.
#
# This file is part of libtabula.
#
# libtabula is free software; you can redistribute it and/or modify it
................................................................................
configure_file(src/libtabula.h.in src/libtabula.h)
configure_file(src/ssx/Doxyfile.in src/ssx/Doxyfile)

include_directories(src ${PROJECT_BINARY_DIR}/src ${MYSQL_INCLUDE_DIR})
get_filename_component(MYSQL_LIBRARY_DIR "${MYSQL_LIBRARY}" PATH)
link_directories(${MYSQL_LIBRARY_DIR})

add_subdirectory(cmake)
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(src/ssx)
add_subdirectory(test)
add_subdirectory(examples)

# Check for specific post-C++98 features.  Must be after cmake subdir.
include(cmake/CheckCXX11Features.cmake)
CXX_CHECK_FEATURE("long long" HAVE_CXX_LONG_LONG)

# Two testing targets based on the dtest script, one running it
# standalone, one under CTest.  The latter suppresses output and 
# only reports pass/fail.  The dtest target can't depend on "all"
# due to a CMake design weakness, while "test" does implicitly,
# since it's integrated into the CMake design.
add_custom_target(dtest

Added cmake/CMakeLists.txt.





























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
project("c++11_test")

# Does the compiler need special options to use post-C++98 features?
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" FOUND_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" FOUND_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" FOUND_CXX0X)
if (FOUND_CXX14)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif (FOUND_CXX11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()

Added cmake/CheckCXX11Features.cmake.



























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Checks for post-C++98 features
#
# Original script by Rolf Eike Beer
#
# Modifications by Andreas Weis: http://pageant.ghulbus.eu/?p=664
# Explicitly placed into the public domain
#
# Modified for libtabula, primarily by removing unneeded functionality.

MACRO(CXX_CHECK_FEATURE FEATURE_NAME RESULT_VAR)
	IF (NOT DEFINED ${RESULT_VAR})
		SET(_LOG_NAME "\"${FEATURE_NAME}\"")
		string(REPLACE " " "_" BASE_NAME ${FEATURE_NAME})
		SET(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx_${BASE_NAME}")
		SET(_SRCFILE_BASE ${CMAKE_SOURCE_DIR}/cmake/c++-test-${BASE_NAME})
		MESSAGE(STATUS "Checking for C++ ${_LOG_NAME} feature...")

		SET(_SRCFILE "${_SRCFILE_BASE}.cpp")
		SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
		SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")

		IF (CROSS_COMPILING)
			try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
				try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
		ELSE (CROSS_COMPILING)
			try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
					"${_bindir}" "${_SRCFILE}")
			IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} TRUE)
			ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} FALSE)
			ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
				try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
						"${_bindir}_fail" "${_SRCFILE_FAIL}")
				IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} TRUE)
				ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} FALSE)
				ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
		ENDIF (CROSS_COMPILING)
		IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
			try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
			IF (_TMP_RESULT)
				SET(${RESULT_VAR} FALSE)
			ELSE (_TMP_RESULT)
				SET(${RESULT_VAR} TRUE)
			ENDIF (_TMP_RESULT)
		ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})

		IF (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${_LOG_NAME} feature supported")
		ELSE (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${_LOG_NAME} feature NOT supported")
		ENDIF (${RESULT_VAR})
		SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++ feature ${_LOG_NAME}")
	ENDIF (NOT DEFINED ${RESULT_VAR})
ENDMACRO(CXX_CHECK_FEATURE)

Added cmake/c++-test-long_long.cpp.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
int main(void)
{
	long long l;
	unsigned long long ul;

	return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
}

Changes to src/common.h.

1
2
3
4
5
6
7

8

9


10
11
12
13
14
15
16
17
18
19
..
27
28
29
30
31
32
33









34
35
36
37
38
39
40
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
136
137
138
139
140
141
142




143
144
145
146
147
148
149
150
/// \file common.h
/// \brief This file includes top-level definitions for use both
/// internal to the library, and outside it.  Contrast libtabula.h
///
/// This file mostly takes care of platform differences.

/***********************************************************************

 Copyright © 1998 by Kevin Atkinson, © 1999-2001 by MySQL AB,

 © 2004-2009 by Educational Technology Resources, Inc., and


 © 2009 by Warren Young.  Others may also hold copyrights on code
 in this file.  See the CREDITS.md file in the top directory of the
 distribution for details.

 This file is part of libtabula.

 libtabula is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
 by the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
................................................................................
 License along with libtabula; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 USA
***********************************************************************/

#if !defined(LIBTABULA_COMMON_H)
#define LIBTABULA_COMMON_H










#if !defined(DOXYGEN_IGNORE)
// Doxygen will not generate documentation for the following stuff.

// Enable SSQLS by default.  Turned off below on platforms where we
// know it doesn't work.
#define LIBTABULA_SSQLS_COMPATIBLE
................................................................................
		// Not making a DLL at all, so no-op these declspecs
		#define LIBTABULA_EXPORT
	#endif

	// We need to use the DOS/Windows path separator here
	#define LIBTABULA_PATH_SEPARATOR '\\'
#else
	// If not VC++, MinGW, or Xcode, we assume we're on a system using
	// autoconf, so bring in the config.h file it wrote containing the
	// config test results.  Only do this during the library build, and
	// even then, not if included from a libtabula header file, since
	// config.h cannot be safely installed with the other headers.
#	if defined(LIBTABULA_NOT_HEADER) && !defined(MYSQLPP_XCODE)
#		include "config.h"
#	endif

	// Make DLL stuff a no-op on this platform.
	#define LIBTABULA_EXPORT

	// Assume POSIX path separator
	#define LIBTABULA_PATH_SEPARATOR '/'
#endif

................................................................................

/// \brief Used to disambiguate overloads of equal_list() in SSQLSes.
enum sql_cmp_type { sql_use_compare };

#if !defined(DOXYGEN_IGNORE)
// Figure out how to get large integer support on this system.  Suppress
// refman documentation for these typedefs, as they're system-dependent.




#if defined(LIBTABULA_NO_LONG_LONGS)
// Alias "longlong" and "ulonglong" to the regular "long" counterparts
typedef unsigned long ulonglong;
typedef long longlong;
#elif defined(_MSC_VER)
// It's VC++, so we'll use Microsoft's 64-bit integer types
typedef unsigned __int64 ulonglong;
typedef __int64 longlong;







>
|
>
|
>
>
|
|
<







 







>
>
>
>
>
>
>
>
>







 







<
<
<
<
<
<
<
<
<







 







>
>
>
>
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
114
115
116
117
118
119
120









121
122
123
124
125
126
127
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/// \file common.h
/// \brief This file includes top-level definitions for use both
/// internal to the library, and outside it.  Contrast libtabula.h
///
/// This file mostly takes care of platform differences.

/***********************************************************************
 Copyright
   © 1998 by Kevin Atkinson
   © 1999-2001 by MySQL AB
   © 2004-2009, 2015 by Educational Technology Resources, Inc.
   © 2009, 2014 by Warren Young
   
 Others may also hold copyrights on code in this file.  See the
 CREDITS.md file in the top directory of the distribution for details.


 This file is part of libtabula.

 libtabula is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
 by the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
................................................................................
 License along with libtabula; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 USA
***********************************************************************/

#if !defined(LIBTABULA_COMMON_H)
#define LIBTABULA_COMMON_H

// Bring in the file CMake wrote to persist the results of some of the
// checks it made.  Unlike with the autotools config.h generated in
// MySQL++, this file always exists, so we can use it unconditionally.
// Also, since the library normally installs its headers into a sub
// directory of a standard include directory, we don't need to worry
// about the name being too generic, thus conflicting with another
// library's config.h.
#include "config.h"

#if !defined(DOXYGEN_IGNORE)
// Doxygen will not generate documentation for the following stuff.

// Enable SSQLS by default.  Turned off below on platforms where we
// know it doesn't work.
#define LIBTABULA_SSQLS_COMPATIBLE
................................................................................
		// Not making a DLL at all, so no-op these declspecs
		#define LIBTABULA_EXPORT
	#endif

	// We need to use the DOS/Windows path separator here
	#define LIBTABULA_PATH_SEPARATOR '\\'
#else









	// Make DLL stuff a no-op on this platform.
	#define LIBTABULA_EXPORT

	// Assume POSIX path separator
	#define LIBTABULA_PATH_SEPARATOR '/'
#endif

................................................................................

/// \brief Used to disambiguate overloads of equal_list() in SSQLSes.
enum sql_cmp_type { sql_use_compare };

#if !defined(DOXYGEN_IGNORE)
// Figure out how to get large integer support on this system.  Suppress
// refman documentation for these typedefs, as they're system-dependent.
#if defined(HAVE_LONG_LONG)
// CMake positively found support for C99-like "long long" in C++ here
typedef unsigned long long ulonglong;
typedef long long longlong;
#elif defined(LIBTABULA_NO_LONG_LONGS)
// Alias "longlong" and "ulonglong" to the regular "long" counterparts
typedef unsigned long ulonglong;
typedef long longlong;
#elif defined(_MSC_VER)
// It's VC++, so we'll use Microsoft's 64-bit integer types
typedef unsigned __int64 ulonglong;
typedef __int64 longlong;