Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
134
cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.C
Normal file
134
cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.C
Normal file
@@ -0,0 +1,134 @@
|
||||
// $TOG: SSPath.C /main/5 1998/04/17 11:49:33 mgreess $
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
|
||||
#else
|
||||
#include "dti_cc/CC_Tokenizer.h"
|
||||
#endif
|
||||
|
||||
#include "SSPath.h"
|
||||
#include "Debug.h"
|
||||
#include "SymTab.h"
|
||||
#include "StyleSheetExceptions.h"
|
||||
|
||||
unsigned int GI_CASE_SENSITIVE = false;
|
||||
|
||||
PathTerm::PathTerm(const Element& element) :
|
||||
f_element(element), f_PQExpr(0)
|
||||
{
|
||||
}
|
||||
|
||||
PathTerm::PathTerm(const Symbol& symbol, PQExpr* expr) :
|
||||
f_element(symbol), f_PQExpr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
PathTerm::PathTerm(const char* symbol, PQExpr* expr) :
|
||||
f_element(gElemSymTab -> intern(symbol, true)), f_PQExpr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
PathTerm::~PathTerm()
|
||||
{
|
||||
delete f_PQExpr;
|
||||
}
|
||||
|
||||
unsigned int PathTerm::operator ==(const PathTerm&)
|
||||
{
|
||||
MESSAGE(cerr, "PathTerm::operator ==() should not be called");
|
||||
throw(CASTBEEXCEPT badEvaluationException());
|
||||
return 0;
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream& out, PathTerm& pt)
|
||||
{
|
||||
out << pt.symbol() << " (" << int(pt.f_PQExpr) << ") ";
|
||||
return out;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////
|
||||
|
||||
void SSPath::appendPathTerm(PathTerm* pt)
|
||||
{
|
||||
if ( pt -> pqexpr() )
|
||||
f_containPathQualifier = true;
|
||||
|
||||
append(pt);
|
||||
}
|
||||
|
||||
void SSPath::prependPath(SSPath& p)
|
||||
{
|
||||
if ( p.entries() == 0 )
|
||||
return;
|
||||
|
||||
CC_TPtrDlistIterator<PathTerm> l_Iter(p);
|
||||
l_Iter += p.entries();
|
||||
|
||||
PathTerm* l_pathTerm = 0;
|
||||
|
||||
do {
|
||||
//prepend(new PathTerm(*l_Iter.key()));
|
||||
|
||||
l_pathTerm = l_Iter.key();
|
||||
|
||||
prepend(l_pathTerm);
|
||||
|
||||
if ( l_pathTerm -> pqexpr() )
|
||||
f_containPathQualifier = true;
|
||||
|
||||
|
||||
} while ( --l_Iter );
|
||||
}
|
||||
|
||||
SSPath::SSPath()
|
||||
: f_containPathQualifier(false), f_fastGetIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
SSPath::~SSPath()
|
||||
{
|
||||
// clean up memory
|
||||
clearAndDestroy();
|
||||
delete f_fastGetIndex;
|
||||
}
|
||||
|
||||
SSPath::SSPath(char* str, unsigned int AssignId) :
|
||||
f_containPathQualifier(false), f_fastGetIndex(0)
|
||||
{
|
||||
CC_String a(str);
|
||||
CC_Tokenizer next(a);
|
||||
CC_String token;
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
while ( !(token=next()).isNull() ) {
|
||||
append(new PathTerm(token.data(), 0));
|
||||
}
|
||||
#else
|
||||
while ( next() ) {
|
||||
append(new PathTerm(token.data(), 0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, SSPath& p)
|
||||
{
|
||||
CC_TPtrDlistIterator<PathTerm> l_Iter(p);
|
||||
while ( ++l_Iter ) {
|
||||
out << *l_Iter.key() << ' ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void SSPath::fastGetIndex()
|
||||
{
|
||||
f_fastGetIndex = new value_vector<PathTermPtr>(entries());
|
||||
|
||||
CC_TPtrDlistIterator<PathTerm> l_Iter(*this);
|
||||
int i=0;
|
||||
while ( ++l_Iter ) {
|
||||
(*f_fastGetIndex)[i++] = l_Iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user