Loading...
Searching...
No Matches
command.hpp
Go to the documentation of this file.
/*##############################################################################
VSQLite++ - virtuosic bytes SQLite3 C++ wrapper
Copyright (c) 2006-2014 Vinzenz Feenstra vinzenz.feenstra@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of virtuosic bytes nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
##############################################################################*/
#ifndef GUARD_SQLITE_COMMAND_HPP_INCLUDED
#define GUARD_SQLITE_COMMAND_HPP_INCLUDED
#include <boost/cstdint.hpp>
#include <boost/noncopyable.hpp>
#include <sqlite/connection.hpp>
#include <vector>
struct sqlite3_stmt;
namespace sqlite{
struct null_type{};
extern null_type nil;
struct command : boost::noncopyable{
command(connection & con, std::string const & sql);
virtual ~command();
void clear();
bool emit();
bool operator()();
void bind(int idx);
void bind(int idx, int v);
void bind(int idx, boost::int64_t v);
void bind(int idx, double v);
void bind(int idx, std::string const & v);
void bind(int idx, void const * buf, size_t buf_size);
void bind(int idx, std::vector<unsigned char> const & v);
command & operator % (null_type const & p);
command & operator % (int p);
command & operator % (boost::int64_t p);
command & operator % (double p);
command & operator % (std::string const & p);
command & operator % (std::vector<unsigned char> const & p);
protected:
void access_check();
bool step();
struct sqlite3 * get_handle();
private:
void prepare();
void finalize();
private:
connection & m_con;
std::string m_sql;
protected:
sqlite3_stmt * stmt;
private:
int last_arg_idx;
};
}
#endif //GUARD_SQLITE_COMMAND_HPP_INCLUDED
connection.hpp
sqlite
Definition command.hpp:42
sqlite::nil
null_type nil
nil is used instead of NULL within the operator % syntax in this wrapper
sqlite::command::prepare
void prepare()
sqlite::command::bind
void bind(int idx, void const *buf, size_t buf_size)
binds the binary/blob buf to the given 1 based index
sqlite::command::bind
void bind(int idx)
binds NULL to the given 1 based index
sqlite::command::finalize
void finalize()
sqlite::command::m_con
connection & m_con
Definition command.hpp:184
sqlite::command::bind
void bind(int idx, double v)
binds the double v to the given 1 based index
sqlite::command::access_check
void access_check()
sqlite::command::last_arg_idx
int last_arg_idx
Definition command.hpp:189
sqlite::command::emit
bool emit()
emit executes the sql command If you have used placeholders you must have replaced all placeholders
sqlite::command::step
bool step()
sqlite::command::m_sql
std::string m_sql
Definition command.hpp:185
sqlite::command::bind
void bind(int idx, boost::int64_t v)
binds the 64-Bit integer v to the given 1 based index
sqlite::command::bind
void bind(int idx, int v)
binds the 32-Bit integer v to the given 1 based index
sqlite::command::~command
virtual ~command()
command destructor
sqlite::command::bind
void bind(int idx, std::vector< unsigned char > const &v)
binds the binary/blob v to the given 1 based index
sqlite::command::clear
void clear()
clear is used if you'd like to reuse a command object
sqlite::command::command
command(connection &con, std::string const &sql)
command constructor
sqlite::command::stmt
sqlite3_stmt * stmt
Definition command.hpp:187
sqlite::command::get_handle
struct sqlite3 * get_handle()
sqlite::command::operator%
command & operator%(null_type const &p)
replacement for void command::bind(int idx); To use this operator% you have to use the global object ...
sqlite::command::bind
void bind(int idx, std::string const &v)
binds the text/string v to the given 1 based index
sqlite::command::operator()
bool operator()()
works exactly like the method command::emit
sqlite::connection
connection is used to open, close, attach and detach a database. Further it has to be passed to all c...
Definition connection.hpp:45
sqlite::null_type
null_type is an empty type used to represent NULL values
Definition command.hpp:46