Fix FreeBSD build.
[haiku.git] / headers / os / locale / FormattingConventions.h
blob607400d86f4e4c2d89015fbcbafd625294ffb02a
1 /*
2 * Copyright 2003-2011, Haiku, Inc.
3 * Distributed under the terms of the MIT Licence.
4 */
5 #ifndef _FORMATTING_CONVENTIONS_H_
6 #define _FORMATTING_CONVENTIONS_H_
9 #include <Archivable.h>
10 #include <List.h>
11 #include <LocaleStrings.h>
12 #include <String.h>
13 #include <SupportDefs.h>
16 class BBitmap;
17 class BLanguage;
18 class BMessage;
20 #ifndef U_ICU_NAMESPACE
21 #define U_ICU_NAMESPACE icu
22 #endif
23 namespace U_ICU_NAMESPACE {
24 class DateFormat;
25 class Locale;
29 enum BMeasurementKind {
30 B_METRIC = 0,
31 B_US
35 enum BDateFormatStyle {
36 B_FULL_DATE_FORMAT = 0,
37 B_LONG_DATE_FORMAT,
38 B_MEDIUM_DATE_FORMAT,
39 B_SHORT_DATE_FORMAT,
41 B_DATE_FORMAT_STYLE_COUNT
45 enum BTimeFormatStyle {
46 B_FULL_TIME_FORMAT = 0,
47 B_LONG_TIME_FORMAT,
48 B_MEDIUM_TIME_FORMAT,
49 B_SHORT_TIME_FORMAT,
51 B_TIME_FORMAT_STYLE_COUNT
55 class BFormattingConventions : public BArchivable {
56 public:
57 BFormattingConventions(const char* id = NULL);
58 BFormattingConventions(
59 const BFormattingConventions& other);
60 BFormattingConventions(const BMessage* archive);
62 BFormattingConventions& operator=(
63 const BFormattingConventions& other);
65 ~BFormattingConventions();
67 bool operator==(
68 const BFormattingConventions& other) const;
69 bool operator!=(
70 const BFormattingConventions& other) const;
72 const char* ID() const;
73 const char* LanguageCode() const;
74 const char* CountryCode() const;
76 bool AreCountrySpecific() const;
78 status_t GetNativeName(BString& name) const;
79 status_t GetName(BString& name,
80 const BLanguage* displayLanguage = NULL
81 ) const;
83 const char* GetString(uint32 id) const;
85 status_t GetDateFormat(BDateFormatStyle style,
86 BString& outFormat) const;
87 status_t GetTimeFormat(BTimeFormatStyle style,
88 BString& outFormat) const;
89 status_t GetDateTimeFormat(BDateFormatStyle dateStyle,
90 BTimeFormatStyle timeStyle,
91 BString& outFormat) const;
92 status_t GetNumericFormat(BString& outFormat) const;
93 status_t GetMonetaryFormat(BString& outFormat) const;
95 void SetExplicitDateFormat(BDateFormatStyle style,
96 const BString& format);
97 void SetExplicitTimeFormat(BTimeFormatStyle style,
98 const BString& format);
99 void SetExplicitDateTimeFormat(
100 BDateFormatStyle dateStyle,
101 BTimeFormatStyle timeStyle,
102 const BString& format);
103 void SetExplicitNumericFormat(const BString& format);
104 void SetExplicitMonetaryFormat(
105 const BString& format);
107 BMeasurementKind MeasurementKind() const;
109 bool UseStringsFromPreferredLanguage() const;
110 void SetUseStringsFromPreferredLanguage(bool value);
112 bool Use24HourClock() const;
113 void SetExplicitUse24HourClock(bool value);
114 void UnsetExplicitUse24HourClock();
116 virtual status_t Archive(BMessage* archive,
117 bool deep = true) const;
119 class Private;
120 private:
121 friend class Private;
123 mutable BString fCachedDateFormats[B_DATE_FORMAT_STYLE_COUNT];
124 mutable BString fCachedTimeFormats[B_TIME_FORMAT_STYLE_COUNT];
125 mutable BString fCachedDateTimeFormats
126 [B_DATE_FORMAT_STYLE_COUNT]
127 [B_TIME_FORMAT_STYLE_COUNT];
128 mutable BString fCachedNumericFormat;
129 mutable BString fCachedMonetaryFormat;
130 mutable int8 fCachedUse24HourClock;
132 BString fExplicitDateFormats[B_DATE_FORMAT_STYLE_COUNT];
133 BString fExplicitTimeFormats[B_TIME_FORMAT_STYLE_COUNT];
134 BString fExplicitDateTimeFormats
135 [B_DATE_FORMAT_STYLE_COUNT]
136 [B_TIME_FORMAT_STYLE_COUNT];
137 BString fExplicitNumericFormat;
138 BString fExplicitMonetaryFormat;
139 int8 fExplicitUse24HourClock;
141 bool fUseStringsFromPreferredLanguage;
143 U_ICU_NAMESPACE::Locale* fICULocale;
144 void CoerceFormatForClock(BString& outFormat) const;
148 #endif /* _FORMATTING_CONVENTIONS_H_ */