// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include namespace Nz { inline MTLParser::Material* MTLParser::AddMaterial(const std::string& matName) { return &m_materials[matName]; } inline void MTLParser::Clear() { m_materials.clear(); } inline const MTLParser::Material* MTLParser::GetMaterial(const std::string& materialName) const { auto it = m_materials.find(materialName); if (it != m_materials.end()) return &it->second; else return nullptr; } inline const std::unordered_map& MTLParser::GetMaterials() const { return m_materials; } template void MTLParser::Emit(const T& text) const { m_outputStream << text; if (m_outputStream.rdbuf()->str().size() > 1024 * 1024) Flush(); } inline void MTLParser::EmitLine() const { Emit('\n'); } template void MTLParser::EmitLine(const T& line) const { Emit(line); Emit('\n'); } inline void MTLParser::Error(const std::string& message) { NazaraError(message + " at line #" + std::to_string(m_lineCount)); } inline void MTLParser::Flush() const { m_currentStream->Write(std::move(m_outputStream).str()); m_outputStream.str({}); } inline void MTLParser::Warning(const std::string& message) { NazaraWarning(message + " at line #" + std::to_string(m_lineCount)); } inline void MTLParser::UnrecognizedLine(bool error) { std::string message = "Unrecognized \"" + m_currentLine + '"'; if (error) Error(message); else Warning(message); } } #include