MCPcopy Create free account
hub / github.com/DFHack/dfhack / imbue_with_locale

Function imbue_with_locale

library/MiscUtils.cpp:91–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89static const std::locale * system_loc = try_get_locale("");
90
91DFHACK_EXPORT void imbue_with_locale(std::ostringstream &ss, NumberFormatType type) {
92 if (type == NumberFormatType::ENGLISH || type == NumberFormatType::SYSTEM) {
93 try {
94 if (english_loc && type == NumberFormatType::ENGLISH)
95 ss.imbue(*english_loc);
96 else if (system_loc && type == NumberFormatType::SYSTEM)
97 ss.imbue(*system_loc);
98 } catch (std::exception &e) {
99 std::cerr << e.what() << std::endl;
100 }
101 }
102 if (type != NumberFormatType::SCIENTIFIC)
103 ss << std::fixed;
104 ss << std::setprecision(2);
105}
106
107// magnitude to (suffix, divisor)
108static const std::vector<std::pair<const char *, double>> sig_fig_db = {

Callers 1

format_numberFunction · 0.85

Calls 1

whatMethod · 0.45

Tested by

no test coverage detected