/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/parabix.20090922/src/symtab.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-09-23 17:13:04 UTC
  • Revision ID: csa@dside.dyndns.org-20090923171304-osvtr4zqb29h11kd
Intel, Tango, Phobos, and RapidXML parsers; Memory benchmark scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
14
struct eqstr
 
15
{
 
16
  bool operator()(const char* s1, const char* s2) const
 
17
  {
 
18
    return strcmp(s1, s2) == 0;
 
19
  }
 
20
};
 
21
 
 
22
struct Name_Data
 
23
{
 
24
        char * name_string;
 
25
        int        lgth;
 
26
};
 
27
 
 
28
const char * predefined[] = {"lt", "gt", "amp", "quot", "apos"};
 
29
 
 
30
class Symbol_Table {
 
31
public:
 
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;
 
54
private:
 
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