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&);
virtual DateIntervalInfo* clone() const;
virtual ~DateIntervalInfo();
virtual 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::DateIntervalFormat
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:300
icu::DateIntervalInfo
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns.
Definition: dtitvinf.h:154
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::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::getDefaultOrder
UBool getDefaultOrder() const
Get default order – whether the first date in pattern is later date or not.
icu::DateIntervalInfo::~DateIntervalInfo
virtual ~DateIntervalInfo()
Destructor.
icu::DateIntervalInfo::clone
virtual DateIntervalInfo * clone() const
Clone this object polymorphically.
icu::DateIntervalInfo::operator=
DateIntervalInfo & operator=(const DateIntervalInfo &)
Assignment operator.
icu::DateIntervalInfo::setFallbackIntervalPattern
void setFallbackIntervalPattern(const UnicodeString &fallbackPattern, UErrorCode &status)
Re-set the fallback interval pattern.
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(const DateIntervalInfo &)
Copy constructor.
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(const Locale &locale, UErrorCode &status)
Construct DateIntervalInfo for the given locale,.
icu::DateIntervalInfo::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::DateIntervalInfo::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::DateIntervalInfo::operator==
virtual bool operator==(const DateIntervalInfo &other) const
Return true if another object is semantically equal to this one.
icu::DateIntervalInfo::DateIntervalInfo
DateIntervalInfo(UErrorCode &status)
Default constructor.
icu::DateIntervalInfo::getFallbackIntervalPattern
UnicodeString & getFallbackIntervalPattern(UnicodeString &result) const
Get the fallback interval pattern.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
dtptngen.h
C++ API: Date/Time Pattern Generator.
locid.h
C++ API: Locale ID object.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:335
U_HIDDEN
#define U_HIDDEN
This is used to mark internal structs declared within external classes, to prevent the internal struc...
Definition: platform.h:811
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:247
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:415
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:301