]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/cstr.cpp
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / common / cstr.cpp
1 /*
2 *******************************************************************************
3 * Copyright (C) 2015-2016, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: charstr.cpp
7 */
8 #include "unicode/utypes.h"
9 #include "unicode/unistr.h"
10
11 #include "charstr.h"
12 #include "cstr.h"
13
14 U_NAMESPACE_BEGIN
15
16 CStr::CStr(const UnicodeString &in) {
17 UErrorCode status = U_ZERO_ERROR;
18 int32_t length = in.extract(0, in.length(), NULL, (uint32_t)0);
19 int32_t resultCapacity = 0;
20 char *buf = s.getAppendBuffer(length, length, resultCapacity, status);
21 if (U_SUCCESS(status)) {
22 in.extract(0, in.length(), buf, resultCapacity);
23 s.append(buf, length, status);
24 }
25 }
26
27 CStr::~CStr() {
28 }
29
30 const char * CStr::operator ()() const {
31 return s.data();
32 }
33
34 U_NAMESPACE_END