diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-11-20 00:37:49 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-11-20 00:37:49 +0100 |
| commit | b53ca99c59cbc064f935b2b97cbd80e1b653e89b (patch) | |
| tree | e4ad34f47d062b03cc20aad71eca2e749921ceb9 /unity-shared | |
| parent | c6ea4897d0d8051c7de20f8f005c306cf6f99898 (diff) | |
IntrospectionData: use a template-based internal function to add a SIMPLE type value
(bzr r3506.7.12)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/IntrospectionData.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/unity-shared/IntrospectionData.cpp b/unity-shared/IntrospectionData.cpp index 68e20c541..0b4267578 100644 --- a/unity-shared/IntrospectionData.cpp +++ b/unity-shared/IntrospectionData.cpp @@ -65,89 +65,95 @@ void add_(GVariantBuilder* builder_, std::string const& name, ValueType type, st g_variant_builder_add(builder_, "{sv}", name.c_str(), static_cast<GVariant*>(Variant::FromVector(new_values))); } -IntrospectionData& IntrospectionData::add(std::string const& name, bool value) +template <typename TYPE> +void add_simple_value_(GVariantBuilder* builder_, std::string const& name, TYPE value) { add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); +} + +IntrospectionData& IntrospectionData::add(std::string const& name, bool value) +{ + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, char const* value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, std::string const& value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, int16_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, int32_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, int64_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, uint16_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, uint32_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, uint64_t value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } #if __WORDSIZE != 64 IntrospectionData& IntrospectionData::add(std::string const& name, long value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, unsigned long value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } #endif IntrospectionData& IntrospectionData::add(std::string const& name, float value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, double value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } IntrospectionData& IntrospectionData::add(std::string const& name, GVariant* value) { - add_(builder_, name, ValueType::SIMPLE, {Variant(value)}); + add_simple_value_(builder_, name, value); return *this; } |
