diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4fcad13..fc69057 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -40,4 +40,7 @@ Version 0.7.0 - January 9 2014 Added a new Database::createFunction() API Added std::string version of existing APIs Improved CMake with more build options and Doxygen auto-detection - \ No newline at end of file + +Version 0.8.0 - Februrary 26 2014 + Changed Column::getText() to return empty string "" by default instead of NULL pointer (to handle std::string conversion) + diff --git a/Doxyfile b/Doxyfile index 801804d..d13a4f0 100644 --- a/Doxyfile +++ b/Doxyfile @@ -32,7 +32,7 @@ PROJECT_NAME = SQLiteC++ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.7.0 +PROJECT_NUMBER = 0.8.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/examples/example1/example.db3 b/examples/example1/example.db3 index c02726b..89a7419 100644 Binary files a/examples/example1/example.db3 and b/examples/example1/example.db3 differ diff --git a/examples/example1/main.cpp b/examples/example1/main.cpp index db368ee..57510d3 100644 --- a/examples/example1/main.cpp +++ b/examples/example1/main.cpp @@ -4,7 +4,7 @@ * * Demonstrate how-to use the SQLite++ wrapper * - * Copyright (c) 2012-2013 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * Copyright (c) 2012-2014 Sebastien Rombauts (sebastien.rombauts@gmail.com) * * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) @@ -118,7 +118,7 @@ int main (void) std::string name2 = query.getColumn(2).getName(); std::cout << "aliased result [\"" << name0.c_str() << "\", \"" << name1.c_str() << "\", \"" << name2.c_str() << "\"]\n"; #ifdef SQLITE_ENABLE_COLUMN_METADATA - // Show how to get origin names of the table columns from which thoses result columns come from. + // Show how to get origin names of the table columns from which theses result columns come from. // Requires the SQLITE_ENABLE_COLUMN_METADATA preprocessor macro to be // also defined at compile times of the SQLite library itself. name0 = query.getColumn(0).getOriginName(); diff --git a/src/Column.cpp b/src/Column.cpp index 09f03d4..2ca474e 100644 --- a/src/Column.cpp +++ b/src/Column.cpp @@ -3,7 +3,7 @@ * @ingroup SQLiteCpp * @brief Encapsulation of a Column in a row of the result pointed by the prepared SQLite::Statement. * - * Copyright (c) 2012-2013 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * Copyright (c) 2012-2014 Sebastien Rombauts (sebastien.rombauts@gmail.com) * * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) @@ -63,10 +63,10 @@ double Column::getDouble(void) const noexcept // nothrow } // Return a pointer to the text value (NULL terminated string) of the column specified by its index starting at 0 -const char* Column::getText(void) const noexcept // nothrow +const char* Column::getText(const char* apDefaultValue /* = "" */) const noexcept // nothrow { - // TODO what if NULL !? - return (const char*)sqlite3_column_text(mStmtPtr, mIndex); + const char* pText = (const char*)sqlite3_column_text(mStmtPtr, mIndex); + return (pText?pText:apDefaultValue); } // Return a pointer to the text value (NULL terminated string) of the column specified by its index starting at 0 diff --git a/src/Column.h b/src/Column.h index 86bdd99..7207c8f 100644 --- a/src/Column.h +++ b/src/Column.h @@ -3,7 +3,7 @@ * @ingroup SQLiteCpp * @brief Encapsulation of a Column in a row of the result pointed by the prepared SQLite::Statement. * - * Copyright (c) 2012-2013 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * Copyright (c) 2012-2014 Sebastien Rombauts (sebastien.rombauts@gmail.com) * * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) @@ -35,6 +35,8 @@ namespace SQLite * 2) the SQLite "Serialized" mode is not supported by SQLiteC++, * because of the way it shares the underling SQLite precompiled statement * in a custom shared pointer (See the inner class "Statement::Ptr"). + * + * @todo inline all simple getters */ class Column { @@ -80,7 +82,7 @@ public: * @warning The value pointed at is only valid while the statement is valid (ie. not finalized), * thus you must copy it before using it beyond its scope (to a std::string for instance). */ - const char* getText (void) const noexcept; // nothrow + const char* getText (const char* apDefaultValue = "") const noexcept; // nothrow /** * @brief Return a pointer to the binary blob value of the column. * @@ -184,7 +186,6 @@ public: /// Inline cast operator to std::string inline operator const std::string() const { - // TODO what if NULL !? return getText(); } #endif diff --git a/src/SQLiteC++.h b/src/SQLiteC++.h index 4a10d7f..18440bf 100644 --- a/src/SQLiteC++.h +++ b/src/SQLiteC++.h @@ -5,7 +5,7 @@ * * Include this main header file in your project to gain access to all functionality provided by the wrapper. * - * Copyright (c) 2012-2013 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * Copyright (c) 2012-2014 Sebastien Rombauts (sebastien.rombauts@gmail.com) * * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) @@ -38,5 +38,5 @@ * with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same * numbers used in [SQLITECPP_VERSION]. */ -#define SQLITECPP_VERSION "0.7.0" -#define SQLITECPP_VERSION_NUMBER 0006000 +#define SQLITECPP_VERSION "0.8.0" +#define SQLITECPP_VERSION_NUMBER 0008000