djiparsetxt
Data Structures | Macros | Functions
DJITxtParser.hh File Reference
#include <sys/types.h>
#include <stdlib.h>
Include dependency graph for DJITxtParser.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  DJITxtParser
 

Macros

#define END_OF_DATA   1
 

Functions

u_int8_t getByte (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
u_int16_t get2BytesBE (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
u_int16_t get2BytesLE (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
unsigned getWord32BE (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
unsigned getWord32LE (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
u_int64_t getWord64LE (u_int8_t const *&ptr, u_int8_t const *limit=NULL)
 
void printString (char const *label, u_int8_t const *&ptr, unsigned stringLength, u_int8_t const *limit=NULL)
 
void printHex (char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
 

Macro Definition Documentation

#define END_OF_DATA   1

Function Documentation

u_int16_t get2BytesBE ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)

Definition at line 34 of file DJITxtParser.cpp.

References END_OF_DATA.

Referenced by RecordAndDetailsParser::parseRecord_JPEG().

34  {
35  if (limit != NULL && ptr > limit-2) throw END_OF_DATA;
36  u_int8_t byte1 = *ptr++;
37  u_int8_t byte2 = *ptr++;
38  return (byte1<<8)|byte2;
39 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47
u_int16_t get2BytesLE ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)

Definition at line 41 of file DJITxtParser.cpp.

References END_OF_DATA.

Referenced by RecordAndDetailsParser::note2ByteDateField(), and RecordAndDetailsParser::note2ByteField().

41  {
42  if (limit != NULL && ptr > limit-2) throw END_OF_DATA;
43  u_int8_t byte1 = *ptr++;
44  u_int8_t byte2 = *ptr++;
45  return (byte2<<8)|byte1;
46 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47
u_int8_t getByte ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)
unsigned getWord32BE ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)

Definition at line 48 of file DJITxtParser.cpp.

References END_OF_DATA.

Referenced by main().

48  {
49  if (limit != NULL && ptr > limit-4) throw END_OF_DATA;
50  unsigned result = (ptr[0]<<24)|(ptr[1]<<16)|(ptr[2]<<8)|ptr[3];
51  ptr += 4;
52  return result;
53 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47
unsigned getWord32LE ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)

Definition at line 55 of file DJITxtParser.cpp.

References END_OF_DATA.

Referenced by getWord64LE(), RecordAndDetailsParser::note4ByteField(), and RecordAndDetailsParser::note4ByteFloatField().

55  {
56  if (limit != NULL && ptr > limit-4) throw END_OF_DATA;
57  unsigned result = (ptr[3]<<24)|(ptr[2]<<16)|(ptr[1]<<8)|ptr[0];
58  ptr += 4;
59  return result;
60 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47
u_int64_t getWord64LE ( u_int8_t const *&  ptr,
u_int8_t const *  limit = NULL 
)

Definition at line 62 of file DJITxtParser.cpp.

References getWord32LE().

Referenced by main(), RecordAndDetailsParser::note8ByteDoubleField(), RecordAndDetailsParser::note8ByteLatitudeOrLongitudeFieldInDegrees(), RecordAndDetailsParser::note8ByteLatitudeOrLongitudeFieldInRadians(), and RecordAndDetailsParser::note8ByteTimestampField().

62  {
63  u_int64_t resultLow = getWord32LE(ptr, limit);
64  u_int64_t resultHigh = getWord32LE(ptr, limit);
65  return (resultHigh<<32)|resultLow;
66 }
unsigned getWord32LE(u_int8_t const *&ptr, u_int8_t const *limit)
void printHex ( char const *  label,
u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 83 of file DJITxtParser.cpp.

Referenced by RecordAndDetailsParser::parseRecordUnknownFormat().

83  {
84  if (limit == NULL) return;
85  if (label != NULL) fprintf(stderr, "%s: ", label);
86  for (u_int8_t const* p = ptr; p < limit; ++p) fprintf(stderr, ":%02x", *p);
87  fprintf(stderr, "\n");
88 }
void printString ( char const *  label,
u_int8_t const *&  ptr,
unsigned  stringLength,
u_int8_t const *  limit = NULL 
)

Definition at line 68 of file DJITxtParser.cpp.

References END_OF_DATA.

68  {
69  if (limit != NULL && ptr > limit - stringLength) throw END_OF_DATA;
70 
71  char str[stringLength+1];
72  unsigned i;
73  for (i = 0; i < stringLength; ++i) str[i] = *ptr++;
74  str[i] = '\0';
75 
76  if (label == NULL) {
77  fprintf(stderr, "%s\n", str);
78  } else {
79  fprintf(stderr, "%s: %s\n", label, str);
80  }
81 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47