本文整理汇总了C++中ArangoClient::setDatabaseName方法的典型用法代码示例。如果您正苦于以下问题:C++ ArangoClient::setDatabaseName方法的具体用法?C++ ArangoClient::setDatabaseName怎么用?C++ ArangoClient::setDatabaseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArangoClient
的用法示例。
在下文中一共展示了ArangoClient::setDatabaseName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
LocalEntryFunction();
TRIAGENS_C_INITIALIZE(argc, argv);
TRIAGENS_REST_INITIALIZE(argc, argv);
TRI_InitializeLogging(false);
// .............................................................................
// set defaults
// .............................................................................
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// use a minimum value for batches
if (ChunkSize < 1024 * 128) {
ChunkSize = 1024 * 128;
}
if (! InputDirectory.empty() &&
InputDirectory.back() == TRI_DIR_SEPARATOR_CHAR) {
// trim trailing slash from path because it may cause problems on ... Windows
TRI_ASSERT(InputDirectory.size() > 0);
InputDirectory.pop_back();
}
// .............................................................................
// check input directory
// .............................................................................
if (InputDirectory == "" || ! TRI_IsDirectory(InputDirectory.c_str())) {
cerr << "Error: input directory '" << InputDirectory << "' does not exist" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
if (! ImportStructure && ! ImportData) {
cerr << "Error: must specify either --create-collection or --import-data" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == nullptr) {
cerr << "Error: invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
Connection = GeneralClientConnection::factory(BaseClient.endpointServer(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol());
Client = new SimpleHttpClient(Connection, BaseClient.requestTimeout(), false);
Client->setLocationRewriter(nullptr, &rewriteLocation);
Client->setUserNamePassword("/", BaseClient.username(), BaseClient.password());
string versionString = GetArangoVersion();
if (CreateDatabase && LastErrorCode == TRI_ERROR_ARANGO_DATABASE_NOT_FOUND) {
// database not found, but database creation requested
std::string old = BaseClient.databaseName();
cout << "Creating database '" << old << "'" << endl;
BaseClient.setDatabaseName("_system");
int res = TryCreateDatabase(old);
if (res != TRI_ERROR_NO_ERROR) {
cerr << "Could not create database '" << old << "'" << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
// restore old database name
BaseClient.setDatabaseName(old);
// re-fetch version
versionString = GetArangoVersion();
}
if (! Connection->isConnected()) {
cerr << "Could not connect to endpoint " << BaseClient.endpointServer()->getSpecification() << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
//.........这里部分代码省略.........