mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 10:16:01 -04:00
Adding getBlob, getType and isInteger/isFloat/isText/isBlob/isNull methods to the Column class
This commit is contained in:
parent
dc4802edd5
commit
2412de7676
12
TODO.txt
12
TODO.txt
@ -5,14 +5,14 @@ C++11 explicit support
|
||||
Update Doxygen Documentation, but remove it from the master branch
|
||||
Publish the Doxygen Documentation in the Github Pages (gh-pages branch)
|
||||
|
||||
Missing features in v0.4.0:
|
||||
- **Blob** => make an example/test with image stored in a row
|
||||
- getColumnType + isText + isInt + isDouble...
|
||||
Missing test/example in v0.5.0:
|
||||
- BLOB : make an example with images stored in a row
|
||||
|
||||
Missing features in v0.5.0:
|
||||
- make an example/test with image stored in a row
|
||||
- getColumnByName ? std::map getRow() ?
|
||||
|
||||
Missing documentation in v0.4.0:
|
||||
- parameters of functions in Column and Statement
|
||||
- Help for the helper functions
|
||||
Missing documentation in v0.5.0:
|
||||
- This wrapper is not thread safe : compare to the thread safety of the SQLite3 library
|
||||
|
||||
Advanced missing features:
|
||||
|
@ -51,6 +51,18 @@ const char* Column::getText(void) const throw() // nothrow
|
||||
return (const char*)sqlite3_column_text(mStmtPtr, mIndex);
|
||||
}
|
||||
|
||||
// Return a pointer to the text value (NULL terminated string) of the column specified by its index starting at 0
|
||||
const void* Column::getBlob(void) const throw() // nothrow
|
||||
{
|
||||
return sqlite3_column_blob(mStmtPtr, mIndex);
|
||||
}
|
||||
|
||||
// Return the type of the value of the column
|
||||
int Column::getType(void) const throw() // nothrow
|
||||
{
|
||||
return sqlite3_column_type(mStmtPtr, mIndex);
|
||||
}
|
||||
|
||||
// Return the number of bytes used by the text value of the column
|
||||
int Column::getBytes(void) const throw() // nothrow
|
||||
{
|
||||
|
@ -42,16 +42,52 @@ public:
|
||||
// they copy the Statement::Ptr which in turn increments the reference counter.
|
||||
|
||||
/// Return the integer value of the column.
|
||||
int getInt (void) const throw();
|
||||
int getInt (void) const throw(); // nothrow
|
||||
/// Return the 64bits integer value of the column.
|
||||
sqlite3_int64 getInt64 (void) const throw();
|
||||
sqlite3_int64 getInt64 (void) const throw(); // nothrow
|
||||
/// Return the double (64bits float) value of the column.
|
||||
double getDouble(void) const throw();
|
||||
double getDouble(void) const throw(); // nothrow
|
||||
/// Return a pointer to the text value (NULL terminated string) of the column.
|
||||
/// 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 throw();
|
||||
// TODO const void* getBlob (void) const throw();
|
||||
const char* getText (void) const throw(); // nothrow
|
||||
const void* getBlob (void) const throw(); // nothrow
|
||||
|
||||
/**
|
||||
* @brief Return the type of the value of the column
|
||||
*
|
||||
* Return either SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL.
|
||||
*
|
||||
* @warning After a type conversion (by a call to a getXxx on a Column of a Yyy type),
|
||||
* the value returned by sqlite3_column_type() is undefined.
|
||||
*/
|
||||
int getType(void) const throw(); // nothrow
|
||||
|
||||
/// Test if the column is an integer type value (meaningfull only before any conversion)
|
||||
inline bool isInteger(void) const throw() // nothrow
|
||||
{
|
||||
return (SQLITE_INTEGER == getType());
|
||||
}
|
||||
/// Test if the column is a floting point type value (meaningfull only before any conversion)
|
||||
inline bool isFloat(void) const throw() // nothrow
|
||||
{
|
||||
return (SQLITE_FLOAT == getType());
|
||||
}
|
||||
/// Test if the column is a text type value (meaningfull only before any conversion)
|
||||
inline bool isText(void) const throw() // nothrow
|
||||
{
|
||||
return (SQLITE_TEXT == getType());
|
||||
}
|
||||
/// Test if the column is a binary blob type value (meaningfull only before any conversion)
|
||||
inline bool isBlob(void) const throw() // nothrow
|
||||
{
|
||||
return (SQLITE_BLOB == getType());
|
||||
}
|
||||
/// Test if the column is NULL (meaningfull only before any conversion)
|
||||
inline bool isNull(void) const throw() // nothrow
|
||||
{
|
||||
return (SQLITE_NULL == getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the number of bytes used by the text value of the column
|
||||
@ -84,6 +120,11 @@ public:
|
||||
{
|
||||
return getText();
|
||||
}
|
||||
/// Inline cast operator to void*
|
||||
inline operator const void*() const
|
||||
{
|
||||
return getBlob();
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
// NOTE : the following is required by GCC to cast a Column result in a std::string
|
||||
// (error: conversion from ‘SQLite::Column’ to non-scalar type ‘std::string {aka std::basic_string<char>}’ requested)
|
||||
|
Loading…
x
Reference in New Issue
Block a user