xref: /haiku/headers/os/locale/Format.h (revision 44f11d0982feb6ed1cc66c4d6d0a26bffd8ce4d4)
1 /*
2  * Copyright 2003-2010, Haiku, Inc.
3  * Distributed under the terms of the MIT Licence.
4 */
5 #ifndef _B_FORMAT_H_
6 #define _B_FORMAT_H_
7 
8 #include <FormatParameters.h>
9 #include <FormattingConventions.h>
10 #include <Locker.h>
11 #include <Language.h>
12 #include <SupportDefs.h>
13 
14 
15 // types of fields contained in formatted strings
16 enum {
17 	// number format fields
18 	B_CURRENCY_FIELD,
19 	B_DECIMAL_SEPARATOR_FIELD,
20 	B_EXPONENT_FIELD,
21 	B_EXPONENT_SIGN_FIELD,
22 	B_EXPONENT_SYMBOL_FIELD,
23 	B_FRACTION_FIELD,
24 	B_GROUPING_SEPARATOR_FIELD,
25 	B_INTEGER_FIELD,
26 	B_PERCENT_FIELD,
27 	B_PERMILLE_FIELD,
28 	B_SIGN_FIELD,
29 
30 	// date format fields
31 	// TODO: ...
32 };
33 
34 // structure filled in while formatting
35 struct format_field_position {
36 	uint32	field_type;
37 	int32	start;
38 	int32	length;
39 };
40 
41 
42 class BLocale;
43 
44 class BFormat {
45 public:
46 			status_t				SetLocale(const BLocale& locale);
47 	virtual	status_t				SetLanguage(const BLanguage& newLanguage);
48 	virtual	status_t				SetFormattingConventions(
49 										const BFormattingConventions&
50 											conventions);
51 
52 			status_t				InitCheck() const;
53 protected:
54 									BFormat();
55 									BFormat(const BFormat& other);
56 	virtual 						~BFormat();
57 
58 			BFormat&				operator=(const BFormat& other);
59 
60 protected:
61 	mutable	BLocker					fLock;
62 			BFormattingConventions	fConventions;
63 			BLanguage				fLanguage;
64 			status_t				fInitStatus;
65 };
66 
67 
68 #endif	// _B_FORMAT_H_
69