// // Copyright (C) 2007 Refractions Research, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // #include #include #include #include #include #include #include "fdoutility.h" using namespace fdoutility; int main(int argc, char* argv[]) { try { std::wstring provider(L"OSGeo.PostGIS.3.2"); // Name of new datastore being created std::wstring datastore(L"warsaw"); // Connection string without datastore specified std::wstring connStr(L"service=fdo_test;username=mloskot;password=pantera;"); std::wcout << "Connection string: " << connStr << std::endl; // Create connection FdoPtr conn = fdoutility::create_connection(provider); // Open connection conn->SetConnectionString(connStr.c_str()); FdoConnectionState state = conn->Open(); std::wcout << "Connection state: " << state << std::endl; // Create datastore FdoPtr cmd; cmd = static_cast(conn->CreateCommand(FdoCommandType_DestroyDataStore)); assert(0 != cmd); FdoPtr props = cmd->GetDataStoreProperties(); assert(0 != props); FdoInt32 size = 0; FdoString **names = props->GetPropertyNames(size); assert(0 != names); for (FdoInt32 i = 0; i < size; i++) { assert(0 != names[i]); std::wstring name(names[i]); if (name == L"DataStore") props->SetProperty(name.c_str(), datastore.c_str()); else assert(!"Unknown property name"); } std::wcout << "DataStore properties: " << std::endl; fdoutility::list_properties(std::wcout, props); cmd->Execute(); std::wcout << "Destroyed datastore: " << datastore << std::endl; } catch (FdoException* ex) { std::wcout << L"*** FDO Error:\n"; int i = 5; FdoException* nex = ex; while (nex) { wchar_t const* msg = nex->GetExceptionMessage(); if (NULL == msg) { msg = L"NO MESSAGE"; } std::wcout << std::setw(++i) << L"*** " << msg << std::endl; nex = nex->GetCause(); } ex->Release(); } catch(std::exception& ex) { std::cout << "*** Std Error: " << ex.what() << std::endl; } catch(...) { std::cout << "*** Undefined error!\n" << std::endl; } return 0; }