📄 sqlapi.h
字号:
// find first instance of substring
int Find(const SAChar *lpszSub) const;
// find first instance of substring starting at zero-based index
int Find(const SAChar *lpszSub, int nStart) const;
// simple formatting
// printf-like formatting using passed string
void Format(const SAChar *lpszFormat, ...);
// printf-like formatting using variable arguments parameter
void FormatV(const SAChar *, va_list argList);
// Access to string implementation buffer as "C" character array
// get pointer to modifiable buffer at least as long as nMinBufLength
SAChar *GetBuffer(int nMinBufLength);
// release buffer, setting length to nNewLength (or to first nul if -1)
void ReleaseBuffer(int nNewLength = -1);
// Use LockBuffer/UnlockBuffer to turn refcounting off
// turn refcounting off
SAChar *LockBuffer();
// turn refcounting back on
void UnlockBuffer();
// Special buffer access routines to manipulate binary data
// get binary data length (in bytes)
int GetBinaryLength() const;
// return pointer to const binary data buffer
operator const void *() const;
// get pointer to modifiable binary data buffer at least as long as nMinBufLengthInBytes
void *GetBinaryBuffer(int nMinBufLengthInBytes);
// release buffer, setting length to nNewLength (or to first nul if -1)
void ReleaseBinaryBuffer(int nNewLengthInBytes);
// Special conversion functions (multibyte <-> Unicode)
#ifdef SA_UNICODE
// return pointer to const multibyte string, convert if needed
const char *GetMultiByteChars() const;
// get string length (in multibyte characters)
int GetMultiByteCharsLength() const;
#define GetWideChars operator const SAChar *
#define GetWideCharsLength GetLength
#else // !SA_UNICODE
#define GetMultiByteChars operator const SAChar *
#define GetMultiByteCharsLength GetLength
// return pointer to const Unicode string, convert if needed
const wchar_t *GetWideChars() const;
// get string length (in Unicode characters)
int GetWideCharsLength() const;
#endif // !SA_UNICODE
// Implementation
public:
~SAString();
protected:
SAChar *m_pchData; // pointer to ref counted string data
// implementation helpers
SAStringData *GetData() const;
void Init();
void AllocBuffer(int nLen);
#ifdef SA_UNICODE
void AssignBinaryCopy(int nSrcLenInBytes, const void *pSrcData);
void ConcatBinaryCopy(int nSrc1LenInBytes, const void *pSrc1Data, int nSrc2LenInBytes, const void *pSrc2Data);
void ConcatBinaryInPlace(int nSrcLen, const void *pData);
#endif // SA_UNICODE
void AssignCopy(int nSrcLen, const SAChar *lpszSrcData);
void ConcatCopy(int nSrc1Len, const SAChar *lpszSrc1Data, int nSrc2Len, const SAChar *lpszSrc2Data);
void ConcatInPlace(int nSrcLen, const SAChar *lpszSrcData);
void CopyBeforeWrite();
void AllocBeforeWrite(int nLen);
void Release();
static void Release(SAStringData *pData);
static int SafeStrlen(const SAChar *lpsz);
static void FreeData(SAStringData *pData);
};
// Compare helpers
bool SQLAPI_API operator==(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator==(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator==(const SAChar *s1, const SAString &s2);
bool SQLAPI_API operator!=(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator!=(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator!=(const SAChar *s1, const SAString &s2);
bool SQLAPI_API operator<(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator<(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator<(const SAChar *s1, const SAString &s2);
bool SQLAPI_API operator>(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator>(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator>(const SAChar *s1, const SAString &s2);
bool SQLAPI_API operator<=(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator<=(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator<=(const SAChar *s1, const SAString &s2);
bool SQLAPI_API operator>=(const SAString &s1, const SAString &s2);
bool SQLAPI_API operator>=(const SAString &s1, const SAChar *s2);
bool SQLAPI_API operator>=(const SAChar *s1, const SAString &s2);
class SQLAPI_API SANull
{
};
class SQLAPI_API SADateTime
{
static int m_saMonthDays[13];
static bool DateFromTm(
unsigned short wYear, unsigned short wMonth, unsigned short wDay,
unsigned short wHour, unsigned short wMinute, unsigned short wSecond,
unsigned long nNanoSecond,
double &dtDest);
static bool TmFromDate(
double dtSrc,
struct tm &tmDest, unsigned long &nNanoSecond);
protected:
void Init_Tm();
struct tm m_tm;
unsigned long m_nFraction; // 0..999999999
int nReserved;
public:
SADateTime();
SADateTime(const SADateTime &other);
SADateTime(const struct tm &tmValue);
operator struct tm &();
operator struct tm() const;
SADateTime(double dt);
operator double() const;
SADateTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec);
int GetYear() const; // year, f.ex., 1999, 2000
int GetMonth() const; // 1..12
int GetDay() const; // 1..31
int GetHour() const; // 0..23
int GetMinute() const; // 0..59
int GetSecond() const; // 0..59
int GetDayOfWeek() const; // 1..7, 1=Sunday, 2=Monday, and so on
int GetDayOfYear() const; // 1..366, where January 1 = 1
unsigned long &Fraction();
unsigned long Fraction() const;
// return the current date/time value
static SADateTime GetCurrentTime();
};
class SQLAPI_API SAPos
{
friend class SACommand;
SAString m_sName;
public:
SAPos(int nByID);
SAPos(const SAString& sByName);
};
class SQLAPI_API saOptions
{
int m_nOptionCount;
SAParam **m_ppOptions;
public:
saOptions();
virtual ~saOptions();
SAString &operator[](const SAString &sOptionName);
SAString operator[](const SAString &sOptionName) const;
};
typedef void (*EnumCursors_t)(ISACursor *, void *);
class SQLAPI_API SAConnection
{
friend class SACommand;
friend class SAField;
friend class SAParam;
friend class ISAConnection;
SAClient_t m_eSAClient;
ISAConnection *m_pISAConnection;
sa_Commands *m_pCommands;
SAIsolationLevel_t m_eIsolationLevel;
SAAutoCommit_t m_eAutoCommit;
saOptions m_Options;
int nReserved;
protected:
void EnumCursors(EnumCursors_t fn, void *pAddlData);
void RegisterCommand(SACommand* pCommand);
void UnRegisterCommand(SACommand* pCommand);
ISACursor *GetISACursor(SACommand* pCommand);
public:
SAConnection();
virtual ~SAConnection();
void setClient(SAClient_t eSAClient);
SAClient_t Client() const;
long ClientVersion() const;
long ServerVersion() const;
SAString ServerVersionString() const;
bool isConnected() const;
void Connect(
const SAString &sDBString,
const SAString &sUserID,
const SAString &sPassword,
SAClient_t eSAClient = SA_Client_NotSpecified);
void Disconnect();
void setIsolationLevel(SAIsolationLevel_t eIsolationLevel);
SAIsolationLevel_t IsolationLevel() const;
void setAutoCommit(SAAutoCommit_t eAutoCommit);
SAAutoCommit_t AutoCommit() const;
void Commit();
void Rollback();
SAString &setOption(const SAString &sOptionName);
SAString Option(const SAString &sOptionName) const;
saAPI *NativeAPI() const;
saConnectionHandles *NativeHandles();
};
class SQLAPI_API SACommand
{
friend class SAConnection;
friend class IibCursor;
friend class IsybCursor;
friend class IssDBLibCursor;
SAConnection *m_pConnection;
SACommandType_t m_eCmdType;
SAString m_sCmd;
bool m_bPrepared;
bool m_bExecuted;
bool m_bFieldsDescribed;
bool m_bSelectBuffersSet;
bool m_bParamsKnown;
int m_nPlaceHolderCount;
saPlaceHolder** m_ppPlaceHolders;
int m_nParamCount;
SAParam **m_ppParams;
int m_nCurParamID;
SAString m_sCurParamName;
int m_nFieldCount;
SAField **m_ppFields;
saOptions m_Options;
int nReserved;
void Init();
SAParam &CreateParam(
const SAString &sName,
SADataType_t eParamType,
int nNativeType,
int nVarSize,
SAParamDirType_t eDirType,
const SAString &sFullName,
int nStart, // param position in SQL statement
int nEnd); // param end position in SQL statemen
void GetParamsSP();
void DescribeFields();
void CreateField(
const SAString &sName,
SADataType_t eFieldType,
int nNativeType,
int nFieldSize,
int nFieldPrecision,
int nFieldScale,
bool bFieldRequired);
void DestroyFields();
// parses sql statement and create bind parameters array if any (In)
// also cancels previous stsement if any
void ParseCmd(
const SAString &sSQL,
SACommandType_t eCmdType);
void UnSetCommandText();
void UnPrepare();
void UnExecute();
public:
SACommand(); // construct command with no associated connection and SQL
SACommand( // construct command based on the given connection and SQL
SAConnection *pConnection,
const SAString &sCmd = SAString(),
SACommandType_t eCmdType = SA_CmdUnknown);
virtual ~SACommand();
SAConnection *Connection();
void setConnection(SAConnection *pConnection);
virtual void Open();
virtual bool isOpened();
virtual void Close();
void setCommandText(
const SAString &sSQL,
SACommandType_t eCmdType = SA_CmdUnknown);
SAString CommandText() const;
SACommandType_t CommandType() const;
virtual void Prepare();
virtual void Execute();
bool isResultSet();
long RowsAffected(); // returns number of rows affected by last DML operation
bool FetchNext(); // returns true if new row is fetched
void Cancel();
SAParam &CreateParam(
const SAString &sName,
SADataType_t eParamType,
int nNativeType,
int nParamSize,
SAParamDirType_t eDirType);
void DestroyParams();
int ParamCount();
SAParam &ParamByIndex(int i); // zero based index of C array
SAParam &Param(int nParamByID); // id in SQL statement, not in C array
SAParam &Param(const SAString& sParamByName);
SACommand &operator << (const SAPos &pos);
SACommand &operator << (const SANull &null);
SACommand &operator << (bool Value);
SACommand &operator << (short Value);
SACommand &operator << (long Value);
SACommand &operator << (float Value);
SACommand &operator << (double Value);
SACommand &operator << (const SADateTime &Value);
SACommand &operator << (const struct tm &Value);
SACommand &operator << (const SAChar *Value); // special overload for string constants
SACommand &operator << (const SAString &Value);
SACommand &operator << (const SABytes &Value);
SACommand &operator << (const SALongBinary &Value);
SACommand &operator << (const SALongChar &Value);
SACommand &operator << (const SABLob &Value);
SACommand &operator << (const SACLob &Value);
int FieldCount();
SAField &Field(int nField); // 1-based field number in result set
SAField &Field(const SAString &sField);
SAField &operator[](int nField); // 1-based field number in result set
SAField &operator[](const SAString &sField);
SAString &setOption(const SAString &sOptionName);
SAString Option(const SAString &sOptionName) const;
saCommandHandles *NativeHandles();
};
class SQLAPI_API SAValueRead
{
friend class ISACursor;
friend class IibCursor;
friend class Iora7Cursor;
friend class Iora8Cursor;
friend class IsbCursor;
friend class IodbcCursor;
friend class IssDBLibCursor;
friend class IssOleDbCursor;
friend class Idb2Cursor;
friend class IinfCursor;
friend class IsybCursor;
friend class ImyCursor;
friend class IpgCursor;
protected:
SALongOrLobReaderModes_t m_eReaderMode;
saLongOrLobReader_t m_fnReader;
unsigned int m_nReaderWantedPieceSize;
void *m_pReaderAddlData;
unsigned char *m_pReaderBuf;
unsigned int m_nReaderAlloc;
unsigned int m_nExpectedSize;
unsigned int m_nReaderRead;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -