trick/trick_source/sim_services/Sie/EnumAttributesMap.cpp
iamthad 3187dd9012 Replace std::endl with "\n" in SIE (#772)
std::endl flushes the output stream. The SIE functions were using it
multiple times per variable. This can have significant performance
impacts on file I/O.

In testing, the S_sie.resource file for SIM_parachute was flushed over
14000 times, each resulting in a separate write system call. With this
patch, only ~40 write calls were performed, and writing the file took
~1/3 as long.

For more information, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rio-endl
2019-05-13 14:31:46 -05:00

34 lines
1.1 KiB
C++

#include <iostream>
#include <fstream>
#include <algorithm>
#include "trick/EnumAttributesMap.hh"
#include "trick/attributes.h"
#include "trick/command_line_protos.h"
// Instantiate static variables for template types for ATTRIBUTES * and ENUM_ATTR *
namespace Trick {
EnumAttributesMap * EnumAttributesMap::pInstance = NULL ;
}
void Trick::EnumAttributesMap::print_xml(std::ofstream & sie_out ) {
std::map<std::string, ENUM_ATTR *>::iterator it ;
ENUM_ATTR * enum_attr ;
for ( it = name_to_attr_map.begin() ; it != name_to_attr_map.end() ; it++ ) {
enum_attr = (*it).second ;
if ( enum_attr != NULL ) {
std::string name = it->first;
std::replace(name.begin(), name.end(), ':', '_');
sie_out << " <enumeration name=\"" << name << "\">\n" ;
while ( enum_attr->label[0] != '\0' ) {
sie_out << " <pair label=\"" << enum_attr->label << "\"" ;
sie_out << " value=\"" << enum_attr->value << "\"/>\n" ;
enum_attr++ ;
}
sie_out << " </enumeration>\n\n" ;
}
}
}