tor-browser

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

tmutamt.h (5019B)


      1 // © 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 *******************************************************************************
      5 * Copyright (C) 2009-2010, Google, International Business Machines Corporation and *
      6 * others. All Rights Reserved.                                                *
      7 *******************************************************************************
      8 */ 
      9 
     10 #ifndef __TMUTAMT_H__
     11 #define __TMUTAMT_H__
     12 
     13 
     14 /**
     15 * \file
     16 * \brief C++ API: time unit amount object.
     17 */
     18 
     19 #include "unicode/utypes.h"
     20 
     21 #if U_SHOW_CPLUSPLUS_API
     22 
     23 #if !UCONFIG_NO_FORMATTING
     24 
     25 #include "unicode/measure.h"
     26 #include "unicode/tmunit.h"
     27 
     28 U_NAMESPACE_BEGIN
     29 
     30 
     31 /**
     32 * Express a duration as a time unit and number. Patterned after Currency.
     33 * @see TimeUnitAmount
     34 * @see TimeUnitFormat
     35 * @stable ICU 4.2
     36 */
     37 class U_I18N_API TimeUnitAmount: public Measure {
     38 public:
     39    /**
     40     * Construct TimeUnitAmount object with the given number and the
     41     * given time unit. 
     42     * @param number        a numeric object; number.isNumeric() must be true
     43     * @param timeUnitField the time unit field of a time unit
     44     * @param status        the input-output error code. 
     45     *                      If the number is not numeric or the timeUnitField
     46     *                      is not valid,
     47     *                      then this will be set to a failing value:
     48     *                      U_ILLEGAL_ARGUMENT_ERROR.
     49     * @stable ICU 4.2
     50     */
     51    TimeUnitAmount(const Formattable& number, 
     52                   TimeUnit::UTimeUnitFields timeUnitField,
     53                   UErrorCode& status);
     54 
     55    /**
     56     * Construct TimeUnitAmount object with the given numeric amount and the
     57     * given time unit. 
     58     * @param amount        a numeric amount.
     59     * @param timeUnitField the time unit field on which a time unit amount
     60     *                      object will be created.
     61     * @param status        the input-output error code. 
     62     *                      If the timeUnitField is not valid,
     63     *                      then this will be set to a failing value:
     64     *                      U_ILLEGAL_ARGUMENT_ERROR.
     65     * @stable ICU 4.2
     66     */
     67    TimeUnitAmount(double amount, TimeUnit::UTimeUnitFields timeUnitField,
     68                   UErrorCode& status);
     69 
     70 
     71    /**
     72     * Copy constructor 
     73     * @stable ICU 4.2
     74     */
     75    TimeUnitAmount(const TimeUnitAmount& other);
     76 
     77 
     78    /**
     79     * Assignment operator
     80     * @stable ICU 4.2
     81     */
     82    TimeUnitAmount& operator=(const TimeUnitAmount& other);
     83 
     84 
     85    /**
     86     * Clone. 
     87     * @return a polymorphic clone of this object. The result will have the same               class as returned by getDynamicClassID().
     88     * @stable ICU 4.2
     89     */
     90    virtual TimeUnitAmount* clone() const override;
     91 
     92    
     93    /**
     94     * Destructor
     95     * @stable ICU 4.2
     96     */
     97    virtual ~TimeUnitAmount();
     98 
     99    
    100    /** 
    101     * Equality operator.  
    102     * @param other  the object to compare to.
    103     * @return       true if this object is equal to the given object.
    104     * @stable ICU 4.2
    105     */
    106    virtual bool operator==(const UObject& other) const;
    107 
    108 
    109    /** 
    110     * Not-equality operator.  
    111     * @param other  the object to compare to.
    112     * @return       true if this object is not equal to the given object.
    113     * @stable ICU 4.2
    114     */
    115    bool operator!=(const UObject& other) const;
    116 
    117 
    118    /**
    119     * Return the class ID for this class. This is useful only for comparing to
    120     * a return value from getDynamicClassID(). For example:
    121     * <pre>
    122     * .   Base* polymorphic_pointer = createPolymorphicObject();
    123     * .   if (polymorphic_pointer->getDynamicClassID() ==
    124     * .       erived::getStaticClassID()) ...
    125     * </pre>
    126     * @return          The class ID for all objects of this class.
    127     * @stable ICU 4.2
    128     */
    129    static UClassID U_EXPORT2 getStaticClassID();
    130 
    131    /**
    132     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
    133     * method is to implement a simple version of RTTI, since not all C++
    134     * compilers support genuine RTTI. Polymorphic operator==() and clone()
    135     * methods call this method.
    136     *
    137     * @return          The class ID for this object. All objects of a
    138     *                  given class have the same class ID.  Objects of
    139     *                  other classes have different class IDs.
    140     * @stable ICU 4.2
    141     */
    142    virtual UClassID getDynamicClassID() const override;
    143 
    144    /**
    145     * Get the time unit.
    146     * @return time unit object.
    147     * @stable ICU 4.2
    148     */
    149    const TimeUnit& getTimeUnit() const;
    150 
    151    /**
    152     * Get the time unit field value.
    153     * @return time unit field value.
    154     * @stable ICU 4.2
    155     */
    156    TimeUnit::UTimeUnitFields getTimeUnitField() const;
    157 };
    158 
    159 
    160 
    161 inline bool
    162 TimeUnitAmount::operator!=(const UObject& other) const {
    163    return !operator==(other);
    164 }
    165 
    166 U_NAMESPACE_END
    167 
    168 #endif /* #if !UCONFIG_NO_FORMATTING */
    169 
    170 #endif /* U_SHOW_CPLUSPLUS_API */
    171 
    172 #endif // __TMUTAMT_H__
    173 //eof
    174 //