Source: xql/xqlodbc.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          xqlOdbc.h  -  description
                             -------------------
    begin                : Mon Jun 26 2000
    copyright            : (C) 2000 by Raoul Markus
    email                : raoul.markus@arcormail.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef _xqlOdbc_h
#define _xqlOdbc_h
 
#include
#include 
#include
//#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "xqltypes.h"
#include "xqlexception.h"
#include 

typedef std::list intList;
typedef std::list::iterator intListIterator;


//#include "xqlObject.h"

/** 
 * ODBC-Driver wrapper. Provides simple execution of queries 
 * rollback and commit statements etc.
 */
class xqlOdbc 
{
  public:
  /**
   * standard constructor. specific things are done by member functions.
   */
  xqlOdbc();
  virtual ~xqlOdbc();
  /**
   * sets the password for the ODBC-Connection
   */
  void setPasswd(const char* passwd);
  /**
   * sets the ODBC-Sourcename for the ODBC-Connection
   */
  void setSource(const char* source);
  /**
   * sets the Username for the ODBC-Connection
   */
  void setUser(const char* user);
  /**
   * executes an update statement. Returns what?
   */
  int execUpdateStmt(std::string pSqlText) const;
  /**
   * gets the maximum id from xqlobject. This function is obsolete.
   */
  int getMaxId() const;
  /**
   * gets a  new id for xqlobject. 
   */
  int getNewId(const char * pTableName) const;
  /**  
   * This function is obsolete. 
   * and should be replaced by getInteger()
   */
  int getCount(char * table, int pId) const;
  /**
   * gets an integer value from a query. If the query returns several values, 
   * only the first one is given back. 
   */
  int getInteger(std::string pSqlText) const;
  /**
   * gets an boolean value from a query. If the query returns several values, 
   * only the first one is given back. 
   */
  bool getBool(char * pSqlText) const;
  /**
   * gets an string value from a query. If the query returns several values, 
   * only the first one is given back. 
   */
  void getString(char * pSqlText, char * pResultString);
  /**
   * opens a connection
   */
  bool getConnection();
  /**
   * close a connection
   */
  void closeConnection();
  /** 
   * starts a transaction;
   */
  void startTransaction() const;
  /**
   * commits a pending transaction
   */
  void commit() const;
  /**
   * rolls back a pending transaction
   */
  void rollback() const;
  /** creates a new unique instance id */
  int getNewInstId();
  /** gets a new TypeId */
  int getNewTypeId();
  /** returns a pointer to the source string */
  char * getSource() const;
  /** returns a pointer to the passwd string */
  char * getPasswd() const;
  /** returns a pointer to the user string */
  char * getUser() const;
  /** initiates the database schema for XQL. Creates the necessary tables.
create the root account which will manage everything else (normally "admin"). 
This function may only be called once. If once called, it will fail on all other calls. 
If the database scema is corrupt, then use repairXQLScheme. Of course, this is not 
possible without data loss. */
  void initXQLScheme();
  /** drops the whole XQL database tables. all data are lost. used to roughly recreate 
damaged database */
  void dropXQLScheme();
  /** returns a list of integers, mostly ids of some object types or instances. */
  intList * getIntegerList(std::string pSql);
  /** saves or creates a stream object in the database.  */
  void storeBinObj(const long id, const char * pData, const long pSize) const;
  /** get binary data from the database for id. raises an xqlException if no data were found 
for the given id. returns the pointer to the binary data pData, and the size (pSize) */
  void getBinObj(const long id, char ** pData, long * pSize) const;;
  /** returns a new, unique fileid */
  long getNewFileId();
  /** 
gets an string value from a query. If the query returns several values, 
only the first one is given back. 
 */
  std::string getString(const std::string pSqlText);
  /** returns a string in pValue and its length in pLength */
//Del by KDevelop:
  
  private:
  char *mUser,*mPasswd, *mSource;
  char mUserBuff[20], mPasswdBuff[20], mSourceBuff[20];
  long                     tReturn;     // result of functions
  char                     mODBCStatus[10]; // Status SQL
  char             mODBCmsg[200],mODBCbuffer[200];
  odbc::Connection* 		mConn;
};
#endif

Generated by: markus on hobbes on Fri Mar 29 16:15:24 2002, using kdoc 2.0a53.