C++ Reference: class StringPiece

This documentation is automatically generated.

Method
AppendToString

Return type: void

Arguments: std::string* target

as_string

Return type: std::string

begin

Return type: iterator

capacity

Return type: int

clear

Return type: void

compare

Return type: int

Arguments: const StringPiece& x

copy

Return type: int

Arguments: char* buf, size_type n, size_type pos = 0

CopyToString

Return type: void

Arguments: std::string* target

data

Return type: const char*

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 std::string.

empty

Return type: bool

end

Return type: iterator

ends_with

Return type: bool

Arguments: const StringPiece& x

Does "this" end with "x"?

find

Return type: int

Arguments: const StringPiece& s, size_type pos = 0

find

Return type: int

Arguments: char c, size_type pos = 0

length

Return type: int

max_size

Return type: int

STL says return size_type, but Google says return int.

rbegin

Return type: const_reverse_iterator

remove_prefix

Return type: void

Arguments: int n

remove_suffix

Return type: void

Arguments: int n

rend

Return type: const_reverse_iterator

rfind

Return type: int

Arguments: const StringPiece& s, size_type pos = npos

rfind

Return type: int

Arguments: char c, size_type pos = npos

set

Return type: void

Arguments: const char* data, int len

set

Return type: void

Arguments: const char* str

set

Return type: void

Arguments: const void* data, int len

size

Return type: int

starts_with

Return type: bool

Arguments: const StringPiece& x

Does "this" start with "x"?

StringPiece

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

StringPiece

Arguments: const char* str

StringPiece

Arguments: const std::string& str

StringPiece

Arguments: const char* offset, int len

substr

Return type: StringPiece

Arguments: size_type pos, size_type n = npos

ToString

Return type: std::string

We also define ToString() here, since many other std::string-like interfaces name the routine that converts to a C++ std::string "ToString", and it's confusing to have the method that does that for a StringPiece be called "as_string()". We also leave the "as_string()" method defined here for existing code.

Send feedback about...

Optimization
Optimization