]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/cstr.h
2 ******************************************************************************
4 * Copyright (C) 2015, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
15 #include "unicode/unistr.h"
16 #include "unicode/uobject.h"
17 #include "unicode/utypes.h"
22 * ICU-internal class CStr, a small helper class to facilitate passing UnicodStrings
23 * to functions needing (const char *) strings, such as printf().
25 * It is intended primarily for use in debugging or in tests. Uses platform
26 * default code page conversion, which will do the best job possible,
27 * but may be lossy, depending on the platform.
30 * UnicodeString s = whatever;
31 * printf("%s", CStr(s)());
33 * The explicit call to the CStr() constructor creates a temporary object.
34 * Operator () on the temporary object returns a (const char *) pointer.
35 * The lifetime of the (const char *) data is that of the temporary object,
36 * which works well when passing it as a parameter to another function, such as printf.
41 class U_COMMON_API CStr
: public UMemory
{
43 CStr(const UnicodeString
&in
);
45 const char * operator ()() const;
49 CStr(const CStr
&other
); // Forbid copying of this class.
50 CStr
&operator =(const CStr
&other
); // Forbid assignment.