tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

tztrans.h (6258B)


      1 // © 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 *******************************************************************************
      5 * Copyright (C) 2007-2008, International Business Machines Corporation and         *
      6 * others. All Rights Reserved.                                                *
      7 *******************************************************************************
      8 */
      9 #ifndef TZTRANS_H
     10 #define TZTRANS_H
     11 
     12 /**
     13 * \file 
     14 * \brief C++ API: Time zone transition
     15 */
     16 
     17 #include "unicode/utypes.h"
     18 
     19 #if U_SHOW_CPLUSPLUS_API
     20 
     21 #if !UCONFIG_NO_FORMATTING
     22 
     23 #include "unicode/uobject.h"
     24 
     25 U_NAMESPACE_BEGIN
     26 
     27 // Forward declaration
     28 class TimeZoneRule;
     29 
     30 /**
     31 * <code>TimeZoneTransition</code> is a class representing a time zone transition.
     32 * An instance has a time of transition and rules for both before and after the transition.
     33 * @stable ICU 3.8
     34 */
     35 class U_I18N_API TimeZoneTransition : public UObject {
     36 public:
     37    /**
     38     * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
     39     * the transition.
     40     * 
     41     * @param time  The time of transition in milliseconds since the base time.
     42     * @param from  The time zone rule used before the transition.
     43     * @param to    The time zone rule used after the transition.
     44     * @stable ICU 3.8
     45     */
     46    TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
     47 
     48    /**
     49     * Constructs an empty <code>TimeZoneTransition</code>
     50     * @stable ICU 3.8
     51     */
     52    TimeZoneTransition();
     53 
     54    /**
     55     * Copy constructor.
     56     * @param source    The TimeZoneTransition object to be copied.
     57     * @stable ICU 3.8
     58     */
     59    TimeZoneTransition(const TimeZoneTransition& source);
     60 
     61    /**
     62     * Destructor.
     63     * @stable ICU 3.8
     64     */
     65    ~TimeZoneTransition();
     66 
     67    /**
     68     * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
     69     * should delete it when done.
     70     * @return  A copy of the object.
     71     * @stable ICU 3.8
     72     */
     73    TimeZoneTransition* clone() const;
     74 
     75    /**
     76     * Assignment operator.
     77     * @param right The object to be copied.
     78     * @stable ICU 3.8
     79     */
     80    TimeZoneTransition& operator=(const TimeZoneTransition& right);
     81 
     82    /**
     83     * Return true if the given TimeZoneTransition objects are semantically equal. Objects
     84     * of different subclasses are considered unequal.
     85     * @param that  The object to be compared with.
     86     * @return  true if the given TimeZoneTransition objects are semantically equal.
     87     * @stable ICU 3.8
     88     */
     89    bool operator==(const TimeZoneTransition& that) const;
     90 
     91    /**
     92     * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
     93     * of different subclasses are considered unequal.
     94     * @param that  The object to be compared with.
     95     * @return  true if the given TimeZoneTransition objects are semantically unequal.
     96     * @stable ICU 3.8
     97     */
     98    bool operator!=(const TimeZoneTransition& that) const;
     99 
    100    /**
    101     * Returns the time of transition in milliseconds.
    102     * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
    103     * @stable ICU 3.8
    104     */
    105    UDate getTime() const;
    106 
    107    /**
    108     * Sets the time of transition in milliseconds.
    109     * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
    110     * @stable ICU 3.8
    111     */
    112    void setTime(UDate time);
    113 
    114    /**
    115     * Returns the rule used before the transition.
    116     * @return The time zone rule used after the transition.
    117     * @stable ICU 3.8
    118     */
    119    const TimeZoneRule* getFrom() const;
    120 
    121    /**
    122     * Sets the rule used before the transition.  The caller remains
    123     * responsible for deleting the <code>TimeZoneRule</code> object.
    124     * @param from The time zone rule used before the transition.
    125     * @stable ICU 3.8
    126     */
    127    void setFrom(const TimeZoneRule& from);
    128 
    129    /**
    130     * Adopts the rule used before the transition.  The caller must
    131     * not delete the <code>TimeZoneRule</code> object passed in.
    132     * @param from The time zone rule used before the transition.
    133     * @stable ICU 3.8
    134     */
    135    void adoptFrom(TimeZoneRule* from);
    136 
    137    /**
    138     * Sets the rule used after the transition.  The caller remains
    139     * responsible for deleting the <code>TimeZoneRule</code> object.
    140     * @param to The time zone rule used after the transition.
    141     * @stable ICU 3.8
    142     */
    143    void setTo(const TimeZoneRule& to);
    144 
    145    /**
    146     * Adopts the rule used after the transition.  The caller must
    147     * not delete the <code>TimeZoneRule</code> object passed in.
    148     * @param to The time zone rule used after the transition.
    149     * @stable ICU 3.8
    150     */
    151    void adoptTo(TimeZoneRule* to);
    152 
    153    /**
    154     * Returns the rule used after the transition.
    155     * @return The time zone rule used after the transition.
    156     * @stable ICU 3.8
    157     */
    158    const TimeZoneRule* getTo() const;
    159 
    160 private:
    161    UDate   fTime;
    162    TimeZoneRule*   fFrom;
    163    TimeZoneRule*   fTo;
    164 
    165 public:
    166    /**
    167     * Return the class ID for this class. This is useful only for comparing to
    168     * a return value from getDynamicClassID(). For example:
    169     * <pre>
    170     * .   Base* polymorphic_pointer = createPolymorphicObject();
    171     * .   if (polymorphic_pointer->getDynamicClassID() ==
    172     * .       erived::getStaticClassID()) ...
    173     * </pre>
    174     * @return          The class ID for all objects of this class.
    175     * @stable ICU 3.8
    176     */
    177    static UClassID U_EXPORT2 getStaticClassID();
    178 
    179    /**
    180     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
    181     * method is to implement a simple version of RTTI, since not all C++
    182     * compilers support genuine RTTI. Polymorphic operator==() and clone()
    183     * methods call this method.
    184     *
    185     * @return          The class ID for this object. All objects of a
    186     *                  given class have the same class ID.  Objects of
    187     *                  other classes have different class IDs.
    188     * @stable ICU 3.8
    189     */
    190    virtual UClassID getDynamicClassID() const override;
    191 };
    192 
    193 U_NAMESPACE_END
    194 
    195 #endif /* #if !UCONFIG_NO_FORMATTING */
    196 
    197 #endif /* U_SHOW_CPLUSPLUS_API */
    198 
    199 #endif // TZTRANS_H
    200 
    201 //eof