43#if defined(__APPLE__) || defined(__FreeBSD__)
110 Unit(Unit::UnitType t = UNIT_COUNTS)
114 Unit(
const std::string& rhs);
117 std::string
PrettyPrint(
double value,
int sigfigs = -1,
bool useDisplayLocale =
true)
const;
118 std::string
PrettyPrintInt64(int64_t value,
int sigfigs = -1,
bool useDisplayLocale =
true)
const;
120 std::string
PrettyPrintRange(
double pixelMin,
double pixelMax,
double rangeMin,
double rangeMax)
const;
122 double ParseString(
const std::string& str,
bool useDisplayLocale =
true);
123 int64_t
ParseStringInt64(
const std::string& str,
bool useDisplayLocale =
true);
128 bool operator==(
const Unit& rhs)
129 {
return m_type == rhs.m_type; }
131 bool operator!=(
const Unit& rhs)
132 {
return m_type != rhs.m_type; }
134 bool operator!=(UnitType rhs)
135 {
return m_type != rhs; }
140 static void SetLocale(
const char* locale);
146 void GetUnitSuffix(UnitType type,
double num,
double& scaleFactor, std::string& prefix, std::string& numprefix, std::string& suffix)
const;
152 static std::string m_slocale;
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57
static void SetPrintingLocale()
Sets the current locale to the user's selected LC_NUMERIC for printing numbers for display.
Definition: Unit.cpp:1228
void GetSIScalingFactor(double num, double &scaleFactor, std::string &prefix) const
Gets the appropriate SI scaling factor for a number.
Definition: Unit.cpp:229
Unit operator*(const Unit &rhs)
Multiplies two units and calculates the resulting unit.
Definition: Unit.cpp:1171
static locale_t m_locale
The user's requested locale for display.
Definition: Unit.h:158
std::string ToString() const
Converts this unit to a string.
Definition: Unit.cpp:124
Unit operator/(const Unit &rhs)
Divides two units and calculates the resulting unit.
Definition: Unit.cpp:1189
void GetUnitSuffix(UnitType type, double num, double &scaleFactor, std::string &prefix, std::string &numprefix, std::string &suffix) const
Gets the suffix for a unit.
Definition: Unit.cpp:308
static locale_t m_defaultLocale
Handle to the "C" locale, used for interchange.
Definition: Unit.h:163
std::string PrettyPrintInt64(int64_t value, int sigfigs=-1, bool useDisplayLocale=true) const
Prints a value with SI scaling factors.
Definition: Unit.cpp:675
std::string PrettyPrintRange(double pixelMin, double pixelMax, double rangeMin, double rangeMax) const
Prints a value with SI scaling factors and unnecessarily significant sub-pixel digits removed.
Definition: Unit.cpp:781
static void SetDefaultLocale()
Sets the current locale to "C" for interchange.
Definition: Unit.cpp:1240
std::string PrettyPrint(double value, int sigfigs=-1, bool useDisplayLocale=true) const
Prints a value with SI scaling factors.
Definition: Unit.cpp:587
double ParseString(const std::string &str, bool useDisplayLocale=true)
Parses a string based on the supplied unit.
Definition: Unit.cpp:962
int64_t ParseStringInt64(const std::string &str, bool useDisplayLocale=true)
Parses a string based on the supplied unit.
Definition: Unit.cpp:1064