bool UMPFile::load () { AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(map::getMapsPath() + _fileName)); if (file) { AutoPtr<Tokeniser> reader(GlobalScriptLibrary().createScriptTokeniser(file->getInputStream())); parse(*reader); return true; } return false; }
std::string MaterialSystem::getBlock (const std::string& texture) { if (texture.empty()) return ""; const std::string textureDir = GlobalTexturePrefix_get(); std::string skippedTextureDirectory = texture.substr(textureDir.length()); if (skippedTextureDirectory.empty()) return ""; MaterialBlockMap::iterator i = _blocks.find(skippedTextureDirectory); if (i != _blocks.end()) return i->second; if (!_materialLoaded) loadMaterials(); if (!_materialLoaded) return ""; StringOutputStream outputStream; StringInputStream inputStream(_material); AutoPtr<Tokeniser> tokeniser(GlobalScriptLibrary().createSimpleTokeniser(inputStream)); int depth = 0; bool found = false; std::string token = tokeniser->getToken(); while (token.length()) { if (token == "{") { depth++; } else if (token == "}") { depth--; } if (depth >= 1) { if (depth == 1 && token == "material") { token = tokeniser->getToken(); if (token == skippedTextureDirectory) { found = true; outputStream << "{ material "; } } if (found) outputStream << token << " "; } else if (found) { outputStream << "}"; break; } token = tokeniser->getToken(); } return outputStream.toString(); }
void LicenseParser::openLicenseFile (const std::string& filename) { clearLicenses(); std::string fullpath; if (os::isAbsolute(filename)) { fullpath = filename; } else { const std::string& appPath = GlobalRegistry().get(RKEY_APP_PATH); fullpath = appPath + filename; } AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(fullpath)); if (file) { AutoPtr<Tokeniser> tokeniser(GlobalScriptLibrary().createScriptTokeniser(file->getInputStream())); parseLicensesFile(*tokeniser, fullpath); } }
bool EntityClassDoom3_parse( TextInputStream& inputStream, const char* filename ){ Tokeniser& tokeniser = GlobalScriptLibrary().m_pfnNewScriptTokeniser( inputStream ); tokeniser.nextLine(); for (;; ) { const char* blockType = tokeniser.getToken(); if ( blockType == 0 ) { return true; } CopiedString tmp( blockType ); if ( !EntityClassDoom3_parseBlock( tokeniser, tmp.c_str() ) ) { globalErrorStream() << GlobalFileSystem().findFile( filename ) << filename << ":" << (unsigned int)tokeniser.getLine() << ": " << tmp.c_str() << " parse failed, skipping rest of file\n"; return false; } } tokeniser.release(); }
void writeGraph (scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const { AutoPtr<TokenWriter> writer(GlobalScriptLibrary().createSimpleTokenWriter(outputStream)); Map_Write(root, traverse, *writer); }