rllib  1
Public Member Functions | Public Attributes | Private Attributes | List of all members
rlBuffer Class Reference

#include <rlbuffer.h>

Public Member Functions

 rlBuffer ()
 
virtual ~rlBuffer ()
 
int resize (int size)
 
int size ()
 
int setText (const char *text)
 
char * line (int i)
 

Public Attributes

void * adr
 
char * c
 
unsigned char * uc
 
int * i
 
unsigned int * ui
 
long * l
 
unsigned long * ul
 
float * f
 
double * d
 

Private Attributes

int _size
 

Detailed Description

class for handling memory buffers.

Definition at line 24 of file rlbuffer.h.

Constructor & Destructor Documentation

◆ rlBuffer()

rlBuffer::rlBuffer ( )

Definition at line 18 of file rlbuffer.cpp.

19 {
20  adr = NULL;
21  c = (char *) adr;
22  uc = (unsigned char *) adr;
23  i = (int *) adr;
24  ui = (unsigned int *) adr;
25  l = (long *) adr;
26  ul = (unsigned long *) adr;
27  f = (float *) adr;
28  d = (double *) adr;
29 }
void * adr
Definition: rlbuffer.h:33
unsigned long * ul
Definition: rlbuffer.h:39
unsigned int * ui
Definition: rlbuffer.h:37
long * l
Definition: rlbuffer.h:38
double * d
Definition: rlbuffer.h:41
unsigned char * uc
Definition: rlbuffer.h:35
int * i
Definition: rlbuffer.h:36
float * f
Definition: rlbuffer.h:40
char * c
Definition: rlbuffer.h:34

◆ ~rlBuffer()

rlBuffer::~rlBuffer ( )
virtual

Definition at line 31 of file rlbuffer.cpp.

32 {
33  if(adr != NULL) delete [] c;
34 }
void * adr
Definition: rlbuffer.h:33
char * c
Definition: rlbuffer.h:34

Member Function Documentation

◆ line()

char * rlBuffer::line ( int  i)

Definition at line 72 of file rlbuffer.cpp.

73 {
74  if(c == NULL) return NULL;
75  char *cptr_start = c;
76  for(int ind=0; ind<i; ind++)
77  {
78  cptr_start = strchr(cptr_start,'\n');
79  if(cptr_start != NULL) cptr_start++;
80  else return NULL;
81  }
82  if((cptr_start - c) >= _size) return NULL;
83  return cptr_start;
84 }
int _size
Definition: rlbuffer.h:44
int * i
Definition: rlbuffer.h:36
char * c
Definition: rlbuffer.h:34

◆ resize()

int rlBuffer::resize ( int  size)

Definition at line 36 of file rlbuffer.cpp.

37 {
38  if(size <= 0) return -1;
39  _size = size;
40  if(adr != NULL) delete [] c;
41 
42  adr = (void *) new char[_size];
43  c = (char *) adr;
44  uc = (unsigned char *) adr;
45  i = (int *) adr;
46  ui = (unsigned int *) adr;
47  l = (long *) adr;
48  ul = (unsigned long *) adr;
49  f = (float *) adr;
50  d = (double *) adr;
51 
52  return _size;
53 }
int _size
Definition: rlbuffer.h:44
void * adr
Definition: rlbuffer.h:33
int size()
Definition: rlbuffer.cpp:55
unsigned long * ul
Definition: rlbuffer.h:39
unsigned int * ui
Definition: rlbuffer.h:37
long * l
Definition: rlbuffer.h:38
double * d
Definition: rlbuffer.h:41
unsigned char * uc
Definition: rlbuffer.h:35
int * i
Definition: rlbuffer.h:36
float * f
Definition: rlbuffer.h:40
char * c
Definition: rlbuffer.h:34

◆ setText()

int rlBuffer::setText ( const char *  text)

Definition at line 60 of file rlbuffer.cpp.

61 {
62  int len;
63  if((len = strlen(text)) >= _size)
64  {
65  printf("rlBuffer::setText() text is too long\n");
66  return -1;
67  }
68  strcpy(c,text);
69  return len;
70 }
int _size
Definition: rlbuffer.h:44
char * c
Definition: rlbuffer.h:34

◆ size()

int rlBuffer::size ( )

Definition at line 55 of file rlbuffer.cpp.

56 {
57  return _size;
58 }
int _size
Definition: rlbuffer.h:44

Member Data Documentation

◆ _size

int rlBuffer::_size
private

Definition at line 44 of file rlbuffer.h.

◆ adr

void* rlBuffer::adr

Definition at line 33 of file rlbuffer.h.

◆ c

char* rlBuffer::c

Definition at line 34 of file rlbuffer.h.

◆ d

double* rlBuffer::d

Definition at line 41 of file rlbuffer.h.

◆ f

float* rlBuffer::f

Definition at line 40 of file rlbuffer.h.

◆ i

int* rlBuffer::i

Definition at line 36 of file rlbuffer.h.

◆ l

long* rlBuffer::l

Definition at line 38 of file rlbuffer.h.

◆ uc

unsigned char* rlBuffer::uc

Definition at line 35 of file rlbuffer.h.

◆ ui

unsigned int* rlBuffer::ui

Definition at line 37 of file rlbuffer.h.

◆ ul

unsigned long* rlBuffer::ul

Definition at line 39 of file rlbuffer.h.


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