22#ifndef __STRINGPIECE_H__
23#define __STRINGPIECE_H__
76 : ptr_(str.data()), length_(
static_cast<int32_t>(str.size())) { }
83 StringPiece(
const char* offset, int32_t len) : ptr_(offset), length_(len) { }
111 const char*
data()
const {
return ptr_; }
117 int32_t
size()
const {
return length_; }
123 int32_t
length()
const {
return length_; }
150 void set(
const char* str);
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A string-like object that points to a sized piece of memory.
StringPiece substr(int32_t pos, int32_t len=npos) const
Returns a substring of this StringPiece.
UBool empty() const
Returns whether the string is empty.
StringPiece(const char *str)
Constructs from a NUL-terminated const char * pointer.
void set(const char *str)
Reset the stringpiece to refer to new data.
StringPiece(const StringPiece &x, int32_t pos, int32_t len)
Substring of another StringPiece.
static const int32_t npos
Maximum integer, used as a default value for substring methods.
void clear()
Sets to an empty string.
const char * data() const
Returns the string pointer.
StringPiece()
Default constructor, creates an empty StringPiece.
void set(const char *xdata, int32_t len)
Reset the stringpiece to refer to new data.
int32_t size() const
Returns the string length.
void remove_prefix(int32_t n)
Removes the first n string units.
void remove_suffix(int32_t n)
Removes the last n string units.
int32_t length() const
Returns the string length.
StringPiece(const StringPiece &x, int32_t pos)
Substring of another StringPiece.
StringPiece(const std::string &str)
Constructs from a std::string.
StringPiece(const char *offset, int32_t len)
Constructs from a const char * pointer and a specified length.
UMemory is the common ICU base class.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
C++ API: Central ICU header for including the C++ standard <string> header and for related definition...
int8_t UBool
The ICU boolean type.
C++ API: Common ICU base class UObject.
Basic definitions for ICU, for both C and C++ APIs.
#define NULL
Define NULL if necessary, to nullptr for C++ and to ((void *)0) for C.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.