ICU 77.1  77.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
48 class CharString;
99 class U_I18N_API Format : public UObject {
100 public:
101 
105  virtual ~Format();
106 
115  virtual bool operator==(const Format& other) const = 0;
116 
124  bool operator!=(const Format& other) const { return !operator==(other); }
125 
132  virtual Format* clone() const = 0;
133 
145  UnicodeString& appendTo,
146  UErrorCode& status) const;
147 
164  virtual UnicodeString& format(const Formattable& obj,
165  UnicodeString& appendTo,
166  FieldPosition& pos,
167  UErrorCode& status) const = 0;
184  virtual UnicodeString& format(const Formattable& obj,
185  UnicodeString& appendTo,
186  FieldPositionIterator* posIter,
187  UErrorCode& status) const;
188 
228  virtual void parseObject(const UnicodeString& source,
229  Formattable& result,
230  ParsePosition& parse_pos) const = 0;
231 
244  void parseObject(const UnicodeString& source,
245  Formattable& result,
246  UErrorCode& status) const;
247 
255 
256 #ifndef U_HIDE_INTERNAL_API
263  const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
264 #endif /* U_HIDE_INTERNAL_API */
265 
266  protected:
268  void setLocaleIDs(const char* valid, const char* actual);
269 
270 protected:
276 
280  Format(const Format&); // Does nothing; for subclasses only
281 
285  Format& operator=(const Format&); // Does nothing; for subclasses
286 
287 
296  static void syntaxError(const UnicodeString& pattern,
297  int32_t pos,
298  UParseError& parseError);
299 
300  private:
301  CharString* actualLocale = nullptr;
302  CharString* validLocale = nullptr;
303 };
304 
305 U_NAMESPACE_END
306 
307 #endif /* #if !UCONFIG_NO_FORMATTING */
308 
309 #endif /* U_SHOW_CPLUSPLUS_API */
310 
311 #endif // _FORMAT
312 //eof
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:58
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:110
Base class for all formats.
Definition: format.h:99
Format()
Default constructor for subclass use only.
Format(const Format &)
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
Parse a string to produce an object.
static void syntaxError(const UnicodeString &pattern, int32_t pos, UParseError &parseError)
Simple function for initializing a UParseError from a UnicodeString.
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const =0
Format an object to produce a string.
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format an object to produce a string.
Format & operator=(const Format &)
const char * getLocaleID(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this format object.
void setLocaleIDs(const char *valid, const char *actual)
virtual ~Format()
Destructor.
void parseObject(const UnicodeString &source, Formattable &result, UErrorCode &status) const
Parses a string to produce an object.
virtual Format * clone() const =0
Clone this object polymorphically.
virtual bool operator==(const Format &other) const =0
Return true if the given Format objects are semantically equal.
bool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:124
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this format object.
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:63
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
C++ API: FieldPosition identifies the fields in a formatted output.
C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing.
C++ API: FieldPosition Iterator.
C++ API: Locale ID object.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C API: Parse Error Information.
C++ API: Canonical Iterator.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
C++ API: Unicode String.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:316