2 * Copyright 2003-2011, Haiku, Inc.
3 * Distributed under the terms of the MIT Licence.
5 #ifndef _FORMATTING_CONVENTIONS_H_
6 #define _FORMATTING_CONVENTIONS_H_
9 #include <Archivable.h>
11 #include <LocaleStrings.h>
13 #include <SupportDefs.h>
20 #ifndef U_ICU_NAMESPACE
21 #define U_ICU_NAMESPACE icu
23 namespace U_ICU_NAMESPACE
{
29 enum BMeasurementKind
{
35 enum BDateFormatStyle
{
36 B_FULL_DATE_FORMAT
= 0,
41 B_DATE_FORMAT_STYLE_COUNT
45 enum BTimeFormatStyle
{
46 B_FULL_TIME_FORMAT
= 0,
51 B_TIME_FORMAT_STYLE_COUNT
55 class BFormattingConventions
: public BArchivable
{
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();
68 const BFormattingConventions
& other
) const;
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
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;
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_ */