From 8a91304f4b07a43344cbbe32234a74db74832222 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 26 May 2014 14:43:32 +0200 Subject: [PATCH 1/1] First kick with a conversion of two records from YAZ --- src/.gitignore | 2 ++ src/Makefile | 17 +++++++++++ src/tst.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 src/.gitignore create mode 100644 src/Makefile create mode 100644 src/tst.cpp diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..75ad7b2 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,2 @@ +*.o +tst diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..dc991bf --- /dev/null +++ b/src/Makefile @@ -0,0 +1,17 @@ + +O=tst.o + +ZORBA := ../../zorba/zorba-3.0/build/dist + +CXXFLAGS=-I$(ZORBA)/include + +LIB=-L $(ZORBA)/lib -lzorba_simplestore + +tst: $(O) + $(CXX) $^ -o $@ $(LIB) + +clean: + rm -f *.o tst + +run: tst + LD_LIBRARY_PATH=$(ZORBA)/lib ./tst diff --git a/src/tst.cpp b/src/tst.cpp new file mode 100644 index 0000000..f35415d --- /dev/null +++ b/src/tst.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +using namespace zorba; + +bool +example_1(Zorba* aZorba) +{ + XQuery_t lQuery = aZorba->compileQuery("1+2"); + + std::cout << lQuery << std::endl; + + return true; +} + +bool +example_2(Zorba* aZorba) +{ + XQuery_t lQuery = aZorba->createQuery(); + std::string path( "/home/adam/proj/marc2bibframe/xbin/zorba3-0.xqy"); + + std::unique_ptr qfile; + + qfile.reset( new std::ifstream( path.c_str() ) ); + + Zorba_CompilerHints lHints; + + // lQuery->setFileName("http://base/"); + lQuery->setFileName("/home/adam/proj/marc2bibframe/xbin/"); + + lQuery->compile(*qfile.get(), lHints); + + zorba::DynamicContext* lDynamicContext = lQuery->getDynamicContext(); + + zorba::Item lItem = aZorba->getItemFactory()->createString("http://base/"); + lDynamicContext->setVariable("baseuri", lItem); + + lItem = aZorba->getItemFactory()->createString( + "/home/adam/proj/yaz/test/marc6.xml"); + lDynamicContext->setVariable("marcxmluri", lItem); + + lItem = aZorba->getItemFactory()->createString("rdfxml"); + lDynamicContext->setVariable("serialization", lItem); + + std::cout << lQuery << std::endl; + + lItem = aZorba->getItemFactory()->createString( + "/home/adam/proj/yaz/test/marc7.xml"); + lDynamicContext->setVariable("marcxmluri", lItem); + + std::cout << lQuery << std::endl; + + return true; +} + +int main(int argc, char **argv) +{ + void* lStore = StoreManager::getStore(); + Zorba *lZorba = Zorba::getInstance(lStore); + + assert(lZorba); + + example_1(lZorba); + + example_2(lZorba); + + lZorba->shutdown(); + StoreManager::shutdownStore(lStore); + return 0; +} +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + -- 1.7.10.4