/*
* Copyright 1995, 1996 Perforce Software. All rights reserved.
*
* This file is part of Perforce - the FAST SCM System.
*/
/*
* strtable.h - a string table, using StrDict interface
*
* Classes defined:
*
* StrPtrDict - a dictionary whose values we don't own
* StrBufDict - a dictionary whose values we do own
*
* Public methods:
*
* Clear() - reset table, making all variables unset
* GetVar() - look up variable, return value (or 0 if not set)
* SetVar() - set variable/value pair
*
* XXX Total dumb duplication of StrPtrDict into StrBufDict.
*/
#ifndef _strtable_h_
#define _strtable_h_
class StrPtrTable {
public:
StrPtrTable();
~StrPtrTable();
void Clear()
{
tabLength = 0;
}
int GetCount()
{
return tabLength;
}
StrPtr * GetTable()
{
return tabVal;
}
void SetVar( const StrPtr &val );
private:
StrRef *tabVal;
int tabSize;
int tabLength;
} ;
struct StrPtrEntry;
class StrPtrDict : public StrDict {
public:
StrPtrDict();
~StrPtrDict();
void Clear()
{
tabLength = 0;
}
// virtuals of StrDict
StrPtr * VGetVar( const StrPtr &var );
void VSetVar( const StrPtr &var, const StrPtr &val );
void VRemoveVar( const StrPtr &var );
int VGetVarX( int x, StrRef &var, StrRef &val );
private:
StrPtrEntry *elems;
int tabSize;
int tabLength;
} ;
struct StrBufEntry;
class StrBufDict : public StrDict {
public:
StrBufDict();
StrBufDict( StrDict & dict );
StrBufDict & operator =( StrDict & dict );
~StrBufDict();
void Clear()
{
tabLength = 0;
}
int GetCount()
{
return tabLength;
}
// virtuals of StrDict
StrPtr * VGetVar( const StrPtr &var );
void VSetVar( const StrPtr &var, const StrPtr &val );
void VRemoveVar( const StrPtr &var );
int VGetVarX( int x, StrRef &var, StrRef &val );
private:
void Set( StrDict & dict );
StrBufEntry *elems;
int tabSize;
int tabLength;
} ;
#endif /* _strtable_h_ */