bool CatSolution::writeTo( const QString& pth ) { QFile fl(pth); if(fl.open(QFile::WriteOnly)) { QTextStream ots(&fl); ots.setCodec(QTextCodec::codecForLocale()); // ots << myDoc.toString(); myDoc.save(ots,1); return true; } return false; }
static void writeImplementationCppFile(const QString& namespaceName, const QString& baseFileName, const std::list<FunctionSignature>& functions, const QString& path, const QString &API, bool templateValue, bool includeDebug) { QString outputFilename = path + "/" + baseFileName + "_" + API + ".cpp"; QFile of(outputFilename); if ( !of.open(QIODevice::WriteOnly) ) { std::cout << "Could not open " << outputFilename.toStdString() << std::endl; throw std::runtime_error(""); } QTextStream ots(&of); ots << "/*\n" " * THIS FILE WAS GENERATED AUTOMATICALLY FROM glad.h by tools/utils/generateGLIncludes, DO NOT EDIT\n" " */\n" "\n" "#include \"" << baseFileName << ".h\"\n" "\n"; if (!templateValue) { ots << "#ifdef HAVE_OSMESA\n" "#include <GL/gl_mangle.h>\n" "#include <GL/glu_mangle.h>\n" "#include <GL/osmesa.h>\n" "#endif // HAVE_OSMESA\n"; } ots << "\n\n"; if (templateValue) { ots << "extern \"C\" {\n"; for (std::list<FunctionSignature>::const_iterator it = functions.begin(); it != functions.end(); ++it) { if (includeDebug) { ots << "#ifdef DEBUG\n" "extern " << it->funcPNType << " glad_debug_" << it->funcName << ";\n" "#else\n"; } ots << "extern " << it->funcPNType << " glad_" << it->funcName << ";\n"; if (includeDebug) { ots << "#endif\n"; } } ots << "} // extern C\n" "\n"; } ots << "namespace " << namespaceName << " {\n" "\n"; // Write the load functions ots << "template <>\n" "void OSGLFunctions<" << (templateValue ? "true" : "false") << ">::load_functions() {\n"; if (!templateValue) { ots << "#ifdef HAVE_OSMESA\n" "\n"; } for (std::list<FunctionSignature>::const_iterator it = functions.begin(); it != functions.end(); ++it) { if (templateValue) { // OpenGL functions are directly pointing to the ones loaded by glad if (includeDebug) { ots << "#ifdef DEBUG\n" " _" << it->funcName << " = glad_debug_" << it->funcName << ";\n" "#else\n"; } { ots << " _" << it->funcName << " = glad_" << it->funcName << ";\n"; } if (includeDebug) { ots << "#endif\n"; } } else { // Mesa functions are loaded ots << " _" << it->funcName << " = (" << it->funcPNType << ")OSMesaGetProcAddress(\"" << it->funcName << "\");\n"; } } if (!templateValue) { ots << "#endif // HAVE_OSMESA\n"; } ots << "} // load_functions\n" "\n"; ots << "template class OSGLFunctions<" << (templateValue ? "true" : "false") << ">;\n" "\n"; ots << "} // namespace " << namespaceName << "\n" "\n"; } // writeImplementationCppFile