ICU 52.1  52.1
listformatter.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2012-2013, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: listformatter.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 20120426
14 * created by: Umesh P. Nair
15 */
16 
17 #ifndef __LISTFORMATTER_H__
18 #define __LISTFORMATTER_H__
19 
20 #include "unicode/utypes.h"
21 
22 #ifndef U_HIDE_DRAFT_API
23 
24 #include "unicode/unistr.h"
25 #include "unicode/locid.h"
26 
28 
30 class Hashtable;
31 
32 #ifndef U_HIDE_INTERNAL_API
33 
34 struct ListFormatData : public UMemory {
35  UnicodeString twoPattern;
36  UnicodeString startPattern;
37  UnicodeString middlePattern;
38  UnicodeString endPattern;
39 
40  ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) :
41  twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {}
42 };
43 #endif /* U_HIDE_INTERNAL_API */
44 
45 
63 
64  public:
65 
71 
76  ListFormatter& operator=(const ListFormatter& other);
77 
86  static ListFormatter* createInstance(UErrorCode& errorCode);
87 
97  static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);
98 
99 #ifndef U_HIDE_INTERNAL_API
100 
110  static ListFormatter* createInstance(const Locale& locale, const char* style, UErrorCode& errorCode);
111 #endif /* U_HIDE_INTERNAL_API */
112 
118  virtual ~ListFormatter();
119 
120 
131  UnicodeString& format(const UnicodeString items[], int32_t n_items,
132  UnicodeString& appendTo, UErrorCode& errorCode) const;
133 
134 #ifndef U_HIDE_INTERNAL_API
135 
138  ListFormatter(const ListFormatData* listFormatterData);
139 #endif /* U_HIDE_INTERNAL_API */
140 
141  private:
142  static void initializeHash(UErrorCode& errorCode);
143  static const ListFormatData* getListFormatData(const Locale& locale, const char *style, UErrorCode& errorCode);
144 
145  ListFormatter();
146  void addNewString(const UnicodeString& pattern, UnicodeString& originalString,
147  const UnicodeString& newString, UErrorCode& errorCode) const;
148 
149  const ListFormatData* data;
150 };
151 
153 
154 #endif /* U_HIDE_DRAFT_API */
155 #endif