daeInt DAE::save(daeString documentName, daeBool replace) { if (!database) setDatabase(NULL); if (!plugin) setIOPlugin(NULL); if (registerFunc) registerFunc(); if ( !plugin || !database ) { return DAE_ERR_BACKEND_IO; } plugin->setDatabase(database); // Find the document we want by name daeDocument* document = database->getDocument(documentName); if(document == NULL) return DAE_ERR_COLLECTION_DOES_NOT_EXIST; // Save it out to the URI it was loaded from return plugin->write(document->getDocumentURI(), document, replace); }
// batch file operations daeInt DAE::load(daeString name, daeString docBuffer) { if (!database) setDatabase(NULL); if (!plugin) setIOPlugin(NULL); if (registerFunc) registerFunc(); if ( !plugin || !database ) { //printf( "no plugin or database\n" ); daeErrorHandler::get()->handleError("no plugin or database\n"); return DAE_ERR_BACKEND_IO; } plugin->setDatabase(database); if (!name || name[0] == '\0') return DAE_ERR_INVALID_CALL; daeURI tempURI(name); return plugin->read(tempURI, docBuffer); }
daeInt DAE::saveAs(daeString name, daeString documentName, daeBool replace) { if (!database) setDatabase(NULL); if (!plugin) setIOPlugin(NULL); if (registerFunc) registerFunc(); if ( !plugin || !database ) { return DAE_ERR_BACKEND_IO; } plugin->setDatabase(database); // Find the document we want by name daeDocument* document = database->getDocument(documentName); if(document == NULL) return DAE_ERR_COLLECTION_DOES_NOT_EXIST; // Make a URI from "name" and save to that daeURI tempURI(name, true); return plugin->write(&tempURI, document, replace); }
daeInt DAE::saveAs(daeString name, daeUInt documentIndex, daeBool replace) { if (!database) setDatabase(NULL); if (!plugin) setIOPlugin(NULL); if (registerFunc) registerFunc(); if ( !plugin || !database ) { return DAE_ERR_BACKEND_IO; } plugin->setDatabase(database); if(documentIndex >= database->getDocumentCount()) return DAE_ERR_COLLECTION_DOES_NOT_EXIST; daeDocument *document = database->getDocument(documentIndex); daeURI tempURI(name); return plugin->write(&tempURI, document, replace); }
daeInt DAE::save(daeUInt documentIndex, daeBool replace) { if (!database) setDatabase(NULL); if (!plugin) setIOPlugin(NULL); if (registerFunc) registerFunc(); if ( !plugin || !database ) { return DAE_ERR_BACKEND_IO; } plugin->setDatabase(database); if(documentIndex >= database->getDocumentCount()) return DAE_ERR_COLLECTION_DOES_NOT_EXIST; daeDocument *document = database->getDocument(documentIndex); // Save it out to the URI it was loaded from return plugin->write(document->getDocumentURI(), document, replace); }