diff -r 000000000000 -r 2b3e5ec03512 servlib/storage/PostgresSQLImplementation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servlib/storage/PostgresSQLImplementation.h Thu Apr 21 14:57:45 2011 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright 2004-2006 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _POSTGRES_SQL_IMPLEMENTATION_H_ +#define _POSTGRES_SQL_IMPLEMENTATION_H_ + +#include +#include +#include + +namespace dtn { + +/** + * Postgres based implementation of SQL database. + */ +class PostgresSQLImplementation : public oasys::SQLImplementation, public oasys::Logger { +public: + PostgresSQLImplementation(); + + ///@{ + /// Virtual functions inherited from SQLImplementation + int connect(const char* dbname); + int close(); + bool has_table(const char* tablename); + int exec_query(const char* query); + int num_tuples(); + const char* get_value(int tuple_no, int field_no); +// size_t get_value_length(int tuple_no, int field_no); + + + const char* escape_string(const char* from); + const u_char* escape_binary(const u_char* from, int from_length); + const u_char* unescape_binary(const u_char* from); + + ///@} + +private: + PGconn* db_; ///< the db connection + PGresult* query_result_; /// result of the last query performed +}; +} // namespace dtn + +#endif /* _POSTGRES_SQL_IMPLEMENTATION_H_ */