CkByteData C++ Class Reference (Visual C++)
CkByteData
* This is a freeware class/component/library.
Represents a chunk of byte data and provides methods for accessing it, adding to it, or saving and loading from files.
Properties
bool get_Utf8(void) const; void put_Utf8(bool b);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
Methods
void append(const unsigned char * data, unsigned long numBytes);
Appends byte data to the data already contained in the object.
void append(const char * byteData, unsigned long numBytes);
Appends byte data to the data already contained in the object.
void appendChar(char ch);
Appends a single byte.
void appendEncoded(const char * str, const char * encoding);
Appends binary data from an encoded string. The encoding can be "hex", "base64", "quoted-printable", or "url". The input string is decoded from the specified encoding and the binary data is appended to the calling object's content.
bool appendFile(const char * filename);
Opens a file for binary append, appends the CkByteData contents, and closes the file.
void appendInt(int v, bool littleEndian);
To be documented soon...
void appendRange(const CkByteData & byteData, unsigned long index, unsigned long numBytes);
To be documented soon...
void appendShort(short v, bool littleEndian);
To be documented soon...
void appendStr(const char * str);
Appends a null-terminated string to the data, without including the terminating null.
bool beginsWith(const CkByteData & byteData);
To be documented soon...
bool beginsWith2(const char * byteData, unsigned long byteDataLen);
To be documented soon...
void borrowData(unsigned char * yourData, unsigned long numBytes);
Sets the CkByteData's data pointer and size to memory outside the object. This is useful in cases where a CkByteData object is needed, but copying data into the CkByteData is not desired.
void byteSwap4321();
To be documented soon...
void clear();
Clears the CkByteData object of all data.
void encode(const char * encoding, CkString & str);
Encodes binary data according to the encoding requested. The encoding can be specified as "hex", "base64", "url", or "quoted-printable". Returns true for success, false for failure.
void ensureBuffer(unsigned long numBytes);
To be documented soon...
int findBytes(const CkByteData & byteData);
To be documented soon...
int findBytes2(const char * byteData, unsigned long byteDataLen);
To be documented soon...
unsigned char getByte(unsigned long byteIndex);
Returns the Nth byte of the binary data. The 1st byte is at index 0.
const unsigned char * getBytes();
To be documented soon...
char getChar(unsigned long byteIndex);
Returns the Nth byte of the binary content as a "char". The 1st byte is at index 0.
const unsigned char * getData();
Returns a pointer to the internal buffer. Be careful with this method because if additional data is appended, the data within the object may be relocated and the pointer may cease to be valid.
const unsigned char * getDataAt(unsigned long byteIndex);
Same as getData, except it gets a pointer to the data at a byte offset. (0 = the start of buffer)
const char * getEncoded(const char * encoding);
To be documented soon...
const char * getEncodedRange(const char * encoding, unsigned long index, unsigned long numBytes);
To be documented soon...
int getInt(unsigned long byteIndex);
Returns the 4-byte integer located at a specific byte index.
const unsigned char * getRange(unsigned long byteIndex, unsigned long numBytes);
To be documented soon...
const char * getRangeStr(unsigned long byteIndex, unsigned long numAnsiChars);
To be documented soon...
short getShort(unsigned long byteIndex);
Returns the 2-byte integer located at a specific byte index.
unsigned long getSize();
Returns the number of bytes in the data buffer.
unsigned int getUInt(unsigned long byteIndex);
Returns the 4-byte unsigned integer located at a specific byte index.
unsigned short getUShort(unsigned long byteIndex);
Returns the 2-byte unsigned integer located at a specific byte index.
bool is7bit();
To be documented soon...
bool loadFile(const char * filename);
Equivalent to clear() followed by appendFile().
void pad(int blockSize, int paddingScheme);
To be documented soon...
void preAllocate(unsigned long expectedNumBytes);
To be documented soon...
void removeChunk(unsigned long index, unsigned long numBytes);
To be documented soon...
unsigned char * removeData();
Removes the data from the CkByteData object. The caller will receivea pointer to the memory buffer, and is responsible for deleting it. Example: unsigned char *data = byteData.removeData(); ... do something with the data.... delete [] data;
bool saveFile(const char * filename);
Saves the byte data to a file. If the file already exists, it will be overwritten.
void shorten(unsigned long numBytes);
Discards N bytes from the end of the data.
const char * to_s();
To be documented soon...
void unpad(int blockSize, int paddingScheme);
To be documented soon...
|