forked from mandovinnie/Lute-Tab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer.h
46 lines (38 loc) · 1.13 KB
/
buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
/*
*
* read and write to an intermediate buffer
*
*
*/
#ifndef __BUFFER__
#define __BUFFER__
/* #define BUFSIZ 512 */
enum mode {Creat, Append};
class buffer {
protected:
char * bytes;
int read_ptr;
int num_bytes; // bytes put in buffer
int size; // total size of buffer
public:
virtual void PutByte(const char c);
virtual unsigned char GetByte();
virtual unsigned char unGet(const char c);
void PutLine(const char * l); /* newline on end */
void PutString(const char * l); /* no newline */
unsigned int PutStringC(const char * l){
PutString(l);
return (strlen(l));
}
void PutChar(const char c) {PutByte(c);} /* ascii */
void Put10(const int num); /* format decimal */
void Put16(const int num); /* format hexidecimal */
void PutF(const double num, const int res); /* format double */
char * GetLine(char *buf, int buflen);
int Tell();
virtual int Seek(const long offset, const int how);
virtual void dump(const char *fname, const mode mode);
};
enum How { rew =0, cur=1, end=2}; // for Seek
#endif /* __BUFFER__ */