1 /*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "stdafx.h"
17
18 #include "node_factory.h"
19 #include "node_items.h"
20 #include "simple_store.h"
21 #include "store_defs.h"
22
23 namespace zorba
24 {
25
26 namespace simplestore
27 {
28
29
instance()30 NodeFactory& NodeFactory::instance()
31 {
32 return GET_STORE().getNodeFactory();
33 }
34
35
NodeFactory()36 NodeFactory::NodeFactory()
37 {
38 }
39
40
~NodeFactory()41 NodeFactory::~NodeFactory()
42 {
43 }
44
45
createXmlTree()46 XmlTree* NodeFactory::createXmlTree()
47 {
48 return new XmlTree(NULL, GET_STORE().createTreeId());
49 }
50
51
createDocumentNode()52 DocumentNode* NodeFactory::createDocumentNode()
53 {
54 return new DocumentNode();
55 }
56
57
createDocumentNode(XmlTree * tree,const zstring & baseUri,const zstring & docUri)58 DocumentNode* NodeFactory::createDocumentNode(
59 XmlTree* tree,
60 const zstring& baseUri,
61 const zstring& docUri)
62 {
63 return new DocumentNode(tree, baseUri, docUri);
64 }
65
66
createElementNode(store::Item_t & nodeName,ulong numBindings,ulong numAttributes)67 ElementNode* NodeFactory::createElementNode(
68 store::Item_t& nodeName,
69 ulong numBindings,
70 ulong numAttributes)
71 {
72 return new ElementNode(nodeName, numBindings, numAttributes);
73 }
74
75
createElementNode(XmlTree * tree,InternalNode * parent,bool append,csize pos,store::Item_t & nodeName,store::Item_t & typeName,bool haveTypedValue,bool haveEmptyValue,bool isInSubstGroup,const store::NsBindings * localBindings,zstring & baseUri)76 ElementNode* NodeFactory::createElementNode(
77 XmlTree* tree,
78 InternalNode* parent,
79 bool append,
80 csize pos,
81 store::Item_t& nodeName,
82 store::Item_t& typeName,
83 bool haveTypedValue,
84 bool haveEmptyValue,
85 bool isInSubstGroup,
86 const store::NsBindings* localBindings,
87 zstring& baseUri)
88 {
89 return new ElementNode(tree, parent, append, pos, nodeName, typeName,
90 haveTypedValue, haveEmptyValue, isInSubstGroup,
91 localBindings, baseUri);
92 }
93
94
createAttributeNode(store::Item_t & qname)95 AttributeNode* NodeFactory::createAttributeNode(
96 store::Item_t& qname)
97 {
98 return new AttributeNode(qname);
99 }
100
101
createAttributeNode(XmlTree * tree,ElementNode * parent,bool append,csize pos,store::Item_t & attrName,store::Item_t & typeName,store::Item_t & typedValue,bool isListValue,bool hidden)102 AttributeNode* NodeFactory::createAttributeNode(
103 XmlTree* tree,
104 ElementNode* parent,
105 bool append,
106 csize pos,
107 store::Item_t& attrName,
108 store::Item_t& typeName,
109 store::Item_t& typedValue,
110 bool isListValue,
111 bool hidden)
112 {
113 return new AttributeNode(tree, parent, append, pos, attrName,
114 typeName, typedValue, isListValue, hidden);
115 }
116
117
createTextNode(zstring & content)118 TextNode* NodeFactory::createTextNode(zstring& content)
119 {
120 return new TextNode(content);
121 }
122
123
createTextNode(XmlTree * tree,InternalNode * parent,bool append,csize pos,zstring & content)124 TextNode* NodeFactory::createTextNode(
125 XmlTree* tree,
126 InternalNode* parent,
127 bool append,
128 csize pos,
129 zstring& content)
130 {
131 return new TextNode(tree, parent, append, pos, content);
132 }
133
134
createTextNode(InternalNode * parent,store::Item_t & content,bool isListValue)135 TextNode* NodeFactory::createTextNode(
136 InternalNode* parent,
137 store::Item_t& content,
138 bool isListValue)
139 {
140 return new TextNode(parent, content, isListValue);
141 }
142
143
createPiNode(zstring & target,zstring & content)144 PiNode* NodeFactory::createPiNode(
145 zstring& target,
146 zstring& content)
147 {
148 return new PiNode(target, content);
149 }
150
151
createPiNode(XmlTree * tree,InternalNode * parent,bool append,csize pos,zstring & target,zstring & content)152 PiNode* NodeFactory::createPiNode(
153 XmlTree* tree,
154 InternalNode* parent,
155 bool append,
156 csize pos,
157 zstring& target,
158 zstring& content)
159 {
160 return new PiNode(tree, parent, append, pos, target, content);
161 }
162
163
createCommentNode(zstring & content)164 CommentNode* NodeFactory::createCommentNode(
165 zstring& content)
166 {
167 return new CommentNode(content);
168 }
169
170
createCommentNode(XmlTree * tree,InternalNode * parent,bool append,csize pos,zstring & content)171 CommentNode* NodeFactory::createCommentNode(
172 XmlTree* tree,
173 InternalNode* parent,
174 bool append,
175 csize pos,
176 zstring& content)
177 {
178 return new CommentNode(tree, parent, append, pos, content);
179 }
180
181
182 } /* namespace simplestore */
183
184 } /* namespace store */
185 /* vim:set et sw=2 ts=2: */
186