The Pedigree Project  0.1
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
StringView Class Reference
+ Inheritance diagram for StringView:
+ Collaboration diagram for StringView:

Public Member Functions

 StringView (const char *s)
 
 StringView (const char *s, size_t length)
 
 StringView (const StringView &other)
 
 StringView (const String &other)
 
StringViewoperator= (const StringView &s)
 
bool operator== (const char *s) const
 
bool operator== (const String &s) const
 
bool operator== (const StringView &s) const
 
bool compare (const char *s, size_t length) const
 
size_t length () const
 
StringView substring (size_t start, size_t end, bool hashed=HASH_STRINGVIEWS_BY_DEFAULT) const
 
String toString () const
 
char operator[] (size_t index) const
 
size_t nextCharacter (size_t i) const
 
size_t prevCharacter (size_t i) const
 
uint32_t hash () const
 
uint32_t hash ()
 
const char * str () const
 
void setHashingEnable (bool enabled)
 

Protected Member Functions

virtual bool defaultHashingEnabled () const
 

Private Member Functions

bool compareHash (const StringView &other) const
 
bool compareHash (const String &other) const
 
uint32_t computeHash () const
 
 StringView (const char *s, size_t length, uint32_t hash, bool hashingEnabled)
 

Private Attributes

const char * m_String
 
size_t m_Length
 
uint32_t m_Hash
 
bool m_HashingEnabled
 

Friends

class String
 

Detailed Description

Definition at line 34 of file StringView.h.

Member Function Documentation

bool StringView::compare ( const char *  s,
size_t  length 
) const

Perform a sized comparison on the given string. Generally this will perform better than operator==(const char *)

Definition at line 106 of file StringView.cc.

References String::m_Length, and UNLIKELY.

void StringView::setHashingEnable ( bool  enabled)

Set whether hashing is enabled for this StringView. Hashing makes comparisons against different strings faster, at the expense of much slower creation.

Definition at line 205 of file StringView.cc.

References String::computeHash(), String::hash(), String::m_Hash, String::m_Length, and String::view().

StringView StringView::substring ( size_t  start,
size_t  end,
bool  hashed = HASH_STRINGVIEWS_BY_DEFAULT 
) const

Pass hashed = true to hash the substring, which makes this slower.

Definition at line 131 of file StringView.cc.

References assert, String::computeHash(), ERROR, String::m_Hash, String::m_Length, String::String(), and UNLIKELY.

Referenced by Filesystem::findNode(), and Filesystem::findParent().

+ Here is the caller graph for this function:


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