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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/unicode/measure.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +* Copyright (c) 2004-2006, International Business Machines
     1.7 +* Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +* Author: Alan Liu
    1.10 +* Created: April 26, 2004
    1.11 +* Since: ICU 3.0
    1.12 +**********************************************************************
    1.13 +*/
    1.14 +#ifndef __MEASURE_H__
    1.15 +#define __MEASURE_H__
    1.16 +
    1.17 +#include "unicode/utypes.h"
    1.18 +
    1.19 +/**
    1.20 + * \file 
    1.21 + * \brief C++ API: MeasureUnit object.
    1.22 + */
    1.23 + 
    1.24 +#if !UCONFIG_NO_FORMATTING
    1.25 +
    1.26 +#include "unicode/fmtable.h"
    1.27 +
    1.28 +U_NAMESPACE_BEGIN
    1.29 +
    1.30 +class MeasureUnit;
    1.31 +
    1.32 +/**
    1.33 + * An amount of a specified unit, consisting of a number and a Unit.
    1.34 + * For example, a length measure consists of a number and a length
    1.35 + * unit, such as feet or meters.  This is an abstract class.
    1.36 + * Subclasses specify a concrete Unit type.
    1.37 + *
    1.38 + * <p>Measure objects are parsed and formatted by subclasses of
    1.39 + * MeasureFormat.
    1.40 + *
    1.41 + * <p>Measure objects are immutable.
    1.42 + *
    1.43 + * <p>This is an abstract class.
    1.44 + *
    1.45 + * @author Alan Liu
    1.46 + * @stable ICU 3.0
    1.47 + */
    1.48 +class U_I18N_API Measure: public UObject {
    1.49 + public:
    1.50 +    /**
    1.51 +     * Construct an object with the given numeric amount and the given
    1.52 +     * unit.  After this call, the caller must not delete the given
    1.53 +     * unit object.
    1.54 +     * @param number a numeric object; amount.isNumeric() must be TRUE
    1.55 +     * @param adoptedUnit the unit object, which must not be NULL
    1.56 +     * @param ec input-output error code. If the amount or the unit
    1.57 +     * is invalid, then this will be set to a failing value.
    1.58 +     * @stable ICU 3.0
    1.59 +     */
    1.60 +    Measure(const Formattable& number, MeasureUnit* adoptedUnit,
    1.61 +            UErrorCode& ec);
    1.62 +
    1.63 +    /**
    1.64 +     * Copy constructor
    1.65 +     * @stable ICU 3.0
    1.66 +     */
    1.67 +    Measure(const Measure& other);
    1.68 +
    1.69 +    /**
    1.70 +     * Assignment operator
    1.71 +     * @stable ICU 3.0
    1.72 +     */
    1.73 +    Measure& operator=(const Measure& other);
    1.74 +
    1.75 +    /**
    1.76 +     * Return a polymorphic clone of this object.  The result will
    1.77 +     * have the same class as returned by getDynamicClassID().
    1.78 +     * @stable ICU 3.0
    1.79 +     */
    1.80 +    virtual UObject* clone() const = 0;
    1.81 +
    1.82 +    /**
    1.83 +     * Destructor
    1.84 +     * @stable ICU 3.0
    1.85 +     */
    1.86 +    virtual ~Measure();
    1.87 +    
    1.88 +    /**
    1.89 +     * Equality operator.  Return true if this object is equal
    1.90 +     * to the given object.
    1.91 +     * @stable ICU 3.0
    1.92 +     */
    1.93 +    UBool operator==(const UObject& other) const;
    1.94 +
    1.95 +    /**
    1.96 +     * Return a reference to the numeric value of this object.  The
    1.97 +     * numeric value may be of any numeric type supported by
    1.98 +     * Formattable.
    1.99 +     * @stable ICU 3.0
   1.100 +     */
   1.101 +    inline const Formattable& getNumber() const;
   1.102 +
   1.103 +    /**
   1.104 +     * Return a reference to the unit of this object.
   1.105 +     * @stable ICU 3.0
   1.106 +     */
   1.107 +    inline const MeasureUnit& getUnit() const;
   1.108 +
   1.109 + protected:
   1.110 +    /**
   1.111 +     * Default constructor.
   1.112 +     * @stable ICU 3.0
   1.113 +     */
   1.114 +    Measure();
   1.115 +
   1.116 + private:
   1.117 +    /**
   1.118 +     * The numeric value of this object, e.g. 2.54 or 100.
   1.119 +     */
   1.120 +    Formattable number;
   1.121 +
   1.122 +    /**
   1.123 +     * The unit of this object, e.g., "millimeter" or "JPY".  This is
   1.124 +     * owned by this object.
   1.125 +     */
   1.126 +    MeasureUnit* unit;
   1.127 +};
   1.128 +
   1.129 +inline const Formattable& Measure::getNumber() const {
   1.130 +    return number;
   1.131 +}
   1.132 +
   1.133 +inline const MeasureUnit& Measure::getUnit() const {
   1.134 +    return *unit;
   1.135 +}
   1.136 +
   1.137 +U_NAMESPACE_END
   1.138 +
   1.139 +#endif // !UCONFIG_NO_FORMATTING
   1.140 +#endif // __MEASURE_H__

mercurial