Loading...
Searching...
No Matches
dtitvinf.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2008-2016, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
* File DTITVINF.H
*
*******************************************************************************
*/
#ifndef __DTITVINF_H__
#define __DTITVINF_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/udat.h"
#include "unicode/locid.h"
#include "unicode/ucal.h"
#include "unicode/dtptngen.h"
U_NAMESPACE_BEGIN
class U_I18N_API DateIntervalInfo final : public UObject {
public:
DateIntervalInfo(UErrorCode& status);
DateIntervalInfo(const Locale& locale, UErrorCode& status);
DateIntervalInfo(const DateIntervalInfo&);
DateIntervalInfo& operator=(const DateIntervalInfo&);
DateIntervalInfo* clone() const;
~DateIntervalInfo();
bool operator==(const DateIntervalInfo& other) const;
bool operator!=(const DateIntervalInfo& other) const;
void setIntervalPattern(const UnicodeString& skeleton,
UCalendarDateFields lrgDiffCalUnit,
const UnicodeString& intervalPattern,
UErrorCode& status);
UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
UCalendarDateFields field,
UnicodeString& result,
UErrorCode& status) const;
UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
UErrorCode& status);
UBool getDefaultOrder() const;
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
friend class DateIntervalFormat;
struct U_HIDDEN DateIntervalSink;
enum IntervalPatternIndex
{
kIPI_ERA,
kIPI_YEAR,
kIPI_MONTH,
kIPI_DATE,
kIPI_AM_PM,
kIPI_HOUR,
kIPI_MINUTE,
kIPI_SECOND,
kIPI_MILLISECOND,
kIPI_MAX_INDEX
};
public:
#ifndef U_HIDE_INTERNAL_API
enum {
kMaxIntervalPatternIndex = kIPI_MAX_INDEX
};
#endif /* U_HIDE_INTERNAL_API */
private:
void initializeData(const Locale& locale, UErrorCode& status);
/* Set Interval pattern.
*
* It sets interval pattern into the hash map.
*
* @param skeleton skeleton on which the interval pattern based
* @param lrgDiffCalUnit the largest different calendar unit.
* @param intervalPattern the interval pattern on the largest different
* calendar unit.
* @param status output param set to success/failure code on exit
*/
void setIntervalPatternInternally(const UnicodeString& skeleton,
UCalendarDateFields lrgDiffCalUnit,
const UnicodeString& intervalPattern,
UErrorCode& status);
const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
int8_t& bestMatchDistanceInfo) const;
static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
int32_t* skeletonFieldWidth);
static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
int32_t anotherFieldWidth,
char patternLetter);
static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
UCalendarDateFields field,
UErrorCode& status);
void deleteHash(Hashtable* hTable);
Hashtable* initHash(UErrorCode& status);
void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
// data members
// fallback interval pattern
UnicodeString fFallbackIntervalPattern;
// default order
UBool fFirstDateInPtnIsLaterDate;
// HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
// HashMap( skeleton, pattern[largest_different_field] )
Hashtable* fIntervalPatterns;
};// end class DateIntervalInfo
inline bool
DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
return !operator==(other);
}
U_NAMESPACE_END
#endif
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::DateIntervalInfo::setIntervalPattern
void setIntervalPattern(const UnicodeString &skeleton, UCalendarDateFields lrgDiffCalUnit, const UnicodeString &intervalPattern, UErrorCode &status)
Provides a way for client to build interval patterns.
icu::DateIntervalInfo::getFallbackIntervalPattern
UnicodeString & getFallbackIntervalPattern(UnicodeString &result) const
Get the fallback interval pattern.
icu::DateIntervalInfo::operator!=
bool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition dtitvinf.h:511
icu::DateIntervalInfo::operator==
bool operator==(const DateIntervalInfo &other) const
Return true if another object is semantically equal to this one.
icu::DateIntervalInfo::operator=
DateIntervalInfo & operator=(const DateIntervalInfo &)
Assignment operator.
icu::DateIntervalInfo::getDefaultOrder
UBool getDefaultOrder() const
Get default order – whether the first date in pattern is later date or not.
icu::DateIntervalInfo::setFallbackIntervalPattern
void setFallbackIntervalPattern(const UnicodeString &fallbackPattern, UErrorCode &status)
Re-set the fallback interval pattern.
icu::DateIntervalInfo::DateIntervalFormat
friend class DateIntervalFormat
DateIntervalFormat will need access to getBestSkeleton(), parseSkeleton(), enum IntervalPatternIndex,...
Definition dtitvinf.h:340
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(const DateIntervalInfo &)
Copy constructor.
icu::DateIntervalInfo::getIntervalPattern
UnicodeString & getIntervalPattern(const UnicodeString &skeleton, UCalendarDateFields field, UnicodeString &result, UErrorCode &status) const
Get the interval pattern given skeleton and the largest different calendar field.
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(const Locale &locale, UErrorCode &status)
Construct DateIntervalInfo for the given locale,.
icu::DateIntervalInfo::~DateIntervalInfo
~DateIntervalInfo()
Destructor.
icu::DateIntervalInfo::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::DateIntervalInfo::clone
DateIntervalInfo * clone() const
Clone this object polymorphically.
icu::DateIntervalInfo::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(UErrorCode &status)
Default constructor.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
dtptngen.h
C++ API: Date/Time Pattern Generator.
locid.h
C++ API: Locale ID object.
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition stringpiece.h:346
U_HIDDEN
#define U_HIDDEN
This is used to mark internal structs declared within external classes, to prevent the internal struc...
Definition platform.h:813
ucal.h
C API: Calendar.
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:202
udat.h
C API: DateFormat.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316