ContentToken.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef ContentToken_INCLUDED
#define ContentToken_INCLUDED 1
#ifdef __GNUG__
#pragma interface
#endif
#include "Owner.h"
#include "Text.h"
#include "Vector.h"
#include "NCVector.h"
#include "Boolean.h"
#ifdef SP_NAMESPACE
#endif
struct SP_API Transition {
enum { invalidIndex = -1 };
// When performing this transition, reset all andState with index >= this.
unsigned clearAndStateStartIndex;
// This transition is possible only if all AND groups whose AND depth
// is >= this (and contains the LeafContentToken that this transition is
// from) have had all their non-nullable members matched.
unsigned andDepth;
// If this is 1, then this transition requires that the AND group
// whose AND depth is andDepth - 1 have a non-nullable member unmatched,
// and thus this transition is not ambiguous with a transition whose
// AND depth is < andDepth.
// Index in andState that must be clear for this transition to be
// allowed.
unsigned requireClear;
// Index in andState that is to be set after performing this transition.
unsigned toSet;
};
FirstSet();
void init(LeafContentToken *);
size_t requiredIndex() const;
void setNotRequired();
// index of contextually required token or -1 if none
};
LastSet() { }
};
struct GroupInfo;
struct SP_API ContentModelAmbiguity {
const LeafContentToken *from;
const LeafContentToken *to1;
const LeafContentToken *to2;
unsigned andDepth;
};
virtual ~ContentToken();
OccurrenceIndicator occurrenceIndicator() const;
Boolean inherentlyOptional() const;
static unsigned andDepth(const AndModelGroup *);
static unsigned andIndex(const AndModelGroup *);
unsigned andClearIndex,
unsigned andDepth,
unsigned requireClear
= (unsigned)Transition::invalidIndex,
unsigned toSet
= (unsigned)Transition::invalidIndex);
Boolean &pcdataUnreachable) = 0;
virtual void setOrGroupMember();
unsigned andGroupIndex() const;
};
unsigned nMembers() const;
ContentToken &member(unsigned i);
const ContentToken &member(unsigned i) const;
unsigned long grpgtcnt() const;
const ModelGroup *asModelGroup() const;
void setOrGroup();
};
unsigned andDepth() const;
unsigned andIndex() const;
unsigned andGroupIndex() const;
const AndModelGroup *andAncestor() const;
unsigned andDepth_; // number of and groups that contain this
unsigned andIndex_;
unsigned andGroupIndex_;
const AndModelGroup *andAncestor_;
};
};
};
AndInfo() { }
const AndModelGroup *andAncestor;
unsigned andGroupIndex;
};
// A LeafContentToken is not quite the same as a primitive content token.
// A data tag group is a primitive content token but not a LeafContentToken.
unsigned index() const;
unsigned typeIndex() const;
const ElementType *elementType() const;
unsigned andClearIndex,
unsigned andDepth,
unsigned requireClear,
unsigned toSet);
void setFinal();
unsigned &minAndDepth,
const LeafContentToken *&newpos) const;
const LeafContentToken *&newpos) const;
void possibleTransitions(const AndState &, unsigned minAndDepth, Vector<const ElementType *> &) const;
unsigned minAndDepth) const;
unsigned minAndDepth) const;
unsigned &minAndDepth,
const LeafContentToken *&newpos) const;
unsigned computeMinAndDepth(const AndState&) const;
Boolean orGroupMember() const;
void setOrGroupMember();
const AndModelGroup *andAncestor() const;
unsigned andDepth() const;
const LeafContentToken *asLeafContentToken() const;
const ElementType *element_;
unsigned computeMinAndDepth1(const AndState&) const;
unsigned leafIndex_;
unsigned typeIndex_;
// 0 none, 1 yes - simple, 2 - compled
char pcdataTransitionType_;
};
PcdataToken();
};
};
};
// first content token is a DataTagElementToken, second is PcdataToken
};
};
CompiledModelGroup *copy() const;
const LeafContentToken *initial() const;
unsigned andStateSize() const;
Boolean containsPcdata() const;
const ModelGroup *modelGroup() const;
unsigned andStateSize_;
};
AndState(unsigned);
void clearFrom(unsigned);
void set(unsigned);
void clearFrom1(unsigned);
unsigned clearFrom_;
};
MatchState();
Boolean isFinished() const;
const LeafContentToken *impliedStartTag() const;
void doRequiredTransition();
const LeafContentToken *currentPosition() const;
const LeafContentToken *pos_;
unsigned minAndDepth_;
};
inline
{
return occurrenceIndicator_;
}
inline
unsigned LeafContentToken::index() const
{
return leafIndex_;
}
inline
unsigned LeafContentToken::typeIndex() const
{
return typeIndex_;
}
inline
{
return inherentlyOptional_;
}
inline
{
return element_;
}
inline
unsigned AndModelGroup::andDepth() const
{
return andDepth_;
}
inline
unsigned AndModelGroup::andIndex() const
{
return andIndex_;
}
inline
unsigned ModelGroup::nMembers() const
{
}
inline
{
}
inline
{
return (andAncestor
: 0);
}
inline
{
return *members_[i];
}
inline
{
return *members_[i];
}
inline
void LeafContentToken::setFinal()
{
isFinal_ = 1;
}
inline
{
return isFinal_;
}
inline
{
return orGroupMember_;
}
inline
unsigned CompiledModelGroup::andStateSize() const
{
return andStateSize_;
}
inline
{
return containsPcdata_;
}
inline
{
return andAncestor_;
}
inline
unsigned AndModelGroup::andGroupIndex() const
{
return andGroupIndex_;
}
inline
{
}
inline
{
return modelGroup_.pointer();
}
inline
{
}
inline
unsigned LeafContentToken::andDepth() const
{
}
inline
{
}
inline
unsigned &minAndDepth,
const LeafContentToken *&newpos)
const
{
if (pcdataTransitionType_ == 1) {
return 1;
}
else if (pcdataTransitionType_ == 0)
return 0;
else
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
inline
const LeafContentToken *
MatchState::impliedStartTag() const
{
}
inline
void MatchState::doRequiredTransition()
{
}
inline
{
return pos_;
}
inline
{
}
inline
{
return v_[i] == 0;
}
inline
{
v_[i] = 1;
if (i >= clearFrom_)
clearFrom_ = i + 1;
}
inline
{
if (i < clearFrom_)
clearFrom1(i);
}
inline
{
}
inline
{
}
inline
{
return v_[i];
}
inline
{
return requiredIndex_;
}
inline
void FirstSet::setNotRequired()
{
}
#ifdef SP_NAMESPACE
}
#endif
#endif /* not ContentToken_INCLUDED */