BusBricks: CharArray Class Reference
BusBricks  0.1
Customize bus-communication
Loading...
Searching...
No Matches
CharArray Class Reference

Class for storing char-array (byte-array) together with size. The Array is stored on Heap-memory and is extended by adding bytes with "+=" or by write-access to an index larger than the current size. More...

#include <CharArray.h>

Public Member Functions

 CharArray ()
 Construct a new empty Char Array object (0 byte)
 
 ~CharArray ()
 Destroy the Char Array object.
 
 CharArray (const String &str)
 constructor for Arduino-String
 
 CharArray (const CharArray &other)
 Copy constructor.
 
CharArrayoperator= (const CharArray &other)
 Assignment operator.
 
CharArrayoperator= (const String &other)
 Assignment operator for String-assignment.
 
char & operator[] (size_t index)
 Write-Access the element at the specified index.
 
const char & operator[] (size_t index) const
 Read-Access the element at the specified index.
 
CharArrayoperator+= (char c)
 += Operator to append a single character
 
bool operator== (const CharArray &other) const
 Equality Operator.
 
bool operator!= (const CharArray &other) const
 Inequality Operator.
 
size_t getSize () const
 Retrieves the size of the char array.
 
const char * getData () const
 Provides direct access to the internal char array.
 
String getHexString ()
 Get the Hex-Values of the Array as a String.
 

Detailed Description

Class for storing char-array (byte-array) together with size. The Array is stored on Heap-memory and is extended by adding bytes with "+=" or by write-access to an index larger than the current size.

Constructor & Destructor Documentation

◆ CharArray() [1/2]

CharArray::CharArray ( const String & str)

constructor for Arduino-String

Initializes a new CharArray object with the content of the String-object.

Parameters
otherThe String-Object

◆ CharArray() [2/2]

CharArray::CharArray ( const CharArray & other)

Copy constructor.

Initializes a new CharArray object as a copy of another CharArray object.

Parameters
otherThe other CharArray object to copy.

This constructor performs a deep copy of all the data from other, ensuring that the new object is an exact copy of the source object.

Member Function Documentation

◆ getData()

const char * CharArray::getData ( ) const

Provides direct access to the internal char array.

Returns a pointer to the internal char array. This allows direct manipulation of the data stored in the array.

Returns
char* A pointer to the internal char array.
Here is the caller graph for this function:

◆ getHexString()

String CharArray::getHexString ( )

Get the Hex-Values of the Array as a String.

Returns
String

◆ getSize()

size_t CharArray::getSize ( ) const

Retrieves the size of the char array.

Returns the number of elements in the char array.

Returns
size_t The size of the char array.
Here is the caller graph for this function:

◆ operator!=()

bool CharArray::operator!= ( const CharArray & other) const

Inequality Operator.

Parameters
other
Returns
bool

◆ operator+=()

CharArray & CharArray::operator+= ( char c)

+= Operator to append a single character

Parameters
cchar to append
Returns
CharArray&

◆ operator=() [1/2]

CharArray & CharArray::operator= ( const CharArray & other)

Assignment operator.

This operator assigns the values from another object of the same type to the current object.

Parameters
otherThe other CharArray object whose values will be assigned.
Returns
A reference to the current object after assignment.

This operator performs a deep copy of the data from other, ensuring that the current object becomes an exact copy of other.

◆ operator=() [2/2]

CharArray & CharArray::operator= ( const String & str)

Assignment operator for String-assignment.

This operator assigns the values from a String-object to the current object.

Parameters
otherThe String object whose values will be assigned.
Returns
A reference to the current object after assignment.

◆ operator==()

bool CharArray::operator== ( const CharArray & other) const

Equality Operator.

Parameters
other
Returns
bool

◆ operator[]() [1/2]

char & CharArray::operator[] ( size_t index)

Write-Access the element at the specified index.

Returns a reference to the element at the given index in the char array. If the index is out of bounds, a the array will be extended.

Parameters
indexThe index of the element to access.
Returns
char& A reference to the element at the specified index.

◆ operator[]() [2/2]

const char & CharArray::operator[] ( size_t index) const

Read-Access the element at the specified index.

Returns a reference to the element at the given index in the char array. If the index is out of bounds, a refernce to a dummy nullterminator will be returned.

Parameters
indexThe index of the element to access.
Returns
char& A reference to the element at the specified index.

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