home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2001 December
/
PCWorld_2001-12_cd.bin
/
Software
/
Topware
/
Hackman
/
_SETUP.1
/
Varbinds.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-09
|
3KB
|
161 lines
#ifndef _VARBINDS_H
#define _VARBINDS_H
#include "bindstructs.h"
#include "string.h"
class CVARBINDS
{
private:
int iCount,sCount,lCount,fCount,dCount;
CSTRBIND *bStrings[100];
CINTBIND *bInts[100];
CLONGBIND *bLongs[100];
CFUNCBIND *bFuncs[100];
CDBLBIND *bDbls[100];
public:
CVARBINDS();
~CVARBINDS();
void BindDbl(double *, LPSTR);
void BindInt(int *,LPSTR);
void BindLong(long*,LPSTR);
void BindString(LPSTR,LPSTR);
void BindFunc(FARPROC,LPSTR);
int GetInt(LPSTR);
long GetLong(LPSTR);
LPSTR GetString(LPSTR);
FARPROC GetFunc(LPSTR);
double GetDbl(LPSTR);
};
CVARBINDS::CVARBINDS() : iCount(0), sCount(0), lCount(0), fCount(0), dCount(0)
{
}
CVARBINDS::~CVARBINDS()
{
delete []* bStrings;
delete []* bInts;
delete []* bLongs;
delete []* bFuncs;
delete []* bDbls;
}
void CVARBINDS::BindDbl(double *bDouble,LPSTR bStringD)
{ bDbls[dCount]=new CDBLBIND(bDouble,bStringD);
dCount++;
}
void CVARBINDS::BindInt(int *bInt,LPSTR bStringI)
{ bInts[iCount]=new CINTBIND(bInt,bStringI);
iCount++;
}
void CVARBINDS::BindLong(long *bLong,LPSTR bStringL)
{ bLongs[lCount]=new CLONGBIND(bLong,bStringL);
lCount++;
}
void CVARBINDS::BindString(LPSTR bStr,LPSTR bStringS)
{ bStrings[sCount]=new CSTRBIND(bStr,bStringS);
sCount++;
}
void CVARBINDS::BindFunc(FARPROC bFunc,LPSTR bStringF)
{ bFuncs[fCount]=new CFUNCBIND(FARPROC(bFunc),bStringF);
fCount++;
}
int CVARBINDS::GetInt(LPSTR xBind)
{int i=0;
while((i<iCount) && strcmp(bInts[i]->GetBind(),xBind))
{
i++;
}
if( (i==iCount) && !(strcmp(bInts[i]->GetBind(),xBind)) )
{
return -1;
}
else
{
return bInts[i]->GetData();
}
}
FARPROC CVARBINDS::GetFunc(LPSTR xBind)
{int i=0;
while((i<fCount) && strcmp(bFuncs[i]->GetBind(),xBind))
{
i++;
}
if( (i==iCount) && !(strcmp(bFuncs[i]->GetBind(),xBind)))
{
return NULL;
}
else
{
return bFuncs[i]->GetFunction();
}
}
long CVARBINDS::GetLong(LPSTR xBind) //get a Long little doggies...
{int i=0;
while((i<lCount) && strcmp(bLongs[i]->GetBind(),xBind))
{
i++;
}
if( (i==lCount) && !strcmp(bLongs[i-1]->GetBind(),xBind) )
{
return -1;
}
else
{
return bLongs[i]->GetData();
}
}
LPSTR CVARBINDS::GetString(LPSTR xBind)
{int i=0;
while((i<sCount) && strcmp(bStrings[i]->GetBind(),xBind))
{
i++;
}
if( (i==sCount) && bStrings[i]->GetBind()==0)
{
return NULL;
}
else
{
return bStrings[i]->GetData();
}
}
double CVARBINDS::GetDbl(LPSTR xBind)
{
int i=0;
while( (i<dCount) && strcmp(bDbls[i]->GetBind(),xBind))
{
i++;
}
if( (i==dCount) && !strcmp(bDbls[i]->GetBind(),xBind) )
{
return -1;
}
else
{
return bDbls[i]->GetData();
}
}
#endif