webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Public Member Functions | Static Public Attributes | List of all members
StringPiece Class Reference

#include <stringpiece.h>

Inheritance diagram for StringPiece:
UMemory UMemory UMemory

Public Member Functions

 StringPiece ()
 
 StringPiece (const char *str)
 
 StringPiece (const char *offset, int32_t len)
 
 StringPiece (const StringPiece &x, int32_t pos)
 
 StringPiece (const StringPiece &x, int32_t pos, int32_t len)
 
const char * data () const
 
int32_t size () const
 
int32_t length () const
 
UBool empty () const
 
void clear ()
 
void set (const char *xdata, int32_t len)
 
void set (const char *str)
 
void remove_prefix (int32_t n)
 
void remove_suffix (int32_t n)
 
StringPiece substr (int32_t pos, int32_t len=npos) const
 
 StringPiece ()
 
 StringPiece (const char *str)
 
 StringPiece (const char *offset, int32_t len)
 
 StringPiece (const StringPiece &x, int32_t pos)
 
 StringPiece (const StringPiece &x, int32_t pos, int32_t len)
 
const char * data () const
 
int32_t size () const
 
int32_t length () const
 
UBool empty () const
 
void clear ()
 
void set (const char *xdata, int32_t len)
 
void set (const char *str)
 
void remove_prefix (int32_t n)
 
void remove_suffix (int32_t n)
 
StringPiece substr (int32_t pos, int32_t len=npos) const
 
 StringPiece ()
 
 StringPiece (const char *str)
 
 StringPiece (const char *offset, int32_t len)
 
 StringPiece (const StringPiece &x, int32_t pos)
 
 StringPiece (const StringPiece &x, int32_t pos, int32_t len)
 
const char * data () const
 
int32_t size () const
 
int32_t length () const
 
UBool empty () const
 
void clear ()
 
void set (const char *xdata, int32_t len)
 
void set (const char *str)
 
void remove_prefix (int32_t n)
 
void remove_suffix (int32_t n)
 
StringPiece substr (int32_t pos, int32_t len=npos) const
 

Static Public Attributes

static const int32_t npos
 

Detailed Description

A string-like object that points to a sized piece of memory.

We provide non-explicit singleton constructors so users can pass in a "const char*" or a "string" wherever a "StringPiece" is expected.

Functions or methods may use const StringPiece& parameters to accept either a "const char*" or a "string" value that will be implicitly converted to a StringPiece.

Systematic usage of StringPiece is encouraged as it will reduce unnecessary conversions from "const char*" to "string" and back again.

ICU 4.2

Constructor & Destructor Documentation

◆ StringPiece() [1/15]

StringPiece::StringPiece ( )
inline

Default constructor, creates an empty StringPiece. ICU 4.2

◆ StringPiece() [2/15]

StringPiece::StringPiece ( const char *  str)

Constructs from a NUL-terminated const char * pointer.

Parameters
stra NUL-terminated const char * pointer ICU 4.2

◆ StringPiece() [3/15]

StringPiece::StringPiece ( const char *  offset,
int32_t  len 
)
inline

Constructs from a const char * pointer and a specified length.

Parameters
offseta const char * pointer (need not be terminated)
lenthe length of the string; must be non-negative ICU 4.2

◆ StringPiece() [4/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length(). ICU 4.2

◆ StringPiece() [5/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos,
int32_t  len 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length().
lenlength of the substring; must be non-negative and will be pinned to at most x.length() - pos. ICU 4.2

◆ StringPiece() [6/15]

StringPiece::StringPiece ( )
inline

Default constructor, creates an empty StringPiece. ICU 4.2

◆ StringPiece() [7/15]

StringPiece::StringPiece ( const char *  str)

Constructs from a NUL-terminated const char * pointer.

Parameters
stra NUL-terminated const char * pointer ICU 4.2

◆ StringPiece() [8/15]

StringPiece::StringPiece ( const char *  offset,
int32_t  len 
)
inline

Constructs from a const char * pointer and a specified length.

Parameters
offseta const char * pointer (need not be terminated)
lenthe length of the string; must be non-negative ICU 4.2

◆ StringPiece() [9/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length(). ICU 4.2

◆ StringPiece() [10/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos,
int32_t  len 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length().
lenlength of the substring; must be non-negative and will be pinned to at most x.length() - pos. ICU 4.2

◆ StringPiece() [11/15]

StringPiece::StringPiece ( )
inline

Default constructor, creates an empty StringPiece. ICU 4.2

◆ StringPiece() [12/15]

StringPiece::StringPiece ( const char *  str)

Constructs from a NUL-terminated const char * pointer.

Parameters
stra NUL-terminated const char * pointer ICU 4.2

◆ StringPiece() [13/15]

StringPiece::StringPiece ( const char *  offset,
int32_t  len 
)
inline

Constructs from a const char * pointer and a specified length.

Parameters
offseta const char * pointer (need not be terminated)
lenthe length of the string; must be non-negative ICU 4.2

◆ StringPiece() [14/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length(). ICU 4.2

◆ StringPiece() [15/15]

StringPiece::StringPiece ( const StringPiece x,
int32_t  pos,
int32_t  len 
)

Substring of another StringPiece.

Parameters
xthe other StringPiece
posstart position in x; must be non-negative and <= x.length().
lenlength of the substring; must be non-negative and will be pinned to at most x.length() - pos. ICU 4.2

Member Function Documentation

◆ clear() [1/3]

void StringPiece::clear ( )
inline

Sets to an empty string. ICU 4.2

◆ clear() [2/3]

void StringPiece::clear ( )
inline

Sets to an empty string. ICU 4.2

◆ clear() [3/3]

void StringPiece::clear ( )
inline

Sets to an empty string. ICU 4.2

◆ data() [1/3]

const char* StringPiece::data ( ) const
inline

Returns the string pointer. May be NULL if it is empty.

data() may return a pointer to a buffer with embedded NULs, and the returned buffer may or may not be null terminated. Therefore it is typically a mistake to pass data() to a routine that expects a NUL terminated string.

Returns
the string pointer ICU 4.2

◆ data() [2/3]

const char* StringPiece::data ( ) const
inline

Returns the string pointer. May be NULL if it is empty.

data() may return a pointer to a buffer with embedded NULs, and the returned buffer may or may not be null terminated. Therefore it is typically a mistake to pass data() to a routine that expects a NUL terminated string.

Returns
the string pointer ICU 4.2

◆ data() [3/3]

const char* StringPiece::data ( ) const
inline

Returns the string pointer. May be NULL if it is empty.

data() may return a pointer to a buffer with embedded NULs, and the returned buffer may or may not be null terminated. Therefore it is typically a mistake to pass data() to a routine that expects a NUL terminated string.

Returns
the string pointer ICU 4.2

◆ empty() [1/3]

UBool StringPiece::empty ( ) const
inline

Returns whether the string is empty.

Returns
TRUE if the string is empty ICU 4.2

◆ empty() [2/3]

UBool StringPiece::empty ( ) const
inline

Returns whether the string is empty.

Returns
TRUE if the string is empty ICU 4.2

◆ empty() [3/3]

UBool StringPiece::empty ( ) const
inline

Returns whether the string is empty.

Returns
TRUE if the string is empty ICU 4.2

◆ length() [1/3]

int32_t StringPiece::length ( void  ) const
inline

Returns the string length. Same as size().

Returns
the string length ICU 4.2

◆ length() [2/3]

int32_t StringPiece::length ( void  ) const
inline

Returns the string length. Same as size().

Returns
the string length ICU 4.2

◆ length() [3/3]

int32_t StringPiece::length ( void  ) const
inline

Returns the string length. Same as size().

Returns
the string length ICU 4.2

◆ remove_prefix() [1/3]

void StringPiece::remove_prefix ( int32_t  n)
inline

Removes the first n string units.

Parameters
nprefix length, must be non-negative and <=length() ICU 4.2

◆ remove_prefix() [2/3]

void StringPiece::remove_prefix ( int32_t  n)
inline

Removes the first n string units.

Parameters
nprefix length, must be non-negative and <=length() ICU 4.2

◆ remove_prefix() [3/3]

void StringPiece::remove_prefix ( int32_t  n)
inline

Removes the first n string units.

Parameters
nprefix length, must be non-negative and <=length() ICU 4.2

◆ remove_suffix() [1/3]

void StringPiece::remove_suffix ( int32_t  n)
inline

Removes the last n string units.

Parameters
nsuffix length, must be non-negative and <=length() ICU 4.2

◆ remove_suffix() [2/3]

void StringPiece::remove_suffix ( int32_t  n)
inline

Removes the last n string units.

Parameters
nsuffix length, must be non-negative and <=length() ICU 4.2

◆ remove_suffix() [3/3]

void StringPiece::remove_suffix ( int32_t  n)
inline

Removes the last n string units.

Parameters
nsuffix length, must be non-negative and <=length() ICU 4.2

◆ set() [1/6]

void StringPiece::set ( const char *  xdata,
int32_t  len 
)
inline

Reset the stringpiece to refer to new data.

Parameters
xdatapointer the new string data. Need not be nul terminated.
lenthe length of the new data ICU 4.8

◆ set() [2/6]

void StringPiece::set ( const char *  xdata,
int32_t  len 
)
inline

Reset the stringpiece to refer to new data.

Parameters
xdatapointer the new string data. Need not be nul terminated.
lenthe length of the new data ICU 4.8

◆ set() [3/6]

void StringPiece::set ( const char *  xdata,
int32_t  len 
)
inline

Reset the stringpiece to refer to new data.

Parameters
xdatapointer the new string data. Need not be nul terminated.
lenthe length of the new data ICU 4.8

◆ set() [4/6]

void StringPiece::set ( const char *  str)

Reset the stringpiece to refer to new data.

Parameters
stra pointer to a NUL-terminated string. ICU 4.8

◆ set() [5/6]

void StringPiece::set ( const char *  str)

Reset the stringpiece to refer to new data.

Parameters
stra pointer to a NUL-terminated string. ICU 4.8

◆ set() [6/6]

void StringPiece::set ( const char *  str)

Reset the stringpiece to refer to new data.

Parameters
stra pointer to a NUL-terminated string. ICU 4.8

◆ size() [1/3]

int32_t StringPiece::size ( ) const
inline

Returns the string length. Same as length().

Returns
the string length ICU 4.2

◆ size() [2/3]

int32_t StringPiece::size ( ) const
inline

Returns the string length. Same as length().

Returns
the string length ICU 4.2

◆ size() [3/3]

int32_t StringPiece::size ( ) const
inline

Returns the string length. Same as length().

Returns
the string length ICU 4.2

◆ substr() [1/3]

StringPiece StringPiece::substr ( int32_t  pos,
int32_t  len = npos 
) const
inline

Returns a substring of this StringPiece.

Parameters
posstart position; must be non-negative and <= length().
lenlength of the substring; must be non-negative and will be pinned to at most length() - pos.
Returns
the substring StringPiece ICU 4.2

◆ substr() [2/3]

StringPiece StringPiece::substr ( int32_t  pos,
int32_t  len = npos 
) const
inline

Returns a substring of this StringPiece.

Parameters
posstart position; must be non-negative and <= length().
lenlength of the substring; must be non-negative and will be pinned to at most length() - pos.
Returns
the substring StringPiece ICU 4.2

◆ substr() [3/3]

StringPiece StringPiece::substr ( int32_t  pos,
int32_t  len = npos 
) const
inline

Returns a substring of this StringPiece.

Parameters
posstart position; must be non-negative and <= length().
lenlength of the substring; must be non-negative and will be pinned to at most length() - pos.
Returns
the substring StringPiece ICU 4.2

Member Data Documentation

◆ npos

static const int32_t StringPiece::npos
static

Maximum integer, used as a default value for substring methods. ICU 4.2


The documentation for this class was generated from the following file: