intl/icu/source/i18n/unicode/tmutamt.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial