8 #include "daq/slc/base/Reader.h"
10 #include "daq/slc/base/Serializable.h"
18 void Reader::reverse(
void* buf,
size_t len)
20 for (
int c = 0 ; c < (int)len / 2 ; c ++) {
21 char tmp = *((
char*)buf + c);
22 *((
char*)buf + c) = *((
char*)buf + len - 1 - c);
23 *((
char*)buf + len - 1 - c) = tmp;
27 bool Reader::readBool()
30 read(&v,
sizeof(
bool));
34 char Reader::readChar()
37 read(&v,
sizeof(
char));
41 unsigned char Reader::readUChar()
44 read(&v,
sizeof(
unsigned char));
48 short Reader::readShort()
51 read(&v,
sizeof(
short));
52 #if defined(__ENDIAN_L__)
53 reverse(&v,
sizeof(
short));
58 unsigned short Reader::readUShort()
61 read(&v,
sizeof(
unsigned short));
62 #if defined(__ENDIAN_L__)
63 reverse(&v,
sizeof(
unsigned short));
71 read(&v,
sizeof(
int));
72 #if defined(__ENDIAN_L__)
73 reverse(&v,
sizeof(
int));
78 unsigned int Reader::readUInt()
81 read(&v,
sizeof(
unsigned int));
82 #if defined(__ENDIAN_L__)
83 reverse(&v,
sizeof(
unsigned int));
88 long long Reader::readLong()
91 read(&v,
sizeof(
long long));
92 #if defined(__ENDIAN_L__)
93 reverse(&v,
sizeof(
long long));
98 unsigned long long Reader::readULong()
100 unsigned long long v;
101 read(&v,
sizeof(
unsigned long long));
102 #if defined(__ENDIAN_L__)
103 reverse(&v,
sizeof(
unsigned long long));
108 float Reader::readFloat()
111 read(&v,
sizeof(
float));
112 #if defined(__ENDIAN_L__)
113 reverse(&v,
sizeof(
float));
118 double Reader::readDouble()
121 read(&v,
sizeof(
double));
122 #if defined(__ENDIAN_L__)
123 reverse(&v,
sizeof(
double));
128 const std::string Reader::readString()
130 int count = readInt();
134 int c = (count > 1024) ? 1024 : count;
Abstract base class for different kinds of events.