#include <stringpiece.h>

Public Member Functions | |
| StringPiece () | |
| Default constructor, creates an empty StringPiece. | |
| StringPiece (const char *str) | |
| Constructs from a NUL-terminated const char * pointer. | |
| StringPiece (const char *offset, int32_t len) | |
| Constructs from a const char * pointer and a specified length. | |
| StringPiece (const StringPiece &x, int32_t pos) | |
| Substring of another StringPiece. | |
| StringPiece (const StringPiece &x, int32_t pos, int32_t len) | |
| Substring of another StringPiece. | |
| const char * | data () const |
| Returns the string pointer. | |
| int32_t | size () const |
| Returns the string length. | |
| int32_t | length () const |
| Returns the string length. | |
| UBool | empty () const |
| Returns whether the string is empty. | |
| void | clear () |
| Sets to an empty string. | |
| void | remove_prefix (int32_t n) |
| Removes the first n string units. | |
| void | remove_suffix (int32_t n) |
| Removes the last n string units. | |
| StringPiece | substr (int32_t pos, int32_t len=npos) const |
| Returns a substring of this StringPiece. | |
Static Public Attributes | |
| static const int32_t | npos = 0x7fffffff |
| Maximum integer, used as a default value for substring methods. | |
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.
Definition at line 52 of file stringpiece.h.
| StringPiece::StringPiece | ( | ) | [inline] |
Default constructor, creates an empty StringPiece.
Definition at line 62 of file stringpiece.h.
| StringPiece::StringPiece | ( | const char * | str | ) |
Constructs from a NUL-terminated const char * pointer.
| str | a NUL-terminated const char * pointer |
| StringPiece::StringPiece | ( | const char * | offset, | |
| int32_t | len | |||
| ) | [inline] |
Constructs from a const char * pointer and a specified length.
| offset | a const char * pointer (need not be terminated) | |
| len | the length of the string; must be non-negative |
Definition at line 83 of file stringpiece.h.
| StringPiece::StringPiece | ( | const StringPiece & | x, | |
| int32_t | pos | |||
| ) |
Substring of another StringPiece.
| x | the other StringPiece | |
| pos | start position in x; must be non-negative and <= x.length(). |
| StringPiece::StringPiece | ( | const StringPiece & | x, | |
| int32_t | pos, | |||
| int32_t | len | |||
| ) |
Substring of another StringPiece.
| x | the other StringPiece | |
| pos | start position in x; must be non-negative and <= x.length(). | |
| len | length of the substring; must be non-negative and will be pinned to at most x.length() - pos. |
| void StringPiece::clear | ( | ) | [inline] |
Sets to an empty string.
Definition at line 135 of file stringpiece.h.
References NULL.
| 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.
Definition at line 111 of file stringpiece.h.
| UBool StringPiece::empty | ( | ) | const [inline] |
Returns whether the string is empty.
Definition at line 129 of file stringpiece.h.
| int32_t StringPiece::length | ( | void | ) | const [inline] |
Returns the string length.
Same as size().
Definition at line 123 of file stringpiece.h.
| void StringPiece::remove_prefix | ( | int32_t | n | ) | [inline] |
Removes the first n string units.
| n | prefix length, must be non-negative and <=length() |
Definition at line 142 of file stringpiece.h.
| void StringPiece::remove_suffix | ( | int32_t | n | ) | [inline] |
Removes the last n string units.
| n | suffix length, must be non-negative and <=length() |
Definition at line 157 of file stringpiece.h.
| int32_t StringPiece::size | ( | ) | const [inline] |
Returns the string length.
Same as length().
Definition at line 117 of file stringpiece.h.
| StringPiece StringPiece::substr | ( | int32_t | pos, | |
| int32_t | len = npos | |||
| ) | const [inline] |
Returns a substring of this StringPiece.
| pos | start position; must be non-negative and <= length(). | |
| len | length of the substring; must be non-negative and will be pinned to at most length() - pos. |
Definition at line 181 of file stringpiece.h.
const int32_t StringPiece::npos = 0x7fffffff [static] |
Maximum integer, used as a default value for substring methods.
Definition at line 171 of file stringpiece.h.
1.5.7.1