37 return do_check_match(other);
48 return _has_fixed_byte_size;
59 return _fixed_byte_size;
77 return _has_fixed_structure;
90 return _has_range_limits;
103 return _num_length_bytes;
118 return _has_nested_fields;
131 return _num_nested_fields;
149 INLINE
void DCPackerInterface::
150 do_pack_int8(
char *buffer,
int value) {
151 buffer[0] = (char)(value & 0xff);
159 INLINE
void DCPackerInterface::
160 do_pack_int16(
char *buffer,
int value) {
161 buffer[0] = (char)(value & 0xff);
162 buffer[1] = (char)((value >> 8) & 0xff);
170 INLINE
void DCPackerInterface::
171 do_pack_int32(
char *buffer,
int value) {
172 buffer[0] = (char)(value & 0xff);
173 buffer[1] = (char)((value >> 8) & 0xff);
174 buffer[2] = (char)((value >> 16) & 0xff);
175 buffer[3] = (char)((value >> 24) & 0xff);
183 INLINE
void DCPackerInterface::
184 do_pack_int64(
char *buffer, PN_int64 value) {
185 buffer[0] = (char)(value & 0xff);
186 buffer[1] = (char)((value >> 8) & 0xff);
187 buffer[2] = (char)((value >> 16) & 0xff);
188 buffer[3] = (char)((value >> 24) & 0xff);
189 buffer[4] = (char)((value >> 32) & 0xff);
190 buffer[5] = (char)((value >> 40) & 0xff);
191 buffer[6] = (char)((value >> 48) & 0xff);
192 buffer[7] = (char)((value >> 56) & 0xff);
200 INLINE
void DCPackerInterface::
201 do_pack_uint8(
char *buffer,
unsigned int value) {
202 buffer[0] = (char)(value & 0xff);
210 INLINE
void DCPackerInterface::
211 do_pack_uint16(
char *buffer,
unsigned int value) {
212 buffer[0] = (char)(value & 0xff);
213 buffer[1] = (char)((value >> 8) & 0xff);
221 INLINE
void DCPackerInterface::
222 do_pack_uint32(
char *buffer,
unsigned int value) {
223 buffer[0] = (char)(value & 0xff);
224 buffer[1] = (char)((value >> 8) & 0xff);
225 buffer[2] = (char)((value >> 16) & 0xff);
226 buffer[3] = (char)((value >> 24) & 0xff);
234 INLINE
void DCPackerInterface::
235 do_pack_uint64(
char *buffer, PN_uint64 value) {
236 buffer[0] = (char)(value & 0xff);
237 buffer[1] = (char)((value >> 8) & 0xff);
238 buffer[2] = (char)((value >> 16) & 0xff);
239 buffer[3] = (char)((value >> 24) & 0xff);
240 buffer[4] = (char)((value >> 32) & 0xff);
241 buffer[5] = (char)((value >> 40) & 0xff);
242 buffer[6] = (char)((value >> 48) & 0xff);
243 buffer[7] = (char)((value >> 56) & 0xff);
251 INLINE
void DCPackerInterface::
252 do_pack_float64(
char *buffer,
double value) {
253 #ifdef WORDS_BIGENDIAN 255 char *p = (
char *)&value;
256 for (
size_t i = 0; i < 8; i++) {
257 buffer[i] = p[7 - i];
260 memcpy(buffer, &value, 8);
270 INLINE
int DCPackerInterface::
271 do_unpack_int8(
const char *buffer) {
272 return (
int)(
signed char)buffer[0];
280 INLINE
int DCPackerInterface::
281 do_unpack_int16(
const char *buffer) {
282 return (
int)((
unsigned int)(
unsigned char)buffer[0] |
283 ((int)(
signed char)buffer[1] << 8));
291 INLINE
int DCPackerInterface::
292 do_unpack_int32(
const char *buffer) {
293 return (
int)((
unsigned int)(
unsigned char)buffer[0] |
294 ((
unsigned int)(
unsigned char)buffer[1] << 8) |
295 ((
unsigned int)(
unsigned char)buffer[2] << 16) |
296 ((int)(
signed char)buffer[3] << 24));
304 INLINE PN_int64 DCPackerInterface::
305 do_unpack_int64(
const char *buffer) {
306 return (PN_int64)((PN_uint64)(
unsigned char)buffer[0] |
307 ((PN_uint64)(
unsigned char)buffer[1] << 8) |
308 ((PN_uint64)(
unsigned char)buffer[2] << 16) |
309 ((PN_uint64)(
unsigned char)buffer[3] << 24) |
310 ((PN_uint64)(
unsigned char)buffer[4] << 32) |
311 ((PN_uint64)(
unsigned char)buffer[5] << 40) |
312 ((PN_uint64)(
unsigned char)buffer[6] << 48) |
313 ((PN_int64)(
signed char)buffer[7] << 54));
320 INLINE
unsigned int DCPackerInterface::
321 do_unpack_uint8(
const char *buffer) {
322 return (
unsigned int)(
unsigned char)buffer[0];
330 INLINE
unsigned int DCPackerInterface::
331 do_unpack_uint16(
const char *buffer) {
332 return ((
unsigned int)(
unsigned char)buffer[0] |
333 ((
unsigned int)(
unsigned char)buffer[1] << 8));
341 INLINE
unsigned int DCPackerInterface::
342 do_unpack_uint32(
const char *buffer) {
343 return ((
unsigned int)(
unsigned char)buffer[0] |
344 ((
unsigned int)(
unsigned char)buffer[1] << 8) |
345 ((
unsigned int)(
unsigned char)buffer[2] << 16) |
346 ((
unsigned int)(
unsigned char)buffer[3] << 24));
354 INLINE PN_uint64 DCPackerInterface::
355 do_unpack_uint64(
const char *buffer) {
356 return ((PN_uint64)(
unsigned char)buffer[0] |
357 ((PN_uint64)(
unsigned char)buffer[1] << 8) |
358 ((PN_uint64)(
unsigned char)buffer[2] << 16) |
359 ((PN_uint64)(
unsigned char)buffer[3] << 24) |
360 ((PN_uint64)(
unsigned char)buffer[4] << 32) |
361 ((PN_uint64)(
unsigned char)buffer[5] << 40) |
362 ((PN_uint64)(
unsigned char)buffer[6] << 48) |
363 ((PN_int64)(
signed char)buffer[7] << 54));
372 INLINE
double DCPackerInterface::
373 do_unpack_float64(
const char *buffer) {
374 #ifdef WORDS_BIGENDIAN 378 for (
size_t i = 0; i < 8; i++) {
379 reverse[i] = buffer[7 - i];
381 return *(
double *)reverse;
383 return *(
double *)buffer;
384 #endif // WORDS_BIGENDIAN 399 int mask = ((int)1 << (num_bits - 1)) - 1;
404 if (value != mask && value != -1) {
417 PN_int64 mask = ((PN_int64)1 << (num_bits - 1)) - 1;
420 if (value != mask && value != -1) {
436 unsigned int mask = ((
unsigned int)1 << num_bits) - 1;
452 PN_uint64 mask = ((PN_uint64)1 << num_bits) - 1;
bool has_fixed_structure() const
Returns true if this field type always has the same structure regardless of the data in the stream...
bool has_nested_fields() const
Returns true if this field type has any nested fields (and thus expects a push() .
const string & get_name() const
Returns the name of this field, or empty string if the field is unnamed.
static void validate_int_limits(int value, int num_bits, bool &range_error)
Confirms that the signed value fits within num_bits bits.
bool has_fixed_byte_size() const
Returns true if this field type always packs to the same number of bytes, false if it is variable...
int get_num_nested_fields() const
Returns the number of nested fields required by this field type.
static void validate_uint64_limits(PN_uint64 value, int num_bits, bool &range_error)
Confirms that the unsigned value fits within num_bits bits.
size_t get_fixed_byte_size() const
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use...
bool has_range_limits() const
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its...
bool check_match(const DCPackerInterface *other) const
Returns true if the other interface is bitwise the same as this oneāthat is, a uint32 only matches a...
size_t get_num_length_bytes() const
Returns the number of bytes that should be written into the stream on a push() to record the number o...
static void validate_int64_limits(PN_int64 value, int num_bits, bool &range_error)
Confirms that the signed value fits within num_bits bits.
DCPackType get_pack_type() const
Returns the type of value expected by this field.
This defines the internal interface for packing values into a DCField.
static void validate_uint_limits(unsigned int value, int num_bits, bool &range_error)
Confirms that the unsigned value fits within num_bits bits.