本文整理汇总了C++中daeURI类的典型用法代码示例。如果您正苦于以下问题:C++ daeURI类的具体用法?C++ daeURI怎么用?C++ daeURI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了daeURI类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: tempURI
void daeDocument::addExternalReference( daeURI &uri ) {
if ( uri.getContainer() == NULL || uri.getContainer()->getDocument() != this ) {
return;
}
daeURI tempURI( *dae, uri.getURI(), true ); // Remove fragment
referencedDocuments.appendUnique( tempURI.getURI() );
}
开发者ID:Bloodknight,项目名称:T3D-MIT-GMK-Port,代码行数:7,代码来源:daeDocument.cpp
示例2: write
daeInt daeTinyXMLPlugin::write(const daeURI& name, daeDocument *document, daeBool replace)
{
// Make sure database and document are both set
if (!database)
return DAE_ERR_INVALID_CALL;
if(!document)
return DAE_ERR_COLLECTION_DOES_NOT_EXIST;
string fileName = cdom::uriToNativePath(name.str());
if (fileName.empty())
{
daeErrorHandler::get()->handleError( "can't get path in write\n" );
return DAE_ERR_BACKEND_IO;
}
// If replace=false, don't replace existing files
if(!replace)
{
// Using "stat" would be better, but it's not available on all platforms
FILE *tempfd = fopen(fileName.c_str(), "r");
if(tempfd != NULL)
{
// File exists, return error
fclose(tempfd);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(tempfd);
}
m_doc = new TiXmlDocument(name.getURI());
if (m_doc)
{
m_doc->SetTabSize(4);
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
m_doc->LinkEndChild( decl );
writeElement(document->getDomRoot());
// TODO check if writing to zae
// if( 0 ) {
// // Declare a printer
// TiXmlPrinter printer;
//
// // attach it to the document you want to convert in to a std::string
// m_doc->Accept(&printer);
//
// // Create a std::string and copy your document data in to the string
// std::string str = printer.CStr();
//
// // compress str and size to fileName
//
// }
m_doc->SaveFile(fileName.c_str());
delete m_doc;
m_doc = NULL;
}
return DAE_OK;
}
开发者ID:ANR2ME,项目名称:collada-dom,代码行数:59,代码来源:daeTinyXMLPlugin.cpp
示例3: readFromFile
daeElementRef daeTinyXMLPlugin::readFromFile(const daeURI& uri) {
string file = cdom::uriToNativePath(uri.str());
if (file.empty())
return NULL;
TiXmlDocument doc;
doc.LoadFile(file.c_str());
if (!doc.RootElement()) {
daeErrorHandler::get()->handleError((std::string("Failed to open ") + uri.str() +
" in daeTinyXMLPlugin::readFromFile\n").c_str());
return NULL;
}
return readElement(doc.RootElement(), NULL);
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:13,代码来源:daeTinyXMLPlugin.cpp
示例4:
void
daeURIResolver::attemptResolveElement(daeURI& uri, daeString typeNameHint)
{
int i;
int cnt =(int) _KnownResolvers.getCount();
for(i=0;i<cnt;i++)
if ((_KnownResolvers[i]->isProtocolSupported(uri.getProtocol()))&&
((uri.getFile() == NULL) ||
(uri.getFile()[0] == '\0') ||
(_KnownResolvers[i]->isExtensionSupported(uri.getExtension()))) &&
(_KnownResolvers[i]->resolveElement(uri, typeNameHint)))
return;
}
开发者ID:,项目名称:,代码行数:14,代码来源:
示例5:
void
daeURI::copyFrom(const daeURI& copyFrom)
{
if (!container)
container = copyFrom.container;
set(copyFrom.originalStr());
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:7,代码来源:daeURI.cpp
示例6: defined
void
daeURIResolver::attemptResolveURI(daeURI& uri)
{
int i,cnt = (int)_KnownResolvers.getCount();
daeBool foundProtocol = false;
for(i=0;i<cnt;i++)
if (_KnownResolvers[i]->isProtocolSupported(uri.getProtocol())) {
foundProtocol = true;
if (_KnownResolvers[i]->resolveURI(uri))
return;
}
#if defined(_DEBUG) && defined(WIN32)
fprintf(stderr,
"daeURIResolver::attemptResolveURI(%s) - failed\n",
uri.getURI());
#endif
if (!foundProtocol) {
uri.setState(daeURI::uri_failed_unsupported_protocol);
#if defined(_DEBUG) && defined(WIN32)
fprintf(stderr,"**protocol '%s' is not supported**\n",uri.getProtocol());
fflush(stderr);
#endif
}
else {
#if defined(_DEBUG) && defined(WIN32)
fprintf(stderr,"**file(%s/%s) or id(%s) failed to resolve\n",
uri.getFilepath(),uri.getFile(),uri.getID());
fflush(stderr);
#endif
}
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例7: readFromFile
daeElementRef daeLIBXMLPlugin::readFromFile(const daeURI& uri) {
xmlTextReaderHelper readerHelper(uri);
if (!readerHelper.reader) {
daeErrorHandler::get()->handleError((string("Failed to open ") + uri.str() +
" in daeLIBXMLPlugin::readFromFile\n").c_str());
return NULL;
}
return read(readerHelper.reader);
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:9,代码来源:daeLIBXMLPlugin.cpp
示例8: write
daeInt daeTinyXMLPlugin::write(const daeURI& name, daeDocument *document, daeBool replace)
{
// Make sure database and document are both set
if (!database)
return DAE_ERR_INVALID_CALL;
if(!document)
return DAE_ERR_COLLECTION_DOES_NOT_EXIST;
string fileName = cdom::uriToNativePath(name.str());
if (fileName.empty())
{
daeErrorHandler::get()->handleError( "can't get path in write\n" );
return DAE_ERR_BACKEND_IO;
}
// If replace=false, don't replace existing files
if(!replace)
{
// Using "stat" would be better, but it's not available on all platforms
FILE *tempfd = fopen(fileName.c_str(), "r");
if(tempfd != NULL)
{
// File exists, return error
fclose(tempfd);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(tempfd);
}
m_doc = new TiXmlDocument(name.getURI());
if (m_doc)
{
m_doc->SetTabSize(4);
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
m_doc->LinkEndChild( decl );
writeElement(document->getDomRoot());
m_doc->SaveFile(fileName.c_str());
delete m_doc;
m_doc = NULL;
}
return DAE_OK;
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:44,代码来源:daeTinyXMLPlugin.cpp
示例9: write
daeInt daeLIBXMLPlugin::write(const daeURI& name, daeDocument *document, daeBool replace)
{
// Make sure database and document are both set
if (!database)
return DAE_ERR_INVALID_CALL;
if(!document)
return DAE_ERR_COLLECTION_DOES_NOT_EXIST;
// Convert the URI to a file path, to see if we're about to overwrite a file
string file = cdom::uriToNativePath(name.str());
if (file.empty() && saveRawFile)
{
daeErrorHandler::get()->handleError( "can't get path in write\n" );
return DAE_ERR_BACKEND_IO;
}
// If replace=false, don't replace existing files
if(!replace)
{
// Using "stat" would be better, but it's not available on all platforms
FILE *tempfd = fopen(file.c_str(), "r");
if(tempfd != NULL)
{
// File exists, return error
fclose(tempfd);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(tempfd);
}
if ( saveRawFile )
{
string rawFilePath = file + ".raw";
if ( !replace )
{
rawFile = fopen(rawFilePath.c_str(), "rb" );
if ( rawFile != NULL )
{
fclose(rawFile);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(rawFile);
}
rawFile = fopen(rawFilePath.c_str(), "wb");
if ( rawFile == NULL )
{
return DAE_ERR_BACKEND_IO;
}
rawRelPath.set(cdom::nativePathToUri(rawFilePath));
rawRelPath.makeRelativeTo( &name );
}
// Open the file we will write to
writer = xmlNewTextWriterFilename(cdom::fixUriForLibxml(name.str()).c_str(), 0);
if ( !writer ) {
ostringstream msg;
msg << "daeLIBXMLPlugin::write(" << name.str() << ") failed\n";
daeErrorHandler::get()->handleError(msg.str().c_str());
return DAE_ERR_BACKEND_IO;
}
xmlTextWriterSetIndentString( writer, (const xmlChar*)"\t" ); // Don't change this to spaces
xmlTextWriterSetIndent( writer, 1 ); // Turns indentation on
xmlTextWriterStartDocument( writer, "1.0", "UTF-8", NULL );
writeElement( document->getDomRoot() );
xmlTextWriterEndDocument( writer );
xmlTextWriterFlush( writer );
xmlFreeTextWriter( writer );
if ( saveRawFile && rawFile != NULL )
{
fclose( rawFile );
}
return DAE_OK;
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:76,代码来源:daeLIBXMLPlugin.cpp
示例10: dae
daeURI::daeURI(const daeURI& baseURI, const string& uriStr) : dae(baseURI.getDAE())
{
initialize();
set(uriStr, &baseURI);
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:5,代码来源:daeURI.cpp
示例11: write
daeInt daeLIBXMLPlugin::write(const daeURI& name, daeDocument *document, daeBool replace)
{
// Make sure database and document are both set
if (!database) {
return DAE_ERR_INVALID_CALL;
}
if(!document) {
return DAE_ERR_COLLECTION_DOES_NOT_EXIST;
}
// Convert the URI to a file path, to see if we're about to overwrite a file
string file = cdom::uriToNativePath(name.str());
if (file.empty() && saveRawFile)
{
daeErrorHandler::get()->handleError( "can't get path in write\n" );
return DAE_ERR_BACKEND_IO;
}
// If replace=false, don't replace existing files
if(!replace)
{
// Using "stat" would be better, but it's not available on all platforms
FILE *tempfd = fopen(file.c_str(), "r");
if(tempfd != NULL)
{
// File exists, return error
fclose(tempfd);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(tempfd);
}
if ( saveRawFile )
{
string rawFilePath = file + ".raw";
if ( !replace )
{
rawFile = fopen(rawFilePath.c_str(), "rb" );
if ( rawFile != NULL )
{
fclose(rawFile);
return DAE_ERR_BACKEND_FILE_EXISTS;
}
fclose(rawFile);
}
rawFile = fopen(rawFilePath.c_str(), "wb");
if ( rawFile == NULL )
{
return DAE_ERR_BACKEND_IO;
}
rawRelPath.set(cdom::nativePathToUri(rawFilePath));
rawRelPath.makeRelativeTo( &name );
}
std::string fileName = cdom::uriToNativePath(name.str());
bool bcompress = fileName.size() >= 4 && fileName[fileName.size()-4] == '.' && ::tolower(fileName[fileName.size()-3]) == 'z' && ::tolower(fileName[fileName.size()-2]) == 'a' && ::tolower(fileName[fileName.size()-1]) == 'e';
int err=0;
xmlBufferHandler bufhandler;
if( bcompress ) {
// taken from http://xmlsoft.org/examples/testWriter.c
// Create a new XML buffer, to which the XML document will be written
bufhandler.buf = xmlBufferCreate();
if (!bufhandler.buf) {
ostringstream msg;
msg << "daeLIBXMLPlugin::write(" << name.str() << ") testXmlwriterMemory: Error creating the xml buffer\n";
daeErrorHandler::get()->handleError(msg.str().c_str());
return DAE_ERR_BACKEND_IO;
}
// Create a new XmlWriter for memory, with no compression. Remark: there is no compression for this kind of xmlTextWriter
writer = xmlNewTextWriterMemory(bufhandler.buf, 0);
}
else {
// Open the file we will write to
writer = xmlNewTextWriterFilename(cdom::fixUriForLibxml(name.str()).c_str(), 0);
}
if (!writer) {
ostringstream msg;
msg << "daeLIBXMLPlugin::write(" << name.str() << ") Error creating the xml writer\n";
daeErrorHandler::get()->handleError(msg.str().c_str());
return DAE_ERR_BACKEND_IO;
}
err = xmlTextWriterSetIndentString( writer, (const xmlChar*)"\t" ); // Don't change this to spaces
if( err < 0 ) {
}
err = xmlTextWriterSetIndent( writer, 1 ); // Turns indentation on
if( err < 0 ) {
}
err = xmlTextWriterStartDocument( writer, "1.0", "UTF-8", NULL );
if( err < 0 ) {
}
writeElement( document->getDomRoot() );
xmlTextWriterEndDocument( writer );
xmlTextWriterFlush( writer );
xmlFreeTextWriter( writer );
writer = NULL; // reset pointer
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例12: add
void daeRawRefCache::add(const daeURI& uri, daeElement* elt) {
(*lookupTable)[uri.str()] = elt;
}
开发者ID:ANR2ME,项目名称:collada-dom,代码行数:3,代码来源:daeRawResolver.cpp
示例13: remove
void daeRawRefCache::remove(const daeURI& uri) {
lookupTable->erase(uri.str());
}
开发者ID:ANR2ME,项目名称:collada-dom,代码行数:3,代码来源:daeRawResolver.cpp
示例14: xmlTextReaderHelper
xmlTextReaderHelper(const daeURI& uri) {
if((reader = xmlReaderForFile(cdom::fixUriForLibxml(uri.str()).c_str(), NULL, 0)))
xmlTextReaderSetErrorHandler(reader, libxmlErrorHandler, NULL);
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:4,代码来源:daeLIBXMLPlugin.cpp
示例15: fileURI
// This function needs to be re-entrant, it can be called recursively from inside of resolveAll
// to load files that the first file depends on.
daeInt daeLIBXMLPlugin::read(daeURI& uri, daeString docBuffer)
{
// Make sure topMeta has been set before proceeding
if (topMeta == NULL)
{
return DAE_ERR_BACKEND_IO;
}
// Generate a version of the URI with the fragment removed
daeURI fileURI(uri.getURI(),true);
// Create the right type of xmlTextReader on the stack so this function can be re-entrant
xmlTextReaderPtr reader;
if(docBuffer)
{
// Load from memory (experimental)
#if 0 //debug stuff
printf("Reading %s from memory buffer\n", fileURI.getURI());
#endif
reader = xmlReaderForDoc((xmlChar*)docBuffer, fileURI.getURI(), NULL,0);
}
else
{
// Load from URI
#if 0 //debug stuff
printf("Opening %s\n", fileURI.getURI());
#endif
reader = xmlReaderForFile(fileURI.getURI(), NULL,0);
}
if(!reader)
{
printf( "no libxml2 reader\n");
return DAE_ERR_BACKEND_IO;
}
// Start parsing the file
daeElementRef domObject = startParse(topMeta, reader);
// Parsing done, free the xmlReader and error check to make sure we got a valid DOM back
xmlFreeTextReader(reader);
if (!domObject)
{
#if defined(_DEBUG) && defined(WIN32)
fprintf(stderr,"daeLIBXMLPlugin::read(%s) failed - XML Parse Failed\n",
fileURI.getFile());
fflush(stdout);
#endif
printf("not able to load\n");
return DAE_ERR_BACKEND_IO;
}
// Insert the document into the database, the Database will keep a ref on the main dom, so it won't gets deleted
// until we clear the database
daeDocument *document = NULL;
int res = database->insertDocument(fileURI.getURI(),domObject,&document);
if (res!= DAE_OK)
return res;
// Make a vector to store a list of the integration items that need to be processed later
// postProcessDom will fill this in for us (this should probably not be done in the IOPlugin)
std::vector<INTEGRATION_ITEM> intItems;
//insert the elements into the database, for this DB the elements are the Collada object which have
//an ID.
//this function will fill the _integrationItems array as well
postProcessDom(document, domObject, intItems);
database->validate();
daeElement::resolveAll();
//create the integration objects
int size = (int)intItems.size();
int i;
for (i=0;i<size;i++)
intItems[i].intObject->createFromChecked(intItems[i].element);
for (i=0;i<size;i++)
intItems[i].intObject->fromCOLLADAChecked();
for (i=0;i<size;i++)
intItems[i].intObject->fromCOLLADAPostProcessChecked();
//clear the temporary integration items array
intItems.clear();
return DAE_OK;
}
开发者ID:,项目名称:,代码行数:99,代码来源:
示例16: sprintf
daeBool
daeLIBXMLResolver::resolveElement(daeURI& uri, daeString typeNameHint)
{
// Make sure the URI is validated
if (uri.getState() == daeURI::uri_loaded)
{
uri.validate();
}
daeElement* resolved = NULL;
int status;
// Does the URI have a document reference?
if ( (uri.getFile() != NULL) && (strlen(uri.getFile())>0))
{
// The URI contains a document reference, see if it is loaded and try to load it if it's not
if (!_database->isDocumentLoaded(uri.getURI())) {
if ( _loadExternalDocuments ) {
_plugin->read(uri,NULL);
}
else {
uri.setState( daeURI::uri_failed_external_document );
return false;
}
}
// Try to find the id by searching this document only
status = _database->getElement(&resolved,0,uri.getID(),typeNameHint,uri.getURI());
}
else
{
// The URI was just a fragment, so try to find it in the document that contains it.
// !!!GAC not sure if all these pointers will be set when we get here, so assert if any of them aren't
daeElement *tempElement = uri.getContainer();
//assert(tempElement);
daeDocument *tempDocument;
if ( tempElement == NULL || (tempDocument = tempElement->getDocument()) == NULL ) {
uri.setState(daeURI::uri_failed_missing_container);
char msg[256];
sprintf(msg,
"daeLIBXMLResolver::resolveElement() - failed to resolve %s\n",
uri.getURI());
daeErrorHandler::get()->handleError( msg );
return false;
}
//assert(tempDocument);
daeURI *tempURI = tempDocument->getDocumentURI();
//assert(tempURI);
status = _database->getElement(&resolved,0,uri.getID(),typeNameHint,tempURI->getURI());
}
uri.setElement(resolved);
// Error if we didn't successfully resolve the uri
if (status ||(resolved==NULL))
{
uri.setState(daeURI::uri_failed_id_not_found);
char msg[256];
sprintf(msg,
"daeLIBXMLResolver::resolveElement() - failed to resolve %s\n",
uri.getURI());
daeErrorHandler::get()->handleError( msg );
return false;
}
uri.setState(daeURI::uri_success);
return true;
}
开发者ID:andemi02,项目名称:orkid,代码行数:68,代码来源:daeLIBXMLResolver.cpp
注:本文中的daeURI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论