void setPathsOnContext( const ZorbaCMDProperties& aProperties, StaticContext_t& aStaticCtx) { std::vector<String> lPath; std::string lPathStr; // Compute the current working directory to append to all paths. filesystem_path lCWD; // setModulePaths() *overwrites* the URI path and lib path, so there's no // sense in calling both. So if --module-path exists, just use it. aProperties.getModulePath(lPathStr); if (lPathStr.length() > 0) { tokenizePath(lPathStr, lPath); lPath.push_back(lCWD.get_path()); aStaticCtx->setModulePaths(lPath); } else { // Compute and set URI path aProperties.getURIPath(lPathStr); tokenizePath(lPathStr, lPath); lPath.push_back(lCWD.get_path()); aStaticCtx->setURIPath(lPath); lPath.clear(); // Compute and set lib path aProperties.getLibPath(lPathStr); tokenizePath(lPathStr, lPath); lPath.push_back(lCWD.get_path()); aStaticCtx->setLibPath(lPath); } }
bool cxx_api_changes_test4(Zorba* aZorba) { try { std::ifstream lIn("cxx_api_ch4.xq"); assert(lIn.good()); StaticContext_t lStaticContext = aZorba->createStaticContext(); std::vector<String> lModulePaths; lModulePaths.push_back(zorba::CMAKE_BINARY_DIR+"/TEST_URI_PATH/"); lStaticContext->setModulePaths(lModulePaths); XQuery_t lQuery = aZorba->compileQuery(lIn, lStaticContext); std::vector<Item> lVars; Iterator_t varsIte; lQuery->getExternalVariables(varsIte); varsIte->open(); Item temp; while(varsIte->next(temp)) lVars.push_back(temp); varsIte->close(); if (lVars.size() != 3) return false; std::ostringstream lOut; std::vector<Item>::const_iterator lIte = lVars.begin(); std::vector<Item>::const_iterator lEnd = lVars.end(); for (; lIte != lEnd; ++lIte) { lOut << lIte->getStringValue() << " "; } std::string out = lOut.str(); if (out != "testGetExtVarA:ext a testGetExtVarB:ext " && out != "testGetExtVarB:ext a testGetExtVarA:ext " && out != "a testGetExtVarA:ext testGetExtVarB:ext " && out != "a testGetExtVarB:ext testGetExtVarA:ext " && out != "testGetExtVarA:ext testGetExtVarB:ext a " && out != "testGetExtVarB:ext testGetExtVarA:ext a ") return false; } catch (XQueryException& qe) { std::cerr << qe << std::endl; return false; } catch (ZorbaException& e) { std::cerr << e << std::endl; return false; } return true; }