"Fossies" - the Fresh Open Source Software Archive

Member "alphaindex_8h_source.html" (3 Oct 2019, 56214 Bytes) of package /linux/misc/icu4c-65_1-docs.zip:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

ICU 65.1  65.1
alphaindex.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) 2011-2014 International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 */
11 
12 #ifndef INDEXCHARS_H
13 #define INDEXCHARS_H
14 
15 #include "unicode/utypes.h"
16 
17 #if U_SHOW_CPLUSPLUS_API
18 
19 #include "unicode/uobject.h"
20 #include "unicode/locid.h"
21 #include "unicode/unistr.h"
22 
23 #if !UCONFIG_NO_COLLATION
24 
31 
45 
52 
62 
70 
71 
72 struct UHashtable;
74 
75 U_NAMESPACE_BEGIN
76 
77 // Forward Declarations
78 
79 class BucketList;
80 class Collator;
81 class RuleBasedCollator;
82 class StringEnumeration;
83 class UnicodeSet;
84 class UVector;
85 
193 public:
202  class U_I18N_API Bucket : public UObject {
203  public:
208  virtual ~Bucket();
209 
216  const UnicodeString &getLabel() const { return label_; }
223  UAlphabeticIndexLabelType getLabelType() const { return labelType_; }
224 
225  private:
226  friend class AlphabeticIndex;
227  friend class BucketList;
228 
229  UnicodeString label_;
230  UnicodeString lowerBoundary_;
231  UAlphabeticIndexLabelType labelType_;
232  Bucket *displayBucket_;
233  int32_t displayIndex_;
234  UVector *records_; // Records are owned by the inputList_ vector.
235 
236  Bucket(const UnicodeString &label, // Parameter strings are copied.
237  const UnicodeString &lowerBoundary,
239  };
240 
252  public:
257  virtual ~ImmutableIndex();
258 
265  int32_t getBucketCount() const;
266 
277  int32_t getBucketIndex(const UnicodeString &name, UErrorCode &errorCode) const;
278 
286  const Bucket *getBucket(int32_t index) const;
287 
288  private:
289  friend class AlphabeticIndex;
290 
291  ImmutableIndex(BucketList *bucketList, Collator *collatorPrimaryOnly)
292  : buckets_(bucketList), collatorPrimaryOnly_(collatorPrimaryOnly) {}
293 
294  BucketList *buckets_;
295  Collator *collatorPrimaryOnly_;
296  };
297 
310  AlphabeticIndex(const Locale &locale, UErrorCode &status);
311 
326  AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status);
327 
338  virtual AlphabeticIndex &addLabels(const UnicodeSet &additions, UErrorCode &status);
339 
353  virtual AlphabeticIndex &addLabels(const Locale &locale, UErrorCode &status);
354 
359  virtual ~AlphabeticIndex();
360 
367  ImmutableIndex *buildImmutableIndex(UErrorCode &errorCode);
368 
381  virtual const RuleBasedCollator &getCollator() const;
382 
383 
393  virtual const UnicodeString &getInflowLabel() const;
394 
406  virtual AlphabeticIndex &setInflowLabel(const UnicodeString &inflowLabel, UErrorCode &status);
407 
408 
416  virtual const UnicodeString &getOverflowLabel() const;
417 
418 
428  virtual AlphabeticIndex &setOverflowLabel(const UnicodeString &overflowLabel, UErrorCode &status);
429 
437  virtual const UnicodeString &getUnderflowLabel() const;
438 
448  virtual AlphabeticIndex &setUnderflowLabel(const UnicodeString &underflowLabel, UErrorCode &status);
449 
450 
458  virtual int32_t getMaxLabelCount() const;
459 
472  virtual AlphabeticIndex &setMaxLabelCount(int32_t maxLabelCount, UErrorCode &status);
473 
474 
491  virtual AlphabeticIndex &addRecord(const UnicodeString &name, const void *data, UErrorCode &status);
492 
501  virtual AlphabeticIndex &clearRecords(UErrorCode &status);
502 
503 
512  virtual int32_t getBucketCount(UErrorCode &status);
513 
514 
523  virtual int32_t getRecordCount(UErrorCode &status);
524 
525 
526 
539  virtual int32_t getBucketIndex(const UnicodeString &itemName, UErrorCode &status);
540 
541 
548  virtual int32_t getBucketIndex() const;
549 
550 
562  virtual UBool nextBucket(UErrorCode &status);
563 
572  virtual const UnicodeString &getBucketLabel() const;
573 
581  virtual UAlphabeticIndexLabelType getBucketLabelType() const;
582 
591  virtual int32_t getBucketRecordCount() const;
592 
593 
602  virtual AlphabeticIndex &resetBucketIterator(UErrorCode &status);
603 
615  virtual UBool nextRecord(UErrorCode &status);
616 
625  virtual const UnicodeString &getRecordName() const;
626 
627 
636  virtual const void *getRecordData() const;
637 
638 
645  virtual AlphabeticIndex &resetRecordIterator();
646 
647 private:
652  AlphabeticIndex(const AlphabeticIndex &other);
653 
657  AlphabeticIndex &operator =(const AlphabeticIndex & /*other*/) { return *this;}
658 
663  virtual UBool operator==(const AlphabeticIndex& other) const;
664 
669  virtual UBool operator!=(const AlphabeticIndex& other) const;
670 
671  // Common initialization, for use from all constructors.
672  void init(const Locale *locale, UErrorCode &status);
673 
678  void addIndexExemplars(const Locale &locale, UErrorCode &status);
682  UBool addChineseIndexCharacters(UErrorCode &errorCode);
683 
684  UVector *firstStringsInScript(UErrorCode &status);
685 
686  static UnicodeString separated(const UnicodeString &item);
687 
693  void initLabels(UVector &indexCharacters, UErrorCode &errorCode) const;
694  BucketList *createBucketList(UErrorCode &errorCode) const;
695  void initBuckets(UErrorCode &errorCode);
696  void clearBuckets();
697  void internalResetBucketIterator();
698 
699 public:
700 
701  // The Record is declared public only to allow access from
702  // implementation code written in plain C.
703  // It is not intended for public use.
704 
705 #ifndef U_HIDE_INTERNAL_API
706 
712  struct Record: public UMemory {
713  const UnicodeString name_;
714  const void *data_;
715  Record(const UnicodeString &name, const void *data);
716  ~Record();
717  };
719 #endif /* U_HIDE_INTERNAL_API */
720 
721 private:
722 
728  UVector *inputList_;
729 
730  int32_t labelsIterIndex_; // Index of next item to return.
731  int32_t itemsIterIndex_;
732  Bucket *currentBucket_; // While an iteration of the index in underway,
733  // point to the bucket for the current label.
734  // NULL when no iteration underway.
735 
736  int32_t maxLabelCount_; // Limit on # of labels permitted in the index.
737 
738  UnicodeSet *initialLabels_; // Initial (unprocessed) set of Labels. Union
739  // of those explicitly set by the user plus
740  // those from locales. Raw values, before
741  // crunching into bucket labels.
742 
743  UVector *firstCharsInScripts_; // The first character from each script,
744  // in collation order.
745 
746  RuleBasedCollator *collator_;
747  RuleBasedCollator *collatorPrimaryOnly_;
748 
749  // Lazy evaluated: null means that we have not built yet.
750  BucketList *buckets_;
751 
752  UnicodeString inflowLabel_;
753  UnicodeString overflowLabel_;
754  UnicodeString underflowLabel_;
755  UnicodeString overflowComparisonString_;
756 
757  UnicodeString emptyString_;
758 };
759 
760 U_NAMESPACE_END
761 
762 #endif // !UCONFIG_NO_COLLATION
763 
764 #endif /* U_SHOW_CPLUSPLUS_API */
765 
766 #endif
struct UHashtable UHashtable
Definition: msgfmt.h:43
The Collator class performs locale-sensitive string comparison.
Definition: coll.h:167
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
Inflow Label.
Definition: alphaindex.h:61
Normal Label, typically the starting letter of the names in the bucket with this label.
Definition: alphaindex.h:44
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:84
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
An index "bucket" with a label string and type.
Definition: alphaindex.h:202
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables...
Definition: tblcoll.h:115
UAlphabeticIndexLabelType getLabelType() const
Returns whether this bucket is a normal, underflow, overflow, or inflow bucket.
Definition: alphaindex.h:223
Immutable, thread-safe version of AlphabeticIndex.
Definition: alphaindex.h:251
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:251
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:281
C++ API: Common ICU base class UObject.
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:85
AlphabeticIndex supports the creation of a UI index appropriate for a given language.
Definition: alphaindex.h:192
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
Overflow Label.
Definition: alphaindex.h:68
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
const UnicodeString & getLabel() const
Returns the label string.
Definition: alphaindex.h:216
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
Undeflow Label.
Definition: alphaindex.h:51
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UMemory is the common ICU base class.
Definition: uobject.h:115
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
UAlphabeticIndexLabelType
Constants for Alphabetic Index Label Types.
Definition: alphaindex.h:38