19 #include "stringManipulate.h"
21 #define MAX_GRAMMARS_COUNT 5000
25 unsigned char mask_strict,
unsigned char mask_sc,
unsigned char mask_preserve, FILE* out)
30 Index uriIter, lnIter, pfxIter, ruleIter, partIter, prodIter;
36 unsigned int tgCount = 0;
43 fprintf(out,
"errorCode get_%sSchema(EXIPSchema* schema);\n\n", prefix);
44 fprintf(out,
"errorCode get_%sSchema(EXIPSchema* schema)\n{\n\t errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR;\n\t\n\t", prefix);
45 fprintf(out,
"if(schema == NULL)\n\t return EXIP_NULL_POINTER_REF;\n\t");
47 fprintf(out,
"tmp_err_code = initAllocList(&schema->memList);\n\t");
48 fprintf(out,
"if(tmp_err_code != EXIP_OK)\n\t return tmp_err_code;\n\t");
54 fprintf(out,
"PfxTable* pfxTable_%d = memManagedAllocate(&schema->memList, sizeof(PfxTable));\n\t", uriIter);
55 fprintf(out,
"if(pTable_%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter);
60 fprintf(out,
"tmp_err_code += asciiToString(\"");
62 fprintf(out,
"\", &pTable_%d->string_val[%d], &schema->memList, TRUE);\n\t", uriIter, pfxIter);
64 for(; pfxIter < MAXIMUM_NUMBER_OF_PREFIXES_PER_URI; pfxIter++)
66 fprintf(out,
"getEmptyString(&pTable_%d->string_val[%d]);\n\t", uriIter, pfxIter);
68 fprintf(out,
"if(tmp_err_code != EXIP_OK)\n\t return EXIP_UNEXPECTED_ERROR;\n\t");
80 if(mask_specified ==
TRUE)
84 printf(
"\n ERROR: OUT_SRC_DYN output format!");
89 for(ruleIter = 0; ruleIter < tmpGrammar->
count; ruleIter++)
91 for(partIter = 0; partIter < 3; partIter++)
93 if(tmpGrammar->
rule[ruleIter].part[partIter].count > 0)
95 fprintf(out,
"Production* prod_%d_%d_%d_part%d = memManagedAllocate(&schema->memList, %d * sizeof(Production));\n\t", uriIter, lnIter, ruleIter, partIter, tmpGrammar->
rule[ruleIter].part[partIter].count);
96 fprintf(out,
"if(prod_%d_%d_%d_part%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter, lnIter, ruleIter, partIter);
98 for(prodIter = 0; prodIter < tmpGrammar->
rule[ruleIter].part[partIter].count; prodIter++)
100 fprintf(out,
"prod_%d_%d_%d_part%d[%d].evnt.eventType = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].evnt.eventType);
101 fprintf(out,
"prod_%d_%d_%d_part%d[%d].evnt.valueType.exiType = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].evnt.valueType.exiType);
102 fprintf(out,
"prod_%d_%d_%d_part%d[%d].evnt.valueType.simpleTypeId = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].evnt.valueType.simpleTypeId);
103 fprintf(out,
"prod_%d_%d_%d_part%d[%d].nonTermID = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].nonTermID);
104 fprintf(out,
"prod_%d_%d_%d_part%d[%d].qname.uriId = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].qname.uriId);
105 fprintf(out,
"prod_%d_%d_%d_part%d[%d].qname.lnId = %d;\n\t", uriIter, lnIter, ruleIter, partIter, prodIter, tmpGrammar->
rule[ruleIter].part[partIter].prod[prodIter].qname.lnId);
111 fprintf(out,
"GrammarRule* rule_%d_%d = memManagedAllocate(&schema->memList, %d * sizeof(GrammarRule));\n\t", uriIter, lnIter, tmpGrammar->
count);
112 fprintf(out,
"if(rule_%d_%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter, lnIter);
114 for(ruleIter = 0; ruleIter < tmpGrammar->
count; ruleIter++)
116 for(partIter = 0; partIter < 3; partIter++)
118 if(tmpGrammar->
rule[ruleIter].part[partIter].count > 0)
119 fprintf(out,
"rule_%d_%d[%d].part[%d] = prod_%d_%d_%d_part%d;\n\t", uriIter, lnIter, ruleIter, partIter, uriIter, lnIter, ruleIter, partIter);
121 fprintf(out,
"rule_%d_%d[%d].part[%d].prod = NULL;\n\t", uriIter, lnIter, ruleIter, partIter);
123 fprintf(out,
"rule_%d_%d[%d].part[%d].count = %d;\n\t", uriIter, lnIter, ruleIter, partIter, tmpGrammar->
rule[ruleIter].part[partIter].count);
124 fprintf(out,
"rule_%d_%d[%d].part[%d].bits = %d;\n\t", uriIter, lnIter, ruleIter, partIter, tmpGrammar->
rule[ruleIter].part[partIter].bits);
129 fprintf(out,
"EXIGrammar* grammar_%d_%d = memManagedAllocate(&schema->memList, sizeof(EXIGrammar));\n\t", uriIter, lnIter);
130 fprintf(out,
"if(grammar_%d_%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter, lnIter);
132 fprintf(out,
"grammar_%d_%d->contentIndex = %d;\n\t", uriIter, lnIter, tmpGrammar->contentIndex);
133 fprintf(out,
"grammar_%d_%d->props = 0x%02x;\n\t", uriIter, lnIter, tmpGrammar->
props);
134 fprintf(out,
"grammar_%d_%d->count = %d;\n\t", uriIter, lnIter, tmpGrammar->
count);
135 fprintf(out,
"grammar_%d_%d->rule = rule_%d_%d;\n\t", uriIter, lnIter, uriIter, lnIter);
139 printf(
"\n ERROR: MAX_GRAMMARS_COUNT reached!");
145 printf(
"\n ERROR: OUT_SRC_DYN output format!");
148 typeGrammars[tgCount].
uriId = uriIter;
149 typeGrammars[tgCount].
lnId = lnIter;
153 fprintf(out,
"struct LocalNamesRow* LNrows_%d = memManagedAllocate(&schema->memList, %d * sizeof(struct LocalNamesRow));\n\t", uriIter, schema->
uriTable.
uri[uriIter].
lnTable.
count);
154 fprintf(out,
"if(LNrows_%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter);
164 if(tmpGrammar !=
NULL)
165 fprintf(out,
"LNrows_%d[%d].typeGrammar = grammar_%d_%d;\n\t", uriIter, lnIter, typeGrammars[typeGrammarID].uriId, typeGrammars[typeGrammarID].lnId);
167 fprintf(out,
"LNrows_%d[%d].typeGrammar = NULL;\n\t", uriIter, lnIter);
169 fprintf(out,
"LNrows_%d[%d].string_val.str = \"", uriIter, lnIter);
171 fprintf(out,
"\";\n\t");
173 fprintf(out,
"LNrows_%d[%d].vCrossTable = NULL;\n\t", uriIter, lnIter);
177 fprintf(out,
"LocalNamesTable* lTable_%d = memManagedAllocate(&schema->memList, sizeof(LocalNamesTable));\n\t", uriIter);
178 fprintf(out,
"if(lTable_%d == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t", uriIter);
182 fprintf(out,
"lTable_%d->rows = LNrows_%d;\n\t", uriIter, uriIter);
183 fprintf(out,
"lTable_%d->memPair.memBlock = NULL;\n\t", uriIter);
184 fprintf(out,
"lTable_%d->memPair.allocIndx = 0;\n\t", uriIter);
187 fprintf(out,
"struct URIRow* uriRows = memManagedAllocate(&schema->memList, %d * sizeof(struct URIRow));\n\t", schema->
uriTable.
count);
189 fprintf(out,
"if(uriRows == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t");
192 for(uriIter = 0; uriIter < schema->
uriTable.
count; uriIter++)
195 fprintf(out,
"uriRows[%d].pTable = pTable_%d;\n\t", uriIter, uriIter);
197 fprintf(out,
"uriRows[%d].pTable = NULL;\n\t", uriIter);
198 fprintf(out,
"uriRows[%d].lTable = lTable_%d;\n\t", uriIter, uriIter);
199 fprintf(out,
"uriRows[%d].string_val.str = \"", uriIter);
201 fprintf(out,
"\";\n\t");
206 fprintf(out,
"URITable* uriTbl = memManagedAllocate(&schema->memList, sizeof(URITable));\n\t");
207 fprintf(out,
"if(uriTbl == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t");
209 fprintf(out,
"uriTbl->rowCount = %d;\n\t", schema->
uriTable.
count);
210 fprintf(out,
"uriTbl->rows = uriRows;\n\t");
211 fprintf(out,
"uriTbl->memPair.memBlock = NULL;\n\t");
212 fprintf(out,
"uriTbl->memPair.allocIndx = 0;\n\t");
213 fprintf(out,
"QNameID* qnames = memManagedAllocate(&schema->memList, %d * sizeof(QNameID));\n\t", schema->globalElemGrammarTable.count);
214 fprintf(out,
"if(qnames == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t");
216 for(uriIter = 0; uriIter < schema->globalElemGrammarTable.count; uriIter++)
218 fprintf(out,
"qnames[%d].uriId = %d;\n\t", uriIter, schema->globalElemGrammarTable.qname[uriIter].uriId);
219 fprintf(out,
"qnames[%d].lnId = %d;\n\t", uriIter, schema->globalElemGrammarTable.qname[uriIter].lnId);
223 fprintf(out,
"SimpleType* sTypes = memManagedAllocate(&schema->memList, %d * sizeof(SimpleType));\n\t", schema->
simpleTypeTable.
count);
224 fprintf(out,
"if(sTypes == NULL)\n\t return EXIP_MEMORY_ALLOCATION_ERROR;\n\t");
228 fprintf(out,
"sTypes[%d].facetPresenceMask = %d;\n\t", uriIter, schema->
simpleTypeTable.
sType[uriIter].facetPresenceMask);
229 fprintf(out,
"sTypes[%d].maxInclusive = %d;\n\t", uriIter, schema->
simpleTypeTable.
sType[uriIter].maxInclusive);
230 fprintf(out,
"sTypes[%d].minInclusive = %d;\n\t", uriIter, schema->
simpleTypeTable.
sType[uriIter].minInclusive);
231 fprintf(out,
"sTypes[%d].maxLength = %d;\n\t", uriIter, schema->
simpleTypeTable.
sType[uriIter].maxLength);
235 fprintf(out,
"schema->globalElemGrammars = qnames;\n\t");
236 fprintf(out,
"schema->globalElemGrammarTable.count = %d;\n\t", schema->globalElemGrammarTable.count);
237 fprintf(out,
"schema->uriTable = uriTbl;\n\t");
238 fprintf(out,
"schema->simpleTypeArray = sTypes;\n\t");
240 fprintf(out,
"schema->isAugmented = %d;\n\t", mask_specified);
241 fprintf(out,
"schema->isStatic = FALSE;\n\t");
242 fprintf(out,
"return EXIP_OK;\n}");