mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 18:25:57 +00:00
Touch-ups to the API surface
This commit is contained in:
parent
ace6be95bd
commit
a27fa850ea
2 changed files with 41 additions and 26 deletions
|
@ -378,7 +378,7 @@ public:
|
|||
* @param p simple pointer to an array of T objects that is adopted
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
explicit LocalArray(T *p=nullptr) : LocalPointerBase<T>(p), fLength(p==nullptr?0:-1) {}
|
||||
explicit LocalArray(T *p=nullptr) : LocalPointerBase<T>(p), fLength(0) {}
|
||||
/**
|
||||
* Constructor takes ownership and reports an error if nullptr.
|
||||
*
|
||||
|
@ -397,6 +397,18 @@ public:
|
|||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/** Constructor for withLengthAndCheckErrorCode() */
|
||||
LocalArray(T *p, int32_t length, UErrorCode &errorCode) : LocalArray<T>(p) {
|
||||
if (p != nullptr) {
|
||||
fLength = length;
|
||||
} else if (U_SUCCESS(errorCode)) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Move constructor, leaves src with isNull().
|
||||
* @param src source smart pointer
|
||||
|
@ -410,13 +422,15 @@ public:
|
|||
/**
|
||||
* Construct a LocalArray with a specified length.
|
||||
*
|
||||
* @param p Pointer to the array to adopt.
|
||||
* @param length The length of the array.
|
||||
* @return A LocalArray with a length field.
|
||||
* @param p simple pointer to an array of T objects that is adopted
|
||||
* @param length number of valid objects in the array, accesible via length()
|
||||
* @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR
|
||||
* if p==nullptr and no other failure code had been set
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
static LocalArray<T> withLength(T *p, int32_t length) {
|
||||
return LocalArray(p, length);
|
||||
static LocalArray<T> withLengthAndCheckErrorCode(T *p, int32_t length, UErrorCode& status) {
|
||||
return LocalArray(p, length, status);
|
||||
}
|
||||
#endif // U_HIDE_DRAFT_API
|
||||
|
||||
|
@ -454,6 +468,7 @@ public:
|
|||
LocalPointerBase<T>::ptr=src.ptr;
|
||||
src.ptr=nullptr;
|
||||
fLength=src.fLength;
|
||||
src.fLength=0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -468,7 +483,7 @@ public:
|
|||
*/
|
||||
LocalArray<T> &operator=(std::unique_ptr<T[]> &&p) U_NOEXCEPT {
|
||||
adoptInstead(p.release());
|
||||
fLength=-1;
|
||||
fLength=0;
|
||||
return *this;
|
||||
}
|
||||
#endif /* U_HIDE_DRAFT_API */
|
||||
|
@ -504,7 +519,7 @@ public:
|
|||
void adoptInstead(T *p) {
|
||||
delete[] LocalPointerBase<T>::ptr;
|
||||
LocalPointerBase<T>::ptr=p;
|
||||
fLength=-1;
|
||||
fLength=0;
|
||||
}
|
||||
/**
|
||||
* Deletes the array it owns,
|
||||
|
@ -531,7 +546,7 @@ public:
|
|||
} else {
|
||||
delete[] p;
|
||||
}
|
||||
fLength=-1;
|
||||
fLength=0;
|
||||
}
|
||||
/**
|
||||
* Array item access (writable).
|
||||
|
@ -564,14 +579,14 @@ public:
|
|||
* The length of the array contained in the LocalArray. The size must be
|
||||
* provided when the LocalArray is constructed.
|
||||
*
|
||||
* @return The length of the array, or -1 if unknown.
|
||||
* @return The length of the array, or 0 if unknown.
|
||||
* @draft ICU 67
|
||||
*/
|
||||
int32_t length() const { return fLength; }
|
||||
#endif // U_HIDE_DRAFT_API
|
||||
|
||||
private:
|
||||
int32_t fLength = -1;
|
||||
int32_t fLength = 0;
|
||||
|
||||
LocalArray(T *p, int32_t length) : LocalArray(p) {
|
||||
fLength = length;
|
||||
|
|
|
@ -40,8 +40,8 @@ struct MeasureUnitImpl;
|
|||
* square-kilometer, kilojoule, one-per-second.
|
||||
* - COMPOUND: A unit composed of the product of multiple single units. Examples:
|
||||
* meter-per-second, kilowatt-hour, kilogram-meter-per-square-second.
|
||||
* - SEQUENCE: A unit composed of the sum of multiple compound units. Examples: foot+inch,
|
||||
* hour+minute+second, hectare+square-meter.
|
||||
* - SEQUENCE: A unit composed of the sum of multiple single units. Examples: foot+inch,
|
||||
* hour+minute+second, degree+arcminute+arcsecond.
|
||||
*
|
||||
* The complexity determines which operations are available. For example, you cannot set the power
|
||||
* or SI prefix of a compound unit.
|
||||
|
@ -135,91 +135,91 @@ typedef enum UMeasureSIPrefix {
|
|||
UMEASURE_SI_PREFIX_KILO = 3,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: hecto, 10^2.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_HECTO = 2,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: deka, 10^1.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_DEKA = 1,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* The absence of an SI prefix.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_ONE = 0,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: deci, 10^-1.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_DECI = -1,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: centi, 10^-2.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_CENTI = -2,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: milli, 10^-3.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_MILLI = -3,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: micro, 10^-6.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_MICRO = -6,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: nano, 10^-9.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_NANO = -9,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: pico, 10^-12.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_PICO = -12,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: femto, 10^-15.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_FEMTO = -15,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: atto, 10^-18.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_ATTO = -18,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: zepto, 10^-21.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
UMEASURE_SI_PREFIX_ZEPTO = -21,
|
||||
|
||||
/**
|
||||
* SI prefix: FIXME, 10^FIXME.
|
||||
* SI prefix: yocto, 10^-24.
|
||||
*
|
||||
* @draft ICU 67
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue