item_factory.h
Go to the documentation of this file.
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 
17 #ifndef ZORBA_ITEM_FACTORY_API_H
18 #define ZORBA_ITEM_FACTORY_API_H
19 
20 #include <iostream>
21 #include <vector>
22 
23 #include <zorba/config.h>
24 #include <zorba/api_shared_types.h>
25 #include <zorba/item.h>
26 #include <zorba/streams.h>
27 
28 namespace zorba {
29 
30  /** \brief ItemFactory to create Items.
31  *
32  * An instance of this class can be obtained by calling getItemFactory on the Zorba object.
33  *
34  * Each createXXX function of this class creates an Item of an XML Schema item.
35  * If an isNull() call on an Item created by one of these functions returns true the
36  * Item could not be created.
37  */
38  class ZORBA_DLL_PUBLIC ItemFactory
39  {
40  public:
41  /** \brief Destructor
42  */
43  virtual ~ItemFactory() {}
44 
45  /** \brief Creates a String Item
46  * see [http://www.w3.org/TR/xmlschema-2/#string]
47  *
48  * @param aString String representation of the String Item.
49  * @return The String Item
50  */
51  virtual Item
52  createString(const String& aString) = 0;
53 
54  /** \brief Creates a streamable String Item
55  * see [http://www.w3.org/TR/xmlschema-2/#string]
56  *
57  * @param stream An istream from where to read the string's content.
58  * @param streamReleaser A function pointer which is invoked once
59  * the StreamableStringItem is destroyed. Normally this function
60  * will delete the std::istream object passed to it.
61  * @param seekable
62  * @return The streamable String Item
63  */
64  virtual Item
65  createStreamableString( std::istream &stream,
66  StreamReleaser streamReleaser,
67  bool seekable = false ) = 0;
68 
69  /** \brief Creates an AnyURI Item
70  * see [http://www.w3.org/TR/xmlschema-2/#anyURI]
71  *
72  * @param aURI String representation of the AnyURI.
73  * @return The AnyURI Item.
74  */
75  virtual Item
76  createAnyURI(const String& aURI) = 0;
77 
78  /** \brief Creates a QName Item
79  * see [http://www.w3.org/TR/xmlschema-2/#QName]
80  *
81  * @param aNamespace String representation of the namespace.
82  * @param aPrefix String representation of the prefix.
83  * @param aLocalname String representation of the localname.
84  *
85  * @return The QName Item.
86  */
87  virtual Item
88  createQName(const String& aNamespace, const String& aPrefix,
89  const String& aLocalname) = 0;
90 
91  /** \brief Creates a QName Item
92  * see [http://www.w3.org/TR/xmlschema-2/#QName]
93  *
94  * @param aNamespace String representation of the namespace.
95  * @param aLocalname String representation of the localname. *
96  * @return The QName Item.
97  */
98  virtual Item
99  createQName(const String& aNamespace, const String& aLocalname) = 0;
100 
101  /** \brief Creates a QName Item
102  * see [http://www.w3.org/TR/xmlschema-2/#QName]
103  *
104  * The QName is constructed by parsing the string using the notation
105  * invented by James Clark (i.e. {namespace}localname).
106  *
107  * @param aQNameString String in the QName notation by James Clark.
108  * @return The QName Item.
109  */
110  virtual Item
111  createQName(const String& aQNameString) = 0;
112 
113  /** \brief Creates a NCName Item
114  * see [http://www.w3.org/TR/xmlschema-2/#NCName]
115  *
116  * @param aValue String representation of the NCName.
117  * @return The NCName Item.
118  */
119  virtual Item
120  createNCName(const String& aValue) = 0;
121 
122 
123  /** \brief Creates a Base64Binary Item
124  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
125  *
126  * @param aBinData a pointer to the base64 encoded data. The data is copied from aBinData.
127  * @param aLength the length of the base64 encoded data.
128  * @return The Base64Binary Item.
129  */
130  virtual Item
131  createBase64Binary(const char* aBinData, size_t aLength) = 0;
132 
133  /** \brief Creates a Base64Binary Item
134  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
135  *
136  * @param aStream A stream containing the Base64 encoded data. The data is copied from aStream imediately.
137  * @return the Base64Binary Item.
138  */
139  virtual Item
140  createBase64Binary(std::istream& aStream) = 0;
141 
142  /** \brief Creates a Base64Binary Item
143  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
144  *
145  * @param aBinData the data in binary form (not encoded). The data is copied from aBinData.
146  * @param aLength the length of the binary data
147  * @return the Base64Binary Item.
148  */
149  virtual Item
150  createBase64Binary(const unsigned char* aBinData, size_t aLength) = 0;
151 
152  /** \brief Creates a streamable Base64Binary Item
153  * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
154  *
155  * @param stream An istream from where to read the binary's content.
156  * @param streamReleaser A function pointer which is invoked once
157  * the StreamableBase64Binary is destroyed. Normally this function
158  * will delete the std::istream object passed to it.
159  * @param seekable is the given stream seekable
160  * @param encoded is the contents of the given stream already base64
161  * encoded
162  * @return The streamable String Item
163  */
164  virtual Item
165  createStreamableBase64Binary(
166  std::istream &stream,
167  StreamReleaser streamReleaser,
168  bool seekable = false,
169  bool encoded = false) = 0;
170 
171  /** \brief Creates a Boolean Item
172  * see [http://www.w3.org/TR/xmlschema-2/#bool]
173  *
174  * @param aValue bool representation of the Boolean.
175  * @return The Boolean Item.
176  */
177  virtual Item
178  createBoolean(bool aValue) = 0;
179 
180  /** \brief Creates a Decimal Item
181  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
182  *
183  * @param aValue unsigned long representation of the Decimal.
184  * @return The Decimal Item.
185  */
186  virtual Item
187  createDecimalFromLong (unsigned long aValue) = 0;
188 
189  /** \brief Creates a Decimal Item
190  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
191  *
192  * @param aValue double representation of the Decimal.
193  * @return The Decimal Item.
194  */
195  virtual Item
196  createDecimalFromDouble (double aValue) = 0;
197 
198  /** \brief Creates a Decimal Item
199  * see [http://www.w3.org/TR/xmlschema-2/#decimal]
200  *
201  * @param aValue String representation of the Decimal (e.g. 12678967.543233).
202  * @return The Decimal Item.
203  */
204  virtual Item
205  createDecimal (const String& aValue) = 0;
206 
207  /** \brief Creates an Integer Item
208  * see [http://www.w3.org/TR/xmlschema-2/#integer]
209  *
210  * @param aInteger unsigned long representation of the Integer.
211  * @return The Integer Item.
212  */
213  virtual Item
214  createInteger(long long aInteger) = 0;
215 
216  /** \brief Creates an Integer Item
217  * see [http://www.w3.org/TR/xmlschema-2/#integer]
218  *
219  * @param aInteger String representation of the Integer.
220  * @return The Integer Item.
221  */
222  virtual Item
223  createInteger(const String& aInteger) = 0;
224 
225  /** \brief Creates a Long Item
226  * see [http://www.w3.org/TR/xmlschema-2/#long]
227  *
228  * @param aLong long long representation of the Long.
229  * @return The Long Item.
230  */
231  virtual Item
232  createLong ( long long aLong ) = 0;
233 
234  /** \brief Creates a Int Item
235  * see [http://www.w3.org/TR/xmlschema-2/#int]
236  *
237  * @param aInt int representation of the Int.
238  * @return The NCName Item.
239  */
240  virtual Item
241  createInt ( int aInt ) = 0;
242 
243  /** \brief Creates a Short Item
244  * see [http://www.w3.org/TR/xmlschema-2/#short]
245  *
246  * @param aShort short representation of the Short.
247  * @return The Short Item.
248  */
249  virtual Item
250  createShort ( short aShort ) = 0;
251 
252  /** \brief Creates a Byte Item
253  * see [http://www.w3.org/TR/xmlschema-2/#byte]
254  *
255  * @param aByte char representation of the Byte.
256  * @return The Byte Item.
257  */
258  virtual Item
259  createByte ( char aByte ) = 0;
260 
261  /** \brief Creates a Date Item
262  * see [http://www.w3.org/TR/xmlschema-2/#date]
263  *
264  * @param aDate String representation of the Date (e.g. 2002-10-10).
265  * @return The Date Item.
266  */
267  virtual Item
268  createDate ( const String& aDate ) = 0;
269 
270  /** \brief Creates a Date Item
271  * see [http://www.w3.org/TR/xmlschema-2/#date]
272  *
273  * @param aYear short-valued representation of the year.
274  * @param aMonth short-valued representation of the month.
275  * @param aDay short-valued representation of the day.
276  * @return The Date Item.
277  */
278  virtual Item
279  createDate ( short aYear, short aMonth, short aDay ) = 0;
280 
281  /** \brief Creates a DateTime Item
282  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
283  *
284  * @param aYear short-valued representation of the year.
285  * @param aMonth short-valued representation of the month.
286  * @param aDay short-valued representation of the day.
287  * @param aHour short-valued representation of the hour.
288  * @param aMinute short-valued representation of the minute.
289  * @param aSecond double-valued representation of the seconds and fractional seconds.
290  * @param aTimeZone_hours short-valued representation of the difference in hours to UTC.
291  * @return The DateTime Item.
292  */
293  virtual Item
294  createDateTime(short aYear, short aMonth, short aDay,
295  short aHour, short aMinute, double aSecond,
296  short aTimeZone_hours) = 0;
297 
298  /** \brief Creates a DateTime Item without setting a time zone.
299  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
300  *
301  * @param aYear short-valued representation of the year.
302  * @param aMonth short-valued representation of the month.
303  * @param aDay short-valued representation of the day.
304  * @param aHour short-valued representation of the hour.
305  * @param aMinute short-valued representation of the minute.
306  * @param aSecond double-valued representation of the seconds and fractional seconds.
307  * @return The DateTime Item.
308  */
309  virtual Item
310  createDateTime(short aYear, short aMonth, short aDay,
311  short aHour, short aMinute, double aSecond) = 0;
312 
313  /** \brief Creates a DateTime Item
314  * see [http://www.w3.org/TR/xmlschema-2/#dateTime]
315  *
316  * @param aDateTimeValue String representation of the datetime value
317  * (for example, 2002-10-10T12:00:00-05:00).
318  * @return The DateTime Item.
319  */
320  virtual Item
321  createDateTime( const String& aDateTimeValue ) = 0;
322 
323  /** \brief Creates a Double Item
324  * see [http://www.w3.org/TR/xmlschema-2/#double]
325  *
326  * @param aValue double representation of the Double.
327  * @return The Double Item.
328  */
329  virtual Item
330  createDouble ( double aValue ) = 0;
331 
332  /** \brief Creates a Double Item
333  * see [http://www.w3.org/TR/xmlschema-2/#double]
334  *
335  * @param aValue String representation of the Double.
336  * @return The Double Item.
337  */
338  virtual Item
339  createDouble ( const String& aValue ) = 0;
340 
341  /** \brief Creates a Duration Item
342  * see [http://www.w3.org/TR/xmlschema-2/#duration]
343  *
344  * @param aValue String representation of the NCName.
345  * @return The Duration Item.
346  */
347  virtual Item
348  createDuration( const String& aValue ) = 0;
349 
350  /** \brief Creates a Duration Item
351  * see [http://www.w3.org/TR/xmlschema-2/#duration]
352  *
353  * @param aYear short-valued representation of the years.
354  * @param aMonths short-valued representation of the months.
355  * @param aDays short-valued representation of the days.
356  * @param aHours short-valued representation of the hours.
357  * @param aMinutes short-valued representation of the minutes.
358  * @param aSeconds double-valued representation of the seconds and fractional seconds.
359  * @return The Duration Item.
360  */
361  virtual Item
362  createDuration ( short aYear, short aMonths, short aDays,
363  short aHours, short aMinutes, double aSeconds ) = 0;
364 
365  /** \brief Creates a dayTimeDuration Item
366  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
367  *
368  * @param aValue String lexical representation of the duration.
369  * @return the dayTimeDuration Item.
370  */
371  virtual Item
372  createDayTimeDuration( const String& aValue ) = 0;
373 
374  /** \brief Creates a yearMonthDuration Item
375  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
376  *
377  * @param aValue String lexical representation of the duration.
378  * @return the yearMonthDuration Item.
379  */
380  virtual Item
381  createYearMonthDuration( const String& aValue ) = 0;
382 
383  /** \brief Creates a documentNode Item
384  * see [http://www.w3.org/TR/xpath-functions/#duration-subtypes]
385  *
386  * @param aBaseUri String representation of the Base URI.
387  * @param aDocUri String representation of the Document URI.
388  * @return the documentNode Item.
389  */
390  virtual Item
391  createDocumentNode( const String& aBaseUri, const String& aDocUri ) = 0;
392 
393  /** \brief creates a float item
394  * see [http://www.w3.org/tr/xmlschema-2/#float]
395  *
396  * @param aValue string representation of the float.
397  * @return the float item.
398  */
399  virtual Item
400  createFloat ( const String& aValue ) = 0;
401 
402  /** \brief creates a float item
403  * see [http://www.w3.org/tr/xmlschema-2/#float]
404  *
405  * @param aValue float representation of the float.
406  * @return the float item.
407  */
408  virtual Item
409  createFloat ( float aValue ) = 0;
410 
411  /** \brief Creates a gDay Item
412  * see [http://www.w3.org/TR/xmlschema-2/#gDay]
413  *
414  * @param aValue String representation of the gDay.
415  * @return The gDay Item.
416  */
417  virtual Item
418  createGDay ( const String& aValue ) = 0;
419 
420  /** \brief Creates a gDay Item
421  * see [http://www.w3.org/TR/xmlschema-2/#gDay]
422  *
423  * @param aDay short representation of the gDay.
424  * @return The gDay Item.
425  */
426  virtual Item
427  createGDay ( short aDay ) = 0;
428 
429  /** \brief Creates a gMonth Item
430  * see [http://www.w3.org/TR/xmlschema-2/#gMonth]
431  *
432  * @param aValue String representation of the gMonth.
433  * @return The gMonth Item.
434  */
435  virtual Item
436  createGMonth ( const String& aValue ) = 0;
437 
438  /** \brief Creates a gMonth Item
439  * see [http://www.w3.org/TR/xmlschema-2/#gMonth]
440  *
441  * @param aMonth short representation of the gMonth.
442  * @return The gMonth Item.
443  */
444  virtual Item
445  createGMonth ( short aMonth ) = 0;
446 
447  /** \brief Creates a gMonthDay Item
448  * see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
449  *
450  * @param aValue String representation of the gMonthDay.
451  * @return The gMonthDay Item.
452  */
453  virtual Item
454  createGMonthDay ( const String& aValue ) = 0;
455 
456  /** \brief Creates a gMonthDay Item
457  * see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
458  *
459  * @param aMonth short representation of the month.
460  * @param aDay short representation of the day.
461  * @return The gMonthDay Item.
462  */
463  virtual Item
464  createGMonthDay ( short aMonth, short aDay ) = 0;
465 
466  /** \brief Creates a gYear Item
467  * see [http://www.w3.org/TR/xmlschema-2/#gYear]
468  *
469  * @param aValue String representation of the gYear.
470  * @return The gYear Item.
471  */
472  virtual Item
473  createGYear ( const String& aValue ) = 0;
474 
475  /** \brief Creates a gYear Item
476  * see [http://www.w3.org/TR/xmlschema-2/#gYear]
477  *
478  * @param aYear short representation of the gYear.
479  * @return The gYear Item.
480  */
481  virtual Item
482  createGYear ( short aYear ) = 0;
483 
484  /** \brief Creates a gYearMonth Item
485  * see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
486  *
487  * @param aValue String representation of the gYearMonth.
488  * @return The gYearMonth Item.
489  */
490  virtual Item
491  createGYearMonth ( const String& aValue ) = 0;
492 
493  /** \brief Creates a gYearMonth Item
494  * see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
495  *
496  * @param aYear short representation of the year.
497  * @param aMonth short representation of the month.
498  * @return The gYearMonth Item.
499  */
500  virtual Item
501  createGYearMonth ( short aYear, short aMonth ) = 0;
502 
503  /** \brief Creates a HexBinary Item
504  * see [http://www.w3.org/TR/xmlschema-2/#hexBinary]
505  *
506  * @param aHexData pointer to the hexdata.
507  * @param aSize size of the hexdata.
508  * @return The HexBinary Item.
509  */
510  virtual Item
511  createHexBinary ( const char* aHexData, size_t aSize ) = 0;
512 
513  /** \brief Creates a negativeInteger Item
514  * see [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
515  *
516  * @param aValue long long representation of the negativeInteger.
517  * @return The negativeInteger Item.
518  */
519  virtual Item
520  createNegativeInteger ( long long aValue ) = 0;
521 
522  /** \brief Creates a nonNegativeInteger Item
523  * see [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
524  *
525  * @param aValue unsigned long representation of the nonNegativeInteger.
526  * @return The nonNegativeInteger Item.
527  */
528  virtual Item
529  createNonNegativeInteger ( unsigned long long aValue ) = 0;
530 
531  /** \brief Creates a nonPositiveInteger Item
532  * see [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
533  *
534  * @param aValue long long representation of the NCName.
535  * @return The nonPositiveInteger Item.
536  */
537  virtual Item
538  createNonPositiveInteger ( long long aValue ) = 0;
539 
540  /** \brief Creates a positiveInteger\ Item
541  * see [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
542  *
543  * @param aValue unsigned long representation of the positiveInteger.
544  * @return The positiveInteger Item.
545  */
546  virtual Item
547  createPositiveInteger ( unsigned long long aValue ) = 0;
548 
549  /** \brief Creates a Time Item
550  * see [http://www.w3.org/TR/xmlschema-2/#time]
551  *
552  * @param aValue String representation of the Time.
553  * @return The Time Item
554  */
555  virtual Item
556  createTime ( const String& aValue ) = 0;
557 
558  /** \brief Creates a Time Item
559  * see [http://www.w3.org/TR/xmlschema-2/#time]
560  *
561  * @param aHour short representation of the hour.
562  * @param aMinute short representation of the minute.
563  * @param aSecond double representation of the seconds and fractional seconds.
564  * @return The Time Item.
565  */
566  virtual Item
567  createTime ( short aHour, short aMinute, double aSecond ) = 0;
568 
569  /** \brief Creates a Time Item
570  * see [http://www.w3.org/TR/xmlschema-2/#time]
571  *
572  * @param aHour short representation of the hour.
573  * @param aMinute short representation of the minute.
574  * @param aSecond double representation of the seconds and fractional seconds.
575  * @param aTimeZone_hours short representation of the timezone difference in hours to UTC.
576  * @return The Time Item.
577  */
578  virtual Item
579  createTime ( short aHour, short aMinute, double aSecond, short aTimeZone_hours ) = 0;
580 
581  /** \brief Creates an Unsigned Byte Item
582  * see [http://www.w3.org/TR/xmlschema-2/#unsignedByte]
583  *
584  * @param aValue unsignedByte unsigned char representation of the unsigned byte.
585  * @return The Unsigned Byte Item.
586  */
587  virtual Item
588  createUnsignedByte(const unsigned char aValue) = 0;
589 
590  /** \brief Creates an unsigned int Item
591  * see [http://www.w3.org/TR/xmlschema-2/#unsignedInt]
592  *
593  * @param aValue unsigned int representation of the unsignedInt.
594  * @return The unsignedInt Item.
595  */
596  virtual Item
597  createUnsignedInt(unsigned int aValue) = 0;
598 
599  /** \brief Creates an unsignedLong Item
600  * see [http://www.w3.org/TR/xmlschema-2/#unsignedLong]
601  *
602  * @param aValue unsignedLong long long representation of the unsignedLong.
603  * @return The unsignedLong Item.
604  */
605  virtual Item
606  createUnsignedLong(unsigned long long aValue) = 0;
607 
608  /** \brief Creates a unsignedShort Item
609  * see [http://www.w3.org/TR/xmlschema-2/#unsignedShort]
610  *
611  * @param aValue unsigned short representation of the unsignedShort.
612  * @return The unsignedShort Item.
613  */
614  virtual Item
615  createUnsignedShort(unsigned short aValue) = 0;
616 
617  /**
618  * @brief Creates a new element node.
619  *
620  * Create a new element node N and place it at the end among the
621  * children of a given parent node. If no parent is given, N becomes the
622  * root (and single node) of a new XML tree.
623  *
624  * @param aParent The parent P of the new node; may be NULL.
625  * @param aNodeName The fully qualified name of the new node.
626  * @param aTypeName The fully qualified name of the new node's type.
627  * Not allowed to be NULL, use xsd:untyped instead.
628  * @param aHasTypedValue Whether the node has a typed value or not (element
629  * nodes with complex type and element-only content do
630  * not have typed value).
631  * @param aHasEmptyValue True if the typed value of the node is the empty
632  * sequence. This is the case if the element has a
633  * complex type with empty content.
634  * @param aNsBindings A set of namespace bindings. The namespaces property
635  * of N will be the union of this set and the namespaces
636  * property of P.
637  * @return The new node N created by this method
638  */
639  virtual Item
640  createElementNode(Item& aParent,
641  Item aNodeName,
642  Item aTypeName,
643  bool aHasTypedValue,
644  bool aHasEmptyValue,
645  NsBindings aNsBindings) = 0;
646  /**
647  * Create a new attribute node N and place it among the
648  * attributes of a given parent node. If no parent is given, N becomes the
649  * root (and single node) of a new XML tree.
650  *
651  * @param aParent The parent P of the new node; may be NULL.
652  * @param aNodeName The fully qualified name of the new node. The nemaspace
653  * binding implied by this name will be added to the namespaces
654  * of P. If the name prefix is "xml" and the local name is
655  * "base", then the base-uri property of P will be set or
656  * updated accordingly.
657  * @param aTypeName The fully qualified name of the new node's type.
658  * @param aTypedValue The typed value of the new node.
659  * @return The new node N created by this method
660  */
661  virtual Item
662  createAttributeNode(Item aParent,
663  Item aNodeName,
664  Item aTypeName,
665  Item aTypedValue) = 0;
666 
667  virtual Item
668  createAttributeNode(Item aParent,
669  Item aNodeName,
670  Item aTypeName,
671  std::vector<Item> aTypedValue) = 0;
672 
673  /**
674  * Create a new comment node N and place it as the last child of a given
675  * parent node. If no parent is given, N becomes the root (and single node)
676  * of a new XML tree.
677  *
678  * @param aParent The parent P of the new node; may be NULL.
679  * @param aContent The content of the new node.
680  * @return The new node N created by this method
681  */
682  virtual Item createCommentNode (
683  Item aParent,
684  String &aContent) = 0;
685 
686  /**
687  * Create a new Processing Instruction node N and place it among the
688  * children of a given parent node. If no parent is given, N becomes the
689  * root (and single node) of a new XML tree.
690  *
691  * @param aParent The parent P of the new node; may be NULL.
692  * @param aTarget The Target of the new node.
693  * @param aContent The Content of the new node.
694  * @param aBaseUri The Base URI of the new node, may be NULL.
695  * @return The new node N created by this method
696  */
697  virtual Item createPiNode (
698  Item aParent,
699  String &aTarget,
700  String &aContent,
701  String &aBaseUri)=0;
702 
703  /**
704  * Create a new text node N and place it among the
705  * children of a given parent node. If no parent is given, N becomes the
706  * root (and single node) of a new XML tree.
707  *
708  * @param parent The parent P of the new node; may be NULL.
709  * @param content The content of the new node.
710  * @return The new node N created by this method
711  */
712  virtual Item createTextNode(
713  Item parent,
714  String content) = 0;
715 
716  /** \brief Creates a UntypedAtomic Item
717  *
718  * @param value String representation of the UntypedAtomic Item.
719  * @return The UntypedAtomic Item
720  */
721  virtual Item createUntypedAtomic(const String& value) = 0;
722 
723 #ifdef ZORBA_WITH_JSON
724 
725  /**
726  * Create a JSON null item.
727  */
728  virtual Item createJSONNull() = 0;
729 
730  /**
731  * Create a JSON Number item from a string. This will actually be
732  * an xs:integer, xs:double, or xs:decimal, depending on the content
733  * of the string.
734  *
735  * @param aString The input string.
736  */
737  virtual Item createJSONNumber(String aString) = 0;
738 
739  /**
740  * Create a JSON Object containing the specified JSON Pairs.
741  *
742  * @param aNames A vector containing the name and value of each pair.
743  */
744  virtual Item createJSONObject(std::vector<std::pair<Item, Item> >& aNames) = 0;
745 
746  /**
747  * Create a JSON Array containing the specified items.
748  *
749  * @param aItems A std::vector<Item> containing Items which may
750  * be stored in a JSON Array (namely JSON Arrays, JSON Objects,
751  * JSON nulls, valid JSON numeric types, or xs:strings).
752  */
753  virtual Item createJSONArray(std::vector<Item>& aItems) = 0;
754 
755 #endif /* ZORBA_WITH_JSON */
756 
757  /**
758  * @brief Assigns a simple typed value to an element node.
759  *
760  * Creates a simple typed value for an element. Note that this may only
761  * be done once per element. This method should only be used during
762  * creation of a new tree. Using this method to modify elements after
763  * processing has begun has undefined results.
764  *
765  *
766  * @param aElement The element for the typed value; may not be NULL.
767  * @param aTypedValue The typed value for the element.
768  */
769  virtual void
770  assignElementTypedValue(Item& aElement,
771  Item aTypedValue) = 0;
772  /**
773  * @brief Assigns a simple typed value to an element node.
774  *
775  * Creates a simple typed value for an element. Note that this may only
776  * be done once per element. This method should only be used during
777  * creation of a new tree. Using this method to modify elements after
778  * processing has begun has undefined results.
779  *
780  *
781  * @param aElement The element for the typed value; may not be NULL.
782  * @param aTypedValue The typed value for the element.
783  */
784  virtual void
785  assignElementTypedValue(Item& aElement,
786  std::vector<Item>& aTypedValue) = 0;
787 
788  /**
789  * Create an atomic item having a user-defined atomic type.
790  *
791  * @param aBaseItem the base item of the item to create.
792  * @param aTypeName the name of the type of the item to create.
793  *
794  * @return a new atomic item having the given user-defined atomic type.
795  */
796  virtual Item
797  createUserTypedAtomicItem(Item& aBaseItem, Item& aTypeName) = 0;
798 
799  }; // class ItemFactory
800 
801 } // namespace zorba
802 #endif
803 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus