Skip to content

Commit 5db91e5

Browse files
committed
Fixes to logger templates
1 parent a4c2aa8 commit 5db91e5

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/ifcparse/IfcLogger.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ namespace {
3737
static const std::array<std::basic_string<T>, 3> value;
3838
};
3939

40+
template <>
4041
const std::array<std::basic_string<char>, 3> severity_strings<char>::value = { "Notice", "Warning", "Error" };
42+
43+
template <>
4144
const std::array<std::basic_string<wchar_t>, 3> severity_strings<wchar_t>::value = { L"Notice", L"Warning", L"Error" };
4245

4346
template <typename T>
4447
void plain_text_message(T& os, const boost::optional<IfcSchema::IfcProduct*>& current_product, Logger::Severity type, const std::string& message, IfcEntityInstanceData* entity) {
45-
os << "[" << severity_strings<T::char_type>::value[type] << "] ";
48+
os << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
4649
if (current_product) {
4750
os << "{" << (*current_product)->GlobalId().c_str() << "} ";
4851
}
@@ -65,21 +68,21 @@ namespace {
6568

6669
template <typename T>
6770
void json_message(T& os, const boost::optional<IfcSchema::IfcProduct*>& current_product, Logger::Severity type, const std::string& message, IfcEntityInstanceData* entity) {
68-
boost::property_tree::basic_ptree<std::basic_string<T::char_type>, std::basic_string<T::char_type> > pt;
71+
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type> > pt;
6972

7073
// @todo this is crazy
71-
static const T::char_type level_string[] = { 'l', 'e', 'v', 'e', 'l', 0 };
72-
static const T::char_type product_string[] = { 'p', 'r', 'o', 'd', 'u', 'c', 't', 0 };
73-
static const T::char_type message_string[] = { 'm', 'e', 's', 's', 'a', 'g', 'e', 0 };
74-
static const T::char_type instance_string[] = { 'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 0 };
74+
static const typename T::char_type level_string[] = { 'l', 'e', 'v', 'e', 'l', 0 };
75+
static const typename T::char_type product_string[] = { 'p', 'r', 'o', 'd', 'u', 'c', 't', 0 };
76+
static const typename T::char_type message_string[] = { 'm', 'e', 's', 's', 'a', 'g', 'e', 0 };
77+
static const typename T::char_type instance_string[] = { 'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 0 };
7578

76-
pt.put(level_string, severity_strings<T::char_type>::value[type]);
79+
pt.put(level_string, severity_strings<typename T::char_type>::value[type]);
7780
if (current_product) {
78-
pt.put(product_string, string_as<T::char_type>((**current_product).entity->toString()));
81+
pt.put(product_string, string_as<typename T::char_type>((**current_product).entity->toString()));
7982
}
80-
pt.put(message_string, string_as<T::char_type>(message));
83+
pt.put(message_string, string_as<typename T::char_type>(message));
8184
if (entity) {
82-
pt.put(instance_string, string_as<T::char_type>(entity->toString()));
85+
pt.put(instance_string, string_as<typename T::char_type>(entity->toString()));
8386
}
8487
boost::property_tree::write_json(os, pt, false);
8588
}
@@ -109,7 +112,7 @@ void Logger::SetOutput(std::wostream* l1, std::wostream* l2) {
109112

110113
template <typename T>
111114
void Logger::log(T& log2, Logger::Severity type, const std::string& message, IfcEntityInstanceData* entity) {
112-
log2 << "[" << severity_strings[type] << "] ";
115+
log2 << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
113116
if (current_product) {
114117
log2 << "{" << (*current_product)->GlobalId().c_str() << "} ";
115118
}

0 commit comments

Comments
 (0)