|
The Pedigree Project 0.1
|
#include <String.h>
Inheritance diagram for String:
Collaboration diagram for String:Public Member Functions | |
| String () | |
| String (const char *s) | |
| String (const char *s, size_t length) | |
| String (const char *s, size_t length, bool unsafe) | |
| String (const Cord &x) | |
| String (const String &x) | |
| String (const StringView &x) | |
| String (String &&x) noexcept | |
| String & | operator= (String &&x) noexcept |
| String & | operator= (const Cord &x) |
| String & | operator= (const String &x) |
| String & | operator= (const char *s)=delete |
| operator const char * () const | |
| operator StringView () const | |
| String & | operator+= (const String &x) |
| String & | operator+= (const char *s) |
| bool | operator== (const String &s) const |
| bool | operator== (const StringView &s) const |
| bool | operator== (const char *s) const |
| bool | compare (const char *s, size_t len) const |
| template<size_t N> | |
| bool | compare (const char(&s)[N]) const |
| char | operator[] (size_t i) const |
| const char * | cstr () const |
| size_t | length () const |
| size_t | size () const |
| uint32_t | hash () const |
| uint32_t | hash () |
| size_t | nextCharacter (size_t c) const |
| size_t | prevCharacter (size_t c) const |
| void | lchomp () |
| void | chomp () |
| void | strip () |
| void | lstrip () |
| void | rstrip () |
| void | ltrim (size_t n) |
| void | rtrim (size_t n) |
| String | split (size_t offset) |
| void | split (size_t offset, String &back) |
| Vector< String > | tokenise (char token) |
| void | tokenise (char token, Vector< String > &output) const |
| void | tokenise (char token, Vector< StringView > &output) const |
| void | Format (const char *format,...) FORMAT(printf |
| template<size_t N> | |
| void void | assign (const char(&s)[N]) |
| void | assign (const String &x) |
| void | assign (const Cord &x) |
| void | assign (const char *s, size_t len=0, bool unsafe=false) |
| void | reserve (size_t size) |
| virtual void | clear () noexcept |
| void | downsize () |
| bool | endswith (const char c) const |
| bool | endswith (const String &s) const |
| bool | endswith (const char *s, size_t len=0) const |
| bool | startswith (const char c) const |
| bool | startswith (const String &s) const |
| bool | startswith (const char *s, size_t len=0) const |
| ssize_t | find (const char c) const |
| ssize_t | rfind (const char c) const |
| String | copy () const |
| StringView | view () const |
Static Public Member Functions | |
| static size_t | Utf32ToUtf8 (uint32_t utf32, char *utf8) |
Protected Member Functions | |
| bool | iswhitespace (const char c) const |
| void | reserve (size_t size, bool zero) |
| void | computeHash () |
| uint32_t | computeHash () const |
| void | setLength (size_t n) |
| void | setSize (size_t n) |
Private Member Functions | |
| uint32_t | maybeHash () const |
| virtual char * | extract () const |
| void | move (String &&other) noexcept |
| virtual bool | resizable () const |
| virtual bool | assignable () const |
Private Attributes | |
| char * | m_Data |
| size_t | m_Length |
| size_t | m_Size |
| uint32_t | m_Hash |
|
explicit |
|
explicit |
| void String::assign | ( | const char * | s, |
| size_t | len = 0, |
||
| bool | unsafe = false |
||
| ) |
Assign a buffer to this string. Optionally, unsafe can be passed which will completely trust the len parameter. This may be useful for cases where the input string is not necessarily known to have a null terminator, as otherwise assign() will attempt to find the length of the given string to reduce memory usage.
Definition at line 301 of file String.cc.
References assignable(), copy(), extract(), m_Data, m_Hash, m_Length, and m_Size.
|
inline |
|
privatevirtual |
| void String::chomp | ( | ) |
| bool String::compare | ( | const char * | s, |
| size_t | len | ||
| ) | const |
Perform a string comparison with the given string.
Definition at line 202 of file String.cc.
References extract(), m_Length, and UNLIKELY.
Referenced by Ext2Directory::addEntry(), Directory::enumerate(), Ext2Filesystem::removeNode(), and PedigreeCSyscallManager::syscall().
Here is the caller graph for this function:
|
inline |
|
protected |
|
protected |
| String String::copy | ( | ) | const |
| void String::downsize | ( | ) |
| bool String::endswith | ( | const char * | s, |
| size_t | len = 0 |
||
| ) | const |
| bool String::endswith | ( | const char | c | ) | const |
Does this string end with the given string?
Definition at line 654 of file String.cc.
References extract(), and m_Length.
Referenced by UnixSocketSyscalls::bind().
Here is the caller graph for this function:
|
privatevirtual |
Extract the correct string buffer for this string.
Reimplemented in ConstantString< N >.
Definition at line 724 of file String.cc.
References m_Data.
Referenced by assign(), chomp(), compare(), computeHash(), computeHash(), endswith(), find(), lchomp(), lstrip(), nextCharacter(), operator==(), prevCharacter(), rstrip(), startswith(), tokenise(), and view().
Here is the caller graph for this function:| ssize_t String::find | ( | const char | c | ) | const |
| uint32_t String::hash | ( | ) |
Variant of hash() that computes the hash if needed.
Definition at line 229 of file String.cc.
References computeHash(), and m_Hash.
| uint32_t String::hash | ( | ) | const |
Variant of hash() that might compute the hash if needed, but won't update the stored hash.
Definition at line 221 of file String.cc.
References computeHash(), and m_Hash.
Referenced by operator==().
Here is the caller graph for this function:
|
protected |
| void String::lchomp | ( | ) |
| void String::lstrip | ( | ) |
Removes the whitespace from the start of the string.
Definition at line 482 of file String.cc.
References assignable(), extract(), iswhitespace(), m_Hash, and m_Length.
Referenced by strip().
Here is the caller graph for this function:| void String::ltrim | ( | size_t | n | ) |
Remove the first N characters from the string.
Definition at line 415 of file String.cc.
References assignable(), m_Data, m_Hash, and m_Length.
Referenced by RadixTree< T >::insert().
Here is the caller graph for this function:
|
private |
Extract hash without recomputing it.
Definition at line 237 of file String.cc.
References m_Hash.
Referenced by operator==().
Here is the caller graph for this function:
|
privatenoexcept |
| size_t String::nextCharacter | ( | size_t | c | ) | const |
|
inlineexplicit |
|
inline |
Allow implicit typecasts to StringView for passing String to functions taking a StringView.
| bool String::operator== | ( | const String & | s | ) | const |
Definition at line 156 of file String.cc.
References extract(), hash(), LIKELY, m_Hash, m_Length, and maybeHash().
| bool String::operator== | ( | const StringView & | s | ) | const |
| size_t String::prevCharacter | ( | size_t | c | ) | const |
|
protected |
Internal doer for reserve()
Definition at line 367 of file String.cc.
References m_Data, m_Size, and resizable().
|
privatevirtual |
Is this string resizable?
Reimplemented in ConstantString< N >.
Definition at line 789 of file String.cc.
Referenced by downsize(), and reserve().
Here is the caller graph for this function:| void String::rstrip | ( | ) |
Removes the whitespace from the end of the string.
Definition at line 507 of file String.cc.
References assignable(), extract(), iswhitespace(), m_Hash, and m_Length.
Referenced by Symlink::initialise(), and strip().
Here is the caller graph for this function:| void String::rtrim | ( | size_t | n | ) |
|
protected |
|
protected |
| String String::split | ( | size_t | offset | ) |
Splits the string at the given offset - the front portion will be kept in this string, the back portion (including the character at 'offset' will be returned in a new string.
Definition at line 452 of file String.cc.
References split().
Referenced by split().
Here is the caller graph for this function:| bool String::startswith | ( | const char * | s, |
| size_t | len = 0 |
||
| ) | const |
| bool String::startswith | ( | const char | c | ) | const |
| void String::strip | ( | ) |
Removes the whitespace from the both ends of the string.
Definition at line 475 of file String.cc.
References assignable(), lstrip(), and rstrip().
| void String::tokenise | ( | char | token, |
| Vector< StringView > & | output | ||
| ) | const |
|
static |
| StringView String::view | ( | ) | const |
Get a StringView of this String.
Definition at line 783 of file String.cc.
References extract(), m_Hash, and m_Length.
Referenced by Ext2Directory::addEntry(), FatDirectory::addEntry(), Directory::addEphemeralFile(), VFS::find(), VFS::findRetained(), Symlink::followLinkRetained(), File::publishEvent(), Filesystem::removeChild(), and tokenise().
Here is the caller graph for this function:
|
private |
|
private |
Hash of the string.
Definition at line 238 of file String.h.
Referenced by assign(), chomp(), computeHash(), hash(), hash(), lchomp(), lstrip(), ltrim(), maybeHash(), operator==(), rstrip(), rtrim(), and view().
|
private |
The string's length
Definition at line 234 of file String.h.
Referenced by assign(), chomp(), compare(), computeHash(), computeHash(), downsize(), endswith(), find(), lchomp(), lstrip(), ltrim(), operator==(), rstrip(), rtrim(), setLength(), startswith(), tokenise(), and view().
|
private |