Ninja
Public Member Functions | Public Attributes | List of all members
StringPiece Struct Reference

StringPiece represents a slice of a string whose memory is managed externally. More...

#include <string_piece.h>

Public Member Functions

string AsString () const
 Convert the slice into a full-fledged std::string, copying the data into a new string. More...
 
bool operator!= (const StringPiece &other) const
 
bool operator== (const StringPiece &other) const
 
 StringPiece ()
 
 StringPiece (const string &str)
 The constructors intentionally allow for implicit conversions. More...
 
 StringPiece (const char *str)
 
 StringPiece (const char *str, size_t len)
 

Public Attributes

size_t len_
 
const char * str_
 

Detailed Description

StringPiece represents a slice of a string whose memory is managed externally.

It is useful for reducing the number of std::strings we need to allocate.

Definition at line 27 of file string_piece.h.

Constructor & Destructor Documentation

StringPiece::StringPiece ( )
inline

Definition at line 28 of file string_piece.h.

StringPiece::StringPiece ( const string &  str)
inline

The constructors intentionally allow for implicit conversions.

Definition at line 31 of file string_piece.h.

StringPiece::StringPiece ( const char *  str)
inline

Definition at line 32 of file string_piece.h.

StringPiece::StringPiece ( const char *  str,
size_t  len 
)
inline

Definition at line 34 of file string_piece.h.

Member Function Documentation

string StringPiece::AsString ( ) const
inline

Convert the slice into a full-fledged std::string, copying the data into a new string.

Definition at line 45 of file string_piece.h.

Referenced by IncludesNormalize::AbsPath(), State::AddDefault(), State::AddOut(), EvalString::AddSpecial(), EvalString::AddText(), Lexer::Error(), State::GetNode(), ImplicitDepLoader::LoadDepFile(), and IncludesNormalize::Normalize().

bool StringPiece::operator!= ( const StringPiece other) const
inline

Definition at line 39 of file string_piece.h.

bool StringPiece::operator== ( const StringPiece other) const
inline

Definition at line 36 of file string_piece.h.

References len_, and str_.

Member Data Documentation

size_t StringPiece::len_
const char* StringPiece::str_

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