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.

Constructor & Destructor Documentation

◆ StringView() [1/6]

StringView::StringView ( )

Definition at line 26 of file StringView.cc.

◆ StringView() [2/6]

StringView::StringView ( const char *  s)
explicit

Definition at line 31 of file StringView.cc.

◆ StringView() [3/6]

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

Definition at line 39 of file StringView.cc.

◆ StringView() [4/6]

StringView::StringView ( const StringView other)

Definition at line 47 of file StringView.cc.

◆ StringView() [5/6]

StringView::StringView ( const String other)
explicit

Definition at line 53 of file StringView.cc.

◆ StringView() [6/6]

StringView::StringView ( const char *  s,
size_t  length,
uint32_t  hash,
bool  hashingEnabled 
)
private

Definition at line 44 of file StringView.cc.

Member Function Documentation

◆ compare()

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 91 of file StringView.cc.

References UNLIKELY.

◆ compareHash() [1/2]

bool StringView::compareHash ( const String other) const
private

Definition at line 191 of file StringView.cc.

◆ compareHash() [2/2]

bool StringView::compareHash ( const StringView other) const
private

Definition at line 183 of file StringView.cc.

◆ computeHash()

uint32_t StringView::computeHash ( ) const
private

Definition at line 199 of file StringView.cc.

◆ defaultHashingEnabled()

bool StringView::defaultHashingEnabled ( ) const
protectedvirtual

Definition at line 207 of file StringView.cc.

◆ hash() [1/2]

uint32_t StringView::hash ( )

Definition at line 161 of file StringView.cc.

◆ hash() [2/2]

uint32_t StringView::hash ( ) const

Definition at line 153 of file StringView.cc.

◆ length()

size_t StringView::length ( ) const

Definition at line 109 of file StringView.cc.

◆ nextCharacter()

size_t StringView::nextCharacter ( size_t  i) const

Definition at line 145 of file StringView.cc.

◆ operator=()

StringView & StringView::operator= ( const StringView s)

Definition at line 57 of file StringView.cc.

◆ operator==() [1/3]

bool StringView::operator== ( const char *  s) const

Definition at line 65 of file StringView.cc.

◆ operator==() [2/3]

bool StringView::operator== ( const String s) const

Definition at line 69 of file StringView.cc.

◆ operator==() [3/3]

bool StringView::operator== ( const StringView s) const

Definition at line 79 of file StringView.cc.

◆ operator[]()

char StringView::operator[] ( size_t  index) const

Definition at line 135 of file StringView.cc.

◆ prevCharacter()

size_t StringView::prevCharacter ( size_t  i) const

Definition at line 149 of file StringView.cc.

◆ setHashingEnable()

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 173 of file StringView.cc.

Referenced by substring().

+ Here is the caller graph for this function:

◆ str()

const char * StringView::str ( ) const

Definition at line 169 of file StringView.cc.

◆ substring()

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 113 of file StringView.cc.

References setHashingEnable().

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

+ Here is the caller graph for this function:

◆ toString()

String StringView::toString ( ) const

Definition at line 131 of file StringView.cc.

Friends And Related Symbol Documentation

◆ String

friend class String
friend

Definition at line 35 of file StringView.h.

Member Data Documentation

◆ m_Hash

uint32_t StringView::m_Hash
private

Definition at line 92 of file StringView.h.

◆ m_HashingEnabled

bool StringView::m_HashingEnabled
private

Definition at line 93 of file StringView.h.

◆ m_Length

size_t StringView::m_Length
private

Definition at line 91 of file StringView.h.

◆ m_String

const char* StringView::m_String
private

Definition at line 90 of file StringView.h.


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