ICU 50.1.2  50.1.2
format.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2011, International Business Machines Corporation and others.
4 * All Rights Reserved.
5 ********************************************************************************
6 *
7 * File FORMAT.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 03/17/97 clhuang Updated per C++ implementation.
14 * 03/27/97 helena Updated to pass the simple test after code review.
15 ********************************************************************************
16 */
17 // *****************************************************************************
18 // This file was generated from the java source file Format.java
19 // *****************************************************************************
20 
21 #ifndef FORMAT_H
22 #define FORMAT_H
23 
24 
25 #include "unicode/utypes.h"
26 
32 #if !UCONFIG_NO_FORMATTING
33 
34 #include "unicode/unistr.h"
35 #include "unicode/fmtable.h"
36 #include "unicode/fieldpos.h"
37 #include "unicode/fpositer.h"
38 #include "unicode/parsepos.h"
39 #include "unicode/parseerr.h"
40 #include "unicode/locid.h"
41 
43 
94 class U_I18N_API Format : public UObject {
95 public:
96 
100  virtual ~Format();
101 
110  virtual UBool operator==(const Format& other) const = 0;
111 
119  UBool operator!=(const Format& other) const { return !operator==(other); }
120 
127  virtual Format* clone() const = 0;
128 
139  UnicodeString& format(const Formattable& obj,
140  UnicodeString& appendTo,
141  UErrorCode& status) const;
142 
159  virtual UnicodeString& format(const Formattable& obj,
160  UnicodeString& appendTo,
161  FieldPosition& pos,
162  UErrorCode& status) const = 0;
179  virtual UnicodeString& format(const Formattable& obj,
180  UnicodeString& appendTo,
181  FieldPositionIterator* posIter,
182  UErrorCode& status) const;
183 
223  virtual void parseObject(const UnicodeString& source,
224  Formattable& result,
225  ParsePosition& parse_pos) const = 0;
226 
239  void parseObject(const UnicodeString& source,
240  Formattable& result,
241  UErrorCode& status) const;
242 
249  Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
250 
251 #ifndef U_HIDE_INTERNAL_API
252 
258  const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
259 #endif /* U_HIDE_INTERNAL_API */
260 
261  protected:
263  void setLocaleIDs(const char* valid, const char* actual);
264 
265 protected:
270  Format();
271 
275  Format(const Format&); // Does nothing; for subclasses only
276 
280  Format& operator=(const Format&); // Does nothing; for subclasses
281 
282 
291  static void syntaxError(const UnicodeString& pattern,
292  int32_t pos,
293  UParseError& parseError);
294 
295  private:
296  char actualLocale[ULOC_FULLNAME_CAPACITY];
297  char validLocale[ULOC_FULLNAME_CAPACITY];
298 };
299 
301 
302 #endif /* #if !UCONFIG_NO_FORMATTING */
303 
304 #endif // _FORMAT
305 //eof
Base class for all formats.
Definition: format.h:94
C++ API: FieldPosition Iterator.
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
Definition: uloc.h:262
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
C++ API: FieldPosition identifies the fields in a formatted output.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:53
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
C API: Parse Error Information.
C++ API: Canonical Iterator.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
C++ API: Locale ID object.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
Basic definitions for ICU, for both C and C++ APIs.
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:119
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:62
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
C++ API: Formattable is a thin wrapper for primitive numeric types.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:182