Skip to content

Commit ff946bd

Browse files
committed
Changed Column::getText() to return empty string "" by default instead of NULL pointer (to handle std::string conversion)
- Fix issue SRombauts#17
1 parent b0e9104 commit ff946bd

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ Version 0.7.0 - January 9 2014
4040
Added a new Database::createFunction() API
4141
Added std::string version of existing APIs
4242
Improved CMake with more build options and Doxygen auto-detection
43-
43+
44+
Version 0.8.0 - Februrary 26 2014
45+
Changed Column::getText() to return empty string "" by default instead of NULL pointer (to handle std::string conversion)
46+

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PROJECT_NAME = SQLiteC++
3232
# This could be handy for archiving the generated documentation or
3333
# if some version control system is used.
3434

35-
PROJECT_NUMBER = 0.7.0
35+
PROJECT_NUMBER = 0.8.0
3636

3737
# Using the PROJECT_BRIEF tag one can provide an optional one line description
3838
# for a project that appears at the top of each page and should give viewer

examples/example1/example.db3

0 Bytes
Binary file not shown.

examples/example1/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Demonstrate how-to use the SQLite++ wrapper
66
*
7-
* Copyright (c) 2012-2013 Sebastien Rombauts ([email protected])
7+
* Copyright (c) 2012-2014 Sebastien Rombauts ([email protected])
88
*
99
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
1010
* or copy at http://opensource.org/licenses/MIT)
@@ -118,7 +118,7 @@ int main (void)
118118
std::string name2 = query.getColumn(2).getName();
119119
std::cout << "aliased result [\"" << name0.c_str() << "\", \"" << name1.c_str() << "\", \"" << name2.c_str() << "\"]\n";
120120
#ifdef SQLITE_ENABLE_COLUMN_METADATA
121-
// Show how to get origin names of the table columns from which thoses result columns come from.
121+
// Show how to get origin names of the table columns from which theses result columns come from.
122122
// Requires the SQLITE_ENABLE_COLUMN_METADATA preprocessor macro to be
123123
// also defined at compile times of the SQLite library itself.
124124
name0 = query.getColumn(0).getOriginName();

src/Column.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @ingroup SQLiteCpp
44
* @brief Encapsulation of a Column in a row of the result pointed by the prepared SQLite::Statement.
55
*
6-
* Copyright (c) 2012-2013 Sebastien Rombauts ([email protected])
6+
* Copyright (c) 2012-2014 Sebastien Rombauts ([email protected])
77
*
88
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
99
* or copy at http://opensource.org/licenses/MIT)
@@ -63,10 +63,10 @@ double Column::getDouble(void) const noexcept // nothrow
6363
}
6464

6565
// Return a pointer to the text value (NULL terminated string) of the column specified by its index starting at 0
66-
const char* Column::getText(void) const noexcept // nothrow
66+
const char* Column::getText(const char* apDefaultValue /* = "" */) const noexcept // nothrow
6767
{
68-
// TODO what if NULL !?
69-
return (const char*)sqlite3_column_text(mStmtPtr, mIndex);
68+
const char* pText = (const char*)sqlite3_column_text(mStmtPtr, mIndex);
69+
return (pText?pText:apDefaultValue);
7070
}
7171

7272
// Return a pointer to the text value (NULL terminated string) of the column specified by its index starting at 0

src/Column.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @ingroup SQLiteCpp
44
* @brief Encapsulation of a Column in a row of the result pointed by the prepared SQLite::Statement.
55
*
6-
* Copyright (c) 2012-2013 Sebastien Rombauts ([email protected])
6+
* Copyright (c) 2012-2014 Sebastien Rombauts ([email protected])
77
*
88
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
99
* or copy at http://opensource.org/licenses/MIT)
@@ -35,6 +35,8 @@ namespace SQLite
3535
* 2) the SQLite "Serialized" mode is not supported by SQLiteC++,
3636
* because of the way it shares the underling SQLite precompiled statement
3737
* in a custom shared pointer (See the inner class "Statement::Ptr").
38+
*
39+
* @todo inline all simple getters
3840
*/
3941
class Column
4042
{
@@ -80,7 +82,7 @@ class Column
8082
* @warning The value pointed at is only valid while the statement is valid (ie. not finalized),
8183
* thus you must copy it before using it beyond its scope (to a std::string for instance).
8284
*/
83-
const char* getText (void) const noexcept; // nothrow
85+
const char* getText (const char* apDefaultValue = "") const noexcept; // nothrow
8486
/**
8587
* @brief Return a pointer to the binary blob value of the column.
8688
*
@@ -184,7 +186,6 @@ class Column
184186
/// Inline cast operator to std::string
185187
inline operator const std::string() const
186188
{
187-
// TODO what if NULL !?
188189
return getText();
189190
}
190191
#endif

src/SQLiteC++.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Include this main header file in your project to gain access to all functionality provided by the wrapper.
77
*
8-
* Copyright (c) 2012-2013 Sebastien Rombauts ([email protected])
8+
* Copyright (c) 2012-2014 Sebastien Rombauts ([email protected])
99
*
1010
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
1111
* or copy at http://opensource.org/licenses/MIT)
@@ -38,5 +38,5 @@
3838
* with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
3939
* numbers used in [SQLITECPP_VERSION].
4040
*/
41-
#define SQLITECPP_VERSION "0.7.0"
42-
#define SQLITECPP_VERSION_NUMBER 0006000
41+
#define SQLITECPP_VERSION "0.8.0"
42+
#define SQLITECPP_VERSION_NUMBER 0008000

0 commit comments

Comments
 (0)