"Fossies" - the Fresh Open Source Software Archive

Member "reldatefmt_8h_source.html" (3 Oct 2019, 85437 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
reldatefmt.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 * Copyright (C) 2014-2016, International Business Machines Corporation and
6 * others.
7 * All Rights Reserved.
8 *****************************************************************************
9 *
10 * File RELDATEFMT.H
11 *****************************************************************************
12 */
13 
14 #ifndef __RELDATEFMT_H
15 #define __RELDATEFMT_H
16 
17 #include "unicode/utypes.h"
18 
19 #if U_SHOW_CPLUSPLUS_API
20 
21 #include "unicode/uobject.h"
23 #include "unicode/ureldatefmt.h"
24 #include "unicode/locid.h"
25 #include "unicode/formattedvalue.h"
26 
32 #if !UCONFIG_NO_FORMATTING
33 
39 typedef enum UDateRelativeUnit {
40 
46 
52 
58 
64 
70 
76 
82 
83 #ifndef U_HIDE_DEPRECATED_API
84 
89 #endif // U_HIDE_DEPRECATED_API
91 
96 typedef enum UDateAbsoluteUnit {
97 
98  // Days of week have to remain together and in order from Sunday to
99  // Saturday.
105 
111 
117 
123 
129 
135 
141 
147 
153 
159 
165 
171 
177 
178 #ifndef U_HIDE_DRAFT_API
179 
184 
190 #endif // U_HIDE_DRAFT_API
191 
192 #ifndef U_HIDE_DEPRECATED_API
193 
198 #endif // U_HIDE_DEPRECATED_API
200 
206 typedef enum UDateDirection {
207 
213 
219 
225 
231 
237 
243 
244 #ifndef U_HIDE_DEPRECATED_API
245 
250 #endif // U_HIDE_DEPRECATED_API
252 
253 #if !UCONFIG_NO_BREAK_ITERATION
254 
255 U_NAMESPACE_BEGIN
256 
257 class BreakIterator;
258 class RelativeDateTimeCacheData;
259 class SharedNumberFormat;
260 class SharedPluralRules;
261 class SharedBreakIterator;
262 class NumberFormat;
263 class UnicodeString;
264 class FormattedRelativeDateTime;
265 class FormattedRelativeDateTimeData;
266 
267 #ifndef U_HIDE_DRAFT_API
268 
278  public:
283  FormattedRelativeDateTime() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
284 
290 
296 
299 
301  FormattedRelativeDateTime& operator=(const FormattedRelativeDateTime&) = delete;
302 
308 
311 
314 
316  Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
317 
320 
321  private:
322  FormattedRelativeDateTimeData *fData;
323  UErrorCode fErrorCode;
324  explicit FormattedRelativeDateTime(FormattedRelativeDateTimeData *results)
325  : fData(results), fErrorCode(U_ZERO_ERROR) {}
326  explicit FormattedRelativeDateTime(UErrorCode errorCode)
327  : fData(nullptr), fErrorCode(errorCode) {}
328  friend class RelativeDateTimeFormatter;
329 };
330 #endif /* U_HIDE_DRAFT_API */
331 
401 public:
402 
408 
413  RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
414 
426  const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
427 
444  const Locale& locale,
445  NumberFormat *nfToAdopt,
447  UDisplayContext capitalizationContext,
448  UErrorCode& status);
449 
455 
460  RelativeDateTimeFormatter& operator=(
461  const RelativeDateTimeFormatter& other);
462 
467  virtual ~RelativeDateTimeFormatter();
468 
488  UnicodeString& format(
489  double quantity,
490  UDateDirection direction,
491  UDateRelativeUnit unit,
492  UnicodeString& appendTo,
493  UErrorCode& status) const;
494 
495 #ifndef U_HIDE_DRAFT_API
496 
513  FormattedRelativeDateTime formatToValue(
514  double quantity,
515  UDateDirection direction,
516  UDateRelativeUnit unit,
517  UErrorCode& status) const;
518 #endif /* U_HIDE_DRAFT_API */
519 
536  UnicodeString& format(
537  UDateDirection direction,
538  UDateAbsoluteUnit unit,
539  UnicodeString& appendTo,
540  UErrorCode& status) const;
541 
542 #ifndef U_HIDE_DRAFT_API
543 
558  FormattedRelativeDateTime formatToValue(
559  UDateDirection direction,
560  UDateAbsoluteUnit unit,
561  UErrorCode& status) const;
562 #endif /* U_HIDE_DRAFT_API */
563 
584  UnicodeString& formatNumeric(
585  double offset,
587  UnicodeString& appendTo,
588  UErrorCode& status) const;
589 
590 #ifndef U_HIDE_DRAFT_API
591 
609  FormattedRelativeDateTime formatNumericToValue(
610  double offset,
612  UErrorCode& status) const;
613 #endif /* U_HIDE_DRAFT_API */
614 
635  UnicodeString& format(
636  double offset,
638  UnicodeString& appendTo,
639  UErrorCode& status) const;
640 
641 #ifndef U_HIDE_DRAFT_API
642 
660  FormattedRelativeDateTime formatToValue(
661  double offset,
663  UErrorCode& status) const;
664 #endif /* U_HIDE_DRAFT_API */
665 
678  UnicodeString& combineDateAndTime(
679  const UnicodeString& relativeDateString,
680  const UnicodeString& timeString,
681  UnicodeString& appendTo,
682  UErrorCode& status) const;
683 
689  const NumberFormat& getNumberFormat() const;
690 
696  UDisplayContext getCapitalizationContext() const;
697 
703  UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
704 
705 private:
706  const RelativeDateTimeCacheData* fCache;
707  const SharedNumberFormat *fNumberFormat;
708  const SharedPluralRules *fPluralRules;
710  UDisplayContext fContext;
711  const SharedBreakIterator *fOptBreakIterator;
712  Locale fLocale;
713  void init(
714  NumberFormat *nfToAdopt,
715  BreakIterator *brkIter,
716  UErrorCode &status);
717  UnicodeString& adjustForContext(UnicodeString &) const;
718  UBool checkNoAdjustForContext(UErrorCode& status) const;
719 
720  template<typename F, typename... Args>
721  UnicodeString& doFormat(
722  F callback,
723  UnicodeString& appendTo,
724  UErrorCode& status,
725  Args... args) const;
726 
727 #ifndef U_HIDE_DRAFT_API // for FormattedRelativeDateTime
728  template<typename F, typename... Args>
729  FormattedRelativeDateTime doFormatToValue(
730  F callback,
731  UErrorCode& status,
732  Args... args) const;
733 #endif // U_HIDE_DRAFT_API
734 
735  void formatImpl(
736  double quantity,
737  UDateDirection direction,
738  UDateRelativeUnit unit,
739  FormattedRelativeDateTimeData& output,
740  UErrorCode& status) const;
741  void formatAbsoluteImpl(
742  UDateDirection direction,
743  UDateAbsoluteUnit unit,
744  FormattedRelativeDateTimeData& output,
745  UErrorCode& status) const;
746  void formatNumericImpl(
747  double offset,
749  FormattedRelativeDateTimeData& output,
750  UErrorCode& status) const;
751  void formatRelativeImpl(
752  double offset,
754  FormattedRelativeDateTimeData& output,
755  UErrorCode& status) const;
756 };
757 
758 U_NAMESPACE_END
759 
760 #endif /* !UCONFIG_NO_BREAK_ITERATION */
761 #endif /* !UCONFIG_NO_FORMATTING */
762 
763 #endif /* U_SHOW_CPLUSPLUS_API */
764 
765 #endif /* __RELDATEFMT_H */
C++ API: Abstract operations for localized strings.
An immutable class containing the result of a relative datetime formatting operation.
Definition: reldatefmt.h:277
virtual UBool nextPosition(ConstrainedFieldPosition &cfpos, UErrorCode &status) const =0
Iterates over field positions in the FormattedValue.
#define U_OVERRIDE
Defined to the C++11 "override" keyword if available.
Definition: umachine.h:129
One more than the highest normal UDateAbsoluteUnit value.
Definition: reldatefmt.h:197
URelativeDateTimeUnit
Represents the unit for formatting a relative date.
Definition: ureldatefmt.h:78
virtual UnicodeString toString(UErrorCode &status) const =0
Returns the formatted string as a self-contained UnicodeString.
UDisplayContext
Display context settings.
No error, no warning.
Definition: utypes.h:449
C API: Display context types (enum values)
An abstract formatted value: a string with associated field attributes.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
C API: URelativeDateTimeFormatter, relative date formatting of unit + numeric offset.
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:106
FormattedRelativeDateTime()
Default constructor; makes an empty FormattedRelativeDateTime.
Definition: reldatefmt.h:283
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: ureldatefmt.h:45
UDateDirection
Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday". ...
Definition: reldatefmt.h:206
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:242
Formats simple relative dates.
Definition: reldatefmt.h:400
C++ API: Common ICU base class UObject.
Represents a span of a string containing a given field.
#define U_NOEXCEPT
"noexcept" if supported, otherwise empty.
Definition: platform.h:529
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
One more than the highest normal UDateDirection value.
Definition: reldatefmt.h:249
UDateAbsoluteUnit
Represents an absolute unit.
Definition: reldatefmt.h:96
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
virtual Appendable & appendTo(Appendable &appendable, UErrorCode &status) const =0
Appends the formatted string to an Appendable.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
One more than the highest normal UDateRelativeUnit value.
Definition: reldatefmt.h:88
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UMemory is the common ICU base class.
Definition: uobject.h:115
Requested operation can not be completed with ICU in its current state.
Definition: utypes.h:478
UDateRelativeUnit
Represents the unit for formatting a relative date.
Definition: reldatefmt.h:39
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
virtual UnicodeString toTempString(UErrorCode &status) const =0
Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195