/usr/include/OpenJade/Node.h is in libostyle-dev 1.4devel1-21.3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | // Copyright (c) 1996 James Clark
// See the file COPYING for copying permission.
#ifndef Node_INCLUDED
#define Node_INCLUDED 1
#ifdef __GNUG__
#pragma interface
#endif
#include <stddef.h>
#include <limits.h>
#include <OpenSP/IList.h>
#ifdef SP_USE_DLL
#ifdef BUILD_LIBGROVE
#define GROVE_API SP_DLLEXPORT
#else
#define GROVE_API SP_DLLIMPORT
#endif
#else /* not SP_USE_DLL */
#define GROVE_API /* as nothing */
#endif /* not SP_USE_DLL */
#ifdef GROVE_NAMESPACE
#define GROVE_NAMESPACE_SCOPE GROVE_NAMESPACE::
#else
#define GROVE_NAMESPACE_SCOPE
#endif
// Supports the following modules:
// baseabs prlgabs0 prlgabs1 instabs basesds0 instsds0 subdcabs
// rankabs fpiabs
#ifdef GROVE_NAMESPACE
namespace GROVE_NAMESPACE {
#endif
#ifdef SP_MULTI_BYTE
#if UINT_MAX >= 0xffffffffL /* 2^32 - 1 */
typedef unsigned int GroveChar;
#else
typedef unsigned long GroveChar;
#endif
#else /* not SP_MULTI_BYTE */
typedef unsigned char GroveChar;
#endif /* not SP_MULTI_BYTE */
class NodePtr;
class NodeListPtr;
class NamedNodeListPtr;
class GroveString;
class NodeVisitor;
class SdataMapper;
class GroveStringList;
class GroveStringListPtr;
enum AccessResult {
accessOK, // success
accessNull, // value is null
accessTimeout, // timed out waiting for property
accessNotInClass // property is not defined for class
};
struct GROVE_API ComponentName {
enum Id {
noId = -1,
idAllPropertyNames,
idAnd,
idAny,
idApplicationInfo,
idAttributeAssignment,
idAttributeDef,
idAttributeDefs,
idAttributes,
idAttributeValueToken,
idCapacity,
idCdata,
idChar,
idCharset,
idChildrenPropertyName,
idClassName,
idConnector,
idConref,
idContent,
idContentTokens,
idContentType,
idCurrent,
idCurrentAttributeIndex,
idCurrentGroup,
idDataChar,
idDataPropertyName,
idDataSepPropertyName,
idDeclValueType,
idDefaulted,
idDefaultedEntities,
idDefaultEntity,
idDefaultValue,
idDefaultValueType,
idDoctypesAndLinktypes,
idDocument,
idDocumentElement,
idDocumentType,
idDtd,
idElement,
idElements,
idElementToken,
idElementType,
idElementTypes,
idEmpty,
idEntities,
idEntity,
idEntityName,
idEntityType,
idEpilog,
idExclusions,
idExternalData,
idExternalId,
idFixed,
idFormalPublicId,
idGeneralEntities,
idGeneratedSystemId,
idGi,
idGoverning,
idGoverningDoctype,
idGroveRoot,
idId,
idIdref,
idIdrefs,
idImplied,
idIncluded,
idInclusions,
idIso,
idLpd,
idModelGroup,
idMustOmitEndTag,
idName,
idNames,
idNdata,
idNmtkgrp,
idNmtoken,
idNmtokens,
idNonsgml,
idNotation,
idNotationName,
idNotations,
idNumber,
idNumbers,
idNutoken,
idNutokens,
idOccurenceIndicator,
idOmitEndTag,
idOmitStartTag,
idOpt,
idOr,
idOrigin,
idOriginToSubnodeRelPropertyName,
idOwnerId,
idOwnerType,
idParameterEntities,
idParent,
idPcdataToken,
idPi,
idPlus,
idProlog,
idPublicId,
idRankGroup,
idRankStem,
idRankSuffix,
idRcdata,
idReferent,
idRegistered,
idRep,
idRequired,
idSdata,
idSeq,
idSgmlConstants,
idSgmlDocument,
idShortref,
idStem,
idSubdoc,
idSubdocument,
idSubnodePropertyNames,
idSyntax,
idSystemData,
idSystemId,
idText,
idTextClass,
idTextDescription,
idTextDesignatingSequence,
idTextDisplayVersion,
idTextLanguage,
idToken,
idTokens,
idTokenSep,
idTreeRoot,
idUnavailable,
idUnregistered,
idValue
};
enum { nIds = idValue + 1 };
static const char *rcsName(Id);
static const char *sdqlName(Id);
};
struct GROVE_API ClassDef {
ComponentName::Id className;
const ComponentName::Id *allPropertyNames;
const ComponentName::Id *subnodePropertyNames;
ComponentName::Id childrenPropertyName;
ComponentName::Id dataPropertyName;
ComponentName::Id dataSepPropertyName;
static const ClassDef sgmlDocument;
static const ClassDef sgmlConstants;
static const ClassDef dataChar;
static const ClassDef element;
static const ClassDef attributeAssignment;
static const ClassDef attributeDef;
static const ClassDef attributeValueToken;
static const ClassDef pi;
static const ClassDef sdata;
static const ClassDef documentType;
static const ClassDef entity;
static const ClassDef notation;
static const ClassDef externalId;
static const ClassDef externalData;
static const ClassDef subdocument;
static const ClassDef nonSgml;
static const ClassDef message;
static const ClassDef elementType;
static const ClassDef modelGroup;
static const ClassDef elementToken;
static const ClassDef pcdataToken;
static const ClassDef defaultEntity;
static const ClassDef rankStem;
static const ClassDef formalPublicId;
};
class PropertyValue;
class GROVE_API Node {
public:
// property values
// data in GroveString valid till Node destroyed
// default is accessNotInClass
// Intrinsic properties.
virtual AccessResult getOrigin(NodePtr &) const;
virtual AccessResult getParent(NodePtr &) const;
virtual AccessResult getGroveRoot(NodePtr &) const;
virtual AccessResult getTreeRoot(NodePtr &) const;
virtual AccessResult getOriginToSubnodeRelPropertyName(ComponentName::Id &) const = 0;
AccessResult getClassName(ComponentName::Id &) const;
AccessResult getChildrenPropertyName(ComponentName::Id &) const;
AccessResult getDataPropertyName(ComponentName::Id &) const;
AccessResult getDataSepPropertyName(ComponentName::Id &) const;
AccessResult getSubnodePropertyNames(const ComponentName::Id *&) const;
AccessResult getAllPropertyNames(const ComponentName::Id *&) const;
// this allows you to apply some operation to a node
// according to its grove class
virtual void accept(NodeVisitor &) = 0;
virtual const ClassDef &classDef() const = 0;
// not formally properties
virtual AccessResult children(NodeListPtr &) const = 0;
virtual AccessResult follow(NodeListPtr &) const = 0;
// return accessNull if there isn't a first or next
// result accessNotInClass if datatype of otsnr is not node-list or named-node-list
virtual AccessResult nextSibling(NodePtr &) const;
// works the same as nextSibling(), except that when charChunk()
// returns accessOK, returns node following that chunk.
virtual AccessResult nextChunkSibling(NodePtr &) const;
// if result == accessOK, length must be > 0
virtual AccessResult nextChunkAfter(NodePtr &) const;
virtual AccessResult charChunk(const SdataMapper &, GroveString &) const;
// return accessNotInClass if class doesn't have children property
// return accessNull if there isn't a first child
virtual AccessResult firstChild(NodePtr &) const;
// First of this node's siblings.
// accessNotInClass if datatype of otsnr is not node-list or named-node-list
virtual AccessResult firstSibling(NodePtr &) const;
// The index of this node in the list of all its siblings.
virtual AccessResult siblingsIndex(unsigned long &) const;
// Has a default implementation in terms of getAttributes and NodeList::ref
virtual AccessResult attributeRef(unsigned long, NodePtr &) const;
// references the list of the following siblings
// 0 is the next sibling
// Has a default implementation in terms of nextSibling.
virtual AccessResult followSiblingRef(unsigned long, NodePtr &) const;
// For a tokenized attribute returns tokens separated by spaces;
// null for a non-tokenized attribute.
virtual AccessResult tokens(GroveString &) const;
// For an element, the number of elements started before it,
// that is its zero-based index in a pre-order traversal of
// the all the elements in the document.
virtual AccessResult elementIndex(unsigned long &) const;
// Node identity.
// if hash() returns different values for two nodes,
// the operator==() must return false for those two nodes.
virtual unsigned long hash() const;
// Implementation will usually need to call sameGrove().
virtual bool operator==(const Node &node) const = 0;
bool operator!=(const Node &node) const { return !(*this == node); }
// Does this chunk contains nd?
virtual bool chunkContains(const Node &nd) const;
bool sameGrove(const Node &node) const;
typedef const char *IID;
virtual bool queryInterface(IID, const void *&) const;
// Property on SGML document giving list of parser messages.
virtual AccessResult getMessages(NodeListPtr &) const;
// Property of message.
enum Severity { info, warning, error };
virtual AccessResult getSeverity(Severity &) const;
AccessResult property(ComponentName::Id, const SdataMapper &, PropertyValue &) const;
virtual unsigned groveIndex() const = 0;
public:
virtual void addRef() = 0;
// You must call release rather than use delete.
// This is done automatically by NodePtr.
virtual void release() = 0;
protected:
// This enforces this.
#ifdef __GNUG__
virtual
#endif
~Node() { }
public:
// This is special.
// Implemented in terms of charChunk().
AccessResult getChar(const SdataMapper &, GroveChar &) const;
// From here on derived algorithmically from property set.
// Properties common to several node classes.
virtual AccessResult getAttributes(NamedNodeListPtr &) const;
virtual AccessResult getName(GroveString &) const;
virtual AccessResult getSystemData(GroveString &) const;
virtual AccessResult getEntity(NodePtr &) const;
virtual AccessResult getEntityName(GroveString &) const;
virtual AccessResult getExternalId(NodePtr &) const;
virtual AccessResult getNotation(NodePtr &) const;
virtual AccessResult getGi(GroveString &) const;
struct OccurIndicator {
enum Enum { opt, plus, rep };
};
virtual AccessResult getOccurIndicator(OccurIndicator::Enum &) const;
virtual AccessResult getAttributeDefs(NamedNodeListPtr &) const;
virtual AccessResult getText(GroveString &) const;
virtual AccessResult getNotationName(GroveString &) const;
struct EntityType {
enum Enum { text, cdata, sdata, ndata, subdocument, pi };
};
virtual AccessResult getEntityType(EntityType::Enum &) const;
// Properties only on entity
virtual AccessResult getDefaulted(bool &) const;
// Properties only on externalId
virtual AccessResult getPublicId(GroveString &) const;
virtual AccessResult getSystemId(GroveString &) const;
virtual AccessResult getGeneratedSystemId(GroveString &) const;
virtual AccessResult getFormalPublicId(NodePtr &) const;
// Properties only on attributeAssignment
virtual AccessResult getValue(NodeListPtr &) const;
virtual AccessResult getTokenSep(GroveChar &) const;
virtual AccessResult getImplied(bool &) const;
virtual AccessResult getAttributeDef(NodePtr &) const;
// Properties only on attributeDef
virtual AccessResult getCurrentAttributeIndex(long &) const;
virtual AccessResult getCurrentGroup(NodeListPtr &) const;
struct DeclValueType {
enum Enum { cdata, entity, entities, id, idref, idrefs, name, names, nmtoken,
nmtokens, number, numbers, nutoken, nutokens, notation, nmtkgrp };
};
virtual AccessResult getDeclValueType(DeclValueType::Enum &) const;
struct DefaultValueType {
enum Enum { value, fixed, required, current, conref, implied };
};
virtual AccessResult getDefaultValueType(DefaultValueType::Enum &) const;
virtual AccessResult getDefaultValue(NodeListPtr &) const;
virtual AccessResult getTokens(GroveStringListPtr &) const;
// Properties only on element.
virtual bool hasGi(GroveString) const;
virtual AccessResult getId(GroveString &) const;
virtual AccessResult getContent(NodeListPtr &) const;
virtual AccessResult getIncluded(bool &) const;
virtual AccessResult getMustOmitEndTag(bool &) const;
virtual AccessResult getElementType(NodePtr &) const;
// Properties only on elementType.
struct ContentType {
enum Enum { cdata, rcdata, empty, any, modelgrp };
};
virtual AccessResult getContentType(ContentType::Enum &) const;
virtual AccessResult getExclusions(GroveStringListPtr &) const;
virtual AccessResult getInclusions(GroveStringListPtr &) const;
virtual AccessResult getModelGroup(NodePtr &) const;
virtual AccessResult getOmitEndTag(bool &) const;
virtual AccessResult getOmitStartTag(bool &) const;
virtual AccessResult getRankGroup(GroveStringListPtr &) const;
virtual AccessResult getRankStem(GroveString &) const;
virtual AccessResult getRankSuffix(GroveString &) const;
// Properties only on rankStem
virtual AccessResult getElementTypes(NodeListPtr &) const;
virtual AccessResult getStem(GroveString &) const;
// Properties only on modelGroup.
struct Connector {
enum Enum { and_, or_, seq }; // "and", "or" can be keywords
};
virtual AccessResult getConnector(Connector::Enum &) const;
virtual AccessResult getContentTokens(NodeListPtr &) const;
// Properties only on attributeValueToken.
virtual AccessResult getToken(GroveString &) const;
virtual AccessResult getReferent(NodePtr &) const;
// Properties only on doctype
virtual AccessResult getGoverning(bool &) const;
virtual AccessResult getGeneralEntities(NamedNodeListPtr &) const;
virtual AccessResult getNotations(NamedNodeListPtr &) const;
virtual AccessResult getElementTypes(NamedNodeListPtr &) const;
virtual AccessResult getDefaultEntity(NodePtr &) const;
virtual AccessResult getParameterEntities(NamedNodeListPtr &) const;
// Properties only on sgmlDocument.
virtual AccessResult getSgmlConstants(NodePtr &) const;
virtual AccessResult getApplicationInfo(GroveString &) const;
virtual AccessResult getProlog(NodeListPtr &) const;
virtual AccessResult getEpilog(NodeListPtr &) const;
virtual AccessResult getDocumentElement(NodePtr &) const;
virtual AccessResult getElements(NamedNodeListPtr &) const;
virtual AccessResult getEntities(NamedNodeListPtr &) const;
virtual AccessResult getDefaultedEntities(NamedNodeListPtr &) const;
virtual AccessResult getGoverningDoctype(NodePtr &) const;
virtual AccessResult getDoctypesAndLinktypes(NamedNodeListPtr &) const;
// Properties only on dataChar.
// For a non-SGML data character (resulting from a numeric character reference).
// Something like this is being added in the HyTime TC.
virtual AccessResult getNonSgml(unsigned long &) const;
// Properties only on formalPublicId
struct OwnerType {
enum Enum { iso, registered, unregistered };
};
virtual AccessResult getOwnerType(OwnerType::Enum &) const;
virtual AccessResult getOwnerId(GroveString &) const;
struct TextClass {
enum Enum {
capacity,
charset,
document,
dtd,
elements,
entities,
lpd,
nonsgml,
notation,
shortref,
subdoc,
syntax,
text,
};
};
virtual AccessResult getTextClass(TextClass::Enum &) const;
virtual AccessResult getUnavailable(bool &) const;
virtual AccessResult getTextDescription(GroveString &) const;
virtual AccessResult getTextLanguage(GroveString &) const;
virtual AccessResult getTextDesignatingSequence(GroveString &) const;
virtual AccessResult getTextDisplayVersion(GroveString &) const;
};
class GROVE_API NodeList {
public:
virtual AccessResult first(NodePtr &) const = 0;
virtual AccessResult rest(NodeListPtr &) const = 0;
virtual AccessResult chunkRest(NodeListPtr &) const = 0;
// i is a zero based index
// This has a default implementation in terms of first and rest.
virtual AccessResult ref(unsigned long i, NodePtr &) const;
virtual void release() = 0;
virtual void addRef() = 0;
protected:
#ifdef __GNUG__
virtual
#endif
~NodeList() { }
};
class GROVE_API NamedNodeList {
public:
// This must NOT assume that the string has been normalized.
virtual AccessResult namedNode(GroveString, NodePtr &) const = 0;
// Do name normalize appropriate for this NamedNodeList.
// Returns new size (always <= old size).
// This can be used even if list is empty
virtual size_t normalize(GroveChar *, size_t) const = 0;
// Could have used subtyping here, but accessing NamedNodeList
// positionally typically requires different data structure.
virtual NodeListPtr nodeList() const = 0;
// Use this when you don't care about the order.
// May be much more efficient than nodeList().
virtual NodeListPtr nodeListNoOrder() const;
enum Type {
elements,
attributes,
entities,
notations,
doctypesAndLinktypes,
elementTypes,
attributeDefs
};
virtual Type type() const = 0;
// If the node is of a class that occurs in the list,
// return the value of the property that serves as the name
// property for nodes of that class in the named node list.
// Return accessNotInClass if the node is not of a class
// that occurs in the list.
AccessResult nodeName(const NodePtr &, GroveString &) const;
virtual void release() = 0;
virtual void addRef() = 0;
protected:
#ifdef __GNUG__
virtual
#endif
~NamedNodeList() { }
};
class GROVE_API NodePtr {
public:
NodePtr() : node_(0) { }
NodePtr(Node *node) : node_(node) { addRef(); }
~NodePtr() { release(); }
NodePtr(const NodePtr &ptr) : node_(ptr.node_) { addRef(); }
NodePtr &operator=(const NodePtr &ptr) {
ptr.addRef();
release();
node_ = ptr.node_;
return *this;
}
Node *operator->() const { return node_; }
Node &operator*() const { return *node_; }
AccessResult assignOrigin() { return node_->getOrigin(*this); }
AccessResult assignFirstChild() { return node_->firstChild(*this); }
AccessResult assignNextSibling() { return node_->nextSibling(*this); }
AccessResult assignNextChunkSibling() {
return node_->nextChunkSibling(*this);
}
AccessResult assignNextChunkAfter() {
return node_->nextChunkAfter(*this);
}
AccessResult assignFirstSibling() { return node_->firstSibling(*this); }
void assign(Node *node) {
if (node)
node->addRef();
release();
node_ = node;
}
void clear() { release(); node_ = 0; }
operator bool() const { return node_ != 0; }
private:
void addRef() const { if (node_) node_->addRef(); }
void release() const { if (node_) node_->release(); }
Node *node_;
};
class GROVE_API NodeListPtr {
public:
NodeListPtr() : list_(0) { }
NodeListPtr(NodeList *list) : list_(list) { addRef(); }
~NodeListPtr() { release(); }
NodeListPtr(const NodeListPtr &ptr) : list_(ptr.list_) { addRef(); }
NodeListPtr &operator=(const NodeListPtr &ptr) {
ptr.addRef();
release();
list_ = ptr.list_;
return *this;
}
AccessResult assignRest() { return list_->rest(*this); }
AccessResult assignChunkRest() { return list_->chunkRest(*this); }
NodeList *operator->() const { return list_; }
NodeList &operator*() const { return *list_; }
void assign(NodeList *list) {
if (list)
list->addRef();
release();
list_ = list;
}
void clear() { release(); list_ = 0; }
operator bool() const { return list_ != 0; }
private:
void addRef() const { if (list_) list_->addRef(); }
void release() const { if (list_) list_->release(); }
NodeList *list_;
};
class GROVE_API NamedNodeListPtr {
public:
NamedNodeListPtr() : list_(0) { }
NamedNodeListPtr(NamedNodeList *list) : list_(list) { addRef(); }
~NamedNodeListPtr() { release(); }
NamedNodeListPtr(const NamedNodeListPtr &ptr) : list_(ptr.list_) { addRef(); }
NamedNodeListPtr &operator=(const NamedNodeListPtr &ptr) {
ptr.addRef();
release();
list_ = ptr.list_;
return *this;
}
NamedNodeList *operator->() const { return list_; }
NamedNodeList &operator*() const { return *list_; }
void assign(NamedNodeList *list) {
if (list)
list->addRef();
release();
list_ = list;
}
void clear() { release(); list_ = 0; }
operator bool() const { return list_ != 0; }
private:
void addRef() const { if (list_) list_->addRef(); }
void release() const { if (list_) list_->release(); }
NamedNodeList *list_;
};
class GROVE_API GroveString {
public:
typedef const GroveChar *const_iterator;
GroveString() : data_(0), size_(0) { }
GroveString(const GroveChar *data, size_t size)
: data_(data), size_(size) { }
size_t size() const { return size_; }
const GroveChar *data() const { return data_; }
void assign(const GroveChar *data, size_t size) {
data_ = data;
size_ = size;
}
bool operator==(const GroveString &str) const;
bool operator!=(const GroveString &str) const { return !(*this == str); }
GroveChar operator[](size_t i) const { return data_[i]; }
const_iterator begin() const { return data_; }
const_iterator end() const { return data_ + size_; }
private:
const GroveChar *data_;
size_t size_;
};
class GROVE_API GroveStringLink {
public:
GroveStringLink( const GroveString &gs )
: data_(gs), next_(0) { }
friend class GroveStringList;
friend class ConstGroveStringListIter;
private:
GroveString data_;
GroveStringLink *next_;
};
class GroveStringList;
class GROVE_API ConstGroveStringListIter {
public:
friend class GroveStringList;
ConstGroveStringListIter() : link_(0) { }
ConstGroveStringListIter(const GroveStringList &list);
int done() const { return link_ == 0; }
const GroveString &cur() const { return link_->data_; }
void next() { link_ = link_->next_; }
protected:
void attach(const GroveStringLink *link) { link_ = link; }
const GroveStringLink *link_;
};
class GROVE_API GroveStringList {
public:
friend class ConstGroveStringListIter;
GroveStringList() : head_(0), refCount_(0) { }
~GroveStringList();
void append(const GroveString &gs);
void release();
void addRef();
bool canReuse(GroveStringListPtr &ptr) const;
AccessResult first(GroveString &) const;
AccessResult rest(GroveStringListPtr &) const;
const ConstGroveStringListIter &iter() { return iter_; }
private:
unsigned refCount_;
GroveStringLink *head_;
ConstGroveStringListIter iter_;
};
class GROVE_API GroveStringListPtr {
public:
GroveStringListPtr() : list_(0) { }
GroveStringListPtr(GroveStringList *list) : list_(list) { addRef(); }
~GroveStringListPtr() { release(); }
GroveStringListPtr(const GroveStringListPtr &ptr) : list_(ptr.list_) { addRef(); }
GroveStringListPtr &operator=(const GroveStringListPtr &ptr) {
ptr.addRef();
release();
list_ = ptr.list_;
return *this;
}
GroveStringList *operator->() const { return list_; }
GroveStringList &operator*() const { return *list_; }
void assign(GroveStringList *list) {
if (list)
list->addRef();
release();
list_ = list;
}
void clear() { release(); list_ = 0; }
operator bool() const { return list_ != 0; }
private:
void addRef() const { if (list_) list_->addRef(); }
void release() const { if (list_) list_->release(); }
GroveStringList *list_;
};
class GROVE_API SdataMapper {
public:
virtual ~SdataMapper();
// Returns a pointer to a single character or null
virtual bool sdataMap(GroveString name, GroveString text, GroveChar &) const;
};
// See Design Patterns.
class GROVE_API NodeVisitor {
public:
virtual void sgmlDocument(Node &);
virtual void sgmlConstants(Node &);
virtual void dataChar(Node &);
virtual void element(Node &);
virtual void attributeAssignment(Node &);
virtual void attributeDef(Node &);
virtual void attributeValueToken(Node &);
virtual void pi(Node &);
virtual void sdata(Node &);
virtual void documentType(Node &);
virtual void entity(Node &);
virtual void notation(Node &);
virtual void externalId(Node &);
virtual void externalData(Node &);
virtual void subdocument(Node &);
virtual void nonSgml(Node &);
virtual void message(Node &);
virtual void elementType(Node &);
virtual void rankStem(Node &);
virtual void modelGroup(Node &);
virtual void elementToken(Node &);
virtual void pcdataToken(Node &);
virtual void defaultEntity(Node &);
virtual void formalPublicId(Node &);
};
class GROVE_API PropertyValue {
public:
virtual ~PropertyValue() { }
virtual void set(const NodePtr &) = 0;
virtual void set(const NodeListPtr &) = 0;
virtual void set(const NamedNodeListPtr &) = 0;
virtual void set(bool) = 0;
virtual void set(GroveChar) = 0;
virtual void set(GroveString) = 0;
virtual void set(ComponentName::Id) = 0;
virtual void set(const GroveStringListPtr &) = 0;
virtual void set(const ComponentName::Id *) = 0;
virtual void set(long) = 0;
};
inline
AccessResult Node::getChar(const SdataMapper &mapper, GroveChar &c) const
{
GroveString str;
AccessResult ret = charChunk(mapper, str);
if (ret == accessOK)
c = str[0];
return ret;
}
inline
bool Node::sameGrove(const Node &node) const
{
return groveIndex() == node.groveIndex();
}
inline
AccessResult Node::getClassName(ComponentName::Id &name) const
{
name = classDef().className;
return accessOK;
}
inline
AccessResult Node::getChildrenPropertyName(ComponentName::Id &name) const
{
const ClassDef &def = classDef();
if (def.childrenPropertyName == ComponentName::noId)
return accessNull;
name = def.childrenPropertyName;
return accessOK;
}
inline
AccessResult Node::getDataPropertyName(ComponentName::Id &name) const
{
const ClassDef &def = classDef();
if (def.dataPropertyName == ComponentName::noId)
return accessNull;
name = def.dataPropertyName;
return accessOK;
}
inline
AccessResult Node::getDataSepPropertyName(ComponentName::Id &name) const
{
const ClassDef &def = classDef();
if (def.dataSepPropertyName == ComponentName::noId)
return accessNull;
name = def.dataSepPropertyName;
return accessOK;
}
inline
AccessResult Node::getSubnodePropertyNames(const ComponentName::Id *&names) const
{
names = classDef().subnodePropertyNames;
return accessOK;
}
inline
AccessResult Node::getAllPropertyNames(const ComponentName::Id *&names) const
{
names = classDef().allPropertyNames;
return accessOK;
}
#ifdef GROVE_NAMESPACE
}
#endif
#endif /* not Node_INCLUDED */
|