servlib/storage/MysqlSQLImplementation.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2004-2006 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _MYSQL_SQL_IMPLEMENTATION_H_
       
    18 #define _MYSQL_SQL_IMPLEMENTATION_H_
       
    19 
       
    20 #include <mysql.h>
       
    21 #include <oasys/debug/Log.h>
       
    22 #include <oasys/serialize/SQLImplementation.h>
       
    23 
       
    24 namespace dtn {
       
    25 
       
    26 /**
       
    27  * Mysql based implementation of SQL database.
       
    28  */
       
    29 class MysqlSQLImplementation : public oasys::SQLImplementation, public oasys::Logger {
       
    30 public:
       
    31     MysqlSQLImplementation();
       
    32 
       
    33     ///@{
       
    34     /// Virtual functions inherited from SQLImplementation
       
    35     int connect(const char* dbname);
       
    36     int close();
       
    37     bool has_table(const char* tablename);
       
    38     int exec_query(const char* query);
       
    39     int num_tuples();
       
    40     const char* get_value(int tuple_no, int field_no);
       
    41     //   size_t get_value_length(int tuple_no, int field_no);
       
    42     
       
    43     const char* binary_datatype();
       
    44     const char* escape_string(const char* from);
       
    45     const u_char* escape_binary(const u_char* from, int from_length);
       
    46     const u_char* unescape_binary(const u_char* from);
       
    47   
       
    48     ///@}
       
    49 
       
    50 
       
    51 private:
       
    52     MYSQL* db_;  		///< the db connection
       
    53     MYSQL_RES* query_result_;	/// result of the last query performed
       
    54 };
       
    55 } // namespace dtn
       
    56 
       
    57 #endif /* _MYSQL_SQL_IMPLEMENTATION_H_ */