Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ base/

operations_research::StringPiece Class Reference

#include <stringpiece.h>

List of all members.

Public Types

typedef char value_type
 standard STL container boilerplate
typedef const char * pointer
typedef const char & reference
typedef const char & const_reference
typedef size_t size_type
typedef ptrdiff_t difference_type
typedef const char * const_iterator
typedef const char * iterator
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
typedef std::reverse_iterator
< iterator
reverse_iterator

Public Member Functions

 StringPiece ()
 We provide non-explicit singleton constructors so users can pass in a "const char*" or a "string" wherever a "StringPiece" is expected.
 StringPiece (const char *str)
 NOLINT.
 StringPiece (const std::string &str)
 NOLINT.
 StringPiece (const char *offset, int len)
const char * data () const
 data() may return a pointer to a buffer with embedded NULs, and the returned buffer may or may not be null terminated.
int size () const
int length () const
bool empty () const
void clear ()
void set (const char *data, int len)
void set (const char *str)
void set (const void *data, int len)
char operator[] (int i) const
void remove_prefix (int n)
void remove_suffix (int n)
int compare (const StringPiece &x) const
std::string as_string () const
std::string ToString () const
 We also define ToString() here, since many other string-like interfaces name the routine that converts to a C++ string "ToString", and it's confusing to have the method that does that for a StringPiece be called "as_string()".
void CopyToString (std::string *target) const
void AppendToString (std::string *target) const
bool starts_with (const StringPiece &x) const
 Does "this" start with "x".
bool ends_with (const StringPiece &x) const
 Does "this" end with "x".
iterator begin () const
iterator end () const
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
int max_size () const
 STLS says return size_type, but Google says return int.
int capacity () const
int copy (char *buf, size_type n, size_type pos=0) const
int find (const StringPiece &s, size_type pos=0) const
int find (char c, size_type pos=0) const
int rfind (const StringPiece &s, size_type pos=npos) const
int rfind (char c, size_type pos=npos) const
StringPiece substr (size_type pos, size_type n=npos) const

Static Public Attributes

static const size_type npos = size_type(-1)


Detailed Description

Definition at line 36 of file stringpiece.h.


Member Typedef Documentation

standard STL container boilerplate

Definition at line 122 of file stringpiece.h.

Definition at line 123 of file stringpiece.h.

Definition at line 124 of file stringpiece.h.

Definition at line 125 of file stringpiece.h.

Definition at line 126 of file stringpiece.h.

Definition at line 127 of file stringpiece.h.

Definition at line 129 of file stringpiece.h.

Definition at line 130 of file stringpiece.h.

Definition at line 131 of file stringpiece.h.

Definition at line 132 of file stringpiece.h.


Constructor & Destructor Documentation

operations_research::StringPiece::StringPiece (  )  [inline]

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

Definition at line 45 of file stringpiece.h.

operations_research::StringPiece::StringPiece ( const char *  str  )  [inline]

NOLINT.

Definition at line 46 of file stringpiece.h.

operations_research::StringPiece::StringPiece ( const std::string &  str  )  [inline]

NOLINT.

Definition at line 48 of file stringpiece.h.

operations_research::StringPiece::StringPiece ( const char *  offset,
int  len 
) [inline]

Definition at line 50 of file stringpiece.h.


Member Function Documentation

const char* operations_research::StringPiece::data (  )  const [inline]

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 56 of file stringpiece.h.

int operations_research::StringPiece::size (  )  const [inline]

Definition at line 57 of file stringpiece.h.

int operations_research::StringPiece::length (  )  const [inline]

Definition at line 58 of file stringpiece.h.

bool operations_research::StringPiece::empty (  )  const [inline]

Definition at line 59 of file stringpiece.h.

void operations_research::StringPiece::clear (  )  [inline]

Definition at line 61 of file stringpiece.h.

void operations_research::StringPiece::set ( const char *  data,
int  len 
) [inline]

Definition at line 65 of file stringpiece.h.

void operations_research::StringPiece::set ( const char *  str  )  [inline]

Definition at line 69 of file stringpiece.h.

void operations_research::StringPiece::set ( const void *  data,
int  len 
) [inline]

Definition at line 76 of file stringpiece.h.

char operations_research::StringPiece::operator[] ( int  i  )  const [inline]

Definition at line 81 of file stringpiece.h.

void operations_research::StringPiece::remove_prefix ( int  n  )  [inline]

Definition at line 83 of file stringpiece.h.

void operations_research::StringPiece::remove_suffix ( int  n  )  [inline]

Definition at line 88 of file stringpiece.h.

int StringPiece::compare ( const StringPiece x  )  const

Definition at line 69 of file stringpiece.cc.

std::string operations_research::StringPiece::as_string (  )  const [inline]

Definition at line 94 of file stringpiece.h.

std::string operations_research::StringPiece::ToString (  )  const [inline]

We also define ToString() here, since many other string-like interfaces name the routine that converts to a C++ 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.

Definition at line 102 of file stringpiece.h.

void StringPiece::CopyToString ( std::string *  target  )  const

Definition at line 49 of file stringpiece.cc.

void operations_research::StringPiece::AppendToString ( std::string *  target  )  const

bool operations_research::StringPiece::starts_with ( const StringPiece x  )  const [inline]

Does "this" start with "x".

Definition at line 110 of file stringpiece.h.

bool operations_research::StringPiece::ends_with ( const StringPiece x  )  const [inline]

Does "this" end with "x".

Definition at line 116 of file stringpiece.h.

iterator operations_research::StringPiece::begin (  )  const [inline]

Definition at line 133 of file stringpiece.h.

iterator operations_research::StringPiece::end (  )  const [inline]

Definition at line 134 of file stringpiece.h.

const_reverse_iterator operations_research::StringPiece::rbegin (  )  const [inline]

Definition at line 135 of file stringpiece.h.

const_reverse_iterator operations_research::StringPiece::rend (  )  const [inline]

Definition at line 138 of file stringpiece.h.

int operations_research::StringPiece::max_size (  )  const [inline]

STLS says return size_type, but Google says return int.

Definition at line 142 of file stringpiece.h.

int operations_research::StringPiece::capacity (  )  const [inline]

Definition at line 143 of file stringpiece.h.

int StringPiece::copy ( char *  buf,
size_type  n,
size_type  pos = 0 
) const

Definition at line 53 of file stringpiece.cc.

int StringPiece::find ( const StringPiece s,
size_type  pos = 0 
) const

Definition at line 59 of file stringpiece.cc.

int StringPiece::find ( char  c,
size_type  pos = 0 
) const

Definition at line 78 of file stringpiece.cc.

int StringPiece::rfind ( const StringPiece s,
size_type  pos = npos 
) const

Definition at line 86 of file stringpiece.cc.

int StringPiece::rfind ( char  c,
size_type  pos = npos 
) const

Definition at line 96 of file stringpiece.cc.

StringPiece StringPiece::substr ( size_type  pos,
size_type  n = npos 
) const

Definition at line 107 of file stringpiece.cc.


Member Data Documentation

Definition at line 128 of file stringpiece.h.


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