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 execute()19 std::string XQuery::execute() 20 { 21 Zorba_SerializerOptions_t lSerOptions; 22 lSerOptions.indent = ZORBA_INDENT_NO; 23 lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_NO; 24 std::stringstream lStream; 25 theQuery->execute(lStream, &lSerOptions); 26 return lStream.str(); 27 } 28 compile(const std::string & aQuery)29 void XQuery::compile (const std::string &aQuery) 30 { 31 theQuery->compile(aQuery); 32 } 33 compile(const std::string & aQuery,StaticContext & aStaticContext)34 void XQuery::compile (const std::string &aQuery, StaticContext &aStaticContext ) 35 { 36 Zorba_CompilerHints_t hints; 37 theQuery->compile(aQuery, aStaticContext.theStaticContext, hints); 38 } 39 printPlanAsXML()40 std::string XQuery::printPlanAsXML() 41 { 42 std::ostringstream lStream; 43 theQuery->printPlan(lStream); 44 return lStream.str(); 45 } 46 printPlanAsDOT()47 std::string XQuery::printPlanAsDOT() 48 { 49 std::ostringstream lStream; 50 theQuery->printPlan(lStream, true); 51 return lStream.str(); 52 } 53 getDynamicContext()54 DynamicContext XQuery::getDynamicContext() 55 { 56 return DynamicContext(theQuery->getDynamicContext()); 57 } 58 getStaticContext()59 StaticContext XQuery::getStaticContext() 60 { 61 return StaticContext( zorba::StaticContext_t( const_cast<zorba::StaticContext *>(theQuery->getStaticContext()) ) ); 62 } 63 getStaticCollectionManager()64 StaticCollectionManager XQuery::getStaticCollectionManager() 65 { 66 return StaticCollectionManager( theQuery->getStaticCollectionManager() ); 67 } 68 getExternalVariables(Iterator & vars)69 void XQuery::getExternalVariables(Iterator& vars) const 70 { theQuery->getExternalVariables( vars.theIterator ); } 71 72 #ifdef SWIGPYTHON executeSAX(SAX2ContentHandlerProxy * contentHandlerProxy)73 void XQuery::executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy) 74 { theQuery->executeSAX(contentHandlerProxy); } 75 #endif 76 destroy()77 void XQuery::destroy() { theQuery = 0; } iterator()78 Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); } 79 execute(ZorbaIOStream & stream)80 void XQuery::execute( ZorbaIOStream & stream ) 81 { 82 Zorba_SerializerOptions_t lSerOptions; 83 lSerOptions.indent = ZORBA_INDENT_NO; 84 lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; 85 ZorbaStreamBuffer buffer(stream); 86 std::ostream lStream(&buffer); 87 theQuery->execute(lStream, &lSerOptions); 88 return; 89 } 90 execute(ZorbaIOStream & stream,SerializationOptions & serOptions)91 void XQuery::execute( ZorbaIOStream & stream, SerializationOptions & serOptions ) 92 { 93 ZorbaStreamBuffer buffer(stream); 94 std::ostream lStream(&buffer); 95 theQuery->execute(lStream, &serOptions.lOptions); 96 } 97 execute(SerializationOptions & serOptions)98 std::string XQuery::execute( SerializationOptions & serOptions ) 99 { 100 std::stringstream lStream; 101 theQuery->execute(lStream, &serOptions.lOptions); 102 return lStream.str(); 103 } 104 105 106 %} // end Implementation 107 108 %include "XQuery.h" 109