-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement_factory.cpp
More file actions
48 lines (42 loc) · 954 Bytes
/
element_factory.cpp
File metadata and controls
48 lines (42 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "element_factory.h"
#include "svg.h"
#include "rect.h"
static TAG tags[]={
{BAD_CAST"rect", CreateRect},
{BAD_CAST"svg", CreateSvg}
};
ElementFactory::ElementFactory(){
_tags = tags;
}
ElementFactory::~ElementFactory(){
}
Element* ElementFactory::create(xmlNodePtr node){
xmlChar* content = NULL;
Element* element = NULL;
int i;
if (NULL == node || NULL == node->name){
return NULL;
}
for (i = 0; i < sizeof(tags)/sizeof(TAG); i++){
if(!xmlStrcmp(node->name, _tags[i].name)){
element = _tags[i].create(node);
return element;
}
}
#if 0
if (NULL == element){
if (!xmlStrcmp(node->name, BAD_CAST"text")){
content = xmlNodeGetContent(node);
printf("<%s>\n", content);
xmlFree(content);
}else if (!xmlStrcmp(node->name, BAD_CAST"comment")){
content = xmlNodeGetContent(node);
printf("/*%s*/\n", content);
xmlFree(content);
}else{
printf("**%s\n", node->name);
}
}
#endif
return element;
}