itom 2.2.0
|
This is a Qt-free class for byte arrays (strings) without specific encoding information. More...
#include <byteArray.h>
Classes | |
struct | Data |
basic data container for class ByteArray that is implicitely shared over multiple instances of ByteArray of the same content More... | |
Public Member Functions | |
ByteArray () | |
default constructor. The ByteArray is empty. | |
ByteArray (const char *str) | |
constructor that copies the content of str ('\0'-terminated) to this ByteArray. | |
ByteArray (const ByteArray ©Constr) | |
copy constructor: the given byte array is implicitely shared between both instances until its content is changed by one of both participating instances. | |
~ByteArray () | |
destructor: the internal data is deleted if no other instance needs it. | |
ByteArray & | operator= (const ByteArray &rhs) |
another ByteArray is assigned to this ByteArray. The old content is deleted and the given byte array is implicitely shared between both instances. | |
ByteArray & | operator= (const char *str) |
a zero-terminated string is assigned to this ByteArray. The given char* is copied. | |
ByteArray & | append (const char *str) |
ByteArray & | append (const ByteArray &str) |
int | length () const |
int | size () const |
bool | empty () const |
return true if the ByteArray is empty hence its length is 0 | |
const char * | data () const |
return the pointer to the internal character array. If it is empty, the returned pointer still points to a '\0' character. It is never NULL. | |
char & | operator[] (unsigned int i) const |
access the i-th character of the ByteArray. An assertion is raised, if i is out of range | |
char & | operator[] (int i) const |
access the i-th character of the ByteArray. An assertion is raised, if i is out of range | |
bool | operator== (const ByteArray &a) const |
return true, if the content of this ByteArray is equal to the given ByteArray a. | |
bool | operator!= (const ByteArray &a) const |
return false, if the content of this ByteArray is equal to the given ByteArray a. | |
Private Member Functions | |
void | decAndFree (Data *x) |
Private Attributes | |
Data * | d |
Static Private Attributes | |
static char | emptyChar = '\0' |
This is a Qt-free class for byte arrays (strings) without specific encoding information.
This class uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data. It can be used to store 8-bit '\0' terminated strings and is a easy and safe way to handle const char* types. ByteArray is a leightweight class without any dependency to Qt and is used in many itom libraries e.g. the Qt-free itomCommonLib library.
ByteArray & ito::ByteArray::append | ( | const char * | str | ) |
int ito::ByteArray::length | ( | ) | const [inline] |
return the length of the byte array or 0 if it is empty
char& ito::ByteArray::operator[] | ( | unsigned int | i | ) | const [inline] |
char& ito::ByteArray::operator[] | ( | int | i | ) | const [inline] |
int ito::ByteArray::size | ( | ) | const [inline] |
return the length of the byte array or 0 if it is empty
Data* ito::ByteArray::d [private] |
pointer to Data container
char ito::ByteArray::emptyChar = '\0' [static, private] |
static character that represents an empty byte array ('\0').