Program Listing for File character_buffer.hpp
↰ Return to documentation for file (include/ecl/devices/detail/character_buffer.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_DEVICES_BUFFER_HPP_
#define ECL_DEVICES_BUFFER_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
#include <cstring>
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
namespace devices {
/*****************************************************************************
** Interface [CharBuffer]
*****************************************************************************/
class CharBuffer {
public:
/*********************
** Static Variables
**********************/
static const unsigned int buffer_size = 4096;
/*********************
** C&D
**********************/
CharBuffer() : fill_point_marker(0) {}
virtual ~CharBuffer() {}
unsigned int remaining() { return ( buffer_size - fill_point_marker); }
unsigned int size() const { return fill_point_marker; }
bool full() const;
long append(const char &c);
long append(const char* s, unsigned long n);
void clear();
char* c_ptr() { return contents; }
private:
/*********************
** Variables
**********************/
unsigned int fill_point_marker; // Index pointing to where you would write the next char
char contents[buffer_size];
};
/*****************************************************************************
** Interface [CharStringBuffer]
*****************************************************************************/
class CharStringBuffer {
public:
/*********************
** Static Variables
**********************/
static const unsigned int buffer_size = 4095; // Array is actually this + 1
/*********************
** C&D
**********************/
CharStringBuffer() : fill_point_marker(0) {
contents[buffer_size] = '\0';
}
virtual ~CharStringBuffer() {}
unsigned int remaining() { return ( buffer_size - fill_point_marker); }
bool full() const;
long append(const char &c);
long append(const char* s, unsigned long n);
const char* c_str();
void clear();
private:
/*********************
** Variables
**********************/
unsigned int fill_point_marker; // Index pointing to where you would write the next char
char contents[buffer_size+1];
};
} // namespace devices
} // namespace ecl
#endif /* ECL_DEVICES_BUFFER_HPP_ */