// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3******************************************************************************4*5* Copyright (C) 2016, International Business Machines6* Corporation and others. All Rights Reserved.7*8******************************************************************************9*10* File: cstr.h11*/1213#ifndef CSTR_H14#define CSTR_H1516#include "unicode/unistr.h"17#include "unicode/uobject.h"18#include "unicode/utypes.h"1920#include "charstr.h"2122/**23* ICU-internal class CStr, a small helper class to facilitate passing UnicodeStrings24* to functions needing (const char *) strings, such as printf().25*26* It is intended primarily for use in debugging or in tests. Uses platform27* default code page conversion, which will do the best job possible,28* but may be lossy, depending on the platform.29*30* If no other conversion is available, use invariant conversion and substitute31* '?' for non-invariant characters.32*33* Example Usage:34* UnicodeString s = whatever;35* printf("%s", CStr(s)());36*37* The explicit call to the CStr() constructor creates a temporary object.38* Operator () on the temporary object returns a (const char *) pointer.39* The lifetime of the (const char *) data is that of the temporary object,40* which works well when passing it as a parameter to another function, such as printf.41*/4243U_NAMESPACE_BEGIN4445class U_COMMON_API CStr : public UMemory {46public:47CStr(const UnicodeString &in);48~CStr();49const char * operator ()() const;5051private:52CharString s;53CStr(const CStr &other) = delete; // Forbid copying of this class.54CStr &operator =(const CStr &other) = delete; // Forbid assignment.55};5657U_NAMESPACE_END5859#endif606162