while ((symbol = iter.next()) != NULL) {
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
(*currencySymbols)[*total_currency_symbol_count].currencyName =
- const_cast<UChar*>(symbol->getBuffer().get());
+ const_cast<UChar*>(symbol->getBuffer());
(*currencySymbols)[*total_currency_symbol_count].flag = 0;
(*currencySymbols)[(*total_currency_symbol_count)++].currencyNameLen = symbol->length();
}
* @draft ICU 59
*/
operator char16_t *() const { return get(); }
+ // TODO: do we need output conversion and other operator overloads
+ // if we do not change return values to pointer wrappers?
/**
* uint16_t pointer access via type conversion (e.g., static_cast).
* @draft ICU 59
* @see getTerminatedBuffer()
* @stable ICU 2.0
*/
- Char16Ptr getBuffer(int32_t minCapacity);
+ char16_t *getBuffer(int32_t minCapacity);
/**
* Release a read/write buffer on a UnicodeString object with an
* @see getTerminatedBuffer()
* @stable ICU 2.0
*/
- inline ConstChar16Ptr getBuffer() const;
+ inline const char16_t *getBuffer() const;
/**
* Get a read-only pointer to the internal buffer,
* @see getBuffer()
* @stable ICU 2.2
*/
- ConstChar16Ptr getTerminatedBuffer();
+ const char16_t *getTerminatedBuffer();
//========================================
// Constructors
(!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
}
-inline ConstChar16Ptr
+inline const char16_t *
UnicodeString::getBuffer() const {
if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
return nullptr;
}
}
-ConstChar16Ptr
+const char16_t *
UnicodeString::getTerminatedBuffer() {
if(!isWritable()) {
return nullptr;
// External Buffer
//========================================
-Char16Ptr
+char16_t *
UnicodeString::getBuffer(int32_t minCapacity) {
if(minCapacity>=-1 && cloneArrayIfNeeded(minCapacity)) {
fUnion.fFields.fLengthAndFlags|=kOpenGetBuffer;
UnicodeString str(name, "");
putchar('\t');
- u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
u_wmsg_errorName(err));
goto error_cleanup;
} else {
if (U_FAILURE(err)) {
UnicodeString str(name, "");
putchar('\t');
- u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
u_wmsg_errorName(err));
goto error_cleanup;
}
UnicodeString str2(strerror(errno), "");
str2.append((UChar32) 0);
initMsg(pname);
- u_wmsg(stderr, "cantOpenInputF", str1.getBuffer().get(), str2.getBuffer().get());
+ u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer());
return FALSE;
}
closeFile = TRUE;
UChar linebuf[20], offsetbuf[20];
uprv_itou(linebuf, 20, parse.line, 10, 0);
uprv_itou(offsetbuf, 20, parse.offset, 10, 0);
- u_wmsg(stderr, "cantCreateTranslitParseErr", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantCreateTranslitParseErr", str.getTerminatedBuffer(),
u_wmsg_errorName(err), linebuf, offsetbuf);
} else {
- u_wmsg(stderr, "cantCreateTranslit", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantCreateTranslit", str.getTerminatedBuffer(),
u_wmsg_errorName(err));
}
if (U_FAILURE(err)) {
UnicodeString str(fromcpage, "");
initMsg(pname);
- u_wmsg(stderr, "cantOpenFromCodeset", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantOpenFromCodeset", str.getTerminatedBuffer(),
u_wmsg_errorName(err));
goto error_exit;
}
if (U_FAILURE(err)) {
UnicodeString str(tocpage, "");
initMsg(pname);
- u_wmsg(stderr, "cantOpenToCodeset", str.getTerminatedBuffer().get(),
+ u_wmsg(stderr, "cantOpenToCodeset", str.getTerminatedBuffer(),
u_wmsg_errorName(err));
goto error_exit;
}
if (ferror(infile) != 0) {
UnicodeString str(strerror(errno));
initMsg(pname);
- u_wmsg(stderr, "cantRead", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "cantRead", str.getTerminatedBuffer());
goto error_exit;
}
initMsg(pname);
u_wmsg(stderr, "problemCvtToU",
- UnicodeString(pos, length, "").getTerminatedBuffer().get(),
- str.getTerminatedBuffer().get(),
+ UnicodeString(pos, length, "").getTerminatedBuffer(),
+ str.getTerminatedBuffer(),
u_wmsg_errorName(err));
willexit = TRUE;
initMsg(pname);
u_wmsg(stderr, errtag,
- UnicodeString(pos, length, "").getTerminatedBuffer().get(),
- str.getTerminatedBuffer().get(),
+ UnicodeString(pos, length, "").getTerminatedBuffer(),
+ str.getTerminatedBuffer(),
u_wmsg_errorName(err));
- u_wmsg(stderr, "errorUnicode", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "errorUnicode", str.getTerminatedBuffer());
willexit = TRUE;
err = U_ZERO_ERROR; /* reset the error for the rest of the conversion. */
if (wr != outlen) {
UnicodeString str(strerror(errno));
initMsg(pname);
- u_wmsg(stderr, "cantWrite", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "cantWrite", str.getTerminatedBuffer());
willexit = TRUE;
}
UnicodeString upname(pname, (int32_t)(uprv_strlen(pname) + 1));
UnicodeString mname(msg, msgLen + 1);
- res = u_wmsg(fp, "usage", mname.getBuffer().get(), upname.getBuffer().get());
+ res = u_wmsg(fp, "usage", mname.getBuffer(), upname.getBuffer());
if (!ecode) {
if (!res) {
fputc('\n', fp);
initMsg(pname);
UnicodeString str(*iter);
initMsg(pname);
- u_wmsg(stderr, "badBlockSize", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "badBlockSize", str.getTerminatedBuffer());
return 3;
}
} else {
if (U_FAILURE(e) || !printName) {
UnicodeString str(*iter);
initMsg(pname);
- u_wmsg(stderr, "noSuchCodeset", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "noSuchCodeset", str.getTerminatedBuffer());
return 2;
}
} else
} else {
UnicodeString str(*iter);
initMsg(pname);
- u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
return 4;
}
} else {
} else {
UnicodeString str(*iter);
initMsg(pname);
- u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
return 4;
}
} else {
} else {
UnicodeString str(*iter);
initMsg(pname);
- u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer().get());
+ u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
return 4;
}
} else {
UnicodeString str2(strerror(errno), "");
initMsg(pname);
u_wmsg(stderr, "cantCreateOutputF",
- str1.getBuffer().get(), str2.getBuffer().get());
+ str1.getBuffer(), str2.getBuffer());
return 1;
}
} else {
UBool forData(const CollationData &data, UErrorCode &errorCode);
const uint16_t *getTable() const {
- return result.getBuffer();
+ return reinterpret_cast<const uint16_t *>(result.getBuffer());
}
int32_t lengthOfTable() const { return result.length(); }
//------------------------------------------------------
-ConstChar16Ptr U_EXPORT2
+const char16_t * U_EXPORT2
DateFormatSymbols::getPatternUChars(void)
{
return gPatternChars;
}
}
-ConstChar16Ptr NumberFormat::getCurrency() const {
+const char16_t* NumberFormat::getCurrency() const {
return fCurrency;
}
UErrorCode& status) const
{
translatePattern(fPattern, result,
- UnicodeString(DateFormatSymbols::getPatternUChars().get()),
+ UnicodeString(DateFormatSymbols::getPatternUChars()),
fSymbols->fLocalPatternChars, status);
return result;
}
{
translatePattern(pattern, fPattern,
fSymbols->fLocalPatternChars,
- UnicodeString(DateFormatSymbols::getPatternUChars().get()), status);
+ UnicodeString(DateFormatSymbols::getPatternUChars()), status);
}
//----------------------------------------------------------------------
* Return the ISO currency code of this object.
* @stable ICU 3.0
*/
- inline ConstChar16Ptr getISOCurrency() const;
+ inline const char16_t* getISOCurrency() const;
};
inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
return (const CurrencyUnit&) getUnit();
}
-inline ConstChar16Ptr CurrencyAmount::getISOCurrency() const {
+inline const char16_t* CurrencyAmount::getISOCurrency() const {
return getCurrency().getISOCurrency();
}
* Return the ISO currency code of this object.
* @stable ICU 3.0
*/
- inline ConstChar16Ptr getISOCurrency() const;
+ inline const char16_t* getISOCurrency() const;
private:
/**
char16_t isoCode[4];
};
-inline ConstChar16Ptr CurrencyUnit::getISOCurrency() const {
+inline const char16_t* CurrencyUnit::getISOCurrency() const {
return isoCode;
}
* @return the non-localized date-time pattern characters
* @stable ICU 2.0
*/
- static ConstChar16Ptr U_EXPORT2 getPatternUChars(void);
+ static const char16_t * U_EXPORT2 getPatternUChars(void);
/**
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
* the currency in use, or a pointer to the empty string.
* @stable ICU 2.6
*/
- ConstChar16Ptr getCurrency() const;
+ const char16_t* getCurrency() const;
/**
* Set a particular UDisplayContext value in the formatter, such as
break;
case UNUM_CURRENCY_CODE:
- res = UnicodeString(df->getCurrency().get());
+ res = UnicodeString(df->getCurrency());
break;
default:
*/
//if (date[1] != date[2] || result[0] != result[1]) {
if (date[1] != date[2]) {
- errln("Round trip failure: \"%S\" (%f), \"%S\" (%f)",
- static_cast<const UChar *>(result[0].getBuffer()), date[1],
- static_cast<const UChar *>(result[1].getBuffer()), date[2]);
+ errln("Round trip failure: \"%S\" (%f), \"%S\" (%f)", result[0].getBuffer(), date[1], result[1].getBuffer(), date[2]);
}
}
// local pattern chars data is not longer loaded
// from icu locale bundle
assertEquals("patternChars", PATTERN_CHARS, rootSyms.getLocalPatternChars(buf));
- assertEquals("patternChars", PATTERN_CHARS, DateFormatSymbols::getPatternUChars().get());
+ assertEquals("patternChars", PATTERN_CHARS, DateFormatSymbols::getPatternUChars());
assertTrue("DATEFORMAT_FIELD_NAMES", DATEFORMAT_FIELD_NAMES_LENGTH == UDAT_FIELD_COUNT);
#if UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR
assertTrue("Data", UDAT_FIELD_COUNT == uprv_strlen(PATTERN_CHARS));
case Formattable::kObject: {
const CurrencyAmount* c = dynamic_cast<const CurrencyAmount*>(f.getObject());
if (c != NULL) {
- s = _toString(c->getNumber()) + " " + UnicodeString(c->getISOCurrency().get());
+ s = _toString(c->getNumber()) + " " + UnicodeString(c->getISOCurrency());
} else {
s = UnicodeString("Unknown UObject");
}
u_uastrcpy(USD, "USD");
UErrorCode status = U_ZERO_ERROR;
CurrencyAmount USD_1(1.0, USD, status);
- assertEquals("Currency Code", USD, USD_1.getISOCurrency().get());
+ assertEquals("Currency Code", USD, USD_1.getISOCurrency());
CurrencyAmount USD_2(2.0, USD, status);
CurrencyAmount USD_NEG_1(-1.0, USD, status);
if (!assertSuccess("Error creating currencies", status)) {
}
return TRUE;
}
- UnicodeString currStr(currAmt->getISOCurrency().get());
+ UnicodeString currStr(currAmt->getISOCurrency());
Formattable resultFormattable(currAmt->getNumber());
UnicodeString resultStr(UnicodeString::fromUTF8(resultFormattable.getDecimalNumber(status)));
if (tuple.output == "fail") {
uprv_strcpy(theOperation, theInfo);
uprv_strcat(theOperation, ", check currency:");
- assertEquals(theOperation, currency, currencyAmount->getISOCurrency().get());
+ assertEquals(theOperation, currency, currencyAmount->getISOCurrency());
}
} else if (result.getType() != Formattable::kObject ||
(curramt = dynamic_cast<const CurrencyAmount*>(result.getObject())) == NULL ||
curramt->getNumber().getDouble() != 1234.56 ||
- UnicodeString(curramt->getISOCurrency().get()).compare(ISO_CURRENCY_USD)
+ UnicodeString(curramt->getISOCurrency()).compare(ISO_CURRENCY_USD)
) {
errln("FAIL: getCurrencyFormat of default locale (en_US) failed roundtripping the number ");
if (curramt->getNumber().getDouble() != 1234.56) {
errln((UnicodeString)"wong number, expect: 1234.56" + ", got: " + curramt->getNumber().getDouble());
}
if (curramt->getISOCurrency() != ISO_CURRENCY_USD) {
- errln((UnicodeString)"wong currency, expect: USD" + ", got: " + curramt->getISOCurrency().get());
+ errln((UnicodeString)"wong currency, expect: USD" + ", got: " + curramt->getISOCurrency());
}
}
}
appendErr.append("fFormat currency != ")
.append(kUSD)
.append(", =")
- .append(fFormat->getCurrency().get())
+ .append(fFormat->getCurrency())
.append("! ");
okay = FALSE;
}
appendErr.append("gFormat currency != ")
.append(kUSD)
.append(", =")
- .append(gSharedData->fFormat->getCurrency().get())
+ .append(gSharedData->fFormat->getCurrency())
.append("! ");
okay = FALSE;
}
}
// test releaseBuffer() with a NUL-terminated buffer
- test1.getBuffer(20).get()[2]=0;
+ test1.getBuffer(20)[2]=0;
test1.releaseBuffer(); // implicit -1
if(test1.length()!=2 || test1.charAt(0)!=1 || test1.charAt(1) !=2) {
errln("UnicodeString::releaseBuffer(-1) does not properly set the length of the UnicodeString");
// writable alias to another string's buffer: very bad idea, just convenient for this test
test3.setToBogus();
if(!test3.isBogus() ||
- test3.setTo(const_cast<UChar *>(test1.getBuffer().get()),
+ test3.setTo(const_cast<UChar *>(test1.getBuffer()),
test1.length(), test1.getCapacity()).isBogus() ||
test3!=test1) {
errln("bogus.setTo(writable alias) failed");
if (f16BitUnits.length() <= 1) {
// no pool strings to checksum
} else if (U_IS_BIG_ENDIAN) {
- checksum = computeCRC(reinterpret_cast<const char *>(f16BitUnits.getBuffer().get()),
+ checksum = computeCRC(reinterpret_cast<const char *>(f16BitUnits.getBuffer()),
(uint32_t)f16BitUnits.length() * 2, checksum);
} else {
// Swap to big-endian so we get the same checksum on all platforms
UnicodeString s(f16BitUnits);
s.append((UChar)1); // Ensure that we own this buffer.
assert(!s.isBogus());
- uint16_t *p = const_cast<uint16_t *>(static_cast<const uint16_t *>(s.getBuffer()));
+ uint16_t *p = const_cast<uint16_t *>(reinterpret_cast<const uint16_t *>(s.getBuffer()));
for (int32_t count = f16BitUnits.length(); count > 0; --count) {
uint16_t x = *p;
*p++ = (uint16_t)((x << 8) | (x >> 8));