Initial
This commit is contained in:
87
sql/DATAITEM.HPP
Normal file
87
sql/DATAITEM.HPP
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef _SQL_DATAITEM_HPP_
|
||||
#define _SQL_DATAITEM_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common.string.hpp>
|
||||
#endif
|
||||
|
||||
class DataItem
|
||||
{
|
||||
public:
|
||||
DataItem(void);
|
||||
DataItem(const DataItem &someDataItem);
|
||||
DataItem(const String &sourceName,const String &sourceDescription);
|
||||
virtual ~DataItem();
|
||||
DataItem &operator=(const DataItem &someDataItem);
|
||||
WORD operator==(const DataItem &someDataItem);
|
||||
const String &sourceName(void)const;
|
||||
void sourceName(const String &sourceName);
|
||||
const String &sourceDescription(void)const;
|
||||
void sourceDescription(const String &sourceDescription);
|
||||
private:
|
||||
String mSourceName;
|
||||
String mSourceDescription;
|
||||
};
|
||||
|
||||
inline
|
||||
DataItem::DataItem(void)
|
||||
{
|
||||
}
|
||||
|
||||
DataItem::DataItem(const DataItem &someDataItem)
|
||||
{
|
||||
*this=someDataItem;
|
||||
}
|
||||
|
||||
inline
|
||||
DataItem::DataItem(const String &sourceName,const String &sourceDescription)
|
||||
: mSourceName(sourceName), mSourceDescription(sourceDescription)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DataItem::~DataItem()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DataItem &DataItem::operator=(const DataItem &someDataItem)
|
||||
{
|
||||
sourceName(someDataItem.sourceName());
|
||||
sourceDescription(someDataItem.sourceDescription());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DataItem::operator==(const DataItem &someDataItem)
|
||||
{
|
||||
return (sourceName()==someDataItem.sourceName()&&
|
||||
sourceDescription()==someDataItem.sourceDescription());
|
||||
}
|
||||
|
||||
inline
|
||||
const String &DataItem::sourceName(void)const
|
||||
{
|
||||
return mSourceName;
|
||||
}
|
||||
|
||||
inline
|
||||
void DataItem::sourceName(const String &sourceName)
|
||||
{
|
||||
mSourceName=sourceName;
|
||||
}
|
||||
|
||||
inline
|
||||
const String &DataItem::sourceDescription(void)const
|
||||
{
|
||||
return mSourceDescription;
|
||||
}
|
||||
|
||||
inline
|
||||
void DataItem::sourceDescription(const String &sourceDescription)
|
||||
{
|
||||
mSourceDescription=sourceDescription;
|
||||
}
|
||||
#endif
|
||||
70
sql/HDBC.HPP
Normal file
70
sql/HDBC.HPP
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef _SQL_HDBC_HPP_
|
||||
#define _SQL_HDBC_HPP_
|
||||
#ifndef _SQL_SQL_HPP_
|
||||
#include <sql/sql.hpp>
|
||||
#endif
|
||||
|
||||
class HandleDatabase
|
||||
{
|
||||
public:
|
||||
HandleDatabase(void);
|
||||
HandleDatabase(HDBC hDBC);
|
||||
HandleDatabase(const HandleDatabase &someHandleDatabase);
|
||||
~HandleDatabase();
|
||||
HandleDatabase &operator=(const HandleDatabase &someHandleDatabase);
|
||||
HandleDatabase &operator=(HDBC hDBC);
|
||||
WORD operator==(const HandleDatabase &someHandleDatabase)const;
|
||||
operator HDBC(void)const;
|
||||
private:
|
||||
HDBC mhDBC;
|
||||
};
|
||||
|
||||
inline
|
||||
HandleDatabase::HandleDatabase(void)
|
||||
: mhDBC(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase::HandleDatabase(const HandleDatabase &someHandleDatabase)
|
||||
{
|
||||
*this=someHandleDatabase;
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase::HandleDatabase(HDBC hDBC)
|
||||
: mhDBC(hDBC)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase::~HandleDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase &HandleDatabase::operator=(const HandleDatabase &someHandleDatabase)
|
||||
{
|
||||
mhDBC=someHandleDatabase.mhDBC;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase &HandleDatabase::operator=(HDBC hDBC)
|
||||
{
|
||||
mhDBC=hDBC;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD HandleDatabase::operator==(const HandleDatabase &someHandleDatabase)const
|
||||
{
|
||||
return (WORD)(mhDBC==someHandleDatabase.mhDBC);
|
||||
}
|
||||
|
||||
inline
|
||||
HandleDatabase::operator HDBC(void)const
|
||||
{
|
||||
return mhDBC;
|
||||
}
|
||||
#endif
|
||||
71
sql/HENV.HPP
Normal file
71
sql/HENV.HPP
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef _SQL_HENV_HPP_
|
||||
#define _SQL_HENV_HPP_
|
||||
#ifndef _SQL_SQL_HPP_
|
||||
#include <sql/sql.hpp>
|
||||
#endif
|
||||
|
||||
class HandleEnvironment
|
||||
{
|
||||
public:
|
||||
HandleEnvironment(void);
|
||||
HandleEnvironment(HandleEnvironment &someHandleEnvironment);
|
||||
HandleEnvironment(HENV hEnvironment);
|
||||
~HandleEnvironment();
|
||||
HandleEnvironment &operator=(HandleEnvironment &someHandleEnvironment);
|
||||
HandleEnvironment &operator=(HENV hENV);
|
||||
WORD operator==(const HandleEnvironment &someHandleEnvironment)const;
|
||||
operator HENV(void)const;
|
||||
private:
|
||||
HENV mhEnv;
|
||||
};
|
||||
|
||||
inline
|
||||
HandleEnvironment::HandleEnvironment(void)
|
||||
: mhEnv(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment::HandleEnvironment(HandleEnvironment &someHandleEnvironment)
|
||||
{
|
||||
*this=someHandleEnvironment;
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment::HandleEnvironment(HENV hEnvironment)
|
||||
: mhEnv(hEnvironment)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment::~HandleEnvironment()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment &HandleEnvironment::operator=(HandleEnvironment &someHandleEnvironment)
|
||||
{
|
||||
mhEnv=someHandleEnvironment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment &HandleEnvironment::operator=(HENV hEnvironment)
|
||||
{
|
||||
mhEnv=hEnvironment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD HandleEnvironment::operator==(const HandleEnvironment &someHandleEnvironment)const
|
||||
{
|
||||
return (WORD)(mhEnv==someHandleEnvironment.mhEnv);
|
||||
}
|
||||
|
||||
inline
|
||||
HandleEnvironment::operator HENV(void)const
|
||||
{
|
||||
return mhEnv;
|
||||
}
|
||||
#endif
|
||||
|
||||
307
sql/SQL.BAK
Normal file
307
sql/SQL.BAK
Normal file
@@ -0,0 +1,307 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=sql - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to sql - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "sql - Win32 Release" && "$(CFG)" != "sql - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Sql.mak" CFG="sql - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sql - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "sql - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "sql - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\Sql.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\sqldata.obj"
|
||||
-@erase "$(INTDIR)\SQLDB.OBJ"
|
||||
-@erase "$(INTDIR)\SQLSTMT.OBJ"
|
||||
-@erase "$(OUTDIR)\Sql.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/Sql.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Sql.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Sql.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\sqldata.obj" \
|
||||
"$(INTDIR)\SQLDB.OBJ" \
|
||||
"$(INTDIR)\SQLSTMT.OBJ"
|
||||
|
||||
"$(OUTDIR)\Sql.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "msvcobj"
|
||||
# PROP Intermediate_Dir "msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\msvcobj
|
||||
INTDIR=.\msvcobj
|
||||
|
||||
ALL : "..\exe\mssql.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\sqldata.obj"
|
||||
-@erase "$(INTDIR)\SQLDB.OBJ"
|
||||
-@erase "$(INTDIR)\SQLSTMT.OBJ"
|
||||
-@erase "..\exe\mssql.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Zp1 /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /c
|
||||
CPP_PROJ=/nologo /Zp1 /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\msvcobj/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Sql.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssql.lib"
|
||||
LIB32_FLAGS=/nologo /out:"..\exe\mssql.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\sqldata.obj" \
|
||||
"$(INTDIR)\SQLDB.OBJ" \
|
||||
"$(INTDIR)\SQLSTMT.OBJ"
|
||||
|
||||
"..\exe\mssql.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "sql - Win32 Release"
|
||||
# Name "sql - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLSTMT.CPP
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLST=\
|
||||
{$(INCLUDE)}"\.\Hdbc.hpp"\
|
||||
{$(INCLUDE)}"\.\Henv.hpp"\
|
||||
{$(INCLUDE)}"\.\Sql.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlbind.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldata.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldb.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlerror.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlstmt.hpp"\
|
||||
{$(INCLUDE)}"\Common\Assert.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pointer.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLSTMT.OBJ" : $(SOURCE) $(DEP_CPP_SQLST) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLST=\
|
||||
{$(INCLUDE)}"\.\Sqlbind.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlerror.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlstmt.hpp"\
|
||||
{$(INCLUDE)}"\Common\Assert.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLSTMT.OBJ" : $(SOURCE) $(DEP_CPP_SQLST) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLDB.CPP
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLDB=\
|
||||
{$(INCLUDE)}"\.\Hdbc.hpp"\
|
||||
{$(INCLUDE)}"\.\Henv.hpp"\
|
||||
{$(INCLUDE)}"\.\Sql.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldata.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldb.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlerror.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlstmt.hpp"\
|
||||
{$(INCLUDE)}"\Common\Assert.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pointer.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLDB.OBJ" : $(SOURCE) $(DEP_CPP_SQLDB) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLDB=\
|
||||
{$(INCLUDE)}"\.\Hdbc.hpp"\
|
||||
{$(INCLUDE)}"\.\Henv.hpp"\
|
||||
{$(INCLUDE)}"\.\Sql.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldb.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqlerror.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLDB.OBJ" : $(SOURCE) $(DEP_CPP_SQLDB) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sqldata.cpp
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLDA=\
|
||||
{$(INCLUDE)}"\.\Sql.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pointer.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\sqldata.obj" : $(SOURCE) $(DEP_CPP_SQLDA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLDA=\
|
||||
{$(INCLUDE)}"\.\Sql.hpp"\
|
||||
{$(INCLUDE)}"\.\Sqldata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pointer.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\sqldata.obj" : $(SOURCE) $(DEP_CPP_SQLDA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
15
sql/SQL.HPP
Normal file
15
sql/SQL.HPP
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _SQL_SQL_HPP_
|
||||
#define _SQL_SQL_HPP_
|
||||
#ifdef _MSC_VER
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
#else
|
||||
#ifndef WIN32_NT
|
||||
#define WIN32_NT
|
||||
#endif
|
||||
#include <common/windows.hpp>
|
||||
#define _SQL_OS_WINNT
|
||||
#include <sqldef.h>
|
||||
#include <odbc.h>
|
||||
#endif
|
||||
#endif
|
||||
31
sql/SQL.PLG
Normal file
31
sql/SQL.PLG
Normal file
@@ -0,0 +1,31 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: sql - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP41.tmp" with contents
|
||||
[
|
||||
/nologo /MTd /GX /Zi /Od /D "WIN32" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c
|
||||
"D:\work\SQL\sqldata.cpp"
|
||||
"D:\work\SQL\SQLDB.CPP"
|
||||
"D:\work\SQL\SQLSTMT.CPP"
|
||||
]
|
||||
Creating command line "cl.exe @C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP41.tmp"
|
||||
Creating command line "link.exe -lib /nologo /out:"..\exe\mssql.lib" .\msvcobj\sqldata.obj .\msvcobj\SQLDB.OBJ .\msvcobj\SQLSTMT.OBJ "
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
sqldata.cpp
|
||||
SQLDB.CPP
|
||||
SQLSTMT.CPP
|
||||
Creating library...
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
mssql.lib - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
BIN
sql/SQL32.IDE
Normal file
BIN
sql/SQL32.IDE
Normal file
Binary file not shown.
49
sql/SQLBIND.HPP
Normal file
49
sql/SQLBIND.HPP
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef _SQL_SQLBIND_HPP_
|
||||
#define _SQL_SQLBIND_HPP_
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLDATA_HPP_
|
||||
#include <sql/sqldata.hpp>
|
||||
#endif
|
||||
|
||||
class SQLBind
|
||||
{
|
||||
public:
|
||||
SQLBind(void);
|
||||
virtual ~SQLBind();
|
||||
virtual WORD getColumnData(Block<SQLData> &someSQLData)=0;
|
||||
private:
|
||||
SQLBind(const SQLBind &someSQLBind);
|
||||
SQLBind &operator=(const SQLBind &someSQLBind);
|
||||
};
|
||||
|
||||
inline
|
||||
SQLBind::SQLBind(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBind::SQLBind(const SQLBind &/*someSQLBind*/)
|
||||
{ // operation is undefined for this class
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBind::~SQLBind()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBind &SQLBind::operator=(const SQLBind &/*someSQLBind*/)
|
||||
{ // operation is undefined for this class
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLBind::getColumnData(Block<SQLData> &someSQLData)
|
||||
{
|
||||
someSQLData.remove();
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
50
sql/SQLDATA.CPP
Normal file
50
sql/SQLDATA.CPP
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <sql/sqldata.hpp>
|
||||
|
||||
SQLString SQLData::toString(void)
|
||||
{
|
||||
SQLString stringData;
|
||||
|
||||
if(!mSqlData.isOkay())return stringData;
|
||||
switch(type())
|
||||
{
|
||||
case SQLDataBit :
|
||||
case SQLDataVarChar :
|
||||
case SQLDataLongVarChar :
|
||||
case SQLDataCChar :
|
||||
return (char*)(BYTE*)mSqlData;
|
||||
case SQLDataCLong :
|
||||
case SQLDataBigInt :
|
||||
case SQLDataLongVarBinary :
|
||||
::sprintf(stringData,"%ld",*((long*)(BYTE*)mSqlData));
|
||||
return stringData;
|
||||
case SQLDataCShort :
|
||||
case SQLDataTinyInt :
|
||||
::sprintf(stringData,"%d",*((short*)(BYTE*)mSqlData));
|
||||
return stringData;
|
||||
case SQLDataCFloat :
|
||||
case SQLDataFloat :
|
||||
::sprintf(stringData,"%lf",*((float*)(BYTE*)mSqlData));
|
||||
return stringData;
|
||||
case SQLDataCDouble :
|
||||
::sprintf(stringData,"%lf",*((double*)(BYTE*)mSqlData));
|
||||
return stringData;
|
||||
case SQLDataTimeStamp :
|
||||
handleTimeStamp(stringData);
|
||||
break;
|
||||
case SQLDataDate :
|
||||
case SQLDataTime :
|
||||
case SQLDataBinary :
|
||||
case SQLDataDecimal :
|
||||
case SQLDataNumeric :
|
||||
case SQLDataVarBinary :
|
||||
break;
|
||||
}
|
||||
return stringData;
|
||||
}
|
||||
|
||||
void SQLData::handleTimeStamp(String &stringData)
|
||||
{
|
||||
TIMESTAMP_STRUCT *pTimeStamp=(TIMESTAMP_STRUCT*)(BYTE*)mSqlData;
|
||||
::sprintf(stringData,"%04d-%02d-%02d %02d:%02d:%02d.%09d",
|
||||
pTimeStamp->year,pTimeStamp->month,pTimeStamp->day,pTimeStamp->hour,pTimeStamp->minute,pTimeStamp->second,pTimeStamp->fraction);
|
||||
}
|
||||
215
sql/SQLDATA.HPP
Normal file
215
sql/SQLDATA.HPP
Normal file
@@ -0,0 +1,215 @@
|
||||
#ifndef _SQL_SQLDATA_HPP_
|
||||
#define _SQL_SQLDATA_HPP_
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLSTRING_HPP_
|
||||
#include <sql/sqlstring.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQL_HPP_
|
||||
#include <sql/sql.hpp>
|
||||
#endif
|
||||
|
||||
class SQLData
|
||||
{
|
||||
public:
|
||||
enum DataType{SQLDataCChar=SQL_C_CHAR,
|
||||
SQLDataCLong=SQL_C_LONG,
|
||||
SQLDataCShort=SQL_C_SHORT,
|
||||
SQLDataCFloat=SQL_C_FLOAT,
|
||||
SQLDataCDouble=SQL_C_DOUBLE,
|
||||
SQLDataDate=SQL_DATE,
|
||||
SQLDataTime=SQL_TIME,
|
||||
SQLDataTimeStamp=SQL_TIMESTAMP,
|
||||
SQLDataLongVarChar=SQL_LONGVARCHAR,
|
||||
SQLDataBigInt=SQL_BIGINT,
|
||||
SQLDataBinary=SQL_BINARY,
|
||||
SQLDataBit=SQL_BIT,
|
||||
SQLDataChar=SQL_CHAR,
|
||||
SQLDataDecimal=SQL_DECIMAL,
|
||||
SQLDataDouble=SQL_DOUBLE,
|
||||
SQLDataFloat=SQL_FLOAT,
|
||||
SQLDataInteger=SQL_INTEGER,
|
||||
SQLDataLongVarBinary=SQL_LONGVARBINARY,
|
||||
SQLDataNumeric=SQL_NUMERIC,
|
||||
SQLDataReal=SQL_REAL,
|
||||
SQLDataSmallInt=SQL_SMALLINT,
|
||||
SQLTimeStamp=SQL_TIMESTAMP,
|
||||
SQLDataTinyInt=SQL_TINYINT,
|
||||
SQLDataVarBinary=SQL_VARBINARY,
|
||||
SQLDataVarChar=SQL_VARCHAR};
|
||||
enum Disposition{Assume,Delete};
|
||||
SQLData(void);
|
||||
SQLData(DWORD sizeData,DataType typeData);
|
||||
SQLData(SmartPointer<BYTE> &sqlData,DWORD sizeData,DataType typeData);
|
||||
SQLData(const SQLData &somePureData);
|
||||
virtual ~SQLData();
|
||||
WORD operator==(const SQLData &someSQLData)const;
|
||||
SQLData &operator=(const SQLData &someSQLData);
|
||||
DWORD size(void)const;
|
||||
void size(DWORD sizeData);
|
||||
void type(DataType typeData);
|
||||
DataType type(void)const;
|
||||
const String &name(void)const;
|
||||
void name(const String &name);
|
||||
LONG *resultLength(void);
|
||||
SmartPointer<BYTE> &sqlData(void);
|
||||
void sqlData(const SmartPointer<BYTE> &sqlData);
|
||||
SQLString toString(void);
|
||||
int toInt(void);
|
||||
bool toBool(void);
|
||||
float toFloat(void);
|
||||
double toDouble(void);
|
||||
private:
|
||||
void handleTimeStamp(String &stringData);
|
||||
|
||||
SmartPointer<BYTE> mSqlData;
|
||||
DWORD mSizeData;
|
||||
DataType mDataType;
|
||||
LONG mResultLength;
|
||||
String mNameData;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLData::SQLData(void)
|
||||
: mSizeData(0), mDataType(SQLDataChar), mResultLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData::SQLData(DWORD sizeData,DataType typeData)
|
||||
: mSizeData(sizeData), mDataType(typeData), mResultLength(0)
|
||||
{
|
||||
mSqlData=new BYTE[sizeData];
|
||||
::memset((BYTE*)mSqlData,0,sizeData);
|
||||
mSqlData.disposition(PointerDisposition::Delete);
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData::SQLData(SmartPointer<BYTE> &sqlData,DWORD sizeData,DataType typeData)
|
||||
: mResultLength(0)
|
||||
{
|
||||
mSqlData=sqlData;
|
||||
size(sizeData);
|
||||
type(typeData);
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData::SQLData(const SQLData &someSQLData)
|
||||
: mSizeData(someSQLData.mSizeData), mDataType(someSQLData.mDataType), mResultLength(someSQLData.mResultLength)
|
||||
{
|
||||
*this=someSQLData;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData::~SQLData()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLData::operator==(const SQLData &someSQLData)const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData &SQLData::operator=(const SQLData &someSQLData)
|
||||
{
|
||||
size(someSQLData.size());
|
||||
type(someSQLData.type());
|
||||
sqlData(((SQLData&)someSQLData).sqlData());
|
||||
name(someSQLData.name());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD SQLData::size()const
|
||||
{
|
||||
return mSizeData;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLData::size(DWORD size)
|
||||
{
|
||||
mSizeData=size;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLData::DataType SQLData::type(void)const
|
||||
{
|
||||
return mDataType;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLData::type(DataType type)
|
||||
{
|
||||
mDataType=type;
|
||||
}
|
||||
|
||||
inline
|
||||
const String &SQLData::name(void)const
|
||||
{
|
||||
return mNameData;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLData::name(const String &name)
|
||||
{
|
||||
mNameData=name;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG *SQLData::resultLength(void)
|
||||
{
|
||||
return &mResultLength;
|
||||
}
|
||||
|
||||
inline
|
||||
SmartPointer<BYTE> &SQLData::sqlData(void)
|
||||
{
|
||||
return mSqlData;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLData::sqlData(const SmartPointer<BYTE> &sqlData)
|
||||
{
|
||||
mSqlData=sqlData;
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLData::toBool(void)
|
||||
{
|
||||
if(!mSqlData.isOkay())return false;
|
||||
return *((BYTE*)mSqlData)&0x01;
|
||||
}
|
||||
|
||||
inline
|
||||
int SQLData::toInt(void)
|
||||
{
|
||||
if(!mSqlData.isOkay())return 0;
|
||||
return *((int*)(BYTE*)mSqlData);
|
||||
}
|
||||
|
||||
inline
|
||||
float SQLData::toFloat(void)
|
||||
{
|
||||
if(!mSqlData.isOkay())return 0.00;
|
||||
return *((float*)(BYTE*)mSqlData);
|
||||
}
|
||||
|
||||
inline
|
||||
double SQLData::toDouble(void)
|
||||
{
|
||||
if(!mSqlData.isOkay())return 0.00;
|
||||
return *((double*)(BYTE*)mSqlData);
|
||||
}
|
||||
#endif
|
||||
81
sql/SQLDB.CPP
Normal file
81
sql/SQLDB.CPP
Normal file
@@ -0,0 +1,81 @@
|
||||
#include <sql/sqldb.hpp>
|
||||
#include <sql/sqlerror.hpp>
|
||||
|
||||
SQLDb::SQLDb(const String &nameData,const String &userID,const String &password)
|
||||
: mhEnvironment(0), mhConnection(0), mIsOkay(FALSE), mNameData(nameData), mUserID(userID),
|
||||
mPassword(password), mDisposition(InvalidDB)
|
||||
{
|
||||
if(mPassword.isNull())mPassword=" ";
|
||||
open();
|
||||
}
|
||||
|
||||
SQLDb::~SQLDb()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
SQLDb &SQLDb::operator=(const SQLDb &someSQLDb)
|
||||
{
|
||||
close();
|
||||
mhEnvironment=someSQLDb.mhEnvironment;
|
||||
mhConnection=someSQLDb.mhConnection;
|
||||
mNameData=someSQLDb.mNameData;
|
||||
mUserID=someSQLDb.mUserID;
|
||||
mPassword=someSQLDb.mPassword;
|
||||
mIsOkay=someSQLDb.mIsOkay;
|
||||
mDisposition=AssumeDB;
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD SQLDb::open(const String &nameData,const String &userID,const String &password)
|
||||
{
|
||||
close();
|
||||
mNameData=nameData;
|
||||
mUserID=userID;
|
||||
mPassword=password;
|
||||
return open();
|
||||
}
|
||||
|
||||
WORD SQLDb::open(void)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
close();
|
||||
if(SQL_SUCCESS!=::SQLAllocEnv((HENV*)&mhEnvironment))return FALSE;
|
||||
if(SQL_SUCCESS!=::SQLAllocConnect(mhEnvironment,(HDBC*)&mhConnection)){::SQLFreeEnv(mhEnvironment);return FALSE;}
|
||||
sqlReturn=::SQLConnect(mhConnection,(unsigned char*)((char*)mNameData),SQL_NTS,(unsigned char*)((char*)mUserID),SQL_NTS,(unsigned char*)((char*)mPassword),SQL_NTS);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)
|
||||
{
|
||||
sqlReturn=::SQLConnect(mhConnection,(unsigned char*)((char*)mNameData),SQL_NTS,(unsigned char*)((char*)mUserID),SQL_NTS,(unsigned char*)((char*)mPassword),SQL_NTS);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)
|
||||
{
|
||||
::SQLFreeConnect(&mhConnection);
|
||||
::SQLFreeEnv(mhEnvironment);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
mDisposition=CloseDB;
|
||||
return (mIsOkay=TRUE);
|
||||
}
|
||||
|
||||
WORD SQLDb::close(void)
|
||||
{
|
||||
if(!mIsOkay)return FALSE;
|
||||
if(CloseDB==mDisposition)
|
||||
{
|
||||
__try{if(mhConnection){::SQLDisconnect(mhConnection);::SQLFreeConnect(mhConnection);mhConnection=0;}}
|
||||
__except(0,EXCEPTION_EXECUTE_HANDLER){mIsOkay=FALSE;mDisposition=InvalidDB;return FALSE;}
|
||||
}
|
||||
mIsOkay=FALSE;
|
||||
mDisposition=InvalidDB;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD SQLDb::transact(TransactType transactType)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
sqlReturn=::SQLTransact(mhEnvironment,mhConnection,(UINT)transactType);
|
||||
if(SQL_SUCCESS!=sqlReturn||SQL_SUCCESS_WITH_INFO!=sqlReturn)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
106
sql/SQLDB.HPP
Normal file
106
sql/SQLDB.HPP
Normal file
@@ -0,0 +1,106 @@
|
||||
#ifndef _SQL_SQLDB_HPP_
|
||||
#define _SQL_SQLDB_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_HDBC_HPP_
|
||||
#include <sql/hdbc.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_HENV_HPP_
|
||||
#include <sql/henv.hpp>
|
||||
#endif
|
||||
|
||||
class SQLDb
|
||||
{
|
||||
public:
|
||||
enum TransactType{TransactCommit=SQL_COMMIT,TransactRollback=SQL_ROLLBACK};
|
||||
SQLDb(void);
|
||||
SQLDb(const String &nameData,const String &userID,const String &password);
|
||||
SQLDb(HENV hEnvironment,HDBC hConnection);
|
||||
SQLDb(const SQLDb &someSQLDb);
|
||||
virtual ~SQLDb();
|
||||
SQLDb &operator=(const SQLDb &someSQLDb);
|
||||
operator HandleDatabase(void)const;
|
||||
operator HandleEnvironment(void)const;
|
||||
WORD open(const String &nameData,const String &userID,const String &password);
|
||||
WORD transact(TransactType transactType);
|
||||
WORD close(void);
|
||||
WORD isOkay(void)const;
|
||||
WORD isAssigned(void)const;
|
||||
String nameData(void)const;
|
||||
String userID(void)const;
|
||||
String password(void)const;
|
||||
private:
|
||||
enum Disposition{AssumeDB,CloseDB,InvalidDB};
|
||||
WORD open(void);
|
||||
Disposition mDisposition;
|
||||
HandleEnvironment mhEnvironment;
|
||||
HandleDatabase mhConnection;
|
||||
WORD mIsOkay;
|
||||
String mNameData;
|
||||
String mUserID;
|
||||
String mPassword;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(void)
|
||||
: mDisposition(InvalidDB), mhEnvironment(0), mhConnection(0), mIsOkay(FALSE),
|
||||
mNameData("UNSET"), mUserID("UNSET"), mPassword("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(HENV hEnvironment,HDBC hConnection)
|
||||
: mhEnvironment(hEnvironment), mhConnection(hConnection), mDisposition(AssumeDB),
|
||||
mIsOkay(TRUE), mNameData("UNSET"), mUserID("UNSET"), mPassword("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::SQLDb(const SQLDb &someSQLDb)
|
||||
{
|
||||
*this=someSQLDb;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::operator HandleDatabase(void)const
|
||||
{
|
||||
return mhConnection;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDb::operator HandleEnvironment(void)const
|
||||
{
|
||||
return mhEnvironment;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLDb::isAssigned(void)const
|
||||
{
|
||||
return (AssumeDB==mDisposition);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLDb::isOkay(void)const
|
||||
{
|
||||
return mIsOkay;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::nameData(void)const
|
||||
{
|
||||
return mNameData;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::userID(void)const
|
||||
{
|
||||
return mUserID;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLDb::password(void)const
|
||||
{
|
||||
return mPassword;
|
||||
}
|
||||
#endif
|
||||
12
sql/SQLDBND.HPP
Normal file
12
sql/SQLDBND.HPP
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _SQL_SQLDYNAMICBIND_HPP_
|
||||
#define _SQL_SQLDYNAMICBIND_HPP_
|
||||
#ifndef _SQL_SQLDATA_HPP_
|
||||
#include <sql/sqldata.hpp>
|
||||
#endif
|
||||
|
||||
class SQLDynamicBind : public Block<SQLData>
|
||||
{
|
||||
public:
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
61
sql/SQLDSN.HPP
Normal file
61
sql/SQLDSN.HPP
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef _SQL_DATASOURCE_HPP_
|
||||
#define _SQL_DATASOURCE_HPP_
|
||||
#ifndef _SQL_DATAITEM_HPP_
|
||||
#include <sql/dataitem.hpp>
|
||||
#endif
|
||||
|
||||
class DataSource
|
||||
{
|
||||
public:
|
||||
enum Fetch{First=SQL_FETCH_FIRST,Next=SQL_FETCH_NEXT};
|
||||
DataSource(HandleEnvironment &handleEnvironment);
|
||||
virtual ~DataSource();
|
||||
WORD sourceFirst(DataItem &someDataItem);
|
||||
WORD sourceNext(DataItem &someDataItem);
|
||||
private:
|
||||
WORD sourceName(DataItem &someDataItem,Fetch sourceFetch);
|
||||
HandleEnvironment &mhEnvironment;
|
||||
};
|
||||
|
||||
inline
|
||||
DataSource::DataSource(HandleEnvironment &handleEnvironment)
|
||||
: mhEnvironment(handleEnvironment)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DataSource::~DataSource()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DataSource::sourceFirst(DataItem &someDataItem)
|
||||
{
|
||||
return sourceName(someDataItem,First);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DataSource::sourceNext(DataItem &someDataItem)
|
||||
{
|
||||
return sourceName(someDataItem,Next);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DataSource::sourceName(DataItem &someDataItem,Fetch sourceFetch)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
UCHAR sourceName[SQL_MAX_DSN_LENGTH+1];
|
||||
UCHAR sourceDescription[1024];
|
||||
SWORD cbNameLength(sizeof(sourceName));
|
||||
SWORD cbDescriptionLength(sizeof(sourceDescription));
|
||||
SWORD outNameLength;
|
||||
SWORD outDescriptionLength;
|
||||
|
||||
sqlReturn=::SQLDataSources(mhEnvironment,sourceFetch,sourceName,cbNameLength,&outNameLength,sourceDescription,cbDescriptionLength,&outDescriptionLength);
|
||||
if(sqlReturn!=SQL_SUCCESS&&sqlReturn!=SQL_SUCCESS_WITH_INFO)return TRUE;
|
||||
someDataItem.sourceName((char*)sourceName);
|
||||
someDataItem.sourceDescription((char*)sourceDescription);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
63
sql/SQLERROR.HPP
Normal file
63
sql/SQLERROR.HPP
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _SQL_ERROR_HPP_
|
||||
#define _SQL_ERROR_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLSTATEMENT_HPP_
|
||||
#include <sql/sqlstmt.hpp>
|
||||
#endif
|
||||
|
||||
class SQLErr
|
||||
{
|
||||
public:
|
||||
SQLErr(void);
|
||||
virtual ~SQLErr();
|
||||
void sqlErr(const SQLStatement &sqlStatement);
|
||||
void sqlErr(const SQLStatement &sqlStatement,String &strResult);
|
||||
void sqlErr(void);
|
||||
private:
|
||||
enum {MaxErrorLength=512};
|
||||
};
|
||||
|
||||
inline
|
||||
SQLErr::SQLErr(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLErr::~SQLErr()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLErr::sqlErr(const SQLStatement &sqlStatement)
|
||||
{
|
||||
String sqlMessageString;
|
||||
SWORD outlen;
|
||||
|
||||
sqlMessageString.reserve(MaxErrorLength+1);
|
||||
::SQLError(0,0,(SQLStatement&)sqlStatement,0,0,(UCHAR*)(LPSTR)sqlMessageString,MaxErrorLength,&outlen);
|
||||
::MessageBox(::GetFocus(),(LPSTR)sqlMessageString,(LPSTR)"SQLERROR",MB_OK);
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLErr::sqlErr(const SQLStatement &sqlStatement,String &strResult)
|
||||
{
|
||||
SWORD outlen;
|
||||
|
||||
strResult.reserve(MaxErrorLength+1);
|
||||
::SQLError(0,0,(SQLStatement&)sqlStatement,0,0,(UCHAR*)(LPSTR)strResult,MaxErrorLength,&outlen);
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLErr::sqlErr(void)
|
||||
{
|
||||
String sqlMessageString;
|
||||
String sqlState;
|
||||
SWORD outlen;
|
||||
|
||||
sqlMessageString.reserve(MaxErrorLength+1);
|
||||
::SQLError(0,0,0,(UCHAR*)(LPSTR)sqlState,0,(UCHAR*)(LPSTR)sqlMessageString,MaxErrorLength,&outlen);
|
||||
::MessageBox(::GetFocus(),(LPSTR)sqlState,(LPSTR)"SQLERROR",MB_OK);
|
||||
}
|
||||
#endif
|
||||
107
sql/SQLFloat.hpp
Normal file
107
sql/SQLFloat.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef _SQL_SQLFLOAT_HPP_
|
||||
#define _SQL_SQLFLOAT_HPP_
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLSTRING_HPP_
|
||||
#include <sql/sqlstring.hpp>
|
||||
#endif
|
||||
|
||||
class SQLFloat
|
||||
{
|
||||
public:
|
||||
SQLFloat(void);
|
||||
SQLFloat(float someFloat);
|
||||
SQLFloat &operator=(float value);
|
||||
bool operator==(const SQLFloat &someSQLFloat)const;
|
||||
bool operator<(const SQLFloat &someSQLFloat)const;
|
||||
bool operator>(const SQLFloat &someSQLFloat)const;
|
||||
SQLFloat operator*(const SQLFloat &someSQLFloat)const;
|
||||
SQLFloat operator/(const SQLFloat &someSQLFloat)const;
|
||||
SQLFloat operator+(const SQLFloat &someSQLFloat)const;
|
||||
float getValue(void)const;
|
||||
void setValue(float value);
|
||||
SQLString toString(void)const;
|
||||
private:
|
||||
float mData;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLFloat::SQLFloat(void)
|
||||
: mData(0.00)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLFloat::SQLFloat(float someFloat)
|
||||
: mData(someFloat)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLFloat &SQLFloat::operator=(float value)
|
||||
{
|
||||
mData=value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLFloat::operator==(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
return getValue()==someSQLFloat.getValue();
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLFloat::operator<(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
return mData<someSQLFloat.mData;
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLFloat::operator>(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
return mData>someSQLFloat.mData;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLFloat SQLFloat::operator*(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
return getValue()*someSQLFloat.getValue();
|
||||
}
|
||||
|
||||
inline
|
||||
SQLFloat SQLFloat::operator/(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
if(0.00==someSQLFloat.getValue())return 0.00;
|
||||
return getValue()/someSQLFloat.getValue();
|
||||
}
|
||||
|
||||
inline
|
||||
SQLFloat SQLFloat::operator+(const SQLFloat &someSQLFloat)const
|
||||
{
|
||||
return getValue()+someSQLFloat.getValue();
|
||||
}
|
||||
|
||||
inline
|
||||
float SQLFloat::getValue(void)const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLFloat::setValue(float value)
|
||||
{
|
||||
mData=value;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString SQLFloat::toString(void)const
|
||||
{
|
||||
SQLString strString;
|
||||
::sprintf(strString,"%lf",mData);
|
||||
return strString;
|
||||
}
|
||||
#endif
|
||||
163
sql/SQLSTMT.CPP
Normal file
163
sql/SQLSTMT.CPP
Normal file
@@ -0,0 +1,163 @@
|
||||
#include <sql/sqlstmt.hpp>
|
||||
#include <sql/sqlerror.hpp>
|
||||
#include <sql/sqlbind.hpp>
|
||||
#include <common/block.hpp>
|
||||
|
||||
SQLStatement::SQLStatement(void)
|
||||
: mIsOkay(FALSE), mhStatement(FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
SQLStatement::SQLStatement(SQLDb &someSQLDb,SQLBind &sqlBind)
|
||||
: mIsOkay(FALSE), mhStatement(FALSE), mSQLDb(someSQLDb)
|
||||
{
|
||||
sqlBind.getColumnData(mSQLColumnData);
|
||||
open();
|
||||
}
|
||||
|
||||
SQLStatement::SQLStatement(SQLDb &someSQLDb)
|
||||
: mIsOkay(FALSE), mhStatement(FALSE), mSQLDb(someSQLDb)
|
||||
{
|
||||
open();
|
||||
}
|
||||
|
||||
SQLStatement::~SQLStatement()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
SQLStatement &SQLStatement::operator=(const SQLDb &someSQLDb)
|
||||
{
|
||||
close();
|
||||
mSQLDb=someSQLDb;
|
||||
open();
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOL SQLStatement::executeDirect(const String &sqlStatementString)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
sqlReturn=SQLExecDirect(mhStatement,(UCHAR*)(LPSTR)(String&)sqlStatementString,SQL_NTS);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)
|
||||
{SQLErr sqlError;sqlError.sqlErr(*this);return FALSE;}
|
||||
for(int index=0;index<mSQLColumnData.size();index++)
|
||||
::SQLBindCol(mhStatement,(UWORD)(index+1),(SWORD)mSQLColumnData[index].type(),(PTR)(BYTE*)mSQLColumnData[index].sqlData(),(SDWORD)mSQLColumnData[index].size(),(SDWORD FAR*)mSQLColumnData[index].resultLength());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SQLStatement::executeDirect(const String &sqlStatementString,String &strResult)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
sqlReturn=SQLExecDirect(mhStatement,(UCHAR*)(LPSTR)(String&)sqlStatementString,SQL_NTS);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)
|
||||
{
|
||||
SQLErr sqlError;
|
||||
sqlError.sqlErr(*this,strResult);
|
||||
return FALSE;
|
||||
}
|
||||
for(int index=0;index<mSQLColumnData.size();index++)
|
||||
::SQLBindCol(mhStatement,(UWORD)(index+1),(SWORD)mSQLColumnData[index].type(),(PTR)(BYTE*)mSQLColumnData[index].sqlData(),(SDWORD)mSQLColumnData[index].size(),(SDWORD FAR*)mSQLColumnData[index].resultLength());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD SQLStatement::fetch(bool silent)const
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
if(!isOkay()||!mSQLColumnData.size())return FALSE;
|
||||
sqlReturn=::SQLFetch(mhStatement);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)return FALSE;
|
||||
if(SQL_SUCCESS_WITH_INFO==sqlReturn&&!silent){SQLErr sqlError;sqlError.sqlErr(*this);}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int SQLStatement::rowCount(void)const
|
||||
{
|
||||
SQLINTEGER rows(0);
|
||||
|
||||
if(!isOkay())return rows;
|
||||
::SQLRowCount(mhStatement,&rows);
|
||||
return rows;
|
||||
}
|
||||
|
||||
WORD SQLStatement::tables(String database,String owner,String name,String type)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
if(database.isNull()&&owner.isNull()&&name.isNull()&&type.isNull())type="TABLE";
|
||||
sqlReturn=::SQLTables(mhStatement,(BYTE*)0,SQL_NTS,(BYTE*)0,SQL_NTS,(BYTE*)0,SQL_NTS,(BYTE*)(LPSTR)type,SQL_NTS);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)return FALSE;
|
||||
for(int index=0;index<mSQLColumnData.size();index++)
|
||||
::SQLBindCol(mhStatement,(UWORD)(index+1),(SWORD)mSQLColumnData[index].type(),(PTR)(BYTE*)mSQLColumnData[index].sqlData(),(SDWORD)mSQLColumnData[index].size(),(SDWORD FAR*)mSQLColumnData[index].resultLength());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD SQLStatement::cancel(void)const
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
sqlReturn=::SQLCancel(mhStatement);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD SQLStatement::sqlResults(void)
|
||||
{
|
||||
RETCODE sqlReturn;
|
||||
SWORD numCols;
|
||||
SWORD colNameLength;
|
||||
SWORD sqlDataType;
|
||||
SWORD scaleCol;
|
||||
SWORD nullAllowed;
|
||||
DWORD colPrecision;
|
||||
char strColName[MaxColName];
|
||||
|
||||
mSQLColumnData.remove();
|
||||
sqlReturn=::SQLNumResultCols(mhStatement,&numCols);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)return FALSE;
|
||||
for(int colIndex=0;colIndex<numCols;colIndex++)
|
||||
{
|
||||
sqlReturn=::SQLDescribeCol(mhStatement,colIndex+1,(BYTE*)strColName,sizeof(strColName)-1,&colNameLength,&sqlDataType,&colPrecision,&scaleCol,&nullAllowed);
|
||||
if(SQL_SUCCESS!=sqlReturn&&SQL_SUCCESS_WITH_INFO!=sqlReturn)break;
|
||||
if(-1==sqlDataType)
|
||||
{
|
||||
String strDebug;
|
||||
strDebug=String("Encountered bad type for column '")+String(strColName)+String("', skipping column.\n");
|
||||
::OutputDebugString(strDebug);
|
||||
continue;
|
||||
}
|
||||
if(SQLData::SQLDataLongVarBinary==(SQLData::DataType)sqlDataType)colPrecision=MaxImageLength;
|
||||
SQLData sqlData(colPrecision+1,(SQLData::DataType)sqlDataType);
|
||||
sqlData.sqlData().disposition(PointerDisposition::Assume);
|
||||
mSQLColumnData.insert(&sqlData);
|
||||
DWORD colIndex(mSQLColumnData.size()-1);
|
||||
if(SQLData::SQLDataVarChar==(SQLData::DataType)sqlDataType)sqlDataType=(int)SQLData::SQLDataCChar;
|
||||
else if(SQLData::SQLDataLongVarChar==(SQLData::DataType)sqlDataType)sqlDataType=(int)SQLData::SQLDataCChar;
|
||||
else if(SQLData::SQLDataLongVarBinary==(SQLData::DataType)sqlDataType)sqlDataType=(int)SQL_C_BINARY; //SQLData::SQLDataCChar;
|
||||
else if(SQLData::SQLDataFloat==(SQLData::DataType)sqlDataType)sqlDataType=(int)SQLData::SQLDataCFloat;
|
||||
mSQLColumnData[colIndex].sqlData().disposition(PointerDisposition::Delete);
|
||||
mSQLColumnData[colIndex].size(colPrecision+1);
|
||||
mSQLColumnData[colIndex].type((SQLData::DataType)sqlDataType);
|
||||
mSQLColumnData[colIndex].name(strColName);
|
||||
BYTE *ptrData=(BYTE*)mSQLColumnData[colIndex].sqlData();
|
||||
sqlReturn=::SQLBindCol(mhStatement,(UWORD)(colIndex+1),(SWORD)mSQLColumnData[colIndex].type(),ptrData,(SDWORD)mSQLColumnData[colIndex].size(),(SDWORD FAR*)mSQLColumnData[colIndex].resultLength());
|
||||
if(SQL_SUCCESS_WITH_INFO!=sqlReturn&&SQL_SUCCESS!=sqlReturn)break;
|
||||
}
|
||||
return (SQL_SUCCESS==sqlReturn||SQL_SUCCESS_WITH_INFO==sqlReturn);
|
||||
}
|
||||
|
||||
SQLData &SQLStatement::operator[](const String &strNameData)
|
||||
{
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
SQLData &sqlData=mSQLColumnData[index];
|
||||
if(strNameData==sqlData.name())return sqlData;
|
||||
}
|
||||
throw SQLColumnNotFound();
|
||||
return mSQLColumnData[0];
|
||||
}
|
||||
119
sql/SQLSTMT.HPP
Normal file
119
sql/SQLSTMT.HPP
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef _SQL_SQLSTATEMENT_HPP_
|
||||
#define _SQL_SQLSTATEMENT_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ASSERT_HPP_
|
||||
#include <common/assert.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLDATA_HPP_
|
||||
#include <sql/sqldata.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLDB_HPP_
|
||||
#include <sql/sqldb.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQL_HPP_
|
||||
#include <sql/sql.hpp>
|
||||
#endif
|
||||
|
||||
class SQLBind;
|
||||
|
||||
class SQLStatement
|
||||
{
|
||||
friend class SQLErr;
|
||||
public:
|
||||
class SQLColumnNotFound{};
|
||||
SQLStatement(void);
|
||||
SQLStatement(SQLDb &someSQLDb,SQLBind &sqlBind);
|
||||
SQLStatement(SQLDb &someSQLDb);
|
||||
virtual ~SQLStatement();
|
||||
SQLStatement &operator=(const SQLDb &someSQLDb);
|
||||
SQLData &operator[](int colIndex);
|
||||
SQLData &operator[](const String &strNameData);
|
||||
DWORD size(void)const;
|
||||
BOOL executeDirect(const String &sqlStatementString);
|
||||
BOOL executeDirect(const String &sqlStatementString,String &strResult);
|
||||
BOOL call(const String &procName);
|
||||
WORD sqlResults(void);
|
||||
WORD tables(String database,String owner,String name,String type);
|
||||
WORD tables(void);
|
||||
void close(void);
|
||||
WORD open(void);
|
||||
WORD commit(void);
|
||||
WORD fetch(bool silent=false)const;
|
||||
WORD cancel(void)const;
|
||||
int rowCount(void)const;
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
enum {MaxColName=255,MaxImageLength=768000};
|
||||
operator HSTMT(void)const;
|
||||
WORD mIsOkay;
|
||||
HSTMT mhStatement;
|
||||
Block<SQLData> mSQLColumnData;
|
||||
SQLDb mSQLDb;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLData &SQLStatement::operator[](int colIndex)
|
||||
{
|
||||
assert(colIndex<mSQLColumnData.size());
|
||||
return mSQLColumnData[colIndex];
|
||||
}
|
||||
|
||||
inline
|
||||
SQLStatement::operator HSTMT(void)const
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return mhStatement;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLStatement::close(void)
|
||||
{
|
||||
if(!isOkay())return;
|
||||
if(mhStatement){::SQLFreeStmt(mhStatement,SQL_DROP);mhStatement=FALSE;}
|
||||
mIsOkay=FALSE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLStatement::open(void)
|
||||
{
|
||||
close();
|
||||
if(SQL_SUCCESS==::SQLAllocStmt((HandleDatabase)mSQLDb,&mhStatement))return (mIsOkay=TRUE);
|
||||
return (mIsOkay=FALSE);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLStatement::commit(void)
|
||||
{
|
||||
return executeDirect("commit");
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLStatement::tables(void)
|
||||
{
|
||||
return tables(String(),String(),String(),String());
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL SQLStatement::call(const String &procName)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return executeDirect(String("call ")+procName);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD SQLStatement::size(void)const
|
||||
{
|
||||
return mSQLColumnData.size();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SQLStatement::isOkay(void)const
|
||||
{
|
||||
return mIsOkay;
|
||||
}
|
||||
#endif
|
||||
49
sql/SQLTHRD.CPP
Normal file
49
sql/SQLTHRD.CPP
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <sql/sqlthrd.hpp>
|
||||
|
||||
class SQLMessage : public ThreadMessage
|
||||
{
|
||||
public:
|
||||
SQLMessage(void);
|
||||
virtual ~SQLMessage();
|
||||
DWORD &operator[](int indexData);
|
||||
private:
|
||||
enum {SQLDataElements=4};
|
||||
DWORD mSQLDataArray[SQLDataElements];
|
||||
};
|
||||
|
||||
SQLMessage::SQLMessage(void)
|
||||
{
|
||||
}
|
||||
|
||||
SQLMessage::~SQLMessage()
|
||||
{
|
||||
}
|
||||
|
||||
DWORD &SQLMessage::operator[](int indexData)
|
||||
{
|
||||
return mSQLDataArray[indexData]
|
||||
}
|
||||
|
||||
DWORD SQLThread::threadHandler(ThreadMessage &someThreadMessage)
|
||||
{
|
||||
switch(someThreadMessage.message())
|
||||
{
|
||||
case ThreadMessage::TM_CREATE :
|
||||
break;
|
||||
case ThreadMessage::TM_DESTROY :
|
||||
break;
|
||||
case ThreadMessage::TM_USER :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL SQLThread::open(const String &nameData,const String &userID,const String &password)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL SQLThread::openHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
65
sql/SQLTHRD.HPP
Normal file
65
sql/SQLTHRD.HPP
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef _SQL_SQLTHREAD_HPP_
|
||||
#define _SQL_SQLTHREAD_HPP_
|
||||
#ifndef _THREAD_MESSAGETHREAD_HPP_
|
||||
#include <thread/mthread.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class PureVector;
|
||||
template <class T>
|
||||
class SmartPointer;
|
||||
class ThreadCallbackPointer;
|
||||
class SQLDb;
|
||||
|
||||
class SQLThread : public MessageThread
|
||||
{
|
||||
public:
|
||||
enum Mode{Sync,Async};
|
||||
SQLThread(void);
|
||||
virtual ~SQLThread();
|
||||
BOOL open(const String &nameData,const String &userID,const String &password);
|
||||
void insertHandler(ThreadCallbackPointer pThreadCallback);
|
||||
void removeHandler(void);
|
||||
private:
|
||||
SQLThread(const SQLThread &someSQLThread);
|
||||
SQLThread &operator=(const SQLThread &someSQLThread);
|
||||
DWORD threadHandler(ThreadMessage &someThreadMessage);
|
||||
|
||||
ThreadCallback<SQLThread> mThreadHandler;
|
||||
ThreadCallbackPointer mEventHandler;
|
||||
SmartPointer<SQLDb> mSQLDb;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLThread::SQLThread(void)
|
||||
: mThreadHandler(this,&SQLThread::threadHandler), mlpSQLDb(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLThread::~SQLThread()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLThread(const SQLThread &someSQLThread)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
inline
|
||||
SQLThread &operator=(const SQLThread &someSQLThread)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLThread::insertHandler(ThreadCallbackPointer pThreadCallback)
|
||||
{
|
||||
mEventHandler=pThreadCallback;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLThread::removeHandler(void)
|
||||
{
|
||||
mEventHandler=ThreadCallbackPointer();
|
||||
}
|
||||
#endif
|
||||
112
sql/money.hpp
Normal file
112
sql/money.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef _SQL_MONEY_HPP_
|
||||
#define _SQL_MONEY_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
|
||||
class Money
|
||||
{
|
||||
public:
|
||||
Money(void);
|
||||
Money(double value);
|
||||
Money(const Money &someMoney);
|
||||
virtual ~Money();
|
||||
Money &operator=(const Money &someMoney);
|
||||
operator String(void);
|
||||
void format(const String &strFormat);
|
||||
const String &format(void)const;
|
||||
double value(void)const;
|
||||
void value(double value);
|
||||
String toString(void)const;
|
||||
private:
|
||||
double mValue;
|
||||
String mFormat;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
Money::Money(void)
|
||||
: mValue(0.00), mFormat("% 12.2lf")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Money::Money(double value)
|
||||
: mValue(value), mFormat("% 12.2lf")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Money::Money(const Money &someMoney)
|
||||
{
|
||||
*this=someMoney;
|
||||
}
|
||||
|
||||
inline
|
||||
Money::~Money()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Money &Money::operator=(const Money &someMoney)
|
||||
{
|
||||
format(someMoney.format());
|
||||
value(someMoney.value());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Money::operator String(void)
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
inline
|
||||
String Money::toString(void)const
|
||||
{
|
||||
String strString;
|
||||
String moneyString;
|
||||
|
||||
::sprintf(strString,mFormat,mValue);
|
||||
char *strPtr=strString;
|
||||
char *strRoot=strPtr;
|
||||
while(*strPtr!='.')strPtr++;
|
||||
while(TRUE)
|
||||
{
|
||||
for(int count=0;count<3&&strPtr>strRoot&&*strPtr!=' ';count++)strPtr--;
|
||||
if(strPtr<=strRoot)break;
|
||||
moneyString.insert(strPtr);
|
||||
if(*(strPtr-1)!=' ')moneyString.insert(",");
|
||||
*strPtr=0;
|
||||
}
|
||||
moneyString.insert("$");
|
||||
return moneyString;
|
||||
}
|
||||
|
||||
inline
|
||||
void Money::format(const String &strFormat)
|
||||
{
|
||||
mFormat=strFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
const String &Money::format(void)const
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
double Money::value(void)const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
inline
|
||||
void Money::value(double value)
|
||||
{
|
||||
mValue=value;
|
||||
}
|
||||
#endif
|
||||
134
sql/sql.001
Normal file
134
sql/sql.001
Normal file
@@ -0,0 +1,134 @@
|
||||
# Microsoft Developer Studio Project File - Name="sql" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=sql - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sql.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sql.mak" CFG="sql - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sql - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "sql - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\msvcobj"
|
||||
# PROP Intermediate_Dir ".\msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Zp1 /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /FD /c
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssql.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sql - Win32 Release"
|
||||
# Name "sql - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sqldata.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLDB.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLSTMT.CPP
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hdbc.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Henv.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sql.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlbind.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqldata.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqldb.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlerror.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlstmt.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
140
sql/sql.dsp
Normal file
140
sql/sql.dsp
Normal file
@@ -0,0 +1,140 @@
|
||||
# Microsoft Developer Studio Project File - Name="sql" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=sql - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sql.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sql.mak" CFG="sql - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sql - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "sql - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\msvcobj"
|
||||
# PROP Intermediate_Dir ".\msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MTd /GX /Zi /Od /D "WIN32" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssql.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sql - Win32 Release"
|
||||
# Name "sql - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sqldata.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLDB.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SQLSTMT.CPP
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hdbc.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Henv.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sql.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlbind.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqldata.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqldb.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlerror.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sqlstmt.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
sql/sql.dsw
Normal file
29
sql/sql.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "sql"=.\sql.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
338
sql/sql.mak
Normal file
338
sql/sql.mak
Normal file
@@ -0,0 +1,338 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on sql.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=sql - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to sql - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "sql - Win32 Release" && "$(CFG)" != "sql - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sql.mak" CFG="sql - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sql - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "sql - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\.\Release
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\sql.lib"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\sql.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\sqldata.obj"
|
||||
-@erase "$(INTDIR)\SQLDB.OBJ"
|
||||
-@erase "$(INTDIR)\SQLSTMT.OBJ"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "$(OUTDIR)\sql.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)\sql.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\sql.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\sql.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\sqldata.obj" \
|
||||
"$(INTDIR)\SQLDB.OBJ" \
|
||||
"$(INTDIR)\SQLSTMT.OBJ"
|
||||
|
||||
"$(OUTDIR)\sql.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
OUTDIR=.\msvcobj
|
||||
INTDIR=.\msvcobj
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "..\exe\mssql.lib"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "..\exe\mssql.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\sqldata.obj"
|
||||
-@erase "$(INTDIR)\SQLDB.OBJ"
|
||||
-@erase "$(INTDIR)\SQLSTMT.OBJ"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "..\exe\mssql.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /Zp1 /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX /Fo"$(INTDIR)\\"\
|
||||
/Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\msvcobj/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\sql.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
LIB32_FLAGS=/nologo /out:"..\exe\mssql.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\sqldata.obj" \
|
||||
"$(INTDIR)\SQLDB.OBJ" \
|
||||
"$(INTDIR)\SQLSTMT.OBJ"
|
||||
|
||||
"..\exe\mssql.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release" || "$(CFG)" == "sql - Win32 Debug"
|
||||
SOURCE=.\sqldata.cpp
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLDA=\
|
||||
".\Sql.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\sqldata.obj" : $(SOURCE) $(DEP_CPP_SQLDA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLDA=\
|
||||
".\Sql.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\sqldata.obj" : $(SOURCE) $(DEP_CPP_SQLDA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\SQLDB.CPP
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLDB=\
|
||||
".\Hdbc.hpp"\
|
||||
".\Henv.hpp"\
|
||||
".\Sql.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\Sqldb.hpp"\
|
||||
".\Sqlerror.hpp"\
|
||||
".\Sqlstmt.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\assert.hpp"\
|
||||
{$(INCLUDE)}"common\block.hpp"\
|
||||
{$(INCLUDE)}"common\block.tpp"\
|
||||
{$(INCLUDE)}"common\except.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLDB.OBJ" : $(SOURCE) $(DEP_CPP_SQLDB) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLDB=\
|
||||
".\Hdbc.hpp"\
|
||||
".\Henv.hpp"\
|
||||
".\Sql.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\Sqldb.hpp"\
|
||||
".\Sqlerror.hpp"\
|
||||
".\Sqlstmt.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\assert.hpp"\
|
||||
{$(INCLUDE)}"common\block.hpp"\
|
||||
{$(INCLUDE)}"common\block.tpp"\
|
||||
{$(INCLUDE)}"common\except.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLDB.OBJ" : $(SOURCE) $(DEP_CPP_SQLDB) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\SQLSTMT.CPP
|
||||
|
||||
!IF "$(CFG)" == "sql - Win32 Release"
|
||||
|
||||
DEP_CPP_SQLST=\
|
||||
".\Hdbc.hpp"\
|
||||
".\Henv.hpp"\
|
||||
".\Sql.hpp"\
|
||||
".\Sqlbind.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\Sqldb.hpp"\
|
||||
".\Sqlerror.hpp"\
|
||||
".\Sqlstmt.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\assert.hpp"\
|
||||
{$(INCLUDE)}"common\block.hpp"\
|
||||
{$(INCLUDE)}"common\block.tpp"\
|
||||
{$(INCLUDE)}"common\except.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLSTMT.OBJ" : $(SOURCE) $(DEP_CPP_SQLST) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "sql - Win32 Debug"
|
||||
|
||||
DEP_CPP_SQLST=\
|
||||
".\Hdbc.hpp"\
|
||||
".\Henv.hpp"\
|
||||
".\Sql.hpp"\
|
||||
".\Sqlbind.hpp"\
|
||||
".\Sqldata.hpp"\
|
||||
".\Sqldb.hpp"\
|
||||
".\Sqlerror.hpp"\
|
||||
".\Sqlstmt.hpp"\
|
||||
".\sqlstring.hpp"\
|
||||
{$(INCLUDE)}"common\assert.hpp"\
|
||||
{$(INCLUDE)}"common\block.hpp"\
|
||||
{$(INCLUDE)}"common\block.tpp"\
|
||||
{$(INCLUDE)}"common\except.hpp"\
|
||||
{$(INCLUDE)}"common\pointer.hpp"\
|
||||
{$(INCLUDE)}"common\stdio.hpp"\
|
||||
{$(INCLUDE)}"common\stdlib.hpp"\
|
||||
{$(INCLUDE)}"common\string.hpp"\
|
||||
{$(INCLUDE)}"common\windows.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\SQLSTMT.OBJ" : $(SOURCE) $(DEP_CPP_SQLST) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
BIN
sql/sql.mdp
Normal file
BIN
sql/sql.mdp
Normal file
Binary file not shown.
80
sql/sqlbool.hpp
Normal file
80
sql/sqlbool.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef _SQL_SQLBOOL_HPP_
|
||||
#define _SQL_SQLBOOL_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class SQLBool
|
||||
{
|
||||
public:
|
||||
SQLBool(void);
|
||||
SQLBool(const SQLBool &sqlBool);
|
||||
SQLBool(bool value);
|
||||
SQLBool &operator=(const SQLBool &sqlBool);
|
||||
SQLBool &operator=(bool value);
|
||||
operator String(void)const;
|
||||
bool getValue(void)const;
|
||||
void setValue(bool value);
|
||||
String toString(void)const;
|
||||
private:
|
||||
bool mValue;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLBool::SQLBool(void)
|
||||
: mValue(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBool::SQLBool(const SQLBool &sqlBool)
|
||||
: mValue(sqlBool.mValue)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBool::SQLBool(bool value)
|
||||
: mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBool &SQLBool::operator=(const SQLBool &sqlBool)
|
||||
{
|
||||
mValue=sqlBool.mValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBool &SQLBool::operator=(bool value)
|
||||
{
|
||||
mValue=value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLBool::operator String(void)const
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLBool::getValue(void)const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLBool::setValue(bool value)
|
||||
{
|
||||
mValue=value;
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLBool::toString(void)const
|
||||
{
|
||||
String strString;
|
||||
::sprintf(strString,"%d",int(mValue));
|
||||
return strString;
|
||||
}
|
||||
#endif
|
||||
114
sql/sqldate.hpp
Normal file
114
sql/sqldate.hpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#ifndef _SQL_SQLDATE_HPP_
|
||||
#define _SQL_SQLDATE_HPP_
|
||||
#ifndef _SQL_SQLSTRING_HPP_
|
||||
#include <sql/sqlstring.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SDATE_HPP_
|
||||
#include <common/sdate.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SYSTEMTIME_HPP_
|
||||
#include <common/systime.hpp>
|
||||
#endif
|
||||
|
||||
class SQLDate : public SDate
|
||||
{
|
||||
public:
|
||||
SQLDate(void);
|
||||
SQLDate(const SQLDate &someDate);
|
||||
SQLDate(const SDate &someDate);
|
||||
SQLDate(const String &sqlDateString);
|
||||
SQLDate(const SystemTime &systemTime);
|
||||
virtual ~SQLDate();
|
||||
SQLDate &operator=(const SQLDate &someDate);
|
||||
SQLDate &operator=(const SDate &someDate);
|
||||
SQLDate &operator=(const String &sqlDateString);
|
||||
SQLDate &operator=(const SystemTime &systemTime);
|
||||
SQLString toString()const;
|
||||
void fromString(const SQLString &sqlDateString);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
SQLDate::SQLDate(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate::SQLDate(const SQLDate &someDate)
|
||||
{
|
||||
*this=someDate;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate::SQLDate(const SDate &someDate)
|
||||
{
|
||||
*this=someDate;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate::SQLDate(const SystemTime &systemTime)
|
||||
{
|
||||
*this=systemTime;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate::SQLDate(const String &sqlDateString)
|
||||
{
|
||||
fromString(sqlDateString);
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate::~SQLDate()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate &SQLDate::operator=(const SQLDate &someDate)
|
||||
{
|
||||
*this=(SDate&)someDate;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate &SQLDate::operator=(const SDate &someDate)
|
||||
{
|
||||
(SDate&)*this=someDate;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate &SQLDate::operator=(const SystemTime &systemTime)
|
||||
{
|
||||
day(systemTime.day());
|
||||
month(systemTime.month());
|
||||
year(systemTime.year());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLDate &SQLDate::operator=(const String &sqlDateString)
|
||||
{
|
||||
fromString(sqlDateString);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString SQLDate::toString()const
|
||||
{
|
||||
SQLString sqlDateString;
|
||||
::sprintf(sqlDateString,"%04d-%02d-%02d 00:00:00.0",year()?year():1900,month()?month():1,day()?day():1);
|
||||
return sqlDateString;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLDate::fromString(const SQLString &sqlDateString)
|
||||
{
|
||||
if(sqlDateString.isNull())return;
|
||||
year(::atoi(sqlDateString.betweenString(0,'-')));
|
||||
month(::atoi(sqlDateString.betweenString('-','-')));
|
||||
day(::atoi(sqlDateString.betweenString('-',' ').betweenString('-',0)));
|
||||
}
|
||||
#endif
|
||||
68
sql/sqlint.hpp
Normal file
68
sql/sqlint.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _SQL_SQLINT_HPP_
|
||||
#define _SQL_SQLINT_HPP_
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _SQL_SQLSTRING_HPP_
|
||||
#include <sql/sqlstring.hpp>
|
||||
#endif
|
||||
|
||||
class SQLInt
|
||||
{
|
||||
public:
|
||||
SQLInt(void);
|
||||
SQLInt(int someInt);
|
||||
SQLInt &operator=(int value);
|
||||
bool operator==(const SQLInt &someSQLInt)const;
|
||||
int getValue(void)const;
|
||||
void setValue(int value);
|
||||
SQLString toString(void)const;
|
||||
private:
|
||||
int mData;
|
||||
};
|
||||
|
||||
inline
|
||||
SQLInt::SQLInt(void)
|
||||
: mData(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLInt::SQLInt(int someInt)
|
||||
: mData(someInt)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLInt &SQLInt::operator=(int value)
|
||||
{
|
||||
mData=value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
bool SQLInt::operator==(const SQLInt &someSQLInt)const
|
||||
{
|
||||
return getValue()==someSQLInt.getValue();
|
||||
}
|
||||
|
||||
inline
|
||||
int SQLInt::getValue(void)const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
void SQLInt::setValue(int value)
|
||||
{
|
||||
mData=value;
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString SQLInt::toString(void)const
|
||||
{
|
||||
SQLString strString;
|
||||
::sprintf(strString,"%d",mData);
|
||||
return strString;
|
||||
}
|
||||
#endif
|
||||
55
sql/sqlstring.hpp
Normal file
55
sql/sqlstring.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef _SQL_SQLSTRING_HPP_
|
||||
#define _SQL_SQLSTRING_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class SQLString : public String
|
||||
{
|
||||
public:
|
||||
SQLString(void);
|
||||
SQLString(const char *pString);
|
||||
SQLString(const SQLString &sqlString);
|
||||
SQLString(const String &string);
|
||||
virtual ~SQLString();
|
||||
String toString(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
SQLString::SQLString(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString::SQLString(const SQLString &sqlString)
|
||||
: String((String&)sqlString)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString::SQLString(const String &string)
|
||||
: String(string)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString::SQLString(const char *lpString)
|
||||
: String(lpString)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SQLString::~SQLString()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
String SQLString::toString(void)const
|
||||
{
|
||||
if(isNull())return "NULL";
|
||||
String copyString(*this);
|
||||
copyString.replaceToken('\'',' ');
|
||||
return String("'")+copyString+String("'");
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user