ICU 67.1  67.1
format.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 1997-2011, International Business Machines Corporation and others.
6 * All Rights Reserved.
7 ********************************************************************************
8 *
9 * File FORMAT.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 02/19/97 aliu Converted from java.
15 * 03/17/97 clhuang Updated per C++ implementation.
16 * 03/27/97 helena Updated to pass the simple test after code review.
17 ********************************************************************************
18 */
19 // *****************************************************************************
20 // This file was generated from the java source file Format.java
21 // *****************************************************************************
22 
23 #ifndef FORMAT_H
24 #define FORMAT_H
25 
26 
27 #include "unicode/utypes.h"
28 
29 #if U_SHOW_CPLUSPLUS_API
30 
36 #if !UCONFIG_NO_FORMATTING
37 
38 #include "unicode/unistr.h"
39 #include "unicode/fmtable.h"
40 #include "unicode/fieldpos.h"
41 #include "unicode/fpositer.h"
42 #include "unicode/parsepos.h"
43 #include "unicode/parseerr.h"
44 #include "unicode/locid.h"
45 
46 U_NAMESPACE_BEGIN
47 
98 class U_I18N_API Format : public UObject {
99 public:
100 
104  virtual ~Format();
105 
114  virtual UBool operator==(const Format& other) const = 0;
115 
123  UBool operator!=(const Format& other) const { return !operator==(other); }
124 
131  virtual Format* clone() const = 0;
132 
143  UnicodeString& format(const Formattable& obj,
144  UnicodeString& appendTo,
145  UErrorCode& status) const;
146 
163  virtual UnicodeString& format(const Formattable& obj,
164  UnicodeString& appendTo,
165  FieldPosition& pos,
166  UErrorCode& status) const = 0;
183  virtual UnicodeString& format(const Formattable& obj,
184  UnicodeString& appendTo,
185  FieldPositionIterator* posIter,
186  UErrorCode& status) const;
187 
227  virtual void parseObject(const UnicodeString& source,
228  Formattable& result,
229  ParsePosition& parse_pos) const = 0;
230 
243  void parseObject(const UnicodeString& source,
244  Formattable& result,
245  UErrorCode& status) const;
246 
253  Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
254 
255 #ifndef U_HIDE_INTERNAL_API
256 
262  const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
263 #endif /* U_HIDE_INTERNAL_API */
264 
265  protected:
267  void setLocaleIDs(const char* valid, const char* actual);
268 
269 protected:
274  Format();
275 
279  Format(const Format&); // Does nothing; for subclasses only
280 
284  Format& operator=(const Format&); // Does nothing; for subclasses
285 
286 
295  static void syntaxError(const UnicodeString& pattern,
296  int32_t pos,
297  UParseError& parseError);
298 
299  private:
300  char actualLocale[ULOC_FULLNAME_CAPACITY];
301  char validLocale[ULOC_FULLNAME_CAPACITY];
302 };
303 
304 U_NAMESPACE_END
305 
306 #endif /* #if !UCONFIG_NO_FORMATTING */
307 
308 #endif /* U_SHOW_CPLUSPLUS_API */
309 
310 #endif // _FORMAT
311 //eof
Base class for all formats.
Definition: format.h:98
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:123
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:264
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
C++ API: FieldPosition identifies the fields in a formatted output.
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:58
C API: Parse Error Information.
C++ API: Canonical Iterator.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:338
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:110
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52
C++ API: Locale ID object.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:64
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing...
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195