libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
StringLatin1Data Class Reference

Latin1 string storage. One byte = one character. More...

#include <stringdata.h>

Inheritance diagram for StringLatin1Data:
Collaboration diagram for StringLatin1Data:

Public Member Functions

 StringLatin1Data ()=default
 Default constructor. Creates empty Latin1 storage.
 
 StringLatin1Data (const std::string &s)
 Constructs from a std::string (copy).
 
 StringLatin1Data (std::string &&s)
 Constructs from a std::string (move).
 
 StringLatin1Data (const char *s)
 Constructs from a C string.
 
 StringLatin1Data (const char *s, size_t len)
 Constructs from a buffer with explicit length.
 
 StringLatin1Data (size_t ct, char c)
 Constructs a string of repeated characters.
 
size_t length () const override
 Returns the number of characters in the string.
 
Char charAt (size_t idx) const override
 Returns the character at the given index.
 
void setCharAt (size_t idx, Char ch) override
 Sets the character at the given index.
 
bool isLatin1 () const override
 Returns true if the storage uses Latin1 encoding (one byte per character).
 
size_t find (Char ch, size_t from=0) const override
 Finds the first occurrence of a character starting from from.
 
size_t find (const StringData &s, size_t from=0) const override
 Finds the first occurrence of a substring starting from from.
 
size_t rfind (Char ch, size_t from=npos) const override
 Finds the last occurrence of a character at or before from.
 
size_t rfind (const StringData &s, size_t from=npos) const override
 Finds the last occurrence of a substring at or before from.
 
StringDatacreateSubstr (size_t pos, size_t len) const override
 Creates a new StringData containing a substring.
 
void reverseInPlace () override
 Reverses the characters in place.
 
size_t count (const StringData &substr) const override
 Counts non-overlapping occurrences of a substring.
 
void append (const StringData &other) override
 Appends another string's data to this storage.
 
void append (Char ch) override
 Appends a single character.
 
void insert (size_t pos, const StringData &s) override
 Inserts a string at the given position.
 
void erase (size_t pos, size_t count) override
 Erases characters from the string.
 
void clear () override
 Removes all characters from the string.
 
void resize (size_t len, Char fill=Char()) override
 Resizes the string to len characters.
 
size_t byteCount () const override
 Returns the byte count of the encoded string data.
 
uint8_t byteAt (size_t idx) const override
 Returns the byte at the given index.
 
const charcstr () const override
 Returns a null-terminated C string pointer.
 
const std::string & str () const override
 Returns a const reference to the internal std::string representation.
 
uint64_t hash () const override
 Returns a 64-bit hash of the string data.
 
std::string & rawStr ()
 Direct access to the underlying std::string.
 
- Public Member Functions inherited from StringData
virtual StringData_promeki_clone () const =0
 Creates a deep copy of this storage backend.
 
virtual ~StringData ()
 Virtual destructor.
 
bool isEmpty () const
 Returns true if the string has zero length.
 
virtual bool isLiteral () const
 Returns true if the storage wraps an immutable literal.
 

Additional Inherited Members

- Public Attributes inherited from StringData
RefCount _promeki_refct
 Manual reference count (PROMEKI_SHARED cannot be used on abstract classes).
 
- Static Public Attributes inherited from StringData
static constexpr size_t npos = static_cast<size_t>(-1)
 Sentinel value indicating "not found".
 

Detailed Description

Latin1 string storage. One byte = one character.

All character positions and byte positions are identical. This is the fast path for ASCII / Latin1 strings.

Constructor & Destructor Documentation

◆ StringLatin1Data() [1/5]

StringLatin1Data::StringLatin1Data ( const std::string &  s)
inline

Constructs from a std::string (copy).

Parameters
sThe source string.

◆ StringLatin1Data() [2/5]

StringLatin1Data::StringLatin1Data ( std::string &&  s)
inline

Constructs from a std::string (move).

Parameters
sThe source string to move from.

◆ StringLatin1Data() [3/5]

StringLatin1Data::StringLatin1Data ( const char s)
inline

Constructs from a C string.

Parameters
sThe null-terminated string (null treated as empty).

◆ StringLatin1Data() [4/5]

StringLatin1Data::StringLatin1Data ( const char s,
size_t  len 
)
inline

Constructs from a buffer with explicit length.

Parameters
sPointer to character data.
lenNumber of bytes.

◆ StringLatin1Data() [5/5]

StringLatin1Data::StringLatin1Data ( size_t  ct,
char  c 
)
inline

Constructs a string of repeated characters.

Parameters
ctNumber of characters.
cCharacter to repeat.

Member Function Documentation

◆ append() [1/2]

void StringLatin1Data::append ( Char  ch)
overridevirtual

Appends a single character.

Parameters
chThe character to append.

Implements StringData.

◆ append() [2/2]

void StringLatin1Data::append ( const StringData other)
overridevirtual

Appends another string's data to this storage.

Parameters
otherThe data to append.

Implements StringData.

◆ byteAt()

uint8_t StringLatin1Data::byteAt ( size_t  idx) const
inlineoverridevirtual

Returns the byte at the given index.

Parameters
idxZero-based byte index.
Returns
The byte value.

Implements StringData.

◆ byteCount()

size_t StringLatin1Data::byteCount ( ) const
inlineoverridevirtual

Returns the byte count of the encoded string data.

Implements StringData.

◆ charAt()

Char StringLatin1Data::charAt ( size_t  idx) const
overridevirtual

Returns the character at the given index.

Implements StringData.

◆ clear()

void StringLatin1Data::clear ( )
inlineoverridevirtual

Removes all characters from the string.

Implements StringData.

◆ count()

size_t StringLatin1Data::count ( const StringData substr) const
overridevirtual

Counts non-overlapping occurrences of a substring.

Parameters
substrThe substring to count.
Returns
Number of occurrences.

Implements StringData.

◆ createSubstr()

StringData * StringLatin1Data::createSubstr ( size_t  pos,
size_t  len 
) const
overridevirtual

Creates a new StringData containing a substring.

Parameters
posStarting character index.
lenNumber of characters.
Returns
A newly allocated StringData; caller takes ownership.

Implements StringData.

◆ cstr()

const char * StringLatin1Data::cstr ( ) const
inlineoverridevirtual

Returns a null-terminated C string pointer.

Implements StringData.

◆ erase()

void StringLatin1Data::erase ( size_t  pos,
size_t  count 
)
overridevirtual

Erases characters from the string.

Parameters
posStarting character index.
countNumber of characters to erase.

Implements StringData.

◆ find() [1/2]

size_t StringLatin1Data::find ( Char  ch,
size_t  from = 0 
) const
overridevirtual

Finds the first occurrence of a character starting from from.

Parameters
chThe character to search for.
fromStarting character index.
Returns
Character index of the match, or npos if not found.

Implements StringData.

◆ find() [2/2]

size_t StringLatin1Data::find ( const StringData s,
size_t  from = 0 
) const
overridevirtual

Finds the first occurrence of a substring starting from from.

Parameters
sThe substring data to search for.
fromStarting character index.
Returns
Character index of the match, or npos if not found.

Implements StringData.

◆ hash()

uint64_t StringLatin1Data::hash ( ) const
inlineoverridevirtual

Returns a 64-bit hash of the string data.

Implements StringData.

◆ insert()

void StringLatin1Data::insert ( size_t  pos,
const StringData s 
)
overridevirtual

Inserts a string at the given position.

Parameters
posCharacter index at which to insert.
sThe data to insert.

Implements StringData.

◆ isLatin1()

bool StringLatin1Data::isLatin1 ( ) const
inlineoverridevirtual

Returns true if the storage uses Latin1 encoding (one byte per character).

Implements StringData.

◆ length()

size_t StringLatin1Data::length ( ) const
inlineoverridevirtual

Returns the number of characters in the string.

Implements StringData.

◆ resize()

void StringLatin1Data::resize ( size_t  len,
Char  fill = Char() 
)
overridevirtual

Resizes the string to len characters.

Parameters
lenNew character count.
fillCharacter used to pad if growing.

Implements StringData.

◆ reverseInPlace()

void StringLatin1Data::reverseInPlace ( )
overridevirtual

Reverses the characters in place.

Implements StringData.

◆ rfind() [1/2]

size_t StringLatin1Data::rfind ( Char  ch,
size_t  from = npos 
) const
overridevirtual

Finds the last occurrence of a character at or before from.

Parameters
chThe character to search for.
fromMaximum character index to consider (npos = end).
Returns
Character index of the match, or npos if not found.

Implements StringData.

◆ rfind() [2/2]

size_t StringLatin1Data::rfind ( const StringData s,
size_t  from = npos 
) const
overridevirtual

Finds the last occurrence of a substring at or before from.

Parameters
sThe substring data to search for.
fromMaximum character index to consider (npos = end).
Returns
Character index of the match, or npos if not found.

Implements StringData.

◆ setCharAt()

void StringLatin1Data::setCharAt ( size_t  idx,
Char  ch 
)
overridevirtual

Sets the character at the given index.

Parameters
idxZero-based character index.
chThe replacement character.

Implements StringData.

◆ str()

const std::string & StringLatin1Data::str ( ) const
inlineoverridevirtual

Returns a const reference to the internal std::string representation.

Implements StringData.


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