summaryrefslogtreecommitdiff
path: root/indra/llcommon/llunit.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llunit.h')
-rw-r--r--indra/llcommon/llunit.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index c617d2a87f..77c19b5152 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -406,6 +406,22 @@ COMPARISON_OPERATORS(>=)
COMPARISON_OPERATORS(==)
COMPARISON_OPERATORS(!=)
+
+template<typename T>
+struct LLGetUnitLabel
+{
+ static const char* getUnitLabel() { return ""; }
+};
+
+template<typename T, typename STORAGE_T>
+struct LLGetUnitLabel<LLUnit<T, STORAGE_T> >
+{
+ static const char* getUnitLabel() { return T::getUnitLabel(); }
+};
+
+//
+// Unit declarations
+//
namespace LLUnits
{
template<typename T>
@@ -427,9 +443,8 @@ struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> >
struct unit_name \
{ \
typedef base_unit_name base_unit_t; \
- static const char* sUnitLabel; \
+ static const char* getUnitLabel() { return unit_label; } \
}; \
-const char* unit_name::sUnitLabel = unit_label; \
template<typename STORAGE_TYPE> \
struct ConversionFactor<unit_name, base_unit_name, STORAGE_TYPE> \
{ \
@@ -448,8 +463,7 @@ struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \
} \
}
-struct Bytes { typedef Bytes base_unit_t; static const char* sUnitLabel;};
-const char* Bytes::sUnitLabel = "B";
+struct Bytes { typedef Bytes base_unit_t; static const char* getUnitLabel() { return "B"; }};
LL_DECLARE_DERIVED_UNIT(1024, Bytes, Kilobytes, "KiB");
LL_DECLARE_DERIVED_UNIT(1024 * 1024, Bytes, Megabytes, "MiB");
LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024, Bytes, Gigabytes, "GiB");
@@ -458,28 +472,24 @@ LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Kilobits, "Kib");
LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Megabits, "Mib");
LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024 / 8, Bytes, Gigabits, "Gib");
-struct Seconds { typedef Seconds base_unit_t; static const char* sUnitLabel; };
-const char* Seconds::sUnitLabel = "s";
+struct Seconds { typedef Seconds base_unit_t; static const char* getUnitLabel() { return "s"; } };
LL_DECLARE_DERIVED_UNIT(60, Seconds, Minutes, "min");
LL_DECLARE_DERIVED_UNIT(60 * 60, Seconds, Hours, "h");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Seconds, Milliseconds, "ms");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000000.0, Seconds, Microseconds, "\x09\x3cs");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000000000.0, Seconds, Nanoseconds, "ns");
-struct Meters { typedef Meters base_unit_t; static const char* sUnitLabel; };
-const char* Meters::sUnitLabel = "m";
+struct Meters { typedef Meters base_unit_t; static const char* getUnitLabel() { return "m"; } };
LL_DECLARE_DERIVED_UNIT(1000, Meters, Kilometers, "km");
LL_DECLARE_DERIVED_UNIT(1.0 / 100.0, Meters, Centimeters, "cm");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Meters, Millimeters, "mm");
-struct Hertz { typedef Hertz base_unit_t; static const char* sUnitLabel; };
-const char* Hertz::sUnitLabel = "Hz";
+struct Hertz { typedef Hertz base_unit_t; static const char* getUnitLabel() { return "Hz"; } };
LL_DECLARE_DERIVED_UNIT(1000, Hertz, Kilohertz, "KHz");
LL_DECLARE_DERIVED_UNIT(1000 * 1000, Hertz, Megahertz, "MHz");
LL_DECLARE_DERIVED_UNIT(1000 * 1000 * 1000, Hertz, Gigahertz, "GHz");
-struct Radians { typedef Radians base_unit_t; static const char* sUnitLabel;};
-const char* Radians::sUnitLabel = "rad";
+struct Radians { typedef Radians base_unit_t; static const char* getUnitLabel() { return "rad"; } };
LL_DECLARE_DERIVED_UNIT(DEG_TO_RAD, Radians, Degrees, "deg");
} // namespace LLUnits