Esempio n. 1
0
int
execution_plans(int argc, char* argv[])
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba *lZorba = Zorba::getInstance(lStore);

  bool res = false;

  std::cout << "executing example 1" << std::endl;
  res = execution_plan_example_1(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 2" << std::endl;
  res = execution_plan_example_2(lZorba);
  if (!res) return 2; 
  std::cout << std::endl;

  std::cout << "executing example 3" << std::endl;
  res = execution_plan_example_3(lZorba);
  if (!res) return 3; 
  std::cout << std::endl;

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 2
0
int sax2( int argc, char * argv[] )
{
  // create a SAX content handler that prints all events to standard out
  XMLSerializer lContentHandler( std::cout );

  void* lStore = zorba::StoreManager::getStore();

  // initialize the Zorba engine and get a pointer to it
  Zorba* lZorba = Zorba::getInstance(lStore);

  try 
  {
    // compile a query
    XQuery_t lQuery = lZorba->compileQuery("<a xmlns:f=\"foo\" xmlns=\"http://zorba.io/defaultns\"> text a text a <b xmlns:ns1=\"http://zorba.io/usecase1\" attr1=\"value1\" attr2=\"value2\"> text b </b><f:bar>foo</f:bar><foo /><bar /><b><![CDATA[ foo ]]></b></a>");

    // register the content handler created above
    lQuery->registerSAXHandler( &lContentHandler );

    // execute the query and call according SAX callbacks 
    // i.e. equivalent to serializing to xml and parsing using SAX).
    lQuery->executeSAX();
  }
  catch ( ZorbaException &e ) 
  {
    std::cerr << e << std::endl;
  }

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 3
0
int
multithread_stress_test(int argc, char* argv[])
{
  simplestore::SimpleStore* lStore = StoreManager::getStore();
  Zorba*                    lZorba = Zorba::getInstance(StoreManager::getStore());
  bool                      res = false;

  std::cout << std::endl  << "executing multithread test 1 : ";
  res = multithread_stress_example_1(lZorba);
  if (!res) {
    std::cout << "Failed" << std::endl;
    lZorba->shutdown();
    StoreManager::shutdownStore(lStore);
    return 1;
  }
  else std::cout << "Passed" << std::endl;

  lZorba->shutdown();
  StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 4
0
int 
jsoniq(int argc, char* argv[])
{
  void* lStore = StoreManager::getStore();
  Zorba *lZorba = Zorba::getInstance(lStore);

  bool res = false;

  try {
    std::cout << "executing jsoniq example 1" << std::endl;
    res = jsoniq_test::example_1(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 2" << std::endl;
    res = jsoniq_test::example_2(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 3" << std::endl;
    res = jsoniq_test::example_3(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 4" << std::endl;
    res = jsoniq_test::example_4(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 5" << std::endl;
    res = jsoniq_test::example_5(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 6" << std::endl;
    res = jsoniq_test::example_6(lZorba);
    if (!res) return 1;
    std::cout << std::endl;

    std::cout << "executing jsoniq example 9" << std::endl;
    res = jsoniq_test::example_7(lZorba);
    if (!res) return 1;
    std::cout << std::endl;
  }
  catch (ZorbaException& e) {
    std::cout << "ZorbaException raised: " << e.what() << std::endl;
    return 2;
  }

  lZorba->shutdown();
  StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 5
0
void
testMultipleFactoryInitilizations()
{
  Zorba* zorba = NULL;
  void* store = NULL;

  store = zorba::StoreManager::getStore();
  zorba = Zorba::getInstance(store);

  ItemFactory* factory = zorba->getItemFactory();
  factory->createString( "" );

  zorba->shutdown();
  zorba::StoreManager::shutdownStore(store);

  store = zorba::StoreManager::getStore();
  zorba = Zorba::getInstance(store);

  factory = zorba->getItemFactory();
  factory->createString( "" ); // <-- zorba crashes here

  zorba->shutdown();
  zorba::StoreManager::shutdownStore(store);
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
int
runQuery(const char* query)
{
  void* lStore = StoreManager::getStore();
  Zorba *lZorba = Zorba::getInstance(lStore);

  XQuery_t lQuery = lZorba->compileQuery(query);

  std::cout << lQuery << std::endl;

  lZorba->shutdown();
  StoreManager::shutdownStore(lStore);

  return 0;
}
int module_import_check(int argc, char* argv[])
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba *lZorba = Zorba::getInstance(lStore);

  bool res = false;

  res = example1(lZorba);
  if (!res)
    return 1;

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 9
0
int
cxx_api_changes (int argc, char* argv[])
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba* lZorba = Zorba::getInstance(lStore);

  std::cout << "executing cxx_api_changes_test1" << std::endl;
  if (!cxx_api_changes_test1(lZorba))
  {
    return 1;
  }

  std::cout << "executing cxx_api_changes_test2" << std::endl;
  if (!cxx_api_changes_test2(lZorba))
  {
    return 2;
  }

  std::cout << "executing cxx_api_changes_test3" << std::endl;
  if (!cxx_api_changes_test3(lZorba))
  {
    return 3;
  }

  std::cout << "executing cxx_api_changes_test4" << std::endl;
  if (!cxx_api_changes_test4(lZorba))
  {
    return 4;
  }

  std::cout << "executing cxx_api_changes_test5" << std::endl;
  if (!cxx_api_changes_test5(lZorba))
  {
    return 5;
  }

  std::cout << "executing cxx_api_changes_test6" << std::endl;
  if (!cxx_api_changes_test6(lZorba))
  {
    return 6;
  }

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 10
0
int 
errors(int argc, char* argv[])
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba* lZorba = Zorba::getInstance(lStore);
  bool res = false;

  std::cout << "executing example 1" << std::endl;
  res = error_example_1(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 2" << std::endl;
  res = error_example_2(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 3" << std::endl;
  res = error_example_3(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 4" << std::endl;
  res = error_example_4(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 5" << std::endl;
  res = error_example_5(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 6" << std::endl;
  res = error_example_6(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  std::cout << "executing example 7" << std::endl;
  res = error_example_7(lZorba);
  if (!res) return 1; 
  std::cout << std::endl;

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 11
0
int
external_function(int argc, char* argv[]) 
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba* lZorba = Zorba::getInstance(lStore);

  std::cout << "executing external_function_test_1" << std::endl;
  if (!external_function_test_1(lZorba))
  {
    return 1;
  }

  std::cout << "executing external_function_test_2" << std::endl;
  if (!external_function_test_2(lZorba))
  {
    return 2;
  }

  std::cout << "executing external_function_test_3" << std::endl;
  if (!external_function_test_3(lZorba))
  {
    return 3;
  }

  std::cout << "executing external_function_test_4" << std::endl;
  if (!external_function_test_4(lZorba))
  {
    return 4;
  }

  std::cout << "executing external_function_test_5" << std::endl;
  if (!external_function_test_5(lZorba))
  {
    return 4;
  }


  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}
Esempio n. 12
0
int 
xmldatamanager(int argc, char* argv[])
{
  void* lStore = zorba::StoreManager::getStore();
  Zorba* lZorba = Zorba::getInstance(lStore);
  XmlDataManager_t lDataManager = lZorba->getXmlDataManager();
  bool res = false;

  std::cout << "executing example 1" << std::endl;
  res = xmldatamanager_example_1(lZorba, lDataManager);
  if (!res) return 1;
  std::cout << std::endl;

  std::cout << "executing example 2" << std::endl;
  res = xmldatamanager_example_2(lZorba, lDataManager);
  if (!res) return 2;
  std::cout << std::endl;

  std::cout << "executing example 3" << std::endl;
  res = xmldatamanager_example_3(lZorba, lDataManager);
  if (!res) return 3;
  std::cout << std::endl;

  std::cout << "executing example 4" << std::endl;
  res = xmldatamanager_example_4(lZorba, lDataManager);
  if (!res) return 4;
  std::cout << std::endl;

  std::cout << "executing example 5" << std::endl;
  res = xmldatamanager_example_5(lZorba, lDataManager);
  if (!res) return 5;
  std::cout << std::endl;

  lZorba->shutdown();
  zorba::StoreManager::shutdownStore(lStore);
  return 0;
}