source: trunk/src/symtab.h @ 4051

Last change on this file since 4051 was 267, checked in by ksherdy, 10 years ago

Construct and pass string literals as read only (const char *) types.

File size: 1.5 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#include "stringpool.h"
13
14struct eqstr
15{
16  bool operator()(const char* s1, const char* s2) const
17  {
18    return strcmp(s1, s2) == 0;
19  }
20};
21
22struct Name_Data
23{
24        char * name_string;
25        int        lgth;
26};
27
28const char * predefined[] = {"lt", "gt", "amp", "quot", "apos"};
29
30class Symbol_Table {
31public:
32        Symbol_Table();
33
34
35        int Insert_Name(const char * name, int lgth);
36        int ASCII_Lookup_or_Insert_Name(char * name, int lgth);
37        int UTF8_Lookup_or_Insert_Name(char * name, int lgth);
38        int ASCII_Lookup_or_Insert_Nmtoken(char * name, int lgth);
39        int UTF8_Lookup_or_Insert_Nmtoken(char * name, int lgth);
40
41        char * Get_UTF8_name(int nameID);
42        int Get_UTF8_lgth(int nameID);
43
44        char * Get_UTF8_nmtoken(int nmtokenID);
45        int Get_UTF8_nmtoken_lgth(int nmtokenID);
46
47        char * ReserveSymbolSpace(int u8_lgth);
48        int LookupOrInsertReserved();
49        int LookupOrInsertReserved_nmtoken();
50
51        XML_version version;
52        vector<Name_Data> UTF8NameTable;
53        vector<Name_Data> UTF8NmtokenTable;
54private:
55        hash_map<const char *, int, hash<const char *>, eqstr > UTF8NameMap;
56        hash_map<const char *, int, hash<const char *>, eqstr > UTF8NmtokenMap;
57        int globalNameCount;
58        int globalNmtokenCount;
59//      vector<char *> UTF8NameTable;
60
61        char * reserved;
62        int reserved_lgth;
63        StringPool<4096,100> pool;
64};
65
66
67
68#endif
Note: See TracBrowser for help on using the repository browser.