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 %{ // start Implementation 18 createEmptyItem()19 Item Item::createEmptyItem() 20 { return Item(); } 21 getStringValue()22 std::string Item::getStringValue() const 23 { return std::string(theItem.getStringValue().c_str()); } 24 serialize()25 std::string Item::serialize() const 26 { 27 std::stringstream lStream; 28 Zorba_SerializerOptions_t lOptions; 29 lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; 30 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions); 31 zorba::SingletonItemSequence lSequence(theItem); 32 lSerializer->serialize(&lSequence, lStream); 33 return lStream.str(); 34 } serialize(SerializationOptions serOptions)35 std::string Item::serialize(SerializationOptions serOptions) const 36 { 37 std::stringstream lStream; 38 serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; 39 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions); 40 zorba::SingletonItemSequence lSequence(theItem); 41 lSerializer->serialize(&lSequence, lStream); 42 return lStream.str(); 43 } 44 getAtomizationValue()45 Iterator Item::getAtomizationValue () const 46 { return Iterator(theItem.getAtomizationValue()); } 47 getAttributes()48 Iterator Item::getAttributes () const 49 { return Iterator(theItem.getAttributes()); } 50 getBooleanValue()51 bool Item::getBooleanValue () const 52 { return theItem.getBooleanValue(); } 53 getChildren()54 Iterator Item::getChildren () const 55 { return Iterator(theItem.getChildren()); } 56 getEBV()57 Item Item::getEBV () const 58 { return Item(theItem.getEBV()); } 59 getIntValue()60 int Item::getIntValue () const 61 { return theItem.getIntValue(); } 62 getDoubleValue()63 double Item::getDoubleValue () const 64 { return theItem.getDoubleValue(); } 65 getLongValue()66 long long Item::getLongValue () const 67 { return theItem.getLongValue(); } 68 getLocalName()69 std::string Item::getLocalName () const 70 { return std::string(theItem.getLocalName().c_str()); } 71 getNamespace()72 std::string Item::getNamespace () const 73 { return std::string(theItem.getNamespace().c_str()); } 74 getNamespaceBindings()75 std::vector< std::pair< std::string, std::string > > Item::getNamespaceBindings () { 76 std::vector< std::pair< zorba::String, zorba::String > > items; 77 std::vector< std::pair< std::string, std::string > > result; 78 theItem.getNamespaceBindings(items); 79 std::vector< std::pair< zorba::String, zorba::String > >::iterator iter; 80 for(iter = items.begin(); iter != items.end(); iter++) { 81 std::pair< std::string, std::string > pair; 82 pair.first = (*iter).first.c_str(); 83 pair.second = (*iter).second.c_str(); 84 result.push_back(pair); 85 } 86 return result; 87 } 88 getNodeName(Item & aNodeName)89 bool Item::getNodeName (Item &aNodeName) const 90 { return theItem.getNodeName( aNodeName.theItem ); } 91 getParent()92 Item Item::getParent () const 93 { return theItem.getParent(); } 94 getPrefix()95 std::string Item::getPrefix () const 96 { return std::string(theItem.getPrefix().c_str()); } 97 getType()98 Item Item::getType () const 99 { return Item( theItem.getType() ); } 100 getUnsignedIntValue()101 unsigned int Item::getUnsignedIntValue () const 102 { return theItem.getUnsignedIntValue(); } 103 isAtomic()104 bool Item::isAtomic () const 105 { return theItem.isAtomic(); } 106 isNaN()107 bool Item::isNaN () const 108 { return theItem.isNaN(); } 109 isNode()110 bool Item::isNode () const 111 { return theItem.isNode(); } 112 isNull()113 bool Item::isNull () const 114 { return theItem.isNull(); } 115 isPosOrNegInf()116 bool Item::isPosOrNegInf () const 117 { return theItem.isPosOrNegInf(); } 118 getNodeKind()119 int Item::getNodeKind () const 120 { return theItem.getNodeKind(); } 121 close()122 void Item::close() 123 { theItem.close(); } 124 serializeToStream(ZorbaIOStream & aStream)125 void Item::serializeToStream(ZorbaIOStream & aStream) const 126 { 127 ZorbaStreamBuffer buffer(aStream); 128 std::ostream lStream(&buffer); 129 130 Zorba_SerializerOptions_t lOptions; 131 lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; 132 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions); 133 zorba::SingletonItemSequence lSequence(theItem); 134 lSerializer->serialize(&lSequence, lStream); 135 return; 136 } serializeToStream(ZorbaIOStream & aStream,SerializationOptions serOptions)137 void Item::serializeToStream(ZorbaIOStream & aStream, SerializationOptions serOptions) const 138 { 139 ZorbaStreamBuffer buffer(aStream); 140 std::ostream lStream(&buffer); 141 142 Zorba_SerializerOptions_t lOptions; 143 serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; 144 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions); 145 zorba::SingletonItemSequence lSequence(theItem); 146 lSerializer->serialize(&lSequence, lStream); 147 return; 148 } 149 150 %} // end Implementation 151 152 153 %include "Item.h" 154