3 #ifndef GCP_UTIL_NETUNION_H
4 #define GCP_UTIL_NETUNION_H
16 #include "gcp/util/common/DataType.h"
18 #include "gcp/util/common/NetDat.h"
26 static const unsigned NETUNION_UNKNOWN = 0;
54 void addVar(
unsigned id, gcp::util::DataType::Type type,
55 void* vPtr,
unsigned nEl);
77 void setTo(
unsigned id);
87 unsigned sizeOf(
unsigned id);
104 std::map<unsigned int, NetDat::Info> members_;
113 void checkSize(
const std::vector<unsigned char>& bytes);
118 void checkSize(
const std::vector<unsigned char>& bytes,
unsigned id);
123 void resize(
unsigned size);
135 #define NETUNION_UCHAR(id, name) \
136 addVar(id, gcp::util::DataType::UCHAR, (void*)&name, 1)
138 #define NETUNION_UCHAR_ARR(id, name, nEl) \
139 addVar(id, gcp::util::DataType::UCHAR, (void*)name, nEl)
141 #define NETUNION_CHAR(id, name) \
142 addVar(id, gcp::util::DataType::CHAR, (void*)&name, 1)
144 #define NETUNION_CHAR_ARR(id, name, nEl) \
145 addVar(id, gcp::util::DataType::CHAR, (void*)name, nEl)
147 #define NETUNION_BOOL(id, name) \
148 addVar(id, gcp::util::DataType::BOOL, (void*)&name, 1)
150 #define NETUNION_BOOL_ARR(id, name, nEl) \
151 addVar(id, gcp::util::DataType::BOOL, (void*)name, nEl)
153 #define NETUNION_USHORT(id, name) \
154 addVar(id, gcp::util::DataType::USHORT, (void*)&name, 1)
156 #define NETUNION_USHORT_ARR(id, name, nEl) \
157 addVar(id, gcp::util::DataType::USHORT, (void*)name, nEl)
159 #define NETUNION_SHORT(id, name) \
160 addVar(id, gcp::util::DataType::SHORT, (void*)&name, 1)
162 #define NETUNION_SHORT_ARR(id, name, nEl) \
163 addVar(id, gcp::util::DataType::SHORT, (void*)name, nEl)
165 #define NETUNION_UINT(id, name) \
166 addVar(id, gcp::util::DataType::UINT, (void*)&name, 1)
168 #define NETUNION_UINT_ARR(id, name, nEl) \
169 addVar(id, gcp::util::DataType::UINT, (void*)name, nEl)
171 #define NETUNION_INT(id, name) \
172 addVar(id, gcp::util::DataType::INT, (void*)&name, 1)
174 #define NETUNION_INT_ARR(id, name, nEl) \
175 addVar(id, gcp::util::DataType::INT, (void*)name, nEl)
177 #define NETUNION_ULONG(id, name) \
178 addVar(id, gcp::util::DataType::ULONG, (void*)&name, 1)
180 #define NETUNION_ULONG_ARR(id, name, nEl) \
181 addVar(id, gcp::util::DataType::ULONG, (void*)name, nEl)
183 #define NETUNION_LONG(id, name) \
184 addVar(id, gcp::util::DataType::LONG, (void*)&name, 1)
186 #define NETUNION_LONG_ARR(id, name, nEl) \
187 addVar(id, gcp::util::DataType::LONG, (void*)name, nEl)
189 #define NETUNION_FLOAT(id, name) \
190 addVar(id, gcp::util::DataType::FLOAT, (void*)&name, 1)
192 #define NETUNION_FLOAT_ARR(id, name, nEl) \
193 addVar(id, gcp::util::DataType::FLOAT, (void*)name, nEl)
195 #define NETUNION_DOUBLE(id, name) \
196 addVar(id, gcp::util::DataType::DOUBLE, (void*)&name, 1)
198 #define NETUNION_DOUBLE_ARR(id, name, nEl) \
199 addVar(id, gcp::util::DataType::DOUBLE, (void*)name, nEl)
201 #endif // End #ifndef GCP_UTIL_NETUNION_H
void deserialize(const std::vector< unsigned char > &bytes)
Definition: NetUnion.cc:238
Definition: compress.c:1548
NetUnion & operator=(const NetUnion &netUnion)
Definition: NetUnion.cc:54
void setTo(unsigned id)
Definition: NetUnion.cc:184
unsigned size()
Definition: NetUnion.cc:198
NetUnion()
Definition: NetUnion.cc:14
bool memberIsValid(unsigned id)
Definition: NetUnion.cc:158
void addMember(unsigned id, NetDat *member=0, bool alloc=false)
Definition: NetUnion.cc:117
unsigned getType()
Definition: NetUnion.cc:314
void addCase(unsigned id)
Definition: NetUnion.cc:306
unsigned sizeOf(unsigned id)
Definition: NetUnion.cc:286
NetDat *const getMember(unsigned id)
Definition: NetUnion.cc:171
NetDat *const findMember(unsigned id)
Definition: NetUnion.cc:145
Definition: NetUnion.h:23
void addVar(unsigned id, gcp::util::DataType::Type type, void *vPtr, unsigned nEl)
Definition: NetUnion.cc:296
virtual ~NetUnion()
Definition: NetUnion.cc:89