ICU 55.1  55.1
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 
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:
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
icu::FieldPosition
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
fpositer.h
C++ API: FieldPosition Iterator.
parseerr.h
C API: Parse Error Information.
parsepos.h
C++ API: Canonical Iterator.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:336
icu::FieldPositionIterator
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:53
icu::Format::setLocaleIDs
void setLocaleIDs(const char *valid, const char *actual)
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::Format::operator!=
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:119
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
icu::Format
Base class for all formats.
Definition: format.h:94
fieldpos.h
C++ API: FieldPosition identifies the fields in a formatted output.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
icu::Format::operator=
Format & operator=(const Format &)
icu::Format::clone
virtual Format * clone() const =0
Clone this object polymorphically.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
fmtable.h
C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing.
icu::Format::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this format object.
icu::Format::~Format
virtual ~Format()
Destructor.
ULOC_FULLNAME_CAPACITY
#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
icu::Format::syntaxError
static void syntaxError(const UnicodeString &pattern, int32_t pos, UParseError &parseError)
Simple function for initializing a UParseError from a UnicodeString.
icu::Format::getLocaleID
const char * getLocaleID(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this format object.
locid.h
C++ API: Locale ID object.
icu::Format::operator==
virtual UBool operator==(const Format &other) const =0
Return true if the given Format objects are semantically equal.
icu::Format::Format
Format(const Format &)
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::Format::Format
Format()
Default constructor for subclass use only.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185
unistr.h
C++ API: Unicode String.