source: trunk/src/xmlmodel.c @ 3923

Last change on this file since 3923 was 268, checked in by ksherdy, 10 years ago

Initialize global variables since this initialization does not occur 'automatically' for the case Parabix is built as a shared object library.

File size: 1.9 KB
Line 
1/*  xmlmodel.c - XML Model Processor
2    Copyright (c) 2007, 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
9#include "multiliteral.h"
10#include "xmlmodel.h"
11
12void Model_Info::SimpleEntity(const char * entity_Name, const char * replText) {
13
14                int entity_NameID = symbol_table->Insert_Name(entity_Name, strlen(entity_Name));
15                int entityID = GlobalGEntityTable[entity_NameID];
16                if(entityID==0){
17                        GEntity_info * this_info = new GEntity_info;
18                        GlobalGEntityTable[entity_NameID]=++(globalGEntityCount);
19                        entityID = globalGEntityCount;
20
21                        this_info->globalGEntity_id = entityID;
22                        this_info->is_external = false;
23                        this_info->ReplacementText = replText;
24                        this_info->systemLiteral = NULL;
25                        this_info->pubidLiteral = NULL;
26                        this_info->NDataName = NULL;
27                        this_info->is_simple = true;
28
29                        GEntityData.push_back(this_info);
30                }
31}
32Model_Info::Model_Info() {
33        ElementAttributeData.push_back(vector<ATT_info *>());
34        globalElementCount = 0;
35        globalAttributeCount = 0;
36        globalNotationCount = 0;
37        globalGEntityCount = 0;
38        globalPEntityCount = 0; 
39       
40        symbol_table = new Symbol_Table();
41        SimpleEntity("lt", "<");
42        SimpleEntity("gt", ">");
43        SimpleEntity("amp", "&");
44        SimpleEntity("quot", "\"");
45        SimpleEntity("apos", "'");
46}
47
48
49Model_Info::~Model_Info() {
50}
51
52int Model_Info::getOrInsertGlobalElement(int elem_nameID) {
53        int elemID =  GlobalElementTable[elem_nameID];
54        if(elemID==0){
55                GlobalElementTable[elem_nameID]=++(globalElementCount);
56                elemID = globalElementCount;
57
58                ElementAttributeData.push_back(vector<ATT_info *>());
59        }
60        return elemID;
61}
62
63int Model_Info::getOrInsertGlobalAttName(int att_nameID){
64
65        int attID = GlobalAttributeTable[att_nameID];
66        if(attID==0){
67                GlobalAttributeTable[att_nameID]=++(globalAttributeCount);
68                attID = globalAttributeCount;
69        }
70        return attID;
71}
Note: See TracBrowser for help on using the repository browser.