ICU 60.2 60.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

listformatter.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 *
6 * Copyright (C) 2012-2016, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: listformatter.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 20120426
16 * created by: Umesh P. Nair
17 */
18
19 #ifndef __LISTFORMATTER_H__
20 #define __LISTFORMATTER_H__
21
22 #include "unicode/utypes.h"
23
24 #include "unicode/unistr.h"
25 #include "unicode/locid.h"
26
27 U_NAMESPACE_BEGIN
28
30 class Hashtable;
31
33 struct ListFormatInternal;
34
35 /* The following can't be #ifndef U_HIDE_INTERNAL_API, needed for other .h file declarations */
37 struct ListFormatData : public UMemory {
38 UnicodeString twoPattern;
39 UnicodeString startPattern;
40 UnicodeString middlePattern;
41 UnicodeString endPattern;
42
43 ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) :
44 twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {}
45 };
46
47
64 class U_COMMON_API ListFormatter : public UObject{
65
66 public:
67
72 ListFormatter(const ListFormatter&);
73
78 ListFormatter& operator=(const ListFormatter& other);
79
88 static ListFormatter* createInstance(UErrorCode& errorCode);
89
99 static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);
100
101 #ifndef U_HIDE_INTERNAL_API
102
112 static ListFormatter* createInstance(const Locale& locale, const char* style, UErrorCode& errorCode);
113 #endif /* U_HIDE_INTERNAL_API */
114
120 virtual ~ListFormatter();
121
122
133 UnicodeString& format(const UnicodeString items[], int32_t n_items,
134 UnicodeString& appendTo, UErrorCode& errorCode) const;
135
136 #ifndef U_HIDE_INTERNAL_API
137
140 UnicodeString& format(
141 const UnicodeString items[],
142 int32_t n_items,
143 UnicodeString& appendTo,
144 int32_t index,
145 int32_t &offset,
146 UErrorCode& errorCode) const;
150 ListFormatter(const ListFormatData &data, UErrorCode &errorCode);
154 ListFormatter(const ListFormatInternal* listFormatterInternal);
155 #endif /* U_HIDE_INTERNAL_API */
156
157 private:
158 static void initializeHash(UErrorCode& errorCode);
159 static const ListFormatInternal* getListFormatInternal(const Locale& locale, const char *style, UErrorCode& errorCode);
160 struct ListPatternsSink;
161 static ListFormatInternal* loadListFormatInternal(const Locale& locale, const char* style, UErrorCode& errorCode);
162
163 ListFormatter();
164
165 ListFormatInternal* owned;
166 const ListFormatInternal* data;
167 };
168
169 U_NAMESPACE_END
170
171 #endif
icu::ListFormatData
Definition: listformatter.h:37
unistr.h
C++ API: Unicode String.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::ListFormatter
An immutable class for formatting a list, using data from CLDR (or supplied separately).
Definition: listformatter.h:64
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
locid.h
C++ API: Locale ID object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:359
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:112
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188