Attribute.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __GNUG__
#pragma implementation
#endif
#include "splib.h"
#include "Attribute.h"
#include "MessageArg.h"
#include "macros.h"
#include "ParserMessages.h"
#include "StringVectorMessageArg.h"
#include "Syntax.h"
#include "Entity.h"
#include "Notation.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
{
}
{
}
unsigned &specLength) const
{
}
const StringC &,
unsigned &,
unsigned &) const
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
}
{
return 0;
}
const StringC &,
unsigned &specLength) const
{
// A length error will already have been given if
// length > litlen - normsep.
&& normalizedLength > litlen)
return new CdataAttributeValue(text);
}
{
}
{
return new CdataDeclaredValue(*this);
}
{
switch (type) {
case name:
case entityName:
| Syntax::otherNameCategory);
break;
case number:
break;
case nameToken:
| Syntax::otherNameCategory);
break;
case numberToken:
| Syntax::otherNameCategory);
break;
}
}
{
return 1;
}
unsigned &specLength) const
{
}
unsigned &specLength) const
{
: syntax.generalSubstTable()),
space);
size_t i = 0;
for (;;) {
if (i >= length) {
// ends with a space (which would have to have been entered
// via a numeric character reference)
break;
}
size_t startIndex = i;
else
}
else {
for (++i;
i < length
i++)
;
// character value[i] is not allowed anywhere in the value
}
}
}
i++;
}
if (i == length)
break;
}
spaceIndex.push_back(i);
i++;
}
// should we count CDATA and SDATA entities here?
if (isList_) {
normalizedLength += 1;
// length is now the number of characters in each token in the list
// + 1 for each token in the list; so add normsep - 1 for each
// token in the list.
if (normsep > 0)
else
}
// A length error will already have been given if
// length > litlen - normsep.
&& normalizedLength > litlen)
}
{
const Char *s;
return 1;
}
return 0;
}
{
: AttributeDefinitionDesc::name));
}
{
return new TokenizedDeclaredValue(*this);
}
: TokenizedDeclaredValue(type, 0)
{
}
{
}
{
return new GroupDeclaredValue(*this);
}
unsigned &specLength) const
{
return val;
return val;
return val;
}
const StringC &,
unsigned &specLength)
const
{
}
{
if (allowedValues_[i] == token)
return 1;
return 0;
}
{
return &allowedValues_;
}
{
}
{
}
{
return new NameTokenGroupDeclaredValue(*this);
}
{
}
{
return 1;
}
const StringC &,
unsigned &,
unsigned &) const
{
value.tokenLocation(0));
}
return 0;
}
return new NotationAttributeSemantics(notation);
}
{
}
{
return new NotationDeclaredValue(*this);
}
{
}
{
return 1;
}
const StringC &,
unsigned &,
unsigned &nEntityNames) const
{
nEntityNames += nTokens;
value.tokenLocation(i));
}
valid = 0;
}
else if (!entities[i]->isDataOrSubdoc()) {
}
valid = 0;
}
}
if (valid)
return new EntityAttributeSemantics(entities);
else
return 0;
}
{
return new EntityDeclaredValue(*this);
}
: TokenizedDeclaredValue(name, 0)
{
}
{
return 1;
}
const StringC &,
unsigned &,
unsigned &) const
{
prevLoc);
}
return 0;
}
{
}
{
return new IdDeclaredValue(*this);
}
{
}
const StringC &,
unsigned &nIdrefs,
unsigned &) const
{
return 0;
}
{
return 1;
}
{
else
}
{
return new IdrefDeclaredValue(*this);
}
{
}
{
}
AttributeContext &) const
{
return p;
}
const AttributeContext &) const
{
return 0;
}
const AttributeValue *
{
return 0;
}
{
desc.currentIndex = 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
}
{
StringMessageArg(name()));
return 0;
}
{
}
{
return new RequiredAttributeDefinition(*this);
}
CurrentAttributeDefinition::CurrentAttributeDefinition(const StringC &name, DeclaredValue *value, size_t index)
{
}
{
if (context.mayDefaultAttribute()) {
StringMessageArg(name()));
return currentValue;
}
StringMessageArg(name()));
return 0;
}
const AttributeContext &context) const
{
if (!context.mayDefaultAttribute())
return 0;
if (currentValue.isNull())
return 0;
}
AttributeContext &context) const
{
return value;
}
{
}
{
return new CurrentAttributeDefinition(*this);
}
{
return 1;
}
{
}
{
return context.makeImpliedAttributeValue();
}
{
}
{
return new ImpliedAttributeDefinition(*this);
}
const AttributeValue *
const
{
return impliedValue;
}
{
}
{
return 1;
}
{
}
{
return new ConrefAttributeDefinition(*this);
}
{
}
{
if (context.mayDefaultAttribute())
return value_;
StringMessageArg(name()));
return 0;
}
const AttributeContext &context) const
{
}
{
}
{
return new DefaultAttributeDefinition(*this);
}
{
}
{
return 1;
}
const
{
const AttributeValue *fixedValue
case AttributeValue::implied:
case AttributeValue::cdata:
}
break;
case AttributeValue::tokenized:
}
break;
}
}
return value;
}
{
// get the fixed value
}
{
return new FixedAttributeDefinition(*this);
}
{
}
{
anyCurrent_ = 0;
}
else {
}
}
{
index = i;
return 1;
}
return 0;
}
{
return 0;
return 1;
}
unsigned &index) const
{
index = i;
return 1;
}
return 0;
}
{
anyCurrent_ = 1;
}
{
}
{
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
}
{
return notation_;
}
{
return new NotationAttributeSemantics(*this);
}
{
}
{
}
{
return entity_[i];
}
{
return new EntityAttributeSemantics(*this);
}
{
}
{
}
const StringC &,
unsigned &,
unsigned &) const
{
return 0;
}
{
return 0;
}
AttributeContext &, const StringC &)
{
return 0;
}
{
}
const StringC *&) const
{
return implied;
}
{
}
{
return tokenized;
}
{
return &text_;
}
unsigned &nIdrefs,
unsigned &nEntityNames) const
{
return 0;
}
{
}
const StringC *&) const
{
return cdata;
}
{
return &text_;
}
const StringC &)
{
const Char *s;
return 1;
}
return 0;
}
: specIndexPlus_(0)
{
}
{
specIndexPlus_ = 0;
semantics_.clear();
}
nIdrefs_(0), nEntityNames_(0)
{
}
{
}
{
nSpec_ = 0;
conref_ = 0;
nIdrefs_ = 0;
nEntityNames_ = 0;
else {
}
}
{
}
{
{
}
{
nEntityNames_ = tem;
}
{
}
{
}
}
{
}
&& conref_
}
{
else
}
void AttributeList::noteInvalidSpec()
{
// This is needed for error recovery.
// We don't want nSpec_ to be > 0, if there is no attribute definition.
if (nSpec_)
nSpec_++;
}
unsigned &specLength)
{
conref_ = 1;
if (value)
return 0;
return 1;
}
unsigned &specLength)
{
conref_ = 1;
if (value)
}
{
// Check for no attributes
return 0;
// Check for no ID declared
if (i == size_t(-1))
return 0;
// Check for invalid value
const AttributeValue *v = value(i);
if (!v)
return 0;
// Check for implied value
if (!t)
return 0;
return &t->string();
}
{
if (nSpec_ > 0) {
if (val)
// I wish I could avoid casting away const here.
name(i));
break;
}
return 1;
}
return 0;
}
{
if (nSpec_ > 0) {
return 1;
break;
}
}
}
return 0;
}
// This tries to guess this attribute value looks like if it had
// a missing ending quote.
{
switch (type) {
}
break;
break;
default:
lastStr = 0;
break;
}
}
if (lastStr) {
while (lastLen > 0
lastLen--;
&& (vi
return 1;
}
}
return 0;
}
{
}
{
}
Location &)
{
return 1;
}
{
}
{
}
{
return 0;
}
const Location &)
{
return 0;
}
const Location &)
{
return 0;
}
{
if (impliedAttributeValue_.isNull())
return impliedAttributeValue_;
}
#ifdef SP_NAMESPACE
}
#endif