MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / format_string

Function format_string

src/examples/IfcParseExamples.cpp:83–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81typedef std::map<std::string, std::map<std::string, std::string>> element_properties;
82
83std::string format_string(const AttributeValue& argument) {
84 // Argument is a runtime tagged variant for the various data types in a IFC model,
85 // in this particular case we only care about flattening it to a string.
86 // @todo mostly duplicated from XmlSerializer.cpp
87 if (argument.isNull()) {
88 return "-";
89 }
90 auto argument_type = argument.type();
91 switch (argument_type) {
92 case IfcUtil::Argument_BOOL: {
93 const bool b = argument;
94 return b ? "true" : "false";
95 }
96 case IfcUtil::Argument_DOUBLE: {
97 const double d = argument;
98 std::stringstream stream;
99 stream << std::setprecision(std::numeric_limits< double >::max_digits10) << d;
100 return stream.str();
101 break; }
102 case IfcUtil::Argument_STRING:
103 case IfcUtil::Argument_ENUMERATION: {
104 return static_cast<std::string>(argument);
105 break; }
106 case IfcUtil::Argument_INT: {
107 const int v = argument;
108 std::stringstream stream;
109 stream << v;
110 return stream.str();
111 break; }
112 }
113 return "?";
114}
115
116template <typename Schema, typename T>
117void process_pset(element_properties& props, const T* inst) {

Callers 1

process_psetFunction · 0.85

Calls 3

isNullMethod · 0.80
typeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected