Modified:
trunk/SDK/C/Library/MYODBCC.cpp
trunk/SDK/C/include/MYODBCC.h
Log:
Added util functions for dealing with byte array of SQL_NUMERIC_STRUCT
Modified: trunk/SDK/C/Library/MYODBCC.cpp
===================================================================
--- trunk/SDK/C/Library/MYODBCC.cpp 2006-11-15 05:49:38 UTC (rev 675)
+++ trunk/SDK/C/Library/MYODBCC.cpp 2006-11-15 09:09:19 UTC (rev 676)
@@ -2505,6 +2505,40 @@
return str;
}
+void MYODBCC::num_pack( char *str, int val )
+{
+ int i;
+ unsigned char a,b;
+
+ for(i = 0; i < 16; i++)
+ {
+ a = val % 16;
+ b = (val % 256) / 16;
+ val >>= 8;
+ str[i] = (char)(b << 4) | a;
+ }
+}
+
+int MYODBCC::num_unpack( const char *str )
+{
+ int i, off = 1, final = 0;
+ unsigned char x, lsd, msd;
+
+ for(i = 0; i < strlen((char*)str); ++i)
+ {
+ x = str[i];
+ /* get first and second half of char */
+ lsd = x & 0xf;
+ msd = x >> 4;
+
+ final += off * lsd;
+ off <<= 4;
+ final += off * msd;
+ off <<= 4;
+ }
+ return final;
+}
+
BOOL MYODBCC::isConnectAttr( SQLINTEGER nAttribute )
{
switch ( nAttribute )
Modified: trunk/SDK/C/include/MYODBCC.h
===================================================================
--- trunk/SDK/C/include/MYODBCC.h 2006-11-15 05:49:38 UTC (rev 675)
+++ trunk/SDK/C/include/MYODBCC.h 2006-11-15 09:09:19 UTC (rev 676)
@@ -581,10 +581,24 @@
/*@{*/
static int QString_toWString( QString qs, std::wstring *ws );
static int QString_toWCharArray( QString qs, wchar_t *array, int nLenChars = -1 );
- static QString QString_fromWCharArray( const wchar_t *string, int nLenChars = -1 );
+ static QString QString_fromWCharArray( const wchar_t *pwsString, int nLenChars = -1
);
/*@}*/
/*!
+ \name Handle the 'val' member of SQL_NUMERIC_STRUCT.
+
+ Call num_pack to pack the given integer into the byte array
+ of a SQL_NUMERIC_STRUCT and num_unpack to parse the integer
+ from the byte array.
+
+ The string is always 16 bytes long.
+ */
+ /*@{*/
+ static void num_pack( char *str, int val );
+ static int num_unpack( const char *str );
+ /*@}*/
+
+ /*!
\name Method argument/attribute value validators.
These are used to validate that a value is valid - where the value is restricted
to a
| Thread |
|---|
| • Connector/ODBC 5 commit: r676 - in trunk/SDK/C: Library include | jbalint | 15 Nov |