00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _IAISTRINGFORMATUTILS_H_
00023 #define _IAISTRINGFORMATUTILS_H_
00024
00025
00026 #include "IAIUnicodeString.h"
00027 #include "IAILocale.h"
00028
00029 class CAINumberFormatImpl;
00030
00031 namespace ai {
00032
00033
00037 class NumberFormat
00038 {
00039 public:
00040
00046 explicit NumberFormat (void) AINOTHROW;
00047
00053 explicit NumberFormat(const ai::LocaleID locale);
00054
00058 NumberFormat(const NumberFormat& format);
00059
00060 #ifdef AI_HAS_RVALUE_REFERENCES
00061
00064 NumberFormat(NumberFormat&& format) AINOEXCEPT : fImpl{format.fImpl}
00065 {
00066 format.fImpl = nullptr;
00067 }
00068 #endif
00069
00071 ~NumberFormat();
00072
00073 private:
00078 NumberFormat(bool dummyUseDefaultFormatter);
00079
00080 public:
00081
00088 static NumberFormat getFormat(const ai::LocaleID locale = ai::Locale::kDefault);
00089
00101 ai::UnicodeString& toString(const float value, const ai::int32 precision, ai::UnicodeString& str, bool padToPrecision = false);
00102
00109 ai::UnicodeString& toString(const ai::int32 value, ai::UnicodeString& str);
00110
00122 ai::UnicodeString& toString(const double value, const ai::int32 precision, ai::UnicodeString& str, bool padToPrecision = false);
00123
00130 bool parseString(const ai::UnicodeString& str, float& value);
00131
00138 bool parseString(const ai::UnicodeString& str, ai::int32& value);
00139
00146 bool parseString(const ai::UnicodeString& str, double& value);
00147
00149 ai::NumberFormat& operator= (const NumberFormat& rhs);
00150
00151 #ifdef AI_HAS_RVALUE_REFERENCES
00152
00153 ai::NumberFormat& operator= (NumberFormat&& rhs) AINOEXCEPT
00154 {
00155 std::swap(fImpl, rhs.fImpl);
00156 return *this;
00157 }
00158 #endif
00159
00164 ai::UnicodeString getDecimalSeparator();
00165
00170 ai::UnicodeString getThousandsSeparator();
00171
00172 public:
00174 void deleteImpl();
00175
00177 NumberFormat& assign (const NumberFormat& format);
00178
00179 private:
00180
00181 CAINumberFormatImpl* fImpl;
00182
00183 };
00184
00185 }
00186
00187 #endif //_IAISTRINGFORMATUTILS_H_