Skip to content

Commit eac5f97

Browse files
committed
moved specializations outside of class
1 parent 00efcc2 commit eac5f97

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

source/gameanalytics/Server/GACustomFields.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ namespace gameanalytics
5454
}
5555
}
5656

57-
bool CustomFields::checkSize()
57+
bool CustomFields::checkSize() const
5858
{
59-
59+
return fields.size() <= NUM_MAX_CUSTOM_FIELDS;
6060
}
6161
}

source/gameanalytics/Server/GACustomFields.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,53 @@ namespace gameanalytics
4343
{
4444
return defaultValue;
4545
}
46+
47+
private:
48+
49+
template<typename T>
50+
T getValueById(std::string const& key, int id, T const& defaultValue)
51+
{
52+
return (fields.count(key) && fields[key].value.index() == id) ? std::get<T>(fields[key].value) : defaultValue;
53+
}
54+
};
55+
56+
#pragma region get_value_specialization
4657

4758
template<>
48-
std::string getValue<std::string>(std::string const& key, std::string const& defaultValue)
59+
inline std::string CustomFields::getValue<std::string>(std::string const& key, std::string const& defaultValue)
4960
{
5061
return getValueById<std::string>(key, Value::value_str, defaultValue);
5162
}
5263

5364
template<>
54-
int64_t getValue<int64_t>(std::string const& key, int64_t const& defaultValue)
65+
inline int64_t CustomFields::getValue<int64_t>(std::string const& key, int64_t const& defaultValue)
5566
{
5667
return getValueById<int64_t>(key, Value::value_int, defaultValue);
5768
}
5869

5970
template<>
60-
double getValue<double>(std::string const& key, double const& defaultValue)
71+
inline double CustomFields::getValue<double>(std::string const& key, double const& defaultValue)
6172
{
6273
return getValueById<double>(key, Value::value_float, defaultValue);
6374
}
6475

6576
template<>
66-
bool getValue<bool>(std::string const& key, bool const& defaultValue)
77+
inline bool CustomFields::getValue<bool>(std::string const& key, bool const& defaultValue)
6778
{
6879
return getValueById<bool>(key, Value::value_bool, defaultValue);
6980
}
7081

7182
template<>
72-
int getValue<int>(std::string const& key, int const& defaultValue)
83+
inline int CustomFields::getValue<int>(std::string const& key, int const& defaultValue)
7384
{
7485
return static_cast<int>(getValue<int64_t>(key, defaultValue));
7586
}
7687

7788
template<>
78-
float getValue<float>(std::string const& key, float const& defaultValue)
89+
inline float CustomFields::getValue<float>(std::string const& key, float const& defaultValue)
7990
{
8091
return static_cast<float>(getValue<double>(key, defaultValue));
8192
}
8293

83-
private:
84-
85-
template<typename T>
86-
T getValueById(std::string const& key, int id, T const& defaultValue)
87-
{
88-
return (fields.count(key) && fields[key].value.index() == id) ? std::get<T>(fields[key].value) : defaultValue;
89-
}
90-
};
94+
#pragma endregion
9195
}

0 commit comments

Comments
 (0)