| 83 | ForwardTranslator::~ForwardTranslator() = default; |
| 84 | |
| 85 | bool ForwardTranslator::modelToGbXML(const openstudio::model::Model& model, const openstudio::path& path, ProgressBar* progressBar) { |
| 86 | m_progressBar = progressBar; |
| 87 | |
| 88 | m_logSink.setThreadId(std::this_thread::get_id()); |
| 89 | |
| 90 | m_logSink.resetStringStream(); |
| 91 | |
| 92 | pugi::xml_document doc; |
| 93 | //doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\""); |
| 94 | bool result = this->translateModel(model, doc); |
| 95 | |
| 96 | openstudio::filesystem::ofstream file(path, std::ios_base::binary); |
| 97 | if (file.is_open()) { |
| 98 | doc.save(file, " "); |
| 99 | file.close(); |
| 100 | |
| 101 | // validate the gbxml after forward translation |
| 102 | auto gbxmlValidator = XMLValidator::gbxmlValidator(); |
| 103 | gbxmlValidator.validate(path); |
| 104 | |
| 105 | return result; |
| 106 | } |
| 107 | |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | std::string ForwardTranslator::modelToGbXMLString(const openstudio::model::Model& model, ProgressBar* progressBar) { |
| 112 | std::string gbXML_str; |