#include "util.h"
#include "ezxml.h"
Go to the source code of this file.
|
ezxml_t | FindElement (INP ezxml_t Parent, INP const char *Name, INP boolean Required) |
|
ezxml_t | FindFirstElement (INP ezxml_t Parent, INP const char *Name, INP boolean Required) |
|
void | CheckElement (INP ezxml_t Node, INP const char *Name) |
|
void | FreeNode (INOUTP ezxml_t Node) |
|
const char * | FindProperty (INP ezxml_t Parent, INP const char *Name, INP boolean) |
|
boolean | IsWhitespace (char c) |
|
void | CountTokensInString (INP const char *Str, OUTP int *Num, OUTP int *Len) |
|
char ** | GetNodeTokens (INP ezxml_t Node) |
|
char ** | LookaheadNodeTokens (INP ezxml_t Node) |
|
int | CountChildren (INP ezxml_t Node, INP const char *Name, INP int min_count) |
|
int | GetIntProperty (INP ezxml_t Parent, INP char *Name, INP boolean Required, INP int default_value) |
|
float | GetFloatProperty (INP ezxml_t Parent, INP char *Name, INP boolean Required, INP float default_value) |
|
boolean | GetBooleanProperty (INP ezxml_t Parent, INP char *Name, INP boolean Required, INP boolean default_value) |
|
Definition at line 59 of file read_xml_util.c.
60 assert(Node != NULL && Name != NULL);
61 if (0 != strcmp(Node->name, Name)) {
63 "[LINE %d] Element '%s' within element '%s' does match expected "
64 "element type of '%s'\n", Node->line, Node->name, Node->parent->name,
int CountChildren |
( |
INP ezxml_t |
Node, |
|
|
INP const char * |
Name, |
|
|
INP int |
min_count |
|
) |
| |
Definition at line 343 of file read_xml_util.c.
357 if (strcmp(Cur->
name, Name) == 0) {
369 if (Count < min_count) {
370 vpr_printf(TIO_MESSAGE_ERROR,
"[Line %d] Expected node '%s' to have %d "
371 "child elements, but none found.\n", Node->line, Node->name, min_count);
void CountTokensInString |
( |
INP const char * |
Str, |
|
|
OUTP int * |
Num, |
|
|
OUTP int * |
Len |
|
) |
| |
Definition at line 11 of file read_xml_util.c.
22 "[LINE %d] Element '%s' not found within element '%s'.\n",
23 Parent->line, Name, Parent->name);
29 if (Cur != NULL && Cur->
next) {
31 TIO_MESSAGE_ERROR,
"[LINE %d] Element '%s' found twice within element '%s'.\n",
32 Parent->line, Name, Parent->name);
ezxml_t ezxml_child(ezxml_t xml, const char *name)
Definition at line 38 of file read_xml_util.c.
49 "[LINE %d] Element '%s' not found within element '%s'.\n",
50 Parent->line, Name, Parent->name);
ezxml_t ezxml_child(ezxml_t xml, const char *name)
const char* FindProperty |
( |
INP ezxml_t |
Parent, |
|
|
INP const char * |
Name, |
|
|
INP |
boolean |
|
) |
| |
Definition at line 122 of file read_xml_util.c.
129 "[Line %d] Required property '%s' not found for element '%s'.\n",
130 Parent->line, Name, Parent->name);
const char * ezxml_attr(ezxml_t xml, const char *attr)
Definition at line 73 of file read_xml_util.c.
79 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Node '%s' has invalid property %s=\"%s\".\n",
80 Node->line, Node->name, Node->attr[0], Node->attr[1]);
89 "[LINE %d] Node '%s' has unexpected text '%s' within it.\n",
90 Node->line, Node->name, Node->txt);
99 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Node '%s' has invalid child node '%s'.\n",
100 Node->line, Node->name, Cur->
name);
boolean IsWhitespace(char c)
#define ezxml_remove(xml)
Definition at line 314 of file read_xml_util.c.
318 boolean property_value;
320 property_value = default_value;
323 if ((strcmp(Prop,
"false") == 0) || (strcmp(Prop,
"FALSE") == 0)
324 || (strcmp(Prop,
"False") == 0)) {
325 property_value =
FALSE;
326 }
else if ((strcmp(Prop,
"true") == 0) || (strcmp(Prop,
"TRUE") == 0)
327 || (strcmp(Prop,
"True") == 0)) {
328 property_value =
TRUE;
331 TIO_MESSAGE_ERROR,
"[LINE %d] Unknown value %s for boolean attribute %s in %s",
332 Parent->line, Prop, Name, Parent->name);
337 return property_value;
const char * FindProperty(INP ezxml_t Parent, INP const char *Name, INP boolean Required)
ezxml_t ezxml_set_attr(ezxml_t xml, char *name, char *value)
Definition at line 297 of file read_xml_util.c.
301 float property_value;
303 property_value = default_value;
306 property_value = (float)atof(Prop);
309 return property_value;
const char * FindProperty(INP ezxml_t Parent, INP const char *Name, INP boolean Required)
ezxml_t ezxml_set_attr(ezxml_t xml, char *name, char *value)
Definition at line 281 of file read_xml_util.c.
286 property_value = default_value;
289 property_value =
my_atoi(Prop);
292 return property_value;
const char * FindProperty(INP ezxml_t Parent, INP const char *Name, INP boolean Required)
ezxml_t ezxml_set_attr(ezxml_t xml, char *name, char *value)
int my_atoi(const char *str)
Definition at line 165 of file read_xml_util.c.
178 Len = (
sizeof(char) * Len) +
179 (
sizeof(char) * Count);
183 Tokens = (
char **)
my_malloc(
sizeof(
char *) * (Count + 1));
184 Dst = (
char *)
my_malloc(
sizeof(
char) * Len);
215 Tokens[Count] = NULL;
void CountTokensInString(INP const char *Str, OUTP int *Num, OUTP int *Len)
boolean IsWhitespace(char c)
static void * my_malloc(int ibytes)
ezxml_t ezxml_set_txt(ezxml_t xml, char *txt)
Definition at line 224 of file read_xml_util.c.
237 Len = (
sizeof(char) * Len) +
238 (
sizeof(char) * Count);
242 Tokens = (
char **)
my_malloc(
sizeof(
char *) * (Count + 1));
243 Dst = (
char *)
my_malloc(
sizeof(
char) * Len);
273 Tokens[Count] = NULL;
void CountTokensInString(INP const char *Str, OUTP int *Num, OUTP int *Len)
boolean IsWhitespace(char c)
static void * my_malloc(int ibytes)