//  // //  #### # # # -= SQLiteX =-  // // # # ## ## Query.h  // //  ## # ###  // //  ## # ### An SQL query consisting of one or more statements  // //  # # ## ##  // // #### ##### # # R1 (C)2005 Markus Ewald -> License.txt  // //  // #ifndef SQLITEX_QUERY_H #define SQLITEX_QUERY_H #include "SQLiteX/SQLiteX.h" #include "SQLiteX/Variant.h" #include #include #include namespace SQLiteX { class Database; class Transaction; //  // //  SQLiteX::Query  // //  // /// SQL query /** One or more SQL statements which form a query. Instances of this class will collect the results of a query, if any, and enable the user to bind variables in order to circumvent SQL injection attacks */ class Query { friend Database; friend Transaction; public: typedef std::list > ResultType; /// Constructor SQLITEX_API Query(const std::string &sStatements = std::string()); /// Destructor SQLITEX_API ~Query(); // // Query implementation // public: /// Add statements to action SQLITEX_API void add(const std::string &sStatements); /// Bind variable SQLITEX_API void bind(size_t Index, const Variant &Value) { m_BoundVariables.resize(std::max(Index + 1, m_BoundVariables.size())); m_BoundVariables[Index] = Value; } /// Get query results SQLITEX_API const ResultType &getResults() const { return m_Results; } protected: /// Execute the query SQLITEX_API void execute(const SharedSQLite3 &SQLiteDB); private: /// A deque of variable typedef std::deque VariantDeque; /// Bind variables to specified statement void bindVariables(sqlite3 *pSQLiteDB, sqlite3_stmt *pStatement); /// All bound variables of this query VariantDeque m_BoundVariables; /// SQL statements to be executed in a query std::string m_SQLStatements; /// Results of the executed query ResultType m_Results; }; } // namespace SQLiteX #endif // SQLITEX_QUERY_H