File: NumberCache.h

package info (click to toggle)
jade 1.2.1-47
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 8,804 kB
  • ctags: 16,991
  • sloc: cpp: 120,658; sh: 10,522; ansic: 8,228; perl: 378; makefile: 292; sed: 5
file content (50 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download | duplicates (15)
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
// Copyright (c) 1996 James Clark
// See the file copying.txt for copying permission.

#ifndef NumberCache_INCLUDED
#define NumberCache_INCLUDED 1

#include "Boolean.h"
#include "Node.h"
#include "NamedTable.h"
#include "StringC.h"
#include "NCVector.h"

#ifdef DSSSL_NAMESPACE
namespace DSSSL_NAMESPACE {
#endif

class NumberCache {
public:
  NumberCache();
  // Return 0 if argument is not a node.
  bool childNumber(const NodePtr &node, unsigned long &);
  // Number of elements before or equal to node whose gi is equal to s.
  unsigned long elementNumber(const NodePtr &node, const StringC &s);
  // Number of elements before or equal to node whose gi is equal to s,
  // and that are after the last element before node with gi reset.
  unsigned long elementNumberAfter(const NodePtr &, const StringC &s,
				   const StringC &reset);
private:
  struct Entry : Named {
    Entry(const StringC &);
    NodePtr node;
    unsigned long num;
  };
  // A separate cache for each level of the tree.
  NCVector<NamedTable<Entry> > childNumbers_;
  struct ElementEntry : Entry {
    ElementEntry(const StringC &);
    NodePtr subNode;
    unsigned long subNum;
  };
  NamedTable<ElementEntry> elementNumbers_;
  friend struct ElementEntry;
};

#ifdef DSSSL_NAMESPACE
}
#endif

#endif /* not NumberCache_INCLUDED */