Initial
This commit is contained in:
106
sql/SQLDB.HPP
Normal file
106
sql/SQLDB.HPP
Normal file
@@ -0,0 +1,106 @@
|
||||
#ifndef _SQL_SQLDB_HPP_
|
||||
#define _SQL_SQLDB_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_HDBC_HPP_
|
||||
#include <sql/hdbc.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_HENV_HPP_
|
||||
#include <sql/henv.hpp>
|
||||
#endif
|
||||
|
||||
class SQLDb
|
||||
{
|
||||
public:
|
||||
enum TransactType{TransactCommit=SQL_COMMIT,TransactRollback=SQL_ROLLBACK};
|
||||
SQLDb(void);
|
||||
SQLDb(const String &nameData,const String &userID,const String &password);
|
||||
SQLDb(HENV hEnvironment,HDBC hConnection);
|
||||
SQLDb(const SQLDb &someSQLDb);
|
||||
virtual ~SQLDb();
|
||||
SQLDb &operator=(const SQLDb &someSQLDb);
|
||||
operator HandleDatabase(void)const;
|
||||
operator HandleEnvironment(void)const;
|
||||
WORD open(const String &nameData,const String &userID,const String &password);
|
||||
WORD transact(TransactType transactType);
|
||||
WORD close(void);
|
||||
WORD isOkay(void)const;
|
||||
WORD isAssigned(void)const;
|
||||
String nameData(void)const;
|
||||
String userID(void)const;
|
||||
String password(void)const;
|
||||
private:
|
||||
enum Disposition{AssumeDB,CloseDB,InvalidDB};
|
||||
WORD open(void);
|
||||
Disposition mDisposition;
|
||||
HandleEnvironment mhEnvironment;
|
||||
HandleDatabase mhConnection;
|
||||
WORD mIsOkay;
|
||||
String mNameData;
|
||||
String mUserID;
|
||||
String mPassword;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(void)
|
||||
: mDisposition(InvalidDB), mhEnvironment(0), mhConnection(0), mIsOkay(FALSE),
|
||||
mNameData("UNSET"), mUserID("UNSET"), mPassword("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(HENV hEnvironment,HDBC hConnection)
|
||||
: mhEnvironment(hEnvironment), mhConnection(hConnection), mDisposition(AssumeDB),
|
||||
mIsOkay(TRUE), mNameData("UNSET"), mUserID("UNSET"), mPassword("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(const SQLDb &someSQLDb)
|
||||
{
|
||||
*this=someSQLDb;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::operator HandleDatabase(void)const
|
||||
{
|
||||
return mhConnection;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::operator HandleEnvironment(void)const
|
||||
{
|
||||
return mhEnvironment;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLDb::isAssigned(void)const
|
||||
{
|
||||
return (AssumeDB==mDisposition);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLDb::isOkay(void)const
|
||||
{
|
||||
return mIsOkay;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::nameData(void)const
|
||||
{
|
||||
return mNameData;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::userID(void)const
|
||||
{
|
||||
return mUserID;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::password(void)const
|
||||
{
|
||||
return mPassword;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user