"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "source/i18n/measunit_impl.h" between
icu4c-67rc-src.tgz and icu4c-67_1-src.tgz

About: ICU (International Components for Unicode) is a set of C/C++ and Java libraries providing Unicode and Globalization support for software applications on a wide variety of platforms.

measunit_impl.h  (icu4c-67rc-src.tgz):measunit_impl.h  (icu4c-67_1-src.tgz)
skipping to change at line 26 skipping to change at line 26
static const char16_t kDefaultCurrency[] = u"XXX"; static const char16_t kDefaultCurrency[] = u"XXX";
static const char kDefaultCurrency8[] = "XXX"; static const char kDefaultCurrency8[] = "XXX";
/** /**
* A struct representing a single unit (optional SI prefix and dimensionality). * A struct representing a single unit (optional SI prefix and dimensionality).
*/ */
struct SingleUnitImpl : public UMemory { struct SingleUnitImpl : public UMemory {
/** /**
* Gets a single unit from the MeasureUnit. If there are multiple single uni ts, sets an error * Gets a single unit from the MeasureUnit. If there are multiple single uni ts, sets an error
* code and return the base dimensionless unit. Parses if necessary. * code and returns the base dimensionless unit. Parses if necessary.
*/ */
static SingleUnitImpl forMeasureUnit(const MeasureUnit& measureUnit, UErrorC ode& status); static SingleUnitImpl forMeasureUnit(const MeasureUnit& measureUnit, UErrorC ode& status);
/** Transform this SingleUnitImpl into a MeasureUnit, simplifying if possibl e. */ /** Transform this SingleUnitImpl into a MeasureUnit, simplifying if possibl e. */
MeasureUnit build(UErrorCode& status) const; MeasureUnit build(UErrorCode& status) const;
/** Compare this SingleUnitImpl to another SingleUnitImpl. */ /**
* Compare this SingleUnitImpl to another SingleUnitImpl for the sake of
* sorting and coalescing.
*
* Takes the sign of dimensionality into account, but not the absolute
* value: per-meter is not considered the same as meter, but meter is
* considered the same as square-meter.
*
* The dimensionless unit generally does not get compared, but if it did, it
* would sort before other units by virtue of index being < 0 and
* dimensionality not being negative.
*/
int32_t compareTo(const SingleUnitImpl& other) const { int32_t compareTo(const SingleUnitImpl& other) const {
if (dimensionality < 0 && other.dimensionality > 0) { if (dimensionality < 0 && other.dimensionality > 0) {
// Positive dimensions first // Positive dimensions first
return 1; return 1;
} }
if (dimensionality > 0 && other.dimensionality < 0) { if (dimensionality > 0 && other.dimensionality < 0) {
return -1; return -1;
} }
if (index < other.index) { if (index < other.index) {
return -1; return -1;
skipping to change at line 67 skipping to change at line 78
/** /**
* Return whether this SingleUnitImpl is compatible with another for the pur pose of coalescing. * Return whether this SingleUnitImpl is compatible with another for the pur pose of coalescing.
* *
* Units with the same base unit and SI prefix should match, except that the y must also have * Units with the same base unit and SI prefix should match, except that the y must also have
* the same dimensionality sign, such that we don't merge numerator and deno minator. * the same dimensionality sign, such that we don't merge numerator and deno minator.
*/ */
bool isCompatibleWith(const SingleUnitImpl& other) const { bool isCompatibleWith(const SingleUnitImpl& other) const {
return (compareTo(other) == 0); return (compareTo(other) == 0);
} }
/** Simple unit index, unique for every simple unit. */ /**
int32_t index = 0; * Returns true if this unit is the "dimensionless base unit", as produced
* by the MeasureUnit() default constructor. (This does not include the
* likes of concentrations or angles.)
*/
bool isDimensionless() const {
return index == -1;
}
/** Simple unit identifier; memory not owned by the SimpleUnit. */ /**
StringPiece identifier; * Simple unit index, unique for every simple unit, -1 for the dimensionless
* unit. This is an index into a string list in measunit_extra.cpp.
*
* The default value is -1, meaning the dimensionless unit:
* isDimensionless() will return true, until index is changed.
*/
int32_t index = -1;
/** SI prefix. **/ /**
* SI prefix.
*
* This is ignored for the dimensionless unit.
*/
UMeasureSIPrefix siPrefix = UMEASURE_SI_PREFIX_ONE; UMeasureSIPrefix siPrefix = UMEASURE_SI_PREFIX_ONE;
/** Dimensionality. **/ /**
* Dimensionality.
*
* This is meaningless for the dimensionless unit.
*/
int32_t dimensionality = 1; int32_t dimensionality = 1;
}; };
/** /**
* Internal representation of measurement units. Capable of representing all com plexities of units, * Internal representation of measurement units. Capable of representing all com plexities of units,
* including mixed and compound units. * including mixed and compound units.
*/ */
struct MeasureUnitImpl : public UMemory { struct MeasureUnitImpl : public UMemory {
/** Extract the MeasureUnitImpl from a MeasureUnit. */ /** Extract the MeasureUnitImpl from a MeasureUnit. */
static inline const MeasureUnitImpl* get(const MeasureUnit& measureUnit) { static inline const MeasureUnitImpl* get(const MeasureUnit& measureUnit) {
return measureUnit.fImpl; return measureUnit.fImpl;
} }
/** /**
* Parse a unit identifier into a MeasureUnitImpl. * Parse a unit identifier into a MeasureUnitImpl.
* *
* @param identifier The unit identifier string. * @param identifier The unit identifier string.
* @param status Set if the identifier string is not valid. * @param status Set if the identifier string is not valid.
* @return A newly parsed value object. * @return A newly parsed value object. Behaviour of this unit is
* unspecified if an error is returned via status.
*/ */
static MeasureUnitImpl forIdentifier(StringPiece identifier, UErrorCode& sta tus); static MeasureUnitImpl forIdentifier(StringPiece identifier, UErrorCode& sta tus);
/** /**
* Extract the MeasureUnitImpl from a MeasureUnit, or parse if it is not pre sent. * Extract the MeasureUnitImpl from a MeasureUnit, or parse if it is not pre sent.
* *
* @param measureUnit The source MeasureUnit. * @param measureUnit The source MeasureUnit.
* @param memory A place to write the new MeasureUnitImpl if parsing is requ ired. * @param memory A place to write the new MeasureUnitImpl if parsing is requ ired.
* @param status Set if an error occurs. * @param status Set if an error occurs.
* @return A reference to either measureUnit.fImpl or memory. * @return A reference to either measureUnit.fImpl or memory.
skipping to change at line 148 skipping to change at line 180
MeasureUnitImpl result; MeasureUnitImpl result;
result.complexity = complexity; result.complexity = complexity;
result.units.appendAll(units, status); result.units.appendAll(units, status);
result.identifier.append(identifier, status); result.identifier.append(identifier, status);
return result; return result;
} }
/** Mutates this MeasureUnitImpl to take the reciprocal. */ /** Mutates this MeasureUnitImpl to take the reciprocal. */
void takeReciprocal(UErrorCode& status); void takeReciprocal(UErrorCode& status);
/** Mutates this MeasureUnitImpl to append a single unit. */ /**
* Mutates this MeasureUnitImpl to append a single unit.
*
* @return true if a new item was added. If unit is the dimensionless unit,
* it is never added: the return value will always be false.
*/
bool append(const SingleUnitImpl& singleUnit, UErrorCode& status); bool append(const SingleUnitImpl& singleUnit, UErrorCode& status);
/** The complexity, either SINGLE, COMPOUND, or MIXED. */ /** The complexity, either SINGLE, COMPOUND, or MIXED. */
UMeasureUnitComplexity complexity = UMEASURE_UNIT_SINGLE; UMeasureUnitComplexity complexity = UMEASURE_UNIT_SINGLE;
/** /**
* The list of simple units. These may be summed or multiplied, based on the * The list of simple units. These may be summed or multiplied, based on the
value of the * value of the complexity field.
* complexity field. *
* The "dimensionless" unit (SingleUnitImpl default constructor) must not be
* added to this list.
*/ */
MaybeStackVector<SingleUnitImpl> units; MaybeStackVector<SingleUnitImpl> units;
/** /**
* The full unit identifier. Owned by the MeasureUnitImpl. Empty if not co mputed. * The full unit identifier. Owned by the MeasureUnitImpl. Empty if not co mputed.
*/ */
CharString identifier; CharString identifier;
}; };
U_NAMESPACE_END U_NAMESPACE_END
 End of changes. 9 change blocks. 
13 lines changed or deleted 52 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)