source: trunk/src/symtab.h @ 173

Last change on this file since 173 was 173, checked in by lindanl, 11 years ago

End-tags for non UTF-8; predefined symbol fix; DTD parsing fixes.

File size: 1.7 KB
Line 
1/*  symtab.h - XML Symbol Table Module
2    Copyright (c) 2008 Robert D. Cameron
3    Licensed to the public under the Open Software License 3.0.
4    Licensed to International Characters, Inc., under the Academic
5    Free License 3.0.
6*/
7
8#ifndef SYMTAB_H
9#define SYMTAB_H
10
11#include "namechars.h"
12
13struct eqstr
14{
15  bool operator()(const char* s1, const char* s2) const
16  {
17    return strcmp(s1, s2) == 0;
18  }
19};
20
21struct Name_Data
22{
23        char * name_string;
24        int        lgth;
25};
26       
27char * predefined[] = {"lt", "gt", "amp", "quot", "apos"};
28
29/*  A StringPool object provides managed storage for strings.
30   It can grow to accommodate as many strings as desired, subject
31   to space availability.  It is implemented as a vector of
32   pool buffers.  Initially a single buffer of size initial_capacity
33   is allocated.  Strings are inserted into this area until insufficient
34   space remains, at which point a new buffer is allocated for
35   subsequent insertions.  */
36
37class StringPool {
38public:
39       StringPool();
40       ~StringPool();
41       char * Insert(char * s, int lgth);
42private:
43       int buffer_capacity;
44       int buffer_space_used;
45       vector<char *> pool_buffers;
46};
47
48class Symbol_Table {
49public:
50        Symbol_Table();
51
52
53        int Insert_Name(char * name, int lgth);
54        int ASCII_Lookup_or_Insert(char * name, int lgth);     
55        int UTF8_Lookup_or_Insert(char * name, int lgth);
56
57        char * Get_UTF8_name(int nameID);
58        int Get_UTF8_lgth(int nameID);
59       
60        char * ReserveSymbolSpace(int u8_lgth);
61        int LookupOrInsertReserved();
62       
63        XML_version version;
64        vector<Name_Data> UTF8NameTable;
65private:
66        hash_map<const char *, int, hash<const char *>, eqstr > UTF8NameMap;
67        int globalNameCount;
68//      vector<char *> UTF8NameTable;
69
70        char * reserved;
71        int reserved_lgth;
72        StringPool * pool;
73};
74
75
76
77#endif
Note: See TracBrowser for help on using the repository browser.