-#endif
-
-namespace odbc {
-
- class Rowset;
-
- /** A prepared statement.
- *
- * A prepared statement is precompiled by the driver and/or datasource,
- * and can be executed multiple times with different parameters.
- *
- * Parameters are set using the setXXX methods. Note that it's advisable
- * to use the set method compatible with the parameter's SQL type - for
- * example, for a Types::DATE
, setDate()
should
- * be used.
- * Question marks ("?"
) are used in the SQL statement
- * to represent a parameter, for example:
- *
- * std::auto_ptr<PreparedStatement> pstmt
- * =std::auto_ptr<PreparedStatement>(con->prepareStatement
- * ("INSERT INTO SOMETABLE(AN_INTEGER_COL,A_VARCHAR_COL) VALUES(?,?)"));
- * pstmt->setInt(1,10);
- * pstmt->setString(2,"Hello, world!");
- * int affectedRows=pstmt->executeUpdate();
- *
- * @see Connection::prepareStatement()
- */
-
- class ODBCXX_EXPORT PreparedStatement : public Statement {
- friend class Connection;
-
- private:
- void _prepare();
- void _setupParams();
-
- protected:
- ODBCXX_STRING sql_;
- //here we store the parameters
- Rowset* rowset_;
- size_t numParams_;
- std::vector directions_;
- int defaultDirection_;
- bool paramsBound_;
-
- PreparedStatement(Connection* con,
- SQLHSTMT hstmt,
- const ODBCXX_STRING& sql,
- int resultSetType,
- int resultSetConcurrency,
- int defaultDirection =SQL_PARAM_INPUT);
-
- void _bindParams();
- void _unbindParams();
-
- void _checkParam(int idx,
- int* allowed, int numAllowed,
- int defPrec, int defScale);
-
- public:
- /** Destructor */
- virtual ~PreparedStatement();
-
- /** Clears the parameters.
- *
- * The set of parameters stays around until they are set again.
- * To explicitly clear them (and thus release buffers held by the
- * driver), this method should be called.
- */
- void clearParameters();
-
- /** Executes this statement.
- * @return True if the result is a ResultSet, false if it's an
- * update count or unknown.
- */
- bool execute();
-
- /** Executes this statement, assuming it returns a ResultSet.
- *
- * Example:
- * std::auto_ptr<ResultSet> rs =
- * std::auto_ptr<ResultSet>(pstmt->executeQuery(s));
- *
- */
- ResultSet* executeQuery();
-
- /** Executes this statement, assuming it returns an update count */
- int executeUpdate();
-
- /** Sets a parameter value to a double
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setDouble(int idx, double val);
-
- /** Sets a parameter value to a bool
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setBoolean(int idx, bool val);
-
- /** Sets a parameter value to signed char
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setByte(int idx, signed char val);
-
-
- /** Sets a parameter value to a chunk of bytes
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setBytes(int idx, const ODBCXX_BYTES& val);
-
- /** Sets a parameter value to a Date
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setDate(int idx, const Date& val);
-
- /** Sets a parameter value to a float
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setFloat(int idx, float val);
-
-
- /** Sets a parameter value to an int
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setInt(int idx, int val);
-
- /** Sets a parameter value to a Long
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setLong(int idx, Long val);
-
- /** Sets a parameter value to a short
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setShort(int idx, short val);
-
- /** Sets a parameter value to a string
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setString(int idx, const ODBCXX_STRING& val);
-
- /** Sets a parameter value to a Time
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setTime(int idx, const Time& val);
-
- /** Sets a parameter value to a Timestamp
- * @param idx The parameter index, starting at 1
- * @param val The value to set
- */
- void setTimestamp(int idx, const Timestamp& val);
-
- /** Sets a parameter value to an ascii stream.
- * @param idx The parameter index, starting at 1
- * @param s The stream to assign
- * @param len The number of bytes available in the stream
- */
- void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);
-
- /** Sets a parameter value to a binary stream.
- * @param idx The parameter index, starting at 1
- * @param s The stream to assign
- * @param len The number of bytes available in the stream
- */
- void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);
-
-
- /** Sets a parameter value to NULL
- * @param idx The parameter index, starting at 1
- * @param sqlType The SQL type of the parameter
- * @see Types
- */
- void setNull(int idx, int sqlType);
- };
-
-
-} // namespace odbc
-
-#endif // __ODBCXX_PREPAREDSTATEMENT_H
diff --git a/source/odbc++/resultset.h b/source/odbc++/resultset.h
deleted file mode 100644
index 38174e092..000000000
--- a/source/odbc++/resultset.h
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_RESULTSET_H
-#define __ODBCXX_RESULTSET_H
-
-#include
-#include
-#include
-#include
-
-
-namespace odbc {
-
- class ResultSetMetaData;
- class Statement;
- class Rowset;
-
- /** A result set */
- class ODBCXX_EXPORT ResultSet : public ErrorHandler {
- friend class Statement;
- friend class ResultSetMetaData;
-
- private:
- Statement* statement_;
- SQLHSTMT hstmt_;
- bool ownStatement_;
-
-
- int currentFetchSize_;
- int newFetchSize_;
-
- Rowset* rowset_;
- SQLUSMALLINT* rowStatus_;
- SQLUINTEGER rowsInRowset_;
-
- //tells us if the columns are bound right now
- bool colsBound_;
- bool streamedColsBound_;
-
- //the position in the rowset last time we did a bind
- unsigned int bindPos_;
-
- //meta data - it's always there since we need info from it
- ResultSetMetaData* metaData_;
-
- int location_;
-
- bool lastWasNull_;
-
- int rowBeforeInsert_;
- int locBeforeInsert_;
-
- ResultSet(Statement* stmt,SQLHSTMT hstmt, bool ownStmt);
-
- //driver info
- const DriverInfo* _getDriverInfo() const {
- return statement_->_getDriverInfo();
- }
-
- //private utils
- void _applyFetchSize();
- //this makes sure there is a rowset
- void _resetRowset();
-
- //this should be called before any call to SQLExtendedFetch
- void _prepareForFetch();
- //this performs a possibly scrolled fetch with fetchType to rownum
- void _doFetch(int fetchType, int rowNum);
-
- //this should be called after the position in the rowset changes
- SQLRETURN _applyPosition(int mode =SQL_POSITION);
-
- //these bind/unbind all non-streamed columns
- void _bindCols();
- void _unbindCols();
-
- //these bind/unbind all streamed columns
- void _bindStreamedCols();
- void _unbindStreamedCols();
-
- //this sends all needed data from streamed columns
- //to be called from insertRow and updateRow
- void _handleStreams(SQLRETURN r);
-
-
- public:
- /** Destructor */
- virtual ~ResultSet();
-
- //remember to update DatabaseMetaData when changing those values
-
- /** ResultSet concurrency constants.
- */
- enum {
- /** The ResultSet is read only */
- CONCUR_READ_ONLY,
- /** The ResultSet is updatable */
- CONCUR_UPDATABLE
- };
-
-
- /** ResultSet type constants
- */
- enum {
- /** The result set only goes forward. */
- TYPE_FORWARD_ONLY,
- /** The result set is scrollable, but the data in it is not
- * affected by changes in the database.
- */
- TYPE_SCROLL_INSENSITIVE,
- /** The result set is scrollable and sensitive to database changes */
- TYPE_SCROLL_SENSITIVE
- };
-
- /** Moves the cursor to a specific row in this result set.
- * If row is negative, the actual row number is calculated from the
- * end of the result set. Calling absolute(0)
is
- * equivalent to calling beforeFirst()
- * @return true if the cursor is in the result set
- */
- bool absolute(int row);
-
- /** Moves the cursor inside the result set relative to the current row.
- * Negative values are allowed. This call is illegal if there is no
- * current row.
- * @return true if the cursor is in the result set
- */
- bool relative(int rows);
-
- /** Places the cursor after the last row in the result set */
- void afterLast();
-
- /** Places the cursor before the first row in the result set */
- void beforeFirst();
-
- /** Checks if the cursor is after the last row in the result set */
- bool isAfterLast();
-
- /** Checks if the cursor is before the first row in the result set */
- bool isBeforeFirst();
-
- /** Checks if the cursor is on the first row in the result set */
- bool isFirst();
-
- /** Checks if the cursor is on the last row in the result set.
- */
- bool isLast();
-
- /** Returns the current row number.
- * @return The current row number in the result set, or 0
- * if it can't be determined.
- */
- int getRow();
-
- /** Moves to the next row in the result set
- * @return true if the cursor is in the result set
- */
- bool next();
-
- /** Moves to the previous row in the result set
- * @return true if the cursor is in the result set
- */
- bool previous();
-
- /** Moves to the first row in the result set
- * @return true if the cursor is in the result set
- */
- bool first();
-
- /** Moves to the last row in the result set
- * @return true if the cursor is in the result set
- */
- bool last();
-
- /** Moves the cursor to the 'insert row' of this result set.
- * @warning The only valid methods while on the insert row
- * are updateXXX(), insertRow() and moveToCurrentRow().
- * @see moveToCurrentRow()
- */
- void moveToInsertRow();
-
- /** Moves the cursor back to where it was before it was moved
- * to the insert row
- */
- void moveToCurrentRow();
-
- /** Refreshes the current row */
- void refreshRow();
-
- /** Deletes the current row */
- void deleteRow();
-
- /** Inserts the current row.
- * Only valid while on the insert row.
- * @see moveToInsertRow()
- */
- void insertRow();
-
- /** Updates the current row. */
- void updateRow();
-
- /** Cancels any updates done to the current row */
- void cancelRowUpdates();
-
- /** Returns meta data about this result set
- * @see ResultSetMetaData
- */
- ResultSetMetaData* getMetaData() {
- return metaData_;
- }
-
- /** Find a column index by the column's name */
- int findColumn(const ODBCXX_STRING& colName);
-
- /** Checks if the current row is deleted */
- bool rowDeleted();
-
- /** Checks if the current row was inserted */
- bool rowInserted();
-
- /** Checks if the current row was updated */
- bool rowUpdated();
-
- /** Gets the type of this result set */
- int getType();
-
- /** Gets the concurrency of this result set */
- int getConcurrency();
-
-
- /** Gets this result set's current fetch size */
- int getFetchSize() {
- return newFetchSize_;
- }
-
- /** Sets this result set's fetch size (doesn't apply immediately) */
- void setFetchSize(int fetchSize);
-
- /** Gets the cursor name associated with this result set */
- ODBCXX_STRING getCursorName();
-
- /** Gets the Statement that created this result set */
- Statement* getStatement() {
- return statement_;
- }
-
- /** Gets a column's value as a double
- * @param idx The column index, starting at 1
- */
- double getDouble(int idx);
-
- /** Gets a column's value as a bool
- * @param idx The column index, starting at 1
- */
- bool getBoolean(int idx);
-
- /** Gets a column's value as a signed char
- * @param idx The column index, starting at 1
- */
- signed char getByte(int idx);
-
- /** Gets a column's value as a chunk of bytes.
- *
- * @param idx The column index, starting at 1
- */
- ODBCXX_BYTES getBytes(int idx);
-
- /** Gets a column's value as a Date
- * @param idx The column index, starting at 1
- */
- Date getDate(int idx);
-
- /** Gets a column's value as a float
- * @param idx The column index, starting at 1
- */
- float getFloat(int idx);
-
- /** Gets a column's value as an int
- * @param idx The column index, starting at 1
- */
- int getInt(int idx);
-
- /** Gets a column's value as a Long
- * @param idx The column index, starting at 1
- */
- Long getLong(int idx);
-
- /** Gets a column's value as a short
- * @param idx The column index, starting at 1
- */
- short getShort(int idx);
-
- /** Gets a column's value as a string
- * @param idx The column index, starting at 1
- */
- ODBCXX_STRING getString(int idx);
-
- /** Gets a column's value as a Time
- * @param idx The column index, starting at 1
- */
- Time getTime(int idx);
-
- /** Gets a column's value as a Timestamp
- * @param idx The column index, starting at 1
- */
- Timestamp getTimestamp(int idx);
-
- /** Gets a column's value as a double
- * @param colName The name of the column
- */
- double getDouble(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a bool
- * @param colName The name of the column
- */
- bool getBoolean(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a signed char
- * @param colName The name of the column
- */
- signed char getByte(const ODBCXX_STRING& colName);
-
-
- /** Gets a column's value as a chunk of bytes.
- * @param colName The name of the column
- */
- ODBCXX_BYTES getBytes(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a Date
- * @param colName The name of the column
- */
- Date getDate(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a float
- * @param colName The name of the column
- */
- float getFloat(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as an int
- * @param colName The name of the column
- */
- int getInt(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a Long
- * @param colName The name of the column
- */
- Long getLong(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a short
- * @param colName The name of the column
- */
- short getShort(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a string
- * @param colName The name of the column
- */
- ODBCXX_STRING getString(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a Time
- * @param colName The name of the column
- */
- Time getTime(const ODBCXX_STRING& colName);
-
- /** Gets a column's value as a Timestamp
- * @param colName The name of the column
- */
- Timestamp getTimestamp(const ODBCXX_STRING& colName);
-
-
- /** Fetches a column's value as a stream.
- * Note that the stream is owned by the result set
- * and should in no case be deleted by the caller.
- * Also, the returned stream is only valid while the
- * cursor remains on this position.
- * @param idx The column index, starting at 1
- */
- ODBCXX_STREAM* getAsciiStream(int idx);
-
- /** Fetches a column's value as a stream.
- * Note that the stream is owned by the result set
- * and should in no case be deleted by the caller.
- * Also, the returned stream is only valid while the
- * cursor remains on this position.
- * @param colName The column name
- */
- ODBCXX_STREAM* getAsciiStream(const ODBCXX_STRING& colName);
-
- /** Fetches a column's value as a stream.
- * Note that the stream is owned by the result set
- * and should in no case be deleted by the caller.
- * Also, the returned stream is only valid while the
- * cursor remains on this position.
- * @param idx The column index, starting at 1
- */
- ODBCXX_STREAM* getBinaryStream(int idx);
-
- /** Fetches a column's value as a stream.
- * Note that the stream is owned by the result set
- * and should in no case be deleted by the caller.
- * Also, the returned stream is only valid while the
- * cursor remains on this position.
- * @param colName The column name
- */
- ODBCXX_STREAM* getBinaryStream(const ODBCXX_STRING& colName);
-
- /** Checks if the last fetched column value was NULL.
- * Note that if this is true, the returned value was undefined.
- */
- bool wasNull() {
- return lastWasNull_;
- }
-
- /** Sets the value of a column to a double
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateDouble(int idx, double val);
-
- /** Sets the value of a column to a bool
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateBoolean(int idx, bool val);
-
- /** Sets the value of a column to a signed char
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateByte(int idx, signed char val);
-
-
- /** Sets the value of a column to a chunk of bytes
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateBytes(int idx, const ODBCXX_BYTES& val);
-
- /** Sets the value of a column to a Date
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateDate(int idx, const Date& val);
-
- /** Sets the value of a column to a float
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateFloat(int idx, float val);
-
- /** Sets the value of a column to an int
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateInt(int idx, int val);
-
- /** Sets the value of a column to a Long
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateLong(int idx, Long val);
-
- /** Sets the value of a column to a short
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateShort(int idx, short val);
-
- /** Sets the value of a column to a string
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateString(int idx, const ODBCXX_STRING& val);
-
- /** Sets the value of a column to a Time
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateTime(int idx, const Time& val);
-
- /** Sets the value of a column to a Timestamp
- * @param idx The column index, starting at 1
- * @param val The value to set
- */
- void updateTimestamp(int idx, const Timestamp& val);
-
- /** Sets the value of a column to NULL
- * @param idx The column index, starting at 1
- */
- void updateNull(int idx);
-
-
- /** Sets the value of a column to a double
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateDouble(const ODBCXX_STRING& colName, double val);
-
- /** Sets the value of a column to a bool
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateBoolean(const ODBCXX_STRING& colName, bool val);
-
- /** Sets the value of a column to a signed char
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateByte(const ODBCXX_STRING& colName, signed char val);
-
- /** Sets the value of a column to a chunk of bytes
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateBytes(const ODBCXX_STRING& colName,
- const ODBCXX_BYTES& val);
-
-
- /** Sets the value of a column to a Date
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateDate(const ODBCXX_STRING& colName, const Date& val);
-
- /** Sets the value of a column to a float
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateFloat(const ODBCXX_STRING& colName, float val);
-
- /** Sets the value of a column to an int
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateInt(const ODBCXX_STRING& colName, int val);
-
- /** Sets the value of a column to a Long
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateLong(const ODBCXX_STRING& colName, Long val);
-
- /** Sets the value of a column to a short
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateShort(const ODBCXX_STRING& colName, short val);
-
- /** Sets the value of a column to a string
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateString(const ODBCXX_STRING& colName, const ODBCXX_STRING& val);
-
- /** Sets the value of a column to a Time
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateTime(const ODBCXX_STRING& colName, const Time& val);
-
- /** Sets the value of a column to a Timestamp
- * @param colName The name of the column
- * @param val The value to set
- */
- void updateTimestamp(const ODBCXX_STRING& colName, const Timestamp& val);
-
- /** Sets the value of a column to a stream
- * @param idx The column index, starting at 1
- * @param s The stream to assign
- * @param len The number of bytes in the stream
- */
- void updateAsciiStream(int idx, ODBCXX_STREAM* s, int len);
-
- /** Sets the value of a column to the contens of a stream
- * @param colName The column name
- * @param s The stream to assign
- * @param len The number of bytes in the stream
- */
- void updateAsciiStream(const ODBCXX_STRING& colName, ODBCXX_STREAM* s, int len);
-
-
- /** Sets the value of a column to the contens of a stream
- * @param idx The column index, starting at 1
- * @param s The stream to assign
- * @param len The number of bytes in the stream
- */
- void updateBinaryStream(int idx, ODBCXX_STREAM* s, int len);
-
- /** Sets the value of a column to the contens of a stream
- * @param colName The column name
- * @param s The stream to assign
- * @param len The number of bytes in the stream
- */
- void updateBinaryStream(const ODBCXX_STRING& colName, ODBCXX_STREAM* s, int len);
-
- /** Sets the value of a column to NULL
- * @param colName The column name
- */
- void updateNull(const ODBCXX_STRING& colName);
- };
-
-
-
-} // namespace odbc
-
-
-#endif // __ODBCXX_RESULTSET_H
diff --git a/source/odbc++/resultsetmetadata.h b/source/odbc++/resultsetmetadata.h
deleted file mode 100644
index b9be4e238..000000000
--- a/source/odbc++/resultsetmetadata.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_RESULTSETMETADATA_H
-#define __ODBCXX_RESULTSETMETADATA_H
-
-#include
-#include
-#include
-
-namespace odbc {
-
- class ResultSet;
- class DriverInfo;
-
- /** Provides meta data about a result set */
- class ODBCXX_EXPORT ResultSetMetaData {
- friend class ResultSet;
- friend class Statement;
- private:
- ResultSet* resultSet_;
-
- int numCols_;
- std::vector colNames_;
- std::vector colTypes_;
- std::vector colPrecisions_;
- std::vector colScales_;
-#if ODBCVER >= 0x0300
- std::vector colLengths_;
-#endif
-
- //internal stuff
- bool needsGetData_;
-
- //yes, both constructor and destructor are meant to be private
- ResultSetMetaData(ResultSet* rs);
- ~ResultSetMetaData() {}
-
- //driver info
- const DriverInfo* _getDriverInfo() const {
- return resultSet_->_getDriverInfo();
- }
-
- //these fetch info about a column
- int _getNumericAttribute(unsigned int col, SQLUSMALLINT attr);
- ODBCXX_STRING _getStringAttribute(unsigned int col, SQLUSMALLINT attr, unsigned int maxlen =255);
-
- //this loads the above values
- void _fetchColumnInfo();
-
- public:
- /** Nullability constants */
- enum {
- columnNoNulls = SQL_NO_NULLS,
- columnNullable = SQL_NULLABLE,
- columnNullableUnknown = SQL_NULLABLE_UNKNOWN
- };
-
- /** Fetch the number of columns in this result set */
- int getColumnCount() const;
-
- /** Get the name of a column
- * @param column The column index, starting at 1
- */
- const ODBCXX_STRING& getColumnName(int column) const;
-
- /** Get the SQL type of a column
- * @param column The column index, starting at 1
- * @see Types
- */
- int getColumnType(int column) const;
-
- /** Get the precision of a column
- * @param column The column index, starting at 1
- */
- int getPrecision(int column) const;
-
- /** Get the scale of a column
- * @param column The column index, starting at 1
- */
- int getScale(int column) const;
-
- /** Get the display size of a column.
- * @param column The column index, starting at 1
- */
- int getColumnDisplaySize(int column);
-
- /** Get the catalog name for a column.
- * @param column The column index, starting at 1
- */
- ODBCXX_STRING getCatalogName(int column);
-
- /** Get the label (if any) for a column.
- * @param column The column index, starting at 1
- */
- ODBCXX_STRING getColumnLabel(int column);
-
- /** Get the name of a columns SQL type
- * @param column The column index, starting at 1
- */
- ODBCXX_STRING getColumnTypeName(int column);
-
- /** Get the schema name for a column
- * @param column The column index, starting at 1
- */
- ODBCXX_STRING getSchemaName(int column);
-
- /** Get the table name for a column
- * @param column The column index, starting at 1
- */
- ODBCXX_STRING getTableName(int column);
-
- /** Check if a column is autoincrementing
- * @param column The column index, starting at 1
- */
- bool isAutoIncrement(int column);
-
- /** Check if a column is case sensitive
- * @param column The column index, starting at 1
- */
- bool isCaseSensitive(int column);
-
- /** Check if a column can be a currency (eg fixed precision)
- * @param column The column index, starting at 1
- */
- bool isCurrency(int column);
-
- /** Check if a column can be updated
- * @param column The column index, starting at 1
- */
- bool isDefinitelyWritable(int column);
-
- /** Check if a column can be set to NULL
- * @param column The column index, starting at 1
- */
- int isNullable(int column);
-
- /** Check if a column is read only
- * @param column The column index, starting at 1
- */
- bool isReadOnly(int column);
-
- /** Check if a column can be used in a where-clause
- * @param column The column index, starting at 1
- */
- bool isSearchable(int column);
-
- /** Check if a column is signed
- * @param column The column index, starting at 1
- */
- bool isSigned(int column);
-
- /** Check if a column is 'probably' writeable
- * @param column The column index, starting at 1
- */
- bool isWritable(int column);
- };
-
-
-
-} // namespace odbc
-
-
-#endif // __ODBCXX_RESULTSETMETADATA_H
diff --git a/source/odbc++/setup.h b/source/odbc++/setup.h
deleted file mode 100644
index ce37c89ed..000000000
--- a/source/odbc++/setup.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_SETUP_H
-#define __ODBCXX_SETUP_H
-
-#if defined(__WIN32__) && !defined(WIN32)
-# define WIN32 1
-#endif
-
-#if !defined(WIN32)
-# include
-#else
-# include
-#endif
-
-
-#if defined(IN_ODBCXX) && defined(ODBCXX_ENABLE_THREADS)
-# if !defined(_REENTRANT)
-# define _REENTRANT 1
-# endif
-# if !defined(_THREAD_SAFE)
-# define _THREAD_SAFE 1
-# endif
-#endif
-
-// set the UNICODE define activate wide versions of ODBC functions
-#if defined(ODBCXX_UNICODE)
-# if !defined(UNICODE)
-# define UNICODE
-# endif
-#else
-# if defined(UNICODE)
-# undef UNICODE
-# endif
-#endif
-
-// check whether we use strstream or stringstream
-#if defined(IN_ODBCXX)
-# if defined(ODBCXX_UNICODE)
-# define ODBCXX_SSTREAM std::wstringstream
-# else
-# if defined(ODBCXX_HAVE_SSTREAM)
-# define ODBCXX_SSTREAM std::stringstream
-# else
-# define ODBCXX_SSTREAM std::strstream
-# endif
-# endif
-#endif
-
-// check if ODBCVER is forced to something
-#if defined(ODBCXX_ODBCVER)
-# define ODBCVER ODBCXX_ODBCVER
-#endif
-
-// this can confuse our Types::CHAR
-#ifdef CHAR
-#undef CHAR
-#endif
-
-// NDEBUG and cassert
-#if defined(IN_ODBCXX)
-# if !defined(ODBCXX_DEBUG)
-# define NDEBUG
-# endif
-# include
-#endif
-
-// this should do the trick
-#if defined(__GNUC__) && __GNUC__>=3
-# define ODBCXX_HAVE_ISO_CXXLIB
-#endif
-
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
-# if defined(ODBCXX_DLL)
-# if defined(IN_ODBCXX)
-# define ODBCXX_EXPORT __declspec(dllexport)
-# else
-# define ODBCXX_EXPORT __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#if !defined(ODBCXX_EXPORT)
-# define ODBCXX_EXPORT
-#endif
-
-#if defined(_MSC_VER) || defined(__MINGW32__)
-# define ODBCXX_DUMMY_RETURN(x) return (x)
-#else
-# define ODBCXX_DUMMY_RETURN(x) ((void)0)
-#endif
-
-
-// environment abstractions
-
-#if defined(ODBCXX_QT)
-
-# define ODBCXX_STRING QString
-# define ODBCXX_STRING_C(s) QString::fromLocal8Bit(s)
-# define ODBCXX_STRING_CL(s,l) QString::fromLocal8Bit(s,l)
-# define ODBCXX_STRING_LEN(s) s.length()
-# define ODBCXX_STRING_DATA(s) s.local8Bit().data()
-# define ODBCXX_STRING_CSTR(s) s.local8Bit().data()
-
-# define ODBCXX_STREAM QIODevice
-
-# define ODBCXX_BYTES QByteArray
-# define ODBCXX_BYTES_SIZE(b) b.size()
-# define ODBCXX_BYTES_DATA(b) b.data()
-# define ODBCXX_BYTES_C(buf,len) QByteArray().duplicate(buf,len)
-
-#else
-
-# if defined(ODBCXX_UNICODE)
-
-# define ODBCXX_STRING std::wstring
-# define ODBCXX_STRING_C(s) std::wstring(s)
-# define ODBCXX_STRING_CL(s,l) std::wstring(s,l)
-# define ODBCXX_STRING_LEN(s) s.length()
-# define ODBCXX_STRING_DATA(s) s.data()
-# define ODBCXX_STRING_CSTR(s) s.c_str()
-
-# define ODBCXX_STREAM std::wistream
-# define ODBCXX_STREAMBUF std::wstreambuf
-
-# define ODBCXX_BYTES odbc::Bytes
-# define ODBCXX_BYTES_SIZE(b) b.getSize()
-# define ODBCXX_BYTES_DATA(b) b.getData()
-# define ODBCXX_BYTES_C(buf,len) odbc::Bytes((wchar_t*)buf,(size_t)len)
-
-# else
-
-# define ODBCXX_STRING std::string
-# define ODBCXX_STRING_C(s) std::string(s)
-# define ODBCXX_STRING_CL(s,l) std::string(s,l)
-# define ODBCXX_STRING_LEN(s) s.length()
-# define ODBCXX_STRING_DATA(s) s.data()
-# define ODBCXX_STRING_CSTR(s) s.c_str()
-
-# define ODBCXX_STREAM std::istream
-# define ODBCXX_STREAMBUF std::streambuf
-
-# define ODBCXX_BYTES odbc::Bytes
-# define ODBCXX_BYTES_SIZE(b) b.getSize()
-# define ODBCXX_BYTES_DATA(b) b.getData()
-# define ODBCXX_BYTES_C(buf,len) odbc::Bytes((signed char*)buf,(size_t)len)
-
-# endif // ODBCXX_UNICODE
-
-#endif // ODBCXX_QT
-
-#if defined(ODBCXX_UNICODE)
-# define ODBCXX_CHAR_TYPE wchar_t
-# define ODBCXX_SIGNED_CHAR_TYPE wchar_t
-# define ODBCXX_SQLCHAR SQLWCHAR
-# define ODBCXX_STRING_CONST(s) L ## s
-# define ODBCXX_COUT std::wcout
-# define ODBCXX_CERR std::wcerr
-# define ODBCXX_STRTOL wcstol
-#else
-# define ODBCXX_CHAR_TYPE char
-# define ODBCXX_SIGNED_CHAR_TYPE signed char
-# define ODBCXX_SQLCHAR SQLCHAR
-# define ODBCXX_STRING_CONST(s) s
-# define ODBCXX_COUT std::cout
-# define ODBCXX_CERR std::cerr
-# define ODBCXX_STRTOL strtol
-#endif
-
-#endif // __ODBCXX_SETUP_H
diff --git a/source/odbc++/statement.h b/source/odbc++/statement.h
deleted file mode 100644
index 2f4c72064..000000000
--- a/source/odbc++/statement.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_STATEMENT_H
-#define __ODBCXX_STATEMENT_H
-
-#include
-#include
-#include
-#include
-
-namespace odbc {
-
- class ResultSet;
- class DriverInfo;
-
- /** A simple non-prepared statement */
- class ODBCXX_EXPORT Statement : public ErrorHandler {
- friend class Connection;
- friend class ResultSet;
- friend class DatabaseMetaData;
-
- protected:
- Connection* connection_;
- SQLHSTMT hstmt_;
- int lastExecute_;
-
- const DriverInfo* _getDriverInfo() const {
- return connection_->_getDriverInfo();
- }
-
- private:
- ResultSet* currentResultSet_;
-
- int fetchSize_;
- int resultSetType_;
- int resultSetConcurrency_;
-
- //used internally
- enum StatementState {
- STATE_CLOSED,
- STATE_OPEN
- };
-
- StatementState state_;
-
- std::vector batches_;
-
- void _registerResultSet(ResultSet* rs);
- void _unregisterResultSet(ResultSet* rs);
-
- void _applyResultSetType();
-
- ResultSet* _getTypeInfo();
- ResultSet* _getTables(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName,
- const ODBCXX_STRING& types);
-
- ResultSet* _getTablePrivileges(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName);
-
- ResultSet* _getColumnPrivileges(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName,
- const ODBCXX_STRING& columnName);
-
- ResultSet* _getPrimaryKeys(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName);
-
- ResultSet* _getColumns(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName,
- const ODBCXX_STRING& columnName);
-
- ResultSet* _getIndexInfo(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& tableName,
- bool unique, bool approximate);
-
- ResultSet* _getCrossReference(const ODBCXX_STRING& pc,
- const ODBCXX_STRING& ps,
- const ODBCXX_STRING& pt,
- const ODBCXX_STRING& fc,
- const ODBCXX_STRING& fs,
- const ODBCXX_STRING& ft);
-
-
- ResultSet* _getProcedures(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& procName);
-
- ResultSet* _getProcedureColumns(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& procName,
- const ODBCXX_STRING& colName);
-
- ResultSet* _getSpecialColumns(const ODBCXX_STRING& catalog,
- const ODBCXX_STRING& schema,
- const ODBCXX_STRING& table,
- int what,int scope,int nullable);
-
- protected:
- Statement(Connection* con, SQLHSTMT hstmt,
- int resultSetType, int resultSetConcurrency);
-
- //utilities
- SQLUINTEGER _getNumericOption(SQLINTEGER optnum);
- ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
-
- void _setNumericOption(SQLINTEGER optnum, SQLUINTEGER value);
- void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
-
-#if ODBCVER >= 0x0300
- SQLPOINTER _getPointerOption(SQLINTEGER optnum);
- void _setPointerOption(SQLINTEGER optnum, SQLPOINTER value);
-#endif
-
- //this returns true if we have a result set pending
- bool _checkForResults();
-
- //this _always_ returns a ResultSet. If hideMe is true, this statement
- //becomes 'owned' by the ResultSet
- ResultSet* _getResultSet(bool hideMe =false);
-
- //this is called before a Statement (or any of the derived classes)
- //is executed
- void _beforeExecute();
-
- //this is called after a successeful execution
- void _afterExecute();
-
-
- public:
- /** Destructor. Destroys/closes this statement as well as
- * all created resultsets.
- */
- virtual ~Statement();
-
- /** Returns the connection that created this statement */
- Connection* getConnection();
-
-
- /** Cancel an ongoing operation that was executed in another thread */
- void cancel();
-
- /** Execute a given SQL statement.
- * The statement can return multiple results. To get to the
- * next result after processing the first one, getMoreResults() should
- * be called.
- * @param sql The string to execute
- * @return true if a resultset is available
- */
- virtual bool execute(const ODBCXX_STRING& sql);
-
- /** Execute an SQL statement, expected to return a resultset.
- *
- * Example:
- * std::auto_ptr<ResultSet> rs =
- * std::auto_ptr<ResultSet>(stmt->executeQuery(s));
- *
- * @param sql The string to execute
- * @return A ResultSet object.
- */
- virtual ResultSet* executeQuery(const ODBCXX_STRING& sql);
-
- /** Execute an SQL statement, expected to return an update count.
- * @return The number of affected rows
- */
- virtual int executeUpdate(const ODBCXX_STRING& sql);
-
- /** Fetch the current result as an update count.
- *
- * @return the current result's update count (affected rows), or -1
- * if the result is a ResultSet or if there are no more results.
- */
- int getUpdateCount();
-
- /** Fetch the current result as a ResultSet */
- ResultSet* getResultSet();
-
- /** Check if there are more results available on this
- * statment.
- * @return True if this statement has more results to offer.
- */
- bool getMoreResults();
-
- /** Set the cursor name for this statement */
- void setCursorName(const ODBCXX_STRING& name);
-
- /** Fetch the current fetch size (also called rowset size) for
- * resultsets created by this statement.
- */
- int getFetchSize() {
- return fetchSize_;
- }
-
- /** Set the current fetch size for resultsets created by this statement */
- void setFetchSize(int size);
-
- /** Get the concurrency type for resultsets created by this statement */
- int getResultSetConcurrency() {
- return resultSetConcurrency_;
- }
-
- /** Get the type for resultsets created by this statement */
- int getResultSetType() {
- return resultSetType_;
- }
-
- /** Get the query timeout for this statement */
- int getQueryTimeout();
- /** Set the query timeout for this statement */
- void setQueryTimeout(int seconds);
-
- /** Get the maximum number of rows to return in a resultset */
- int getMaxRows();
- /** Set the maximum number of rows to return in a resultset */
- void setMaxRows(int maxRows);
-
- /** Get the maximum field size for resultsets create by this statement */
- int getMaxFieldSize();
- /** Set the maximum field size for resultsets create by this statement */
- void setMaxFieldSize(int maxFieldSize);
-
- /** Sets escape processing on or off
- *
- * For PreparedStatement
s, the command has been parsed on
- * creation, so this setting won't really have any effect.
- */
- void setEscapeProcessing(bool on);
-
- /** Gets the current escape processing setting
- * @return true
if escape processing is on, false
- * otherwise
- */
- bool getEscapeProcessing();
-
- /** Closes all result sets from this execution. This is useful if
- * you don't wish to iterate through all remaining results, or if
- * your driver does not auto-close cursors. */
- void close();
-
- };
-
-
-
-} // namespace odbc
-
-
-#endif // __ODBCXX_STATEMENT_H
diff --git a/source/odbc++/threads.h b/source/odbc++/threads.h
deleted file mode 100644
index 641741140..000000000
--- a/source/odbc++/threads.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_THREADS_H
-#define __ODBCXX_THREADS_H
-
-#include
-
-#if defined(ODBCXX_ENABLE_THREADS)
-
-#if !defined(WIN32)
-# include
-#endif
-
-namespace odbc {
-
- class ODBCXX_EXPORT Mutex {
- private:
-#if !defined(WIN32)
- pthread_mutex_t mutex_;
-#else
- CRITICAL_SECTION mutex_;
-#endif
-
- Mutex(const Mutex&);
- Mutex& operator=(const Mutex&);
-
- public:
- explicit Mutex();
- ~Mutex();
-
- void lock();
- void unlock();
- };
-
- class ODBCXX_EXPORT Locker {
- private:
- Mutex& m_;
- public:
- Locker(Mutex& m)
- :m_(m) {
- m_.lock();
- }
-
- ~Locker() {
- m_.unlock();
- }
- };
-
-} //namespace odbc
-
-// macro used all over the place
-#define ODBCXX_LOCKER(mut) odbc::Locker _locker(mut)
-
-#else // !ODBCXX_ENABLE_THREADS
-
-#define ODBCXX_LOCKER(mut) ((void)0)
-
-#endif
-
-#endif // __ODBCXX_THREADS_H
diff --git a/source/odbc++/types.h b/source/odbc++/types.h
deleted file mode 100644
index bdca0b159..000000000
--- a/source/odbc++/types.h
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- This file is part of libodbc++.
-
- Copyright (C) 1999-2000 Manush Dodunekov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __ODBCXX_TYPES_H
-#define __ODBCXX_TYPES_H
-
-#include
-
-#include
-
-#if !defined(ODBCXX_QT)
-# include
-# else
-# include
-#endif
-
-#include
-#if defined(ODBCXX_NO_STD_TIME_T)
-namespace std {
- using ::time_t;
-};
-#endif
-
-#if defined(ODBCXX_QT)
-class QIODevice;
-#endif
-
-#if defined(ODBCXX_HAVE_ISQL_H) && defined(ODBCXX_HAVE_ISQLEXT_H)
-# include
-# include
-#elif defined(ODBCXX_HAVE_SQL_H) && defined(ODBCXX_HAVE_SQLEXT_H)
-# include
-# include
-#else
-# error "Whoops. Can not recognize the ODBC subsystem."
-#endif
-
-#if defined(ODBCXX_HAVE_SQLUCODE_H)
-# include
-#endif
-
-// fixups for current iODBC, which kindly doesn't provide SQL_TRUE and
-// SQL_FALSE macros
-
-#if !defined(SQL_TRUE)
-# define SQL_TRUE 1
-#endif
-
-#if !defined(SQL_FALSE)
-# define SQL_FALSE 0
-#endif
-
-// MS ODBC SDK misses this in some releases
-#if ODBCVER >= 0x0300 && !defined(SQL_NOT_DEFERRABLE)
-# define SQL_NOT_DEFERRABLE 7
-#endif
-
-
-// Setup our ODBC3_C (odbc3 conditional) macro
-#if ODBCVER >= 0x0300
-
-# define ODBC3_C(odbc3_value,old_value) odbc3_value
-
-#else
-
-# define ODBC3_C(odbc3_value,old_value) old_value
-
-#endif
-
-
-// ODBC3_DC (odbc3 dynamic conditional)
-// Every context using this macro should provide
-// a this->_getDriverInfo() method returning
-// a const DriverInfo*
-
-#if ODBCVER >= 0x0300
-
-# define ODBC3_DC(odbc3_value,old_value) \
-(this->_getDriverInfo()->getMajorVersion()>=3?odbc3_value:old_value)
-
-#else
-
-# define ODBC3_DC(odbc3_value,old_value) old_value
-
-#endif
-
-#if defined(ODBCXX_HAVE_INTTYPES_H)
-# include
-#endif
-
-#include
-
-
-namespace odbc {
-
- // We want Long to be at least 64 bits
-
-#if defined(WIN32)
-
- typedef __int64 Long;
-
-#elif defined(ODBCXX_HAVE_INTTYPES_H)
-
- typedef int64_t Long;
-
-#else
-
-# if ODBCXX_SIZEOF_INT == 8
-
- typedef int Long;
-
-# elif ODBCXX_SIZEOF_LONG == 8
-
- typedef long Long;
-
-# elif ODBCXX_SIZEOF_LONG_LONG == 8
-
- typedef long long Long;
-
-# else
-
-# error "Can't find an appropriate at-least-64-bit integer"
-
-# endif
-
-#endif
-
-
- //constants:
- //how much we try to fetch with each SQLGetData call
- const int GETDATA_CHUNK_SIZE=4*1024;
- //how much we write with each SQLPutData call
- const int PUTDATA_CHUNK_SIZE=GETDATA_CHUNK_SIZE;
-
- //how much we read/write in string<->stream conversion
- //better names for those?
- const int STRING_TO_STREAM_CHUNK_SIZE=1024;
- const int STREAM_TO_STRING_CHUNK_SIZE=STRING_TO_STREAM_CHUNK_SIZE;
-
-
-
-
-
- /** SQL type constants
- */
- struct Types {
- /** Type constants
- */
- enum SQLType {
- /** An SQL BIGINT */
- BIGINT = SQL_BIGINT,
- /** An SQL BINARY (fixed length) */
- BINARY = SQL_BINARY,
- /** An SQL BIT */
- BIT = SQL_BIT,
- /** An SQL CHAR (fixed length) */
- CHAR = SQL_CHAR,
- /** An SQL DATE */
- DATE = ODBC3_C(SQL_TYPE_DATE,SQL_DATE),
- /** An SQL DECIMAL (precision,scale) */
- DECIMAL = SQL_DECIMAL,
- /** An SQL DOUBLE */
- DOUBLE = SQL_DOUBLE,
- /** An SQL FLOAT */
- FLOAT = SQL_FLOAT,
- /** An SQL INTEGER */
- INTEGER = SQL_INTEGER,
- /** An SQL LONGVARBINARY (variable length, huge) */
- LONGVARBINARY = SQL_LONGVARBINARY,
- /** An SQL LONGVARCHAR (variable length, huge) */
- LONGVARCHAR = SQL_LONGVARCHAR,
- /** An SQL NUMERIC (precision,scale) */
- NUMERIC = SQL_NUMERIC,
- /** An SQL REAL */
- REAL = SQL_REAL,
- /** An SQL SMALLINT */
- SMALLINT = SQL_SMALLINT,
- /** An SQL TIME */
- TIME = ODBC3_C(SQL_TYPE_TIME,SQL_TIME),
- /** An SQL TIMESTAMP */
- TIMESTAMP = ODBC3_C(SQL_TYPE_TIMESTAMP,SQL_TIMESTAMP),
- /** An SQL TINYINT */
- TINYINT = SQL_TINYINT,
- /** An SQL VARBINARY (variable length less than 256) */
- VARBINARY = SQL_VARBINARY,
- /** An SQL VARCHAR (variable length less than 256) */
- VARCHAR = SQL_VARCHAR
-#if defined(ODBCXX_HAVE_SQLUCODE_H)
- ,
- /** A wide SQL CHAR (fixed length less than 256) */
- WCHAR = SQL_WCHAR,
- /** A wide SQL VARCHAR (variable length less than 256) */
- WVARCHAR = SQL_WVARCHAR,
- /** A wide SQL LONGVARCHAR (variable length, huge) */
- WLONGVARCHAR = SQL_WLONGVARCHAR
-#endif
- };
- };
-
-
-#if !defined(ODBCXX_QT)
- /** A chunk of bytes.
- *
- * Used for setting and getting binary values.
- * @warning This class uses reference counting. An instance that is
- * referred to from different threads is likely to cause trouble.
- */
- class ODBCXX_EXPORT Bytes {
- private:
- struct Rep {
- ODBCXX_SIGNED_CHAR_TYPE* buf_;
- size_t len_;
- int refCount_;
- Rep(const ODBCXX_SIGNED_CHAR_TYPE* b, size_t l)
- :len_(l), refCount_(0) {
- if(len_>0) {
- buf_=new ODBCXX_SIGNED_CHAR_TYPE[len_];
- memcpy((void*)buf_,(void*)b,len_);
- } else {
- buf_=NULL;
- }
- }
- ~Rep() {
- delete [] buf_;
- }
- };
-
- Rep* rep_;
- public:
- /** Default constructor */
- Bytes()
- :rep_(new Rep(NULL,0)) {
- rep_->refCount_++;
- }
-
- /** Constructor */
- Bytes(const ODBCXX_SIGNED_CHAR_TYPE* data, size_t dataLen)
- :rep_(new Rep(data,dataLen)) {
- rep_->refCount_++;
- }
-
- /** Copy constructor */
- Bytes(const Bytes& b)
- :rep_(b.rep_) {
- rep_->refCount_++;
- }
-
- /** Assignment */
- Bytes& operator=(const Bytes& b) {
- if(--rep_->refCount_==0) {
- delete rep_;
- }
- rep_=b.rep_;
- rep_->refCount_++;
- return *this;
- }
-
- /** Comparison */
- bool operator==(const Bytes& b) const {
- if (getSize()!=b.getSize())
- return false;
- for(size_t i=0;irefCount_==0) {
- delete rep_;
- }
- }
-
- /** Returns a pointer to the data */
- const ODBCXX_SIGNED_CHAR_TYPE* getData() const {
- return rep_->buf_;
- }
-
- /** Returns the size of the data */
- size_t getSize() const {
- return rep_->len_;
- }
- };
-#endif
-
- /** An SQL DATE */
- class ODBCXX_EXPORT Date {
- protected:
- int year_;
- int month_;
- int day_;
-
- virtual void _invalid(const ODBCXX_CHAR_TYPE* what, int value);
-
- int _validateYear(int y) {
- return y;
- }
-
- int _validateMonth(int m) {
- if(m<1 || m>12) {
- this->_invalid(ODBCXX_STRING_CONST("month"),m);
- }
- return m;
- }
-
- int _validateDay(int d) {
- if(d<1 || d>31) {
- this->_invalid(ODBCXX_STRING_CONST("day"),d);
- }
- return d;
- }
-
- public:
- /** Constructor.
- */
- Date(int year, int month, int day) {
- this->setYear(year);
- this->setMonth(month);
- this->setDay(day);
- }
-
- /** Constructor.
- *
- * Sets this date to today.
- */
- explicit Date();
-
- /** Constructor.
- *
- * Sets this date to the specified time_t value.
- */
- Date(std::time_t t) {
- this->setTime(t);
- }
-
- /** Constructor.
- *
- * Sets this date to the specified string in the YYYY-MM-DD format.
- */
- Date(const ODBCXX_STRING& str) {
- this->parse(str);
- }
-
- /** Copy constructor */
- Date(const Date& d)
- :year_(d.year_),
- month_(d.month_),
- day_(d.day_) {}
-
- /** Assignment operator */
- Date& operator=(const Date& d) {
- year_=d.year_;
- month_=d.month_;
- day_=d.day_;
- return *this;
- }
-
- /** Destructor */
- virtual ~Date() {}
-
- /** Sets this date to the specified time_t value */
- virtual void setTime(std::time_t t);
-
- /** Returns the time_t value of 00:00:00 at this date */
- std::time_t getTime() const;
-
- /** Sets this date from a string in the YYYY-MM-DD format */
- void parse(const ODBCXX_STRING& str);
-
- /** Gets the year of this date */
- int getYear() const {
- return year_;
- }
-
- /** Gets the month of this date */
- int getMonth() const {
- return month_;
- }
-
- /** Gets the monthday of this date */
- int getDay() const {
- return day_;
- }
-
- /** Sets the year of this date */
- void setYear(int year) {
- year_=this->_validateYear(year);
- }
-
- /** Sets the month of this date */
- void setMonth(int month) {
- month_=this->_validateMonth(month);
- }
-
- /** Sets the day of this date */
- void setDay(int day) {
- day_=this->_validateDay(day);
- }
-
- /** Gets the date as a string in the YYYY-MM-DD format */
- virtual ODBCXX_STRING toString() const;
- };
-
- /** An SQL TIME */
- class ODBCXX_EXPORT Time {
- protected:
- int hour_;
- int minute_;
- int second_;
-
- virtual void _invalid(const ODBCXX_CHAR_TYPE* what, int value);
-
- int _validateHour(int h) {
- if(h<0 || h>23) {
- this->_invalid(ODBCXX_STRING_CONST("hour"),h);
- }
- return h;
- }
-
- int _validateMinute(int m) {
- if(m<0 || m>59) {
- this->_invalid(ODBCXX_STRING_CONST("minute"),m);
- }
- return m;
- }
-
- int _validateSecond(int s) {
- if(s<0 || s>61) {
- this->_invalid(ODBCXX_STRING_CONST("second"),s);
- }
- return s;
- }
-
- public:
- /** Constructor */
- Time(int hour, int minute, int second) {
- this->setHour(hour);
- this->setMinute(minute);
- this->setSecond(second);
- }
-
- /** Constructor.
- *
- * Sets the time to now.
- */
- explicit Time();
-
- /** Constructor.
- *
- * Sets the time to the specified time_t value.
- */
- Time(std::time_t t) {
- this->setTime(t);
- }
-
- /** Constructor.
- *
- * Sets the time to the specified string in the HH:MM:SS format.
- */
- Time(const ODBCXX_STRING& str) {
- this->parse(str);
- }
-
- /** Copy constructor */
- Time(const Time& t)
- :hour_(t.hour_),
- minute_(t.minute_),
- second_(t.second_) {}
-
- /** Assignment operator */
- Time& operator=(const Time& t) {
- hour_=t.hour_;
- minute_=t.minute_;
- second_=t.second_;
- return *this;
- }
-
- /** Destructor */
- virtual ~Time() {}
-
- /** Sets the time to the specified time_t value */
- virtual void setTime(std::time_t t);
-
- /** Returns the time_t value of 1970-01-01 at this time */
- std::time_t getTime() const;
-
- /** Sets this time from a string in the HH:MM:SS format */
- void parse(const ODBCXX_STRING& str);
-
- /** Gets the hour of this time */
- int getHour() const {
- return hour_;
- }
-
- /** Gets the minute of this time */
- int getMinute() const {
- return minute_;
- }
-
- /** Gets the second of this time */
- int getSecond() const {
- return second_;
- }
-
- /** Sets the hour of this time */
- void setHour(int h) {
- hour_=this->_validateHour(h);
- }
-
- /** Sets the minute of this time */
- void setMinute(int m) {
- minute_=this->_validateMinute(m);
- }
-
- /** Sets the second of this time */
- void setSecond(int s) {
- second_=this->_validateSecond(s);
- }
-
- virtual ODBCXX_STRING toString() const;
- };
-
-
- /** An SQL TIMESTAMP
- */
- class ODBCXX_EXPORT Timestamp : public Date, public Time {
- private:
- int nanos_;
-
- virtual void _invalid(const ODBCXX_CHAR_TYPE* what, int value);
-
- int _validateNanos(int n) {
- if(n<0) {
- this->_invalid(ODBCXX_STRING_CONST("nanoseconds"),n);
- }
- return n;
- }
-
- public:
- /** Constructor */
- Timestamp(int year, int month, int day,
- int hour, int minute, int second,
- int nanos =0)
- :Date(year,month,day), Time(hour,minute,second) {
- this->setNanos(nanos);
- }
-
- /** Constructor.
- *
- * Sets the timestamp to now.
- */
- explicit Timestamp();
-
- /** Constructor.
- *
- * Sets this timestamp to the specified time_t value.
- */
- Timestamp(std::time_t t) {
- this->setTime(t);
- }
-
- /** Constructor.
- *
- * Sets this timestamp from a YYYY-MM-DD HH:MM:SS[.NNN...] format
- */
- Timestamp(const ODBCXX_STRING& s) {
- this->parse(s);
- }
-
-
- /** Copy constructor */
- Timestamp(const Timestamp& t)
- :Date(t),Time(t),nanos_(t.nanos_) {}
-
- /** Assignment operator */
- Timestamp& operator=(const Timestamp& t) {
- Date::operator=(t);
- Time::operator=(t);
- nanos_=t.nanos_;
- return *this;
- }
-
- /** Destructor */
- virtual ~Timestamp() {}
-
- /** Sets this timestamp to the specified time_t value */
- virtual void setTime(std::time_t t);
-
- /** Gets the time_t value of this timestamp */
- virtual std::time_t getTime() const {
- return Date::getTime()+Time::getTime();
- }
-
- /** Set this timestamp from a YYYY-MM-DD HH:MM:SS[.NNN...] format
- */
- void parse(const ODBCXX_STRING& s);
-
- /** Gets the nanoseconds value of this timestamp */
- int getNanos() const {
- return nanos_;
- }
-
- /** Sets the nanoseconds value of this timestamp */
- void setNanos(int nanos) {
- nanos_=this->_validateNanos(nanos);
- }
-
- virtual ODBCXX_STRING toString() const;
- };
-
-
- //this is used for several 'lists of stuff' below
- //expects T to be a pointer-to-something, and
- //the contents will get deleted when the vector
- //itself is deleted
- template class CleanVector : public std::vector {
- private:
- CleanVector(const CleanVector&); //forbid
- CleanVector& operator=(const CleanVector&); //forbid
-
- public:
- explicit CleanVector() {}
- virtual ~CleanVector() {
- typename std::vector::iterator i=this->begin();
- typename std::vector::iterator end=this->end();
- while(i!=end) {
- delete *i;
- ++i;
- }
- this->clear();
- }
- };
-
-
- /** Used internally - represents the result of an SQLError call
- */
- class ODBCXX_EXPORT DriverMessage {
- friend class ErrorHandler;
-
- private:
- ODBCXX_CHAR_TYPE state_[SQL_SQLSTATE_SIZE+1];
- ODBCXX_CHAR_TYPE description_[SQL_MAX_MESSAGE_LENGTH];
- SQLINTEGER nativeCode_;
-
- DriverMessage() {}
-#if ODBCVER < 0x0300
- static DriverMessage* fetchMessage(SQLHENV henv,
- SQLHDBC hdbc,
- SQLHSTMT hstmt);
-#else
- static DriverMessage* fetchMessage(SQLINTEGER handleType,
- SQLHANDLE h,
- int idx);
-#endif
-
- public:
- virtual ~DriverMessage() {}
-
- const ODBCXX_CHAR_TYPE* getSQLState() const {
- return state_;
- }
-
- const ODBCXX_CHAR_TYPE* getDescription() const {
- return description_;
- }
-
- int getNativeCode() const {
- return nativeCode_;
- }
- };
-
-
- /** The exception thrown when errors occur inside the library.
- */
- class SQLException : public std::exception {
- private:
- ODBCXX_STRING reason_;
- ODBCXX_STRING sqlState_;
- int errorCode_;
-#if defined(ODBCXX_UNICODE)
- std::string reason8_;
-#elif defined(ODBCXX_QT)
- QCString reason8_;
-#endif
- public:
- /** Constructor */
- SQLException(const ODBCXX_STRING& reason =ODBCXX_STRING_CONST(""),
- const ODBCXX_STRING& sqlState =ODBCXX_STRING_CONST(""),
- int vendorCode =0)
- :reason_(reason),
- sqlState_(sqlState),
- errorCode_(vendorCode)
-#if defined(ODBCXX_UNICODE)
-{
- const size_t length =sizeof(wchar_t)*reason_.size();
- char* temp =new char[length+1];
- wcstombs(temp,reason_.c_str(),length);
- reason8_ =temp;
- delete[] temp;
-}
-#else
-# if defined(ODBCXX_QT)
- ,reason8_(reason.local8Bit())
-# endif
-{}
-#endif
-
- /** Copy from a DriverMessage */
- SQLException(const DriverMessage& dm)
- :reason_(dm.getDescription()),
- sqlState_(dm.getSQLState()),
- errorCode_(dm.getNativeCode()) {}
-
- /** Destructor */
- virtual ~SQLException() throw() {}
-
- /** Get the vendor error code of this exception */
- int getErrorCode() const {
- return errorCode_;
- }
-
- /** Gets the SQLSTATE of this exception.
- *
- * Consult your local ODBC reference for SQLSTATE values.
- */
- const ODBCXX_STRING& getSQLState() const {
- return sqlState_;
- }
-
- /** Gets the description of this message */
- const ODBCXX_STRING& getMessage() const {
- return reason_;
- }
-
-
- /** Gets the description of this message */
- virtual const char* what() const throw() {
- // the conversion from QString involves a temporary, which
- // doesn't survive this scope. So here, we do a conditional
-#if defined(ODBCXX_QT)
- return reason8_.data();
-#else
-# if defined(ODBCXX_UNICODE)
- return reason8_.c_str();
-# else
- return reason_.c_str();
-# endif
-#endif
- }
- };
-
-
- /** Represents an SQL warning.
- *
- * Contains the same info as an SQLException.
- */
- class SQLWarning : public SQLException {
-
- SQLWarning(const SQLWarning&); //forbid
- SQLWarning& operator=(const SQLWarning&); //forbid
-
- public:
- /** Constructor */
- SQLWarning(const ODBCXX_STRING& reason = ODBCXX_STRING_CONST(""),
- const ODBCXX_STRING& sqlState = ODBCXX_STRING_CONST(""),
- int vendorCode =0)
- :SQLException(reason,sqlState,vendorCode) {}
-
- /** Copy from a DriverMessage */
- SQLWarning(const DriverMessage& dm)
- :SQLException(dm) {}
-
- /** Destructor */
- virtual ~SQLWarning() throw() {}
- };
-
- typedef CleanVector WarningList;
-
-
- template class Deleter {
- private:
- T* ptr_;
- bool isArray_;
-
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-
- public:
- explicit Deleter(T* ptr, bool isArray =false)
- :ptr_(ptr), isArray_(isArray) {}
- ~Deleter() {
- if(!isArray_) {
- delete ptr_;
- } else {
- delete[] ptr_;
- }
- }
- };
-
-} // namespace odbc
-
-
-#endif // __ODBCXX_TYPES_H
diff --git a/subcommands/autotest/test_geodata.txt b/subcommands/autotest/test_geodata.txt
index 3871eb883..aba86c038 100644
--- a/subcommands/autotest/test_geodata.txt
+++ b/subcommands/autotest/test_geodata.txt
@@ -101,7 +101,7 @@ location,latitude,longitude,id,distance
latitude,longitude,id,distance
37.4205,-122.2046,0,0.0
37.5205,-122.3046,1,14196.0
-# geodata merge -D distance ./path_example.csv
+# geodata merge -D distance ../path_example.csv
id,latitude,longitude,configuration,pole_height,distance
0,37.41505,-122.20565,flat3,54,0.0
1,37.4147,-122.20849,sideT,60,254.0
@@ -140,7 +140,7 @@ id,latitude,longitude,configuration,pole_height,distance
34,37.39161,-122.2786,2pole,69,7593.0
35,37.39171,-122.28139,3pole,48,7839.0
36,37.38806,-122.28844,tower,69,8583.0
-# geodata merge -D distance ./path_example.csv -r 100
+# geodata merge -D distance ../path_example.csv -r 100
position,latitude,longitude,configuration,pole_height,id,distance,heading
0,37.41505,-122.20565,flat3,54.0,0.0,0.0,0.0
100,37.41491,-122.20677,,,,100.0,263.0
@@ -162,8 +162,8 @@ position,latitude,longitude,configuration,pole_height,id,distance,heading
1426,37.41307,-122.2216,,,,1426.0,262.9
1490,37.41298,-122.22232,sideT,48.0,8.0,1490.0,262.9
1590,37.41285,-122.22344,,,,1590.0,263.1
-1690,37.41271,-122.22456,sideT,63.0,9.0,1690.0,263.1
1690,37.41271,-122.22456,,,,1690.0,263.1
+1690,37.41271,-122.22456,sideT,63.0,9.0,1690.0,263.1
1790,37.41257,-122.22568,,,,1790.0,262.9
1890,37.41243,-122.2268,,,,1890.0,262.9
1941,37.41236,-122.22736,sideT,54.0,10.0,1941.0,262.9
@@ -190,16 +190,16 @@ position,latitude,longitude,configuration,pole_height,id,distance,heading
3753,37.40566,-122.24446,,,,3753.0,143.8
3759,37.40562,-122.24443,vert3,51.0,18.0,3759.0,143.8
3859,37.40474,-122.24422,,,,3859.0,166.7
-3878,37.40456,-122.24418,vert3,60.0,19.0,3879.0,166.7
-3978,37.40366,-122.24426,,,,3979.0,185.4
+3878,37.40456,-122.24418,vert3,60.0,19.0,3878.0,166.7
+3978,37.40366,-122.24426,,,,3978.0,185.4
4009,37.40339,-122.24429,vert3,60.0,20.0,4009.0,185.4
4109,37.40254,-122.24466,,,,4109.0,203.4
4115,37.40249,-122.24468,vert3,60.0,21.0,4115.0,203.4
4215,37.40175,-122.24532,,,,4215.0,220.9
-4267,37.40136,-122.24566,vert3,66.0,22.0,4268.0,220.9
-4367,37.40095,-122.24666,,,,4368.0,247.6
-4467,37.40053,-122.24767,,,,4468.0,247.6
-4567,37.40012,-122.24867,,,,4568.0,247.6
+4267,37.40136,-122.24566,vert3,66.0,22.0,4267.0,220.9
+4367,37.40095,-122.24666,,,,4367.0,247.6
+4467,37.40053,-122.24767,,,,4467.0,247.6
+4567,37.40012,-122.24867,,,,4567.0,247.6
4627,37.39987,-122.24927,3pole,48.0,23.0,4627.0,247.6
4727,37.39974,-122.25039,,,,4727.0,263.6
4793,37.39966,-122.25113,2pole,54.0,24.0,4793.0,263.6
@@ -217,8 +217,8 @@ position,latitude,longitude,configuration,pole_height,id,distance,heading
5897,37.39888,-122.26359,,,,5897.0,266.0
5977,37.39882,-122.26449,3pole,54.0,27.0,5977.0,266.0
6077,37.39874,-122.26562,,,,6077.0,266.1
-6119,37.39871,-122.2661,2pole,45.0,28.0,6120.0,266.1
-6219,37.39863,-122.26723,,,,6220.0,266.1
+6119,37.39871,-122.2661,2pole,45.0,28.0,6119.0,266.1
+6219,37.39863,-122.26723,,,,6219.0,266.1
6250,37.39861,-122.26757,3pole,54.0,29.0,6250.0,266.1
6350,37.39783,-122.26814,,,,6350.0,216.5
6450,37.39706,-122.26872,,,,6450.0,216.5
@@ -246,8 +246,8 @@ position,latitude,longitude,configuration,pole_height,id,distance,heading
8340,37.38926,-122.28613,,,,8340.0,242.6
8440,37.38876,-122.28708,,,,8440.0,242.6
8540,37.38827,-122.28803,,,,8540.0,242.6
-8583,37.38806,-122.28844,tower,69.0,36.0,8584.0,242.6
-# geodata merge -D distance ./path_example.csv -k position
+8583,37.38806,-122.28844,tower,69.0,36.0,8583.0,242.6
+# geodata merge -D distance ../path_example.csv -k position
position,latitude,longitude,configuration,pole_height,id,distance,heading
0,37.41505,-122.20565,flat3,54,0,0.0,0.0
254,37.4147,-122.20849,sideT,60,1,254.0,263.0
@@ -286,7 +286,7 @@ position,latitude,longitude,configuration,pole_height,id,distance,heading
7593,37.39161,-122.2786,2pole,69,34,7593.0,258.5
7840,37.39171,-122.28139,3pole,48,35,7840.0,272.1
8583,37.38806,-122.28844,tower,69,36,8583.0,242.6
-# geodata merge -D distance ./path_example.csv -k location
+# geodata merge -D distance ../path_example.csv -k location
location,latitude,longitude,configuration,pole_height,id,distance
9q9hg5hw3yyf,37.41505,-122.20565,flat3,54,0,0.0
9q9hg54krv95,37.4147,-122.20849,sideT,60,1,254.0
@@ -325,7 +325,7 @@ location,latitude,longitude,configuration,pole_height,id,distance
9q9h9qzmyj73,37.39161,-122.2786,2pole,69,34,7593.0
9q9h9qvqmpfy,37.39171,-122.28139,3pole,48,35,7840.0
9q9h9q230zd1,37.38806,-122.28844,tower,69,36,8583.0
-# geodata merge -D distance ./path_example.csv -k latitude,longitude
+# geodata merge -D distance ../path_example.csv -k latitude,longitude
latitude,longitude,configuration,pole_height,id,distance
37.41505,-122.20565,flat3,54,0,0.0
37.4147,-122.20849,sideT,60,1,254.0