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