home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
dbutil.zip
/
BUFOP.ZIP
/
HOSTVARS.HPP
< prev
next >
Wrap
Text File
|
1993-09-11
|
4KB
|
110 lines
#ifndef _HOSTVAR_
#define _HOSTVAR_
#include <IString.hpp>
#include "pctypes.hpp"
#include <fstream.h>
/*********************************************************************
* CPP SQL PRECOMPILER
* HOST VARIABLE ROUTINES
* extract host variables from source program(s)
* registar host variables with precompiler services
*
* during the preparing of an SQL statement
* find host variable by name return ID
* create new host varaible(s) for SQLDA and nul indicators
* set the host variable prefix to support struct, pointers and class
*
* during the generation of code
* find host variable by ID
* restore prefix to host variable
* generate SetV
*
*
*********************************************************************/
Boolean InDeclare(); // returns true if in a SQL declare section
void setDeclare(Boolean B);
void initSQLTypes();
void processDeclare(IString & sqlstring); // add a variable to list
class Variable
{
public:
// constructors
Variable();
Variable(IString & theName, int Thelen, int theType, Boolean anObj=false);
Variable(IString & theName);
~Variable();
// operator definitions
inline Boolean operator ==(Variable const & V)const {return (name == V.name);}
Variable & operator=(Variable const & v);
friend ostream& operator<<(ostream & os, Variable & V);
void registerHV(); // register the hostvar
void setName(const IString & thename);
void setV(unsigned short sqlaID, unsigned short idx,ofstream & fout);
void setVNull(unsigned short sqlaID, unsigned short idx,ofstream & fout,
int nullID);
IString Variable:: getFullName();
inline void setID() {ID = ++nxtID;}
inline void changeID(int theID) {ID = theID;}
inline void setLen(int theLen) {len = theLen;}
inline void setType(int theType) {type = theType;}
inline void setPointer(Boolean p = true) {aPointer = p;}
inline void setPrefix(IString const & thePrefix) {prefix = thePrefix;}
inline IString const & getName() const {return name;}
inline IString const & getPrefix() const {return prefix;}
inline IString const & getTypeName() const {return vTypeTxt;}
inline int getLen() {return len;}
inline int getType() {return type;}
inline unsigned long getID() {return ID;}
inline Boolean isaPointer() {return aPointer;}
void setDefaults(Vtype const & V );
void setUnknown();
private:
IString name; // Variable name
unsigned short len; // Variable length
unsigned short type; // Databsse type
Boolean Obj; // set true if processing an object
unsigned long ID; // used by variable array
Boolean aPointer; // this var is a pointer to type
IString prefix; // prefix (in support of struct and class)
IString vTypeTxt; // variable type in text format - for debugging
Boolean IsObject;
static unsigned long nxtID; // next ID number to assign
};
/********************************************************************
* supporting functions
********************************************************************/
// given a host variable name - get the ID
Variable * getVarByName(IString const & theName); // return the variable
// given an ID, get the variable
Variable & getVarByID(long theID);
void dumpVars(); // debug to dump all variables
inline IString const & key (Variable const & V){
return V.getName();
}
#endif