unsigned char array
Dependents: MGC3130 SmartLabXBeeCore
BufferedArray.h
- Committer:
- yangcq88517
- Date:
- 2015-11-11
- Revision:
- 0:b35da77c40ca
- Child:
- 1:77c1ea04eb5a
File content as of revision 0:b35da77c40ca:
#ifndef UK_AC_HERTS_SMARTLAB_XBEE_BufferedArray #define UK_AC_HERTS_SMARTLAB_XBEE_BufferedArray #include "mbed.h" /** * Represent a generic, dynamic-length raw binary data buffer. */ class BufferedArray { protected : /// initial size and automatically increase length. int expandSize; /// Raw data unsigned char * data; /// Current index of the data, could also used as data lendth. int index; /// Max data size that the raw data can hold. int max; void expandSpace(int length); public: BufferedArray(int initialLength, int expandSize); BufferedArray(BufferedArray * bufferedArray); ~BufferedArray(); /** Get the raw data. * @returns unsigned char array. */ unsigned char * gets(); /** Get the raw data from a specific location. * * @param position where to retrieve * * @returns unsigned char array. */ unsigned char * gets(int position); /** Get 1 byte data from a specific location. * * @param position where to retrieve * * @returns unsigned char. */ unsigned char get(int position); /** Get the current index. * @returns unsigned char array. */ int getPosition(); /** Set the index within the max length of raw data. * @param position where to begin read and write */ void setPosition(int position); /** Reset the raw data. * @param length current max size for the raw data */ void allocate(int length); /** Reset the position and does not affect the content of the data. * @param length current max size for the raw data */ void rewind(); /** Write 8-bit data into current posiston and increase by 1. * @param value sigle byte */ void set(unsigned char value); /** Write array of data into current posiston, and increase by the lenght. * @param value array of byte * @param offset start point of the data * @param length length to write */ void sets(const void * value, int length); /** Write 8-bit data into specific posiston and deos not affect the current position. * @param position where to write * @param value sigle byte */ void set(int position, unsigned char value); /** Write array of data into specific posiston and deos not affect the current position. * @param position where to write * @param value array of byte * @param offset start point of the data * @param length length to write */ void sets(int position, const void * value, int length); }; #endif