item_factory.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ZORBA_ITEM_FACTORY_API_H
00017 #define ZORBA_ITEM_FACTORY_API_H
00018 
00019 #include <zorba/config.h>
00020 #include <zorba/api_shared_types.h>
00021 
00022 namespace zorba {
00023   
00024   /** \brief ItemFactory to create Items.
00025    *
00026    * An instance of this class can be obtained by calling getItemFactory on the Zorba object.
00027    *
00028    * Each createXXX function of this class creates an Item of an XML Schema item.
00029    * If an isNull() call on an Item created by one of these functions returns true the
00030    * Item could not be created.
00031    */
00032   class ZORBA_EXTERN_DECL ItemFactory 
00033   {
00034     public:
00035       /** \brief Destructor
00036        */
00037       virtual ~ItemFactory() {}
00038 
00039       /** \brief Creates a String Item 
00040        *         see [http://www.w3.org/TR/xmlschema-2/#string]
00041        *
00042        * @param aString String representation of the String Item.
00043        * @return The String Item
00044        */
00045       virtual Item
00046       createString(const String& aString) = 0;
00047 
00048       /** \brief Creates an AnyURI Item 
00049        *         see [http://www.w3.org/TR/xmlschema-2/#anyURI]
00050        *
00051        * @param aURI String representation of the AnyURI.
00052        * @return The AnyURI Item.
00053        */
00054       virtual Item
00055       createAnyURI(const String& aURI) = 0;
00056 
00057       /** \brief Creates a QName Item 
00058        *         see [http://www.w3.org/TR/xmlschema-2/#QName]
00059        *
00060        * @param aNamespace String representation of the namespace.
00061        * @param aPrefix String representation of the prefix.
00062        * @param aLocalname String representation of the localname.
00063        *
00064        * @return The QName Item.
00065        */
00066       virtual Item
00067       createQName(const String& aNamespace, const String& aPrefix,
00068                   const String& aLocalname) = 0;
00069 
00070       /** \brief Creates a QName Item 
00071        *         see [http://www.w3.org/TR/xmlschema-2/#QName]
00072        *
00073        * @param aNamespace String representation of the namespace.
00074        * @param aLocalname String representation of the localname.       *
00075        * @return The QName Item.
00076        */
00077       virtual Item
00078       createQName(const String& aNamespace, const String& aLocalname) = 0;
00079 
00080       /** \brief Creates a NCName Item 
00081        *         see [http://www.w3.org/TR/xmlschema-2/#NCName]
00082        *
00083        * @param aValue String representation of the NCName.
00084        * @return The NCName Item.
00085        */
00086       virtual Item 
00087       createNCName(const String& aValue) = 0;
00088         
00089     
00090       /** \brief Creates a Base64Binary Item 
00091        *         see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
00092        *
00093        * @param aBinData a pointer to the base64 binary data.
00094        * @param aLength the length of the base64 binary data.
00095        * @return The Base64Binary Item.
00096        */
00097       virtual Item 
00098       createBase64Binary(const char* aBinData, size_t aLength) = 0;
00099       
00100       /** \brief Creates a Boolean Item 
00101        *         see [http://www.w3.org/TR/xmlschema-2/#bool]
00102        *
00103        * @param aValue bool representation of the Boolean.
00104        * @return The Boolean Item.
00105        */
00106       virtual Item 
00107       createBoolean(bool aValue) = 0;
00108     
00109       /** \brief Creates a Decimal Item 
00110        *         see [http://www.w3.org/TR/xmlschema-2/#decimal]
00111        *
00112        * @param aValue unsigned long representation of the Decimal.
00113        * @return The Decimal Item.
00114        */
00115       virtual Item 
00116       createDecimalFromLong (unsigned long aValue) = 0;
00117     
00118       /** \brief Creates a Decimal Item 
00119        *         see [http://www.w3.org/TR/xmlschema-2/#decimal]
00120        *
00121        * @param aValue double representation of the Decimal.
00122        * @return The Decimal Item.
00123        */
00124       virtual Item 
00125       createDecimalFromDouble (double aValue) = 0;
00126 
00127       /** \brief Creates a Decimal Item 
00128        *         see [http://www.w3.org/TR/xmlschema-2/#decimal]
00129        *
00130        * @param aValue String representation of the Decimal (e.g. 12678967.543233).
00131        * @return The Decimal Item.
00132        */
00133       virtual Item 
00134       createDecimal (const String& aValue) = 0;
00135 
00136       /** \brief Creates an Integer Item 
00137        *         see [http://www.w3.org/TR/xmlschema-2/#integer]
00138        *
00139        * @param aInteger unsigned long representation of the Integer.
00140        * @return The Integer Item.
00141        */
00142       virtual Item
00143       createInteger(long long aInteger) = 0;
00144 
00145       /** \brief Creates an Integer Item 
00146        *         see [http://www.w3.org/TR/xmlschema-2/#integer]
00147        *
00148        * @param aInteger String representation of the Integer.
00149        * @return The Integer Item.
00150        */
00151       virtual Item
00152       createInteger(const String& aInteger) = 0;
00153     
00154       /** \brief Creates a Long Item 
00155        *         see [http://www.w3.org/TR/xmlschema-2/#long]
00156        *
00157        * @param aLong long long representation of the Long.
00158        * @return The Long Item.
00159        */
00160       virtual Item
00161       createLong ( long long aLong ) = 0;
00162     
00163       /** \brief Creates a Int Item 
00164        *         see [http://www.w3.org/TR/xmlschema-2/#int]
00165        *
00166        * @param aInt int representation of the Int.
00167        * @return The NCName Item.
00168        */
00169       virtual Item
00170       createInt ( int aInt ) = 0;
00171     
00172       /** \brief Creates a Short Item 
00173        *         see [http://www.w3.org/TR/xmlschema-2/#short]
00174        *
00175        * @param aShort short representation of the Short.
00176        * @return The Short Item.
00177        */
00178       virtual Item
00179       createShort ( short aShort ) = 0;
00180     
00181       /** \brief Creates a Byte Item 
00182        *         see [http://www.w3.org/TR/xmlschema-2/#byte]
00183        *
00184        * @param aByte char representation of the Byte.
00185        * @return The Byte Item.
00186        */
00187       virtual Item
00188       createByte ( char aByte ) = 0;
00189     
00190       /** \brief Creates a Date Item 
00191        *         see [http://www.w3.org/TR/xmlschema-2/#date]
00192        *
00193        * @param aDate String representation of the Date (e.g. 2002-10-10).
00194        * @return The Date Item.
00195        */
00196       virtual Item
00197       createDate ( const String& aDate ) = 0;
00198 
00199       /** \brief Creates a Date Item
00200        *         see [http://www.w3.org/TR/xmlschema-2/#date]
00201        *
00202        * @param aYear short-valued representation of the year.
00203        * @param aMonth short-valued representation of the month.
00204        * @param aDay short-valued representation of the day.
00205        * @return The Date Item.
00206        */
00207       virtual Item
00208       createDate ( short aYear, short aMonth, short aDay ) = 0;
00209       
00210       /** \brief Creates a DateTime Item 
00211        *         see [http://www.w3.org/TR/xmlschema-2/#dateTime]
00212        *
00213        * @param aYear short-valued representation of the year.
00214        * @param aMonth short-valued representation of the month.
00215        * @param aDay short-valued representation of the day.
00216        * @param aHour short-valued representation of the hour.
00217        * @param aMinute short-valued representation of the minute.
00218        * @param aSecond double-valued representation of the seconds and fractional seconds.
00219        * @param aTimeZone_hours short-valued representation of the difference in hours to UTC.
00220        * @return The DateTime Item.
00221        */
00222       virtual Item
00223       createDateTime(short aYear, short aMonth, short aDay, 
00224                      short aHour, short aMinute, double aSecond,
00225                      short aTimeZone_hours) = 0;
00226 
00227       /** \brief Creates a DateTime Item 
00228        *         see [http://www.w3.org/TR/xmlschema-2/#dateTime]
00229        *
00230        * @param aDateTimeValue String representation of the datetime value
00231        *        (for example, 2002-10-10T12:00:00-05:00).
00232        * @return The DateTime Item.
00233        */
00234       virtual Item
00235       createDateTime( const String& aDateTimeValue ) = 0;
00236 
00237       /** \brief Creates a Double Item 
00238        *         see [http://www.w3.org/TR/xmlschema-2/#double]
00239        *
00240        * @param aValue double representation of the Double.
00241        * @return The Double Item.
00242        */
00243       virtual Item
00244       createDouble ( double aValue ) = 0;
00245 
00246       /** \brief Creates a Double Item 
00247        *         see [http://www.w3.org/TR/xmlschema-2/#double]
00248        *
00249        * @param aValue String representation of the Double.
00250        * @return The Double Item.
00251        */
00252       virtual Item
00253       createDouble ( const String& aValue ) = 0;
00254     
00255       /** \brief Creates a Duration Item 
00256        *         see [http://www.w3.org/TR/xmlschema-2/#duration]
00257        *
00258        * @param aValue String representation of the NCName.
00259        * @return The Duration Item.
00260        */
00261       virtual Item
00262       createDuration( const String& aValue ) = 0;
00263       
00264       /** \brief Creates a Duration Item 
00265        *         see [http://www.w3.org/TR/xmlschema-2/#duration]
00266        *
00267        * @param aYear short-valued representation of the years.
00268        * @param aMonths short-valued representation of the months.
00269        * @param aDays short-valued representation of the days.
00270        * @param aHours short-valued representation of the hours.
00271        * @param aMinutes short-valued representation of the minutes.
00272        * @param aSeconds double-valued representation of the seconds and fractional seconds.
00273        * @return The Duration Item.
00274        */
00275       virtual Item
00276       createDuration ( short aYear, short aMonths, short aDays, 
00277                        short aHours, short aMinutes, double aSeconds ) = 0;
00278     
00279       /** \brief creates a float item 
00280        *         see [http://www.w3.org/tr/xmlschema-2/#float]
00281        *
00282        * @param aValue string representation of the float.
00283        * @return the float item.
00284        */
00285       virtual Item
00286       createFloat ( const String& aValue ) = 0;
00287     
00288       /** \brief creates a float item 
00289        *         see [http://www.w3.org/tr/xmlschema-2/#float]
00290        *
00291        * @param aValue float representation of the float.
00292        * @return the float item.
00293        */
00294       virtual Item
00295       createFloat ( float aValue ) = 0;
00296 
00297       /** \brief Creates a gDay Item 
00298        *         see [http://www.w3.org/TR/xmlschema-2/#gDay]
00299        *
00300        * @param aValue String representation of the gDay.
00301        * @return The gDay Item.
00302        */
00303       virtual Item
00304       createGDay ( const String& aValue ) = 0;
00305     
00306       /** \brief Creates a gDay Item 
00307        *         see [http://www.w3.org/TR/xmlschema-2/#gDay]
00308        *
00309        * @param aDay short representation of the gDay.
00310        * @return The gDay Item.
00311        */
00312       virtual Item
00313       createGDay ( short aDay ) = 0;
00314     
00315       /** \brief Creates a gMonth Item
00316        *         see [http://www.w3.org/TR/xmlschema-2/#gMonth]
00317        *
00318        * @param aValue String representation of the gMonth.
00319        * @return The gMonth Item.
00320        */
00321       virtual Item
00322       createGMonth ( const String& aValue ) = 0;
00323 
00324       /** \brief Creates a gMonth Item
00325        *         see [http://www.w3.org/TR/xmlschema-2/#gMonth]
00326        *
00327        * @param aMonth short representation of the gMonth.
00328        * @return The gMonth Item.
00329        */
00330       virtual Item
00331       createGMonth ( short aMonth ) = 0;
00332     
00333       /** \brief Creates a gMonthDay Item 
00334        *         see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
00335        *
00336        * @param aValue String representation of the gMonthDay.
00337        * @return The gMonthDay Item.
00338        */
00339       virtual Item
00340       createGMonthDay ( const String& aValue ) = 0;
00341     
00342       /** \brief Creates a gMonthDay Item 
00343        *         see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
00344        *
00345        * @param aMonth short representation of the month.
00346        * @param aDay short representation of the day.
00347        * @return The gMonthDay Item.
00348        */
00349       virtual Item
00350       createGMonthDay ( short aMonth, short aDay ) = 0;
00351     
00352       /** \brief Creates a gYear Item 
00353        *         see [http://www.w3.org/TR/xmlschema-2/#gYear]
00354        *
00355        * @param aValue String representation of the gYear.
00356        * @return The gYear Item.
00357        */
00358       virtual Item
00359       createGYear ( const String& aValue ) = 0;
00360     
00361       /** \brief Creates a gYear Item 
00362        *         see [http://www.w3.org/TR/xmlschema-2/#gYear]
00363        *
00364        * @param aYear short representation of the gYear.
00365        * @return The gYear Item.
00366        */
00367       virtual Item
00368       createGYear ( short aYear ) = 0;
00369     
00370       /** \brief Creates a gYearMonth Item 
00371        *         see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
00372        *
00373        * @param aValue String representation of the gYearMonth.
00374        * @return The gYearMonth Item.
00375        */
00376       virtual Item
00377       createGYearMonth ( const String& aValue ) = 0;
00378     
00379       /** \brief Creates a gYearMonth Item 
00380        *         see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
00381        *
00382        * @param aYear short representation of the year.
00383        * @param aMonth short representation of the month.
00384        * @return The gYearMonth Item.
00385        */
00386       virtual Item
00387       createGYearMonth ( short aYear, short aMonth ) = 0;
00388     
00389       /** \brief Creates a HexBinary Item 
00390        *         see [http://www.w3.org/TR/xmlschema-2/#hexBinary]
00391        *
00392        * @param aHexData pointer to the hexdata.
00393        * @param aSize size of the hexdata.
00394        * @return The HexBinary Item.
00395        */
00396       virtual Item
00397       createHexBinary ( const char* aHexData, size_t aSize ) = 0;
00398     
00399       /** \brief Creates a negativeInteger Item 
00400        *         see [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
00401        *
00402        * @param aValue long long representation of the negativeInteger.
00403        * @return The negativeInteger Item.
00404        */
00405       virtual Item
00406       createNegativeInteger ( long long aValue ) = 0;
00407 
00408       /** \brief Creates a nonNegativeInteger Item 
00409        *         see [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
00410        *
00411        * @param aValue unsigned long representation of the nonNegativeInteger.
00412        * @return The nonNegativeInteger Item.
00413        */
00414       virtual Item
00415       createNonNegativeInteger ( unsigned long long aValue ) = 0;
00416 
00417       /** \brief Creates a nonPositiveInteger Item 
00418        *         see [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
00419        *
00420        * @param aValue long long representation of the NCName.
00421        * @return The nonPositiveInteger Item.
00422        */
00423       virtual Item
00424       createNonPositiveInteger ( long long aValue ) = 0;
00425 
00426       /** \brief Creates a positiveInteger\ Item 
00427        *         see [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
00428        *
00429        * @param aValue unsigned long representation of the positiveInteger.
00430        * @return The positiveInteger Item.
00431        */
00432       virtual Item
00433       createPositiveInteger ( unsigned long long aValue ) = 0;
00434 
00435       /** \brief Creates a Time Item 
00436        *         see [http://www.w3.org/TR/xmlschema-2/#time]
00437        *
00438        * @param aValue String representation of the Time.
00439        * @return The Time Item
00440        */
00441       virtual Item
00442       createTime ( const String& aValue ) = 0;
00443     
00444       /** \brief Creates a Time Item 
00445        *         see [http://www.w3.org/TR/xmlschema-2/#time]
00446        *
00447        * @param aHour short representation of the hour.
00448        * @param aMinute short representation of the minute.
00449        * @param aSecond double representation of the seconds and fractional seconds.
00450        * @return The Time Item.
00451        */
00452       virtual Item
00453       createTime ( short aHour, short aMinute, double aSecond ) = 0;
00454     
00455       /** \brief Creates a Time Item 
00456        *         see [http://www.w3.org/TR/xmlschema-2/#time]
00457        *
00458        * @param aHour short representation of the hour.
00459        * @param aMinute short representation of the minute.
00460        * @param aSecond double representation of the seconds and fractional seconds.
00461        * @param aTimeZone_hours short representation of the timezone difference in hours to UTC.
00462        * @return The Time Item.
00463        */
00464       virtual Item
00465       createTime ( short aHour, short aMinute, double aSecond, short aTimeZone_hours ) = 0;
00466     
00467       /** \brief Creates an Unsigned Byte Item 
00468        *         see [http://www.w3.org/TR/xmlschema-2/#unsignedByte]
00469        *
00470        * @param aValue unsignedByte unsigned char representation of the unsigned byte.
00471        * @return The Unsigned Byte Item.
00472        */
00473       virtual Item
00474       createUnsignedByte(const unsigned char aValue) = 0;
00475     
00476       /** \brief Creates an unsigned int Item 
00477        *         see [http://www.w3.org/TR/xmlschema-2/#unsignedInt]
00478        *
00479        * @param aValue unsigned int representation of the unsignedInt.
00480        * @return The unsignedInt Item.
00481        */
00482       virtual Item
00483       createUnsignedInt(unsigned int aValue) = 0;
00484     
00485       /** \brief Creates an unsignedLong Item 
00486        *         see [http://www.w3.org/TR/xmlschema-2/#unsignedLong]
00487        *
00488        * @param aValue unsignedLong long long representation of the unsignedLong.
00489        * @return The unsignedLong Item.
00490        */
00491       virtual Item
00492       createUnsignedLong(unsigned long long aValue) = 0;
00493     
00494       /** \brief Creates a unsignedShort Item 
00495        *         see [http://www.w3.org/TR/xmlschema-2/#unsignedShort]
00496        *
00497        * @param aValue unsigned short representation of the unsignedShort.
00498        * @return The unsignedShort Item.
00499        */
00500       virtual Item
00501       createUnsignedShort(unsigned short aValue) = 0;
00502     
00503     
00504   }; /* class ItemFactory */
00505 
00506 } /* namespace zorba */
00507 #endif