Modified:
MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp
MYODBCIns/MYODBCInsLib/MYODBCInsInternal.h
MYODBCIns/include/MYODBCIns.h
MYODBCIns/include/MYODBCInsDataSource.h
MYODBCIns/include/MYODBCInsDriverConnect.h
Log:
Modified: MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCIns.cpp 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/MYODBCInsLib/MYODBCIns.cpp 2006-04-21 23:33:57 UTC (rev 95)
@@ -93,7 +93,7 @@
MYODBCDbgReturn3( "%s", stringlistFriendlyNames );
}
-QStringList MYODBCIns::getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE nScope )
+QStringList MYODBCIns::getDataSourceNames( MYODBCInsDataSource::DATASOURCE_SCOPE nScope )
{
MYODBCDbgEnter();
@@ -207,56 +207,57 @@
}
break;
case PARSE_STATE_VALUE:
+ case PARSE_STATE_VALUE_BRACED:
+ if ( nState == PARSE_STATE_VALUE )
{
- /*
- \internal ODBC Rule
+ if ( !isDelim( stringKeywordValues, nScanChar, &nDelim ) )
+ break;
+ }
+ else if ( nState == PARSE_STATE_VALUE_BRACED )
+ {
+ if ( isDelim( stringKeywordValues, nScanChar, &nDelim ) )
+ {
+ setError( QString( "[%1][%2][ERROR] Missing closing brace for %3
value." ).arg( __FILE__ ).arg( __LINE__ ).arg( stringKeyword ) );
+ MYODBCDbgReturn3( "%d", false );
+ }
- If any keywords are repeated in the connection string, the driver
uses the value
- associated with the first occurrence of the keyword. If the DSN
and DRIVER keywords
- are included in the same connection string, the Driver Manager
and the driver use
- whichever keyword appears first.
- */
+ if ( stringKeywordValues[nScanChar] != QChar( '}' ) )
+ break;
- /* ';' terminates name/value but we may not find one for last */
- if ( isDelimKeywordValue( stringKeywordValues[nScanChar], nDelim ) ||
nScanChar == stringKeywordValues.length() )
- {
-/*
- if ( stringKeyword == "DSN" &&
hashAttributes["DRIVER"].isNull() )
- {
- }
-*/
-/*
- if ( hashAttributes.contains( stringKeyword ) )
- {
- if ( hashAttributes[stringKeyword].isNull() )
- hashAttributes[stringKeyword] = stringKeywordValues.mid(
nAnchorChar, nScanChar - nAnchorChar );
- }
- else
-*/
+ nScanChar++;
+ }
- stringKeyword = QString::null;
- }
- }
+ /*
+ \internal ODBC Rule
+
+ If the DSN and DRIVER keywords are included in the same connection
string,
+ the Driver Manager and the driver use whichever keyword appears
first.
+ */
+ if ( stringKeyword == "DSN" && !hashAttributes["DRIVER"].isNull()
)
+ break;
+
+ if ( stringKeyword == "DRIVER" && !hashAttributes["DSN"].isNull()
)
+ break;
+
+ /*
+ \internal ODBC Rule
+
+ If any keywords are repeated in the connection string, the driver
uses the value
+ associated with the first occurrence of the keyword.
+ */
+ if ( phashKeywordValues->contains( stringKeyword ) )
+ break;
+
+ phashKeywordValues->insert( stringKeyword, stringKeywordValues.mid(
nAnchorChar, nScanChar - nAnchorChar ) );
+ stringKeyword = QString::null;
break;
- case PARSE_STATE_VALUE_BRACED:
- if ( stringKeywordValues[nScanChar] == QChar( '}' ) )
- {
- phashKeywordValues->insert( stringKeyword,
stringKeywordValues.mid( nAnchorChar, nScanChar - nAnchorChar ) );
- stringKeyword = QString::null;
- }
- else if ( isDelim( stringKeywordValues, nScanChar, nDelim ) )
- {
- setError( QString( "[%1][%2][ERROR] Missing closing brace for %3
value." ).arg( __FILE__ ).arg( __LINE__ ).arg( stringKeyword ) );
- MYODBCDbgReturn3( "%d", false );
- }
- break;
default:
MYODBCDbgError( "Unhandled state %d", nState );
MYODBCDbgReturn3( "%d", false );
}
/* terminated a name/value pair */
- if ( isDelimKeywordValue( stringKeywordValues[nScanChar], nDelim )
+ if ( isDelimKeywordValue( stringKeywordValues[nScanChar], &nDelim )
nState = PARSE_STATE_NAME_START;
/* have we advanced to end of string */
@@ -577,12 +578,11 @@
{
MYODBCDbgEnter();
- if ( nDelim == DELIM_BOTH )
- MYODBCDbgError( "nDelim == DELIM_BOTH (%d) but it is too ambigious here.", nDelim
)
-
switch ( nDelim )
{
case DELIM_BOTH:
+ if ( stringKeywordValues[nScanChar] == QChar( '\0' ) )
+ MYODBCDbgReturn3( "%d", true );
break;
case DELIM_NULL:
if ( nScanChar > 0 && stringKeywordValues[nScanChar - 1] == QChar(
'\0' ) && stringKeywordValues[nScanChar] == QChar( '\0' ) )
Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2006-04-21 23:33:57 UTC (rev 95)
@@ -28,23 +28,21 @@
*/
#include "MYODBCInsInternal.h"
-#define MYODBC_INS_ODBCINI_HEADER_SECTION L"ODBC Data Sources"
-
-MYODBCInsDataSource::MYODBCInsDataSource( MYODBC_INS_DATASOURCE_MODE nMode )
+MYODBCInsDataSource::MYODBCInsDataSource()
{
MYODBCDbgEnter();
doClear();
// set desired mode
- this->nMode = nMode;
+ nMode = DATASOURCE_MODE_CONNECT;
// get current scope
- UWORD n = MYODBC_INS_DATASOURCE_SCOPE_BOTH;
+ UWORD n = DATASOURCE_SCOPE_BOTH;
- nScope = MYODBC_INS_DATASOURCE_SCOPE_BOTH;
+ nScope = DATASOURCE_SCOPE_BOTH;
SQLGetConfigMode( &n );
- nScope = (MYODBC_INS_DATASOURCE_SCOPE)n;
+ nScope = (DATASOURCE_SCOPE)n;
MYODBCDbgReturn2();
}
@@ -62,24 +60,14 @@
QHash<QString, QString>::const_iterator i = hashAttributes.constBegin();
while ( i != hashAttributes.constEnd() )
{
- this->hashAttributes[i.key()] = i.value();
+ if ( this->hashAttributes[i.key()].isNull() || bReplace )
+ this->hashAttributes[i.key()] = i.value();
++i;
}
MYODBCDbgReturn3( "%d", true )
}
-/*
-bool MYODBCInsDataSource::setDriverFriendlyName( const QString &stringDriverFileName
)
-{
- MYODBCDbgEnter();
-
- this->stringDriverFileName = stringDriverFileName;
-
- MYODBCDbgReturn3( "%d", true )
-}
-*/
-
bool MYODBCInsDataSource::setName( const QString &stringName )
{
MYODBCDbgEnter();
@@ -179,7 +167,7 @@
MYODBCDbgReturn3( "%d", true )
}
-bool MYODBCInsDataSource::setMode( MYODBC_INS_DATASOURCE_MODE nMode )
+bool MYODBCInsDataSource::setMode( DATASOURCE_MODE nMode )
{
MYODBCDbgEnter();
@@ -188,7 +176,7 @@
MYODBCDbgReturn3( "%d", true )
}
-bool MYODBCInsDataSource::setScope( MYODBC_INS_DATASOURCE_SCOPE nScope )
+bool MYODBCInsDataSource::setScope( DATASOURCE_SCOPE nScope )
{
MYODBCDbgEnter();
@@ -283,21 +271,21 @@
MYODBCDbgReturn3( "%s", hashAttributes["OPTION"] );
}
-MYODBC_INS_DATASOURCE_MODE MYODBCInsDataSource::getMode()
+DATASOURCE_MODE MYODBCInsDataSource::getMode()
{
MYODBCDbgEnter();
MYODBCDbgReturn3( "%d", nMode );
}
-MYODBC_INS_DATASOURCE_SCOPE MYODBCInsDataSource::getScope()
+DATASOURCE_SCOPE MYODBCInsDataSource::getScope()
{
MYODBCDbgEnter();
MYODBCDbgReturn3( "%d", nScope );
}
-bool MYODBCInsDataSource::doRead( const QString &stringDataSourceName,
MYODBC_INS_DATASOURCE_SCOPE nScope )
+bool MYODBCInsDataSource::doRead( const QString &stringDataSourceName,
DATASOURCE_SCOPE nScope )
{
MYODBCDbgEnter();
@@ -337,7 +325,7 @@
The solution is to detect this condition and set mode to
ODBC_SYSTEM_DSN and try again. We
also ensure we reset the mode when done - regardless of outcome.
*/
- if ( nScope == MYODBC_INS_DATASOURCE_SCOPE_BOTH && nLen < nChars
&& sEntryNames[nLen + 1 ] == '\0' )
+ if ( nScope == DATASOURCE_SCOPE_BOTH && nLen < nChars &&
sEntryNames[nLen + 1 ] == '\0' )
{
*sEntryNames = '\0';
SQLSetConfigMode( ODBC_SYSTEM_DSN );
@@ -413,7 +401,7 @@
MYODBCDbgReturn3( "%d", bReturn );
}
-bool MYODBCInsDataSource::doWrite( MYODBC_INS_DATASOURCE_SCOPE nScope )
+bool MYODBCInsDataSource::doWrite( DATASOURCE_SCOPE nScope )
{
MYODBCDbgEnter();
Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp 2006-04-21 23:33:57 UTC (rev 95)
@@ -28,8 +28,8 @@
*/
#include "MYODBCInsInternal.h"
-MYODBCInsDriverConnect::MYODBCInsDriverConnect( MYODBC_INS_DRIVERCONNECT_METHOD
nConnectMethod, MYODBC_INS_DRIVERCONNECT_PROMPT nPrompt )
- : MYODBCInsDataSource( MYODBC_INS_DATASOURCE_MODE_CONNECT )
+MYODBCInsDriverConnect::MYODBCInsDriverConnect( DRIVERCONNECT_METHOD nConnectMethod,
DRIVERCONNECT_PROMPT nPrompt )
+ : MYODBCInsDataSource( DATASOURCE_MODE_CONNECT )
{
MYODBCDbgEnter();
@@ -43,108 +43,50 @@
{
MYODBCDbgEnter();
- MYODBC_INS_ATTR_PARSE_STATE nState = MYODBC_INS_ATTR_PARSE_STATE_NAME_START;
- int nAnchorChar = 0;
- int nScanChar = 0;
- QString stringName;
+ QHash<QString,QString> hashKeywordValues;
- /* short circuit if we have not been given stuff to parse */
- if ( stringConnectString.isEmpty() )
+ if ( !MYODBCIns::getKeywordValues( &hashKeywordValues, stringConnectString,
MYODBCIns::DELIM_BOTH ) )
MYODBCDbgReturn3( "%d", false );
- /* scan the input */
- while ( 1 )
+ // extract DRIVER (because it has diff meaning than as data source attribute)
+ QString stringDRIVER;
+ if ( hashKeywordValues.contains( "DRIVER" ) )
{
- switch ( nState )
- {
- case MYODBC_INS_ATTR_PARSE_STATE_NAME_START:
- {
- if ( stringConnectString[nScanChar].isLetter() ||
stringConnectString[nScanChar] == QChar( '{' ) )
- {
- nAnchorChar = nScanChar;
- nState = MYODBC_INS_ATTR_PARSE_STATE_NAME;
- }
- }
- break;
- case MYODBC_INS_ATTR_PARSE_STATE_NAME:
- {
- if ( (!stringConnectString[nScanChar].isLetter() &&
!stringConnectString[nScanChar].isDigit() && stringConnectString[nScanChar] !=
QChar( '}' )) || stringConnectString[nScanChar] == QChar( '=' ) )
- {
- stringName = stringConnectString.mid( nAnchorChar, nScanChar -
nAnchorChar );
+ stringDRIVER = hashKeywordValues["DRIVER"];
+ hashKeywordValues.remove( "DRIVER" );
+ }
- if ( stringConnectString[nScanChar] == QChar( '=' ) )
- nState = MYODBC_INS_ATTR_PARSE_STATE_VALUE_START;
- else
- nState = MYODBC_INS_ATTR_PARSE_STATE_EQUAL;
- }
- }
- break;
- case MYODBC_INS_ATTR_PARSE_STATE_EQUAL:
- {
- if ( stringConnectString[nScanChar] == QChar( '=' ) )
- nState = MYODBC_INS_ATTR_PARSE_STATE_VALUE_START;
- }
- break;
- case MYODBC_INS_ATTR_PARSE_STATE_VALUE_START:
- {
- if ( !stringConnectString[nScanChar].isSpace() )
- {
- nAnchorChar = nScanChar;
- nState = MYODBC_INS_ATTR_PARSE_STATE_VALUE;
- }
- }
- break;
- case MYODBC_INS_ATTR_PARSE_STATE_VALUE:
- {
- /*
- \internal ODBC Rule
+ // extract DSN (because we will assign it to stringName for the underlying data
source)
+ QString stringDSN;
+ if ( hashKeywordValues.contains( "DSN" ) )
+ {
+ stringDSN = hashKeywordValues["DSN"];
+ hashKeywordValues.remove( "DSN" );
+ }
- If any keywords are repeated in the connection string, the driver
uses the value
- associated with the first occurrence of the keyword. If the DSN
and DRIVER keywords
- are included in the same connection string, the Driver Manager
and the driver use
- whichever keyword appears first.
- */
+ // we must have a DRIVER or a DSN
+ if ( stringDRIVER.isEmpty() && stringDSN.isEmpty() )
+ {
+ MYODBCIns::setError( QString( "[%1][%2][ERROR] DRIVER or DSN values need to be
provided." ).arg( __FILE__ ).arg( __LINE__ ) );
+ MYODBCDbgReturn3( "%d", false );
+ }
- /* ';' terminates name/value but we may not find one for last */
- if ( stringConnectString[nScanChar] == QChar( ';' ) || nScanChar ==
stringConnectString.length() )
- {
- if ( stringName == "DSN" &&
hashAttributes["DRIVER"].isNull() )
- {
- }
+ // apply
+ if ( !setAttributes( hashAttributes, true ) )
+ MYODBCDbgReturn3( "%d", false );
- if ( hashAttributes.contains( stringName ) )
- {
- if ( hashAttributes[stringName].isNull() )
- hashAttributes[stringName] = stringConnectString.mid(
nAnchorChar, nScanChar - nAnchorChar );
- }
- else
+ if ( !stringDRIVER.isEmpty() )
+ setConnectMethod( DRIVERCONNECT_METHOD_DRIVER );
+ else
+ setConnectMethod( DRIVERCONNECT_METHOD_DSN );
+ setName( stringDSN );
+ stringDriverFriendlyName = stringDRIVER;
- stringName = QString::null;
- }
- }
- break;
- default:
- MYODBCDbgError( "Unhandled state %d", nState );
- MYODBCDbgReturn3( "%d", false );
- }
-
- /* ';' is used to terminate a name/value pair */
- if ( stringConnectString[nScanChar] == QChar( ';' ) )
- nState = MYODBC_INS_ATTR_PARSE_STATE_NAME_START;
-
- /* have we advanced to end of string */
- if ( nScanChar == stringConnectString.length() )
- break;
-
- nScanChar++;
-
- } /* while scan */
-
MYODBCDbgReturn3( "%d", true );
}
-bool MYODBCInsDriverConnect::setConnectMethod( MYODBC_INS_DRIVERCONNECT_METHOD
nConnectMethod )
+bool MYODBCInsDriverConnect::setConnectMethod( DRIVERCONNECT_METHOD nConnectMethod )
{
MYODBCDbgEnter();
@@ -153,7 +95,7 @@
MYODBCDbgReturn3( "%d", true );
}
-bool MYODBCInsDriverConnect::setPrompt( MYODBC_INS_DRIVERCONNECT_PROMPT nPrompt )
+bool MYODBCInsDriverConnect::setPrompt( DRIVERCONNECT_PROMPT nPrompt )
{
MYODBCDbgEnter();
@@ -168,103 +110,35 @@
QString stringConnect;
- if ( !stringDATABASE.isNull() )
- {
- stringConnect += "DATABASE=";
- stringConnect += stringDATABASE;
- }
+ if ( nConnectMethod == DRIVERCONNECT_METHOD_DRIVER )
+ stringConnect = "DRIVER=" + stringDriverFriendlyName;
+ else
+ stringConnect = "DSN=" + stringName;
- if ( !stringDESCRIPTION.isNull() )
+ QHash<QString, QString>::const_iterator i = hashAttributes.constBegin();
+ while ( i != hashAttributes.constEnd() )
{
- if ( !stringConnect.isEmpty() )
+ if ( !i.value().isNull() ) // empty is ok but skip null
+ {
stringConnect += QChar( ';' );
- stringConnect += "DESCRIPTION=";
- stringConnect += stringDATABASE;
+ stringConnect += i.key();
+ stringConnect += QChar( '=' );
+ stringConnect += i.value();
+ }
+ ++i;
}
- if ( nConnectMethod == MYODBC_INS_DRIVERCONNECT_METHOD_DRIVER )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "DRIVER=";
- stringConnect += stringDRIVER;
- }
-
- if ( nConnectMethod == MYODBC_INS_DRIVERCONNECT_METHOD_DSN )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "DSN=";
- stringConnect += stringDSN;
- }
-
- if ( !stringOPTION.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "OPTION=";
- stringConnect += stringOPTION;
- }
-
- if ( !stringPASSWORD.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "PWD=";
- stringConnect += stringPASSWORD;
- }
-
- if ( !stringPORT.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "PORT=";
- stringConnect += stringPORT;
- }
-
- if ( !stringSERVER.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "SERVER=";
- stringConnect += stringSERVER;
- }
-
- if ( !stringSOCKET.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "SOCKET=";
- stringConnect += stringSOCKET;
- }
-
- if ( !stringSTMT.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "STMT=";
- stringConnect += stringSTMT;
- }
-
- if ( !stringUSER.isNull() )
- {
- if ( !stringConnect.isEmpty() )
- stringConnect += QChar( ';' );
- stringConnect += "UID=";
- stringConnect += stringUSER;
- }
-
MYODBCDbgReturn3( "%s", stringConnect );
}
-MYODBC_INS_DRIVERCONNECT_METHOD MYODBCInsDriverConnect::getConnectMethod()
+MYODBCInsDriverConnect::DRIVERCONNECT_METHOD MYODBCInsDriverConnect::getConnectMethod()
{
MYODBCDbgEnter();
MYODBCDbgReturn3( "%d", nConnectMethod );
}
-MYODBC_INS_DRIVERCONNECT_PROMPT MYODBCInsDriverConnect::getPrompt()
+MYODBCInsDriverConnect::DRIVERCONNECT_PROMPT MYODBCInsDriverConnect::getPrompt()
{
MYODBCDbgEnter();
Modified: MYODBCIns/MYODBCInsLib/MYODBCInsInternal.h
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsInternal.h 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsInternal.h 2006-04-21 23:33:57 UTC (rev 95)
@@ -6,6 +6,7 @@
/* max dsn's we can have in odbc sys info - need to get rid of this limit */
#define MYODBC_INS_MAX_DSN_NAMES 50
+#define MYODBC_INS_ODBCINI_HEADER_SECTION L"ODBC Data Sources"
#endif
Modified: MYODBCIns/include/MYODBCIns.h
===================================================================
--- MYODBCIns/include/MYODBCIns.h 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/include/MYODBCIns.h 2006-04-21 23:33:57 UTC (rev 95)
@@ -74,7 +74,7 @@
PARSE_STATE_NAME_START, /*!< looking for start of name
*/
PARSE_STATE_NAME, /*!< looking for end of name
*/
PARSE_STATE_VALUE_START, /*!< looking for start of value (could be a
'{') */
- PARSE_STATE_VALUE /*!< looking for end of value
*/
+ PARSE_STATE_VALUE, /*!< looking for end of value
*/
PARSE_STATE_VALUE_BRACED /*!< looking for end of braced value (a '}')
*/
} PARSE_STATE;
@@ -82,7 +82,7 @@
static bool setError( const QString &stringMessage, DWORD nErrorCode =
ODBC_ERROR_GENERAL_ERR );
static QStringList getDriverNames();
- static QStringList getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE nScope );
+ static QStringList getDataSourceNames( MYODBCInsDataSource::DATASOURCE_SCOPE nScope
);
static QString getDefaultInstallLocation();
static bool MYODBCIns::getKeywordValues( QHash<QString,QString>
*phashKeywordValues, const QString &stringKeywordValues, DELIM nDelim = DELIM_BOTH );
static RETCODE getError( WORD nError, DWORD *pnErrorCode, QString &stringMessage
);
@@ -91,12 +91,12 @@
static bool doRegisterDriver( const QString &stringName, const QString
&stringAttributes, DWORD *pnUsageCount = NULL );
static bool doDeregisterDriver( const QString &stringName, bool bRemoveDSNs =
false, DWORD *pnUsageCount = NULL );
- static bool doInsertDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope );
- static bool doUpdateDataSource( const QString &stringName, const QString
&stringAttributes, MYODBC_INS_DATASOURCE_SCOPE nScope );
- static bool doDeleteDataSource( const QString &stringName,
MYODBC_INS_DATASOURCE_SCOPE nScope );
+ static bool doInsertDataSource( const QString &stringName, const QString
&stringAttributes, MYODBCInsDataSource::DATASOURCE_SCOPE nScope );
+ static bool doUpdateDataSource( const QString &stringName, const QString
&stringAttributes, MYODBCInsDataSource::DATASOURCE_SCOPE nScope );
+ static bool doDeleteDataSource( const QString &stringName,
MYODBCInsDataSource::DATASOURCE_SCOPE nScope );
static bool isError();
- static bool isExistsDataSourceName( const QString &stringName,
MYODBC_INS_DATASOURCE_SCOPE nScope );
+ static bool isExistsDataSourceName( const QString &stringName,
MYODBCInsDataSource::DATASOURCE_SCOPE nScope );
protected:
static bool isDelim( const QString &stringKeywordValues, int nScanChar, DELIM
*pnDelim );
Modified: MYODBCIns/include/MYODBCInsDataSource.h
===================================================================
--- MYODBCIns/include/MYODBCInsDataSource.h 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/include/MYODBCInsDataSource.h 2006-04-21 23:33:57 UTC (rev 95)
@@ -50,13 +50,13 @@
// create a new DSN
MYODBCIns::doInsertDataSource( "MyDSN",
"SERVER=localhost;DATABASE=db;UID=myid",
- MYODBC_INS_DATASOURCE_SCOPE_USER );
+ DATASOURCE_SCOPE_USER );
// later... edit DSN
- MYODBCInsDataSource ds( MYODBC_INS_DATASOURCE_MODE_DSN_VIEW );
+ MYODBCInsDataSource ds( DATASOURCE_MODE_DSN_VIEW );
- ds.doRead( "MyDSN", MYODBC_INS_DATASOURCE_SCOPE_USER );
+ ds.doRead( "MyDSN", DATASOURCE_SCOPE_USER );
da.setDATABASE( "test" );
- da.doWrite( MYODBC_INS_DATASOURCE_SCOPE_USER );
+ da.doWrite( DATASOURCE_SCOPE_USER );
\endcode
\sa MYODBCIns
@@ -66,33 +66,32 @@
class MYODBCInsDataSource
{
public:
- MYODBCInsDataSource( MYODBC_INS_DATASOURCE_MODE nMode =
MYODBC_INS_DATASOURCE_MODE_CONNECT );
+ MYODBCInsDataSource();
/*!
\brief DSN edit mode.
Reason why we have created a MYODBC_INS_DATASOURCE.
*/
- typedef enum tMYODBC_INS_DATASOURCE_MODE
+ typedef enum tDATASOURCE_MODE
{
- MYODBC_INS_DATASOURCE_MODE_DSN_ADD, /* For ConfigDSN() - ODBC_ADD_DSN.
*/
- MYODBC_INS_DATASOURCE_MODE_DSN_EDIT, /* For ConfigDSN() - ODBC_CONFIG_DSN.
*/
- MYODBC_INS_DATASOURCE_MODE_DSN_VIEW, /* For command-line tools to list DSN
details. */
- MYODBC_INS_DATASOURCE_MODE_CONNECT /* For SQLDriverConnect().
*/
+ DATASOURCE_MODE_DSN_ADD, /* For ConfigDSN() - ODBC_ADD_DSN.
*/
+ DATASOURCE_MODE_DSN_EDIT, /* For ConfigDSN() - ODBC_CONFIG_DSN.
*/
+ DATASOURCE_MODE_DSN_VIEW, /* For command-line tools to list DSN details.
*/
+ DATASOURCE_MODE_CONNECT /* For SQLDriverConnect().
*/
- } MYODBC_INS_DATASOURCE_MODE;
+ } DATASOURCE_MODE;
- typedef enum tMYODBC_INS_DATASOURCE_SCOPE
+ typedef enum tDATASOURCE_SCOPE
{
- MYODBC_INS_DATASOURCE_SCOPE_BOTH = ODBC_BOTH_DSN,
- MYODBC_INS_DATASOURCE_SCOPE_USER = ODBC_USER_DSN,
- MYODBC_INS_DATASOURCE_SCOPE_SYSTEM = ODBC_SYSTEM_DSN
+ DATASOURCE_SCOPE_BOTH = ODBC_BOTH_DSN,
+ DATASOURCE_SCOPE_USER = ODBC_USER_DSN,
+ DATASOURCE_SCOPE_SYSTEM = ODBC_SYSTEM_DSN
- } MYODBC_INS_DATASOURCE_SCOPE;
+ } DATASOURCE_SCOPE;
bool setAttributes( const QHash<QString,QString> &hashAttributes, bool
bReplace = true );
-// bool setDriverFileName( const QString &stringDriverFileName );
bool setName( const QString &stringName );
bool setDRIVER( const QString &stringDRIVER );
bool setDESCRIPTION( const QString &stringDESCRIPTION );
@@ -104,10 +103,9 @@
bool setSOCKET( const QString &stringSOCKET );
bool setSTMT( const QString &stringSTMT );
bool setOPTION( const QString &stringOPTION );
- bool setMode( MYODBC_INS_DATASOURCE_MODE nMode );
- bool setScope( MYODBC_INS_DATASOURCE_SCOPE nScope );
+ bool setMode( DATASOURCE_MODE nMode );
+ bool setScope( DATASOURCE_SCOPE nScope );
-// QString getDriverFileName();
QString getName();
QString getDRIVER();
QString getDESCRIPTION();
@@ -119,13 +117,13 @@
QString getSOCKET();
QString getSTMT();
QString getOPTION();
- MYODBC_INS_DATASOURCE_MODE getMode();
- MYODBC_INS_DATASOURCE_SCOPE getScope();
+ DATASOURCE_MODE getMode();
+ DATASOURCE_SCOPE getScope();
- bool doRead( const QString &stringDataSourceName, MYODBC_INS_DATASOURCE_SCOPE
nScope );
+ bool doRead( const QString &stringDataSourceName, DATASOURCE_SCOPE nScope );
bool doRead( const QString &stringDataSourceName );
bool doRead();
- bool doWrite( MYODBC_INS_DATASOURCE_SCOPE nScope );
+ bool doWrite( DATASOURCE_SCOPE nScope );
bool doWrite();
void doClear();
static bool doDelete( const QString &stringDataSourceName );
@@ -136,13 +134,11 @@
friend QTextStream &operator<<( QTextStream &stream, const
MYODBCInsDataSource &rval );
protected:
-// QString stringDriverFriendlyName;/* Friendly driver name as used in DSN and connect
str. (ie "MySQL ODBC 3.51 Driver (32 bit)") */
-
QString stringName; /*!< DSN (For example; odbc.ini section
name) */
- QHash<QString,QString> hashAttributes; /*!< DSN attributes (for example;
UID, PWD, DATABASE,... */
+ QHash<QString,QString> hashAttributes; /*!< DSN attributes (for example;
DRIVER, UID, PWD, DATABASE,... */
- MYODBC_INS_DATASOURCE_MODE nMode;
- MYODBC_INS_DATASOURCE_SCOPE nScope;
+ DATASOURCE_MODE nMode;
+ DATASOURCE_SCOPE nScope;
};
#endif
Modified: MYODBCIns/include/MYODBCInsDriverConnect.h
===================================================================
--- MYODBCIns/include/MYODBCInsDriverConnect.h 2006-04-21 20:48:26 UTC (rev 94)
+++ MYODBCIns/include/MYODBCInsDriverConnect.h 2006-04-21 23:33:57 UTC (rev 95)
@@ -31,80 +31,68 @@
#include "MYODBCInsDataSource.h"
-/*!
- \brief Delimiter type used for an attribute string.
-
-*/
-typedef enum tMYODBC_INS_DELIM
-{
- MYODBC_INS_DELIM_NULL,
- MYODBC_INS_DELIM_SEMI,
- MYODBC_INS_DELIM_BOTH
-
-} MYODBC_INS_DELIM;
-
-/*!
- \brief Driver connect method.
-
- Used to indicate what is being used to do
- a SQLDriverConnect.
-*/
-typedef enum tMYODBC_INS_DRIVERCONNECT_METHOD
-{
- MYODBC_INS_DRIVERCONNECT_METHOD_DRIVER,
- MYODBC_INS_DRIVERCONNECT_METHOD_DSN
-
-} MYODBC_INS_DRIVERCONNECT_METHOD;
-
-/*!
- \brief Prompting used during SQLDriverConnect.
-
- Could be a SQLUSMALLINT and then standard
- ODBC values such as SQL_DRIVER_PROMPT but there
- are worthwhile advantages to creating this type
- internally such as compiler validation of a
- switch/case and stricter type on func args and
- more understandable code etc.
-*/
-typedef enum tMYODBC_INS_DRIVERCONNECT_PROMPT
-{
- MYODBC_INS_DRIVERCONNECT_PROMPT_PROMPT,
- MYODBC_INS_DRIVERCONNECT_PROMPT_COMPLETE,
- MYODBC_INS_DRIVERCONNECT_PROMPT_REQUIRED,
- MYODBC_INS_DRIVERCONNECT_PROMPT_NOPROMPT
-
-} MYODBC_INS_DRIVERCONNECT_PROMPT;
-
-
class MYODBCInsDriverConnect : public MYODBCInsDataSource
{
public:
- MYODBCInsDriverConnect( MYODBC_INS_DRIVERCONNECT_METHOD nConnectMethod =
MYODBC_INS_DRIVERCONNECT_METHOD_DRIVER,
- MYODBC_INS_DRIVERCONNECT_PROMPT nPrompt =
MYODBC_INS_DRIVERCONNECT_PROMPT_NOPROMPT );
+ /*!
+ \brief Driver connect method.
+
+ Used to indicate what is being used to do
+ a SQLDriverConnect.
+ */
+ typedef enum tDRIVERCONNECT_METHOD
+ {
+ DRIVERCONNECT_METHOD_DRIVER,
+ DRIVERCONNECT_METHOD_DSN
+
+ } DRIVERCONNECT_METHOD;
+
+ /*!
+ \brief Prompting used during SQLDriverConnect.
+
+ Could be a SQLUSMALLINT and then standard
+ ODBC values such as SQL_DRIVER_PROMPT but there
+ are worthwhile advantages to creating this type
+ internally such as compiler validation of a
+ switch/case and stricter type on func args and
+ more understandable code etc.
+ */
+ typedef enum tDRIVERCONNECT_PROMPT
+ {
+ DRIVERCONNECT_PROMPT_PROMPT,
+ DRIVERCONNECT_PROMPT_COMPLETE,
+ DRIVERCONNECT_PROMPT_REQUIRED,
+ DRIVERCONNECT_PROMPT_NOPROMPT
+
+ } DRIVERCONNECT_PROMPT;
+ MYODBCInsDriverConnect( DRIVERCONNECT_METHOD nConnectMethod =
DRIVERCONNECT_METHOD_DRIVER,
+ DRIVERCONNECT_PROMPT nPrompt =
DRIVERCONNECT_PROMPT_NOPROMPT );
+
+
bool setConnectString( const QString &stringConnectString );
- bool setConnectMethod( MYODBC_INS_DRIVERCONNECT_METHOD nConnectMethod );
- bool setPrompt( MYODBC_INS_DRIVERCONNECT_PROMPT nPrompt );
+ bool setConnectMethod( DRIVERCONNECT_METHOD nConnectMethod );
+ bool setPrompt( DRIVERCONNECT_PROMPT nPrompt );
QString getConnectString();
- MYODBC_INS_DRIVERCONNECT_METHOD getConnectMethod();
- MYODBC_INS_DRIVERCONNECT_PROMPT getPrompt();
+ DRIVERCONNECT_METHOD getConnectMethod();
+ DRIVERCONNECT_PROMPT getPrompt();
protected:
- QString stringDriver; /*!< friendly name - we intercept
the DRIVER attribute as it is diffrent than in DSN */
+ QString stringDriverFriendlyName; /*!< friendly name - we intercept the DRIVER
attribute as it is diffrent than in DSN */
- bool setMode( MYODBC_INS_DATASOURCE_MODE ) { return false; }
- bool setScope( MYODBC_INS_DATASOURCE_SCOPE ) { return false; }
+ bool setMode( DATASOURCE_MODE ) { return false; }
+ bool setScope( DATASOURCE_SCOPE ) { return false; }
- MYODBC_INS_DATASOURCE_MODE getMode() { return nMode; }
- MYODBC_INS_DATASOURCE_SCOPE getScope() { return nScope; }
+ DATASOURCE_MODE getMode() { return nMode; }
+ DATASOURCE_SCOPE getScope() { return nScope; }
- bool doWrite( MYODBC_INS_DATASOURCE_SCOPE ) { return false; }
+ bool doWrite( DATASOURCE_SCOPE ) { return false; }
bool doWrite() { return false; }
void doClear() {}
- MYODBC_INS_DRIVERCONNECT_METHOD nConnectMethod; /*!< SQLDriverConnect() using a
DSN or a DRIVER to connect. */
- MYODBC_INS_DRIVERCONNECT_PROMPT nPrompt; /*!< SQLDriverConnect() kind of
prompting (if any). */
+ DRIVERCONNECT_METHOD nConnectMethod; /*!< SQLDriverConnect() using a DSN or a
DRIVER to connect. */
+ DRIVERCONNECT_PROMPT nPrompt; /*!< SQLDriverConnect() kind of prompting (if
any). */
};
| Thread |
|---|
| • Connector/ODBC 5 commit: r95 - in MYODBCIns: MYODBCInsLib include | pharvey | 22 Apr |