api   api 
/* /*
* OpenDBX - A simple but extensible database abstraction layer * OpenDBX - A simple but extensible database abstraction layer
* Copyright (C) 2004-2007 Norbert Sendetzky <norbert@linuxnetworks.de> * Copyright (C) 2004-2008 Norbert Sendetzky <norbert@linuxnetworks.de>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
skipping to change at line 48 skipping to change at line 48
namespace OpenDBX namespace OpenDBX
{ {
using std::string; using std::string;
class Lob; class Lob;
class Result; class Result;
class Stmt; class Stmt;
class Conn; class Conn;
/**
* Exception thrown by OpenDBX objects
*/
class Exception : public std::runtime_error class Exception : public std::runtime_error
{ {
protected: protected:
/**
* Error code (negative)
*/
int m_error; int m_error;
int m_severity;
/**
* Severity of error (negative: fatal, zero: success, positi
ve: warning)
*/
int m_type;
public: public:
Exception( string msg, int err, int severity ); /**
int getErrorCode(); * Initializes exception object
int getSeverity(); *
* @param string Error message
* @param int Severity of error (negative: fatal, zero: succ
ess, positive: warning)
* @return Exception
*/
Exception( string msg, int err, int type );
/**
* Returns code related to the error
*
* @return Error code
*/
int getCode();
/**
* Returns severity indicator
*
* @return Severity of error (negative: fatal, zero: success
, positive: warning)
*/
int getType();
}; };
/**
* Handling large objects if supported by the database
*/
class Lob class Lob
{ {
protected: protected:
/**
* Private implementation of object
*/
Lob_Impl* m_impl; Lob_Impl* m_impl;
/**
* Reference counter of copies
*/
int* m_ref; int* m_ref;
/**
* Default constructor
*
* @return Lob instance
*/
Lob(); Lob();
/**
* Create large object instance
*
* @param Lob_Impl* Pointer to private implementation
* @return Lob instance
*/
Lob( Lob_Impl* impl ); Lob( Lob_Impl* impl );
friend class Result; friend class Result;
public: public:
/**
* Destroy large object instance if no other references exis
t
*/
~Lob(); ~Lob();
/**
* Assign large object instance to another one
*
* @param const Lob& Large object instance
* @return Large object reference of this instance
*/
Lob& operator=( const Lob& ref ); Lob& operator=( const Lob& ref );
/**
* Close Lob and commit changes
*/
void close();
/**
* Reads content from large object into the buffer
*
* @param void* Pointer to a byte array where the data shoul
d be written to
* @param size_t Length of the given buffer in bytes
* @return Number of bytes written into the buffer
*/
ssize_t read( void* buffer, size_t buflen ); ssize_t read( void* buffer, size_t buflen );
/**
* Writes data from the buffer into the large object
*
* @param void* Pointer to a byte array where the content is
stored
* @param size_t Length of the data in the buffer in bytes
* @return Number of bytes written into the large object
*/
ssize_t write( void* buffer, size_t buflen ); ssize_t write( void* buffer, size_t buflen );
}; };
class Result class Result
{ {
protected: protected:
/**
* Private implementation of object
*/
Result_Impl* m_impl; Result_Impl* m_impl;
/**
* Reference counter of copies
*/
int* m_ref; int* m_ref;
/**
* Default constructor
*
* @return Result instance
*/
Result(); Result();
/**
* Create Result instance
*
* @param Result_Impl* Pointer to private implementation
* @return Result instance
*/
Result( Result_Impl* impl ); Result( Result_Impl* impl );
friend class Stmt; friend class Stmt;
public: public:
/**
* Destroy Result instance if no other references exist
*/
~Result(); ~Result();
/**
* Assign Result instance to another one
*
* @param const Result& Result instance
* @return Result reference of this instance
*/
Result& operator=( const Result& ref ); Result& operator=( const Result& ref );
/**
* Get unfetched rows and clean up the current result set
*/
void finish();
/**
* Fetch one result set from the database server
*
* @param struct timeval* Pointer to a timeval struct specif
ying how long to wait for a result set from the database server
* @param unsigned long Number of rows to fetch at once from
the database server (zero means all rows at once)
* @return Status or error code
*/
odbxres getResult( struct timeval* timeout = NULL, unsigned long chunk = 0 ); odbxres getResult( struct timeval* timeout = NULL, unsigned long chunk = 0 );
/**
* Makes data of next row available
*
* @return Status or error code
*/
odbxrow getRow(); odbxrow getRow();
/**
* Returns the number of rows affected by DELETE, INSERT of
UPDATE statements
*
* @return Number of rows touched
*/
uint64_t rowsAffected(); uint64_t rowsAffected();
/**
* Returns the number of columns available in this result se
t
*
* @return Number of columns
*/
unsigned long columnCount(); unsigned long columnCount();
/**
* Maps the column name to the column number required by oth
er methods
*
* @return Position of column in result set
*/
unsigned long columnPos( const string& name ); unsigned long columnPos( const string& name );
/**
* Returns the name of the column in the current result set
*
* @param unsigned long Position of column in result set
* @return Column name
*/
string columnName( unsigned long pos ); string columnName( unsigned long pos );
/**
* Returns the type of the column in the current result set
*
* @param unsigned long Position of column in result set
* @return Column type
*/
odbxtype columnType( unsigned long pos ); odbxtype columnType( unsigned long pos );
/**
* Returns the size of the content in the current row at the
specified postion
*
* @param unsigned long Position of column in result set
* @return Size of the data in bytes
*/
unsigned long fieldLength( unsigned long pos ); unsigned long fieldLength( unsigned long pos );
/**
* Returns a pointer to the content in the current row at th
e specified postion
*
* @param unsigned long Position of column in result set
* @return Pointer to the data
*/
const char* fieldValue( unsigned long pos ); const char* fieldValue( unsigned long pos );
/**
* Create a large object instance if supported by the databa
se
*
* @param const char* Pointer to the content of a field retu
rned by fieldValue()
* @return Large object instance
*/
Lob getLob( const char* value ); Lob getLob( const char* value );
}; };
class Stmt class Stmt
{ {
protected: protected:
int* m_ref; /**
* Private implementation of object
*/
Stmt_Impl* m_impl; Stmt_Impl* m_impl;
/**
* Reference counter of copies
*/
int* m_ref;
/**
* Default constructor
*
* @return Statement instance
*/
Stmt(); Stmt();
/**
* Create statement instance
*
* @param Stmt_Impl* Pointer to private implementation
* @return Statement instance
*/
Stmt( Stmt_Impl* impl ); Stmt( Stmt_Impl* impl );
friend class Conn; friend class Conn;
public: public:
/**
* Statement objects which can be created
*/
enum Type { Simple }; enum Type { Simple };
/**
* Destroy statement instance if no other references exist
*/
~Stmt(); ~Stmt();
/**
* Assign statement instance to another one
*
* @param const Stmt& Stmt instance
* @return Statement reference of this instance
*/
Stmt& operator=( const Stmt& ref ); Stmt& operator=( const Stmt& ref );
/**
* Execute statement and return Result instance
*
* @return Result instance
*/
Result execute(); Result execute();
}; };
class Conn class Conn
{ {
protected: protected:
/**
* Private implementation of object
*/
Conn_Impl* m_impl; Conn_Impl* m_impl;
/**
* Reference counter of copies
*/
int* m_ref; int* m_ref;
public: public:
/**
* Default constructor
*
* @return Connection instance
*/
Conn(); Conn();
Conn( const char* backend, const char* host, const char* por
t ); /**
Conn( const string& backend, const string& host, const strin * Build connection object using C string parameters
g& port ); *
* @param const char* Name of the backend module to use
* @param const char* Name or IP address of the database ser
ver
* @param const char* Name or number of the port used by the
database server
* @return Connection instance
*/
Conn( const char* backend, const char* host = "", const char
* port = "" );
/**
* Build connection object using C++ string parameters
*
* @param string Name of the backend module to use
* @param string Name or IP address of the database server
* @param string Name or number of the port used by the data
base server
* @return Connection instance
*/
Conn( const string& backend, const string& host = "", const
string& port = "" );
/**
* Destroy connection instance if no other references exist
*/
~Conn(); ~Conn();
/**
* Assign connection instance to another one
*
* @param const Conn& Connection instance
* @return Connection reference of this instance
*/
Conn& operator=( const Conn& ref ); Conn& operator=( const Conn& ref );
void bind( const char* database, const char* who, const char /**
* cred, odbxbind method = ODBX_BIND_SIMPLE ); * Log into database server and select database using C stri
void bind( const string& database, const string& who, const ng parameters
string& cred, odbxbind method = ODBX_BIND_SIMPLE ); *
* @param const char* Name of the database managed by the da
tabase server
* @param const char* Name of the user account known by the
database server
* @param const char* Necessary credential which belongs to
the user account
* @param odbxbind Method used for authentication
*/
void bind( const char* database, const char* who = "", const
char* cred = "", odbxbind method = ODBX_BIND_SIMPLE );
/**
* Log into database server and select database using C++ st
ring parameters
*
* @param const char* Name of the database managed by the da
tabase server
* @param const char* Name of the user account known by the
database server
* @param const char* Necessary credential which belongs to
the user account
* @param odbxbind Method used for authentication
*/
void bind( const string& database, const string& who = "", c
onst string& cred = "", odbxbind method = ODBX_BIND_SIMPLE );
/**
* Close connection to the database server
*/
void unbind(); void unbind();
/**
* Clean up connection object
*/
void finish();
/**
* Test if the database driver module does understand certai
n extensions
*
* @param odbxcap Constant of the capability
* @return True if supported, false if not
*/
bool getCapability( odbxcap cap ); bool getCapability( odbxcap cap );
/**
* Get the value of certain options provided by the database
driver module
*
* @param odbxcap Constant of the option
* @param void* Pointer to memory where the result is stored
*/
void getOption( odbxopt option, void* value ); void getOption( odbxopt option, void* value );
/**
* Set certain options provided by the database driver modul
e
*
* @param odbxcap Constant of the option
* @param void* Pointer to memory which contains the new val
ue
*/
void setOption( odbxopt option, void* value ); void setOption( odbxopt option, void* value );
/**
* Escape potentially dangerous characters in user input usi
ng a C++ string parameter
*
* @param const string& Input string with which may contain
dangerous characters
* @param string& String instance where the escaped characte
rs should be written to
* @return Reference to the second parameter containing the
escaped characters
*/
string& escape( const string& from, string& to ); string& escape( const string& from, string& to );
/**
* Escape potentially dangerous characters in user input usi
ng a C style buffer
*
* @param const char* Input string with which may contain da
ngerous characters
* @param unsigned long Size of the input string to escape i
n bytes
* @param string& String instance where the escaped characte
rs should be written to
* @return Reference to the second parameter containing the
escaped characters
*/
string& escape( const char* from, unsigned long fromlen, str ing& to ); string& escape( const char* from, unsigned long fromlen, str ing& to );
Stmt create( Stmt::Type type, const char* sql, unsigned long /**
size ); * Create statement object from SQL text string using a C st
Stmt create( Stmt::Type type, const string& sql ); yle buffer
*
* @param const char* SQL text string containing a valid sta
tement understood by the database server
* @param unsigned long Size of the SQL text string in bytes
* @param Stmt::Type Type of statements object that should b
e created
* @return Statement instance
*/
Stmt create( const char* sql, unsigned long size = 0, Stmt::
Type type = Stmt::Simple );
/**
* Create statement object from SQL text string using a C++
string
*
* @param string SQL text string containing a valid statemen
t understood by the database server
* @param Stmt::Type Type of statements object that should b
e created
* @return Statement instance
*/
Stmt create( const string& sql, Stmt::Type type = Stmt::Simp
le );
}; };
} // namespace OpenDBX } // namespace OpenDBX
} // extern C++ } // extern C++
#endif #endif
 End of changes. 49 change blocks. 
17 lines changed or deleted 393 lines changed or added


 api.h   api.h 
/* /*
* OpenDBX - A simple but extensible database abstraction layer * OpenDBX - A simple but extensible database abstraction layer
* Copyright (C) 2004-2007 Norbert Sendetzky <norbert@linuxnetworks.de> * Copyright (C) 2004-2008 Norbert Sendetzky <norbert@linuxnetworks.de>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/