PandaRoot
BinaryStoreHelper.h File Reference
#include <assert.h>
#include "PndFTSCADef.h"
#include <cstdio>

Go to the source code of this file.

Functions

template<typename T >
static void BinaryStoreWrite (const T *mem, int count, FILE *f)
 
template<typename T >
static void BinaryStoreWrite (const T &mem, FILE *f)
 
static void BinaryStoreWrite (const void *offsetPtr, const void *mem, FILE *f)
 
template<typename T >
static void BinaryStoreRead (T *mem, int count, FILE *f)
 
template<typename T >
static void BinaryStoreRead (T &mem, FILE *f)
 
template<typename T >
static void BinaryStoreRead (T *&offsetPtr, char *mem, FILE *f)
 

Function Documentation

◆ BinaryStoreRead() [1/3]

template<typename T >
static void BinaryStoreRead ( T *  mem,
int  count,
FILE *  f 
)
inlinestatic

Definition at line 57 of file BinaryStoreHelper.h.

58 {
59  const int read = std::fread(mem, sizeof(T), count, f);
60  assert(read == count);
61  UNUSED_PARAM1(read);
62 }
float f
Definition: P4_F32vec4.h:20

◆ BinaryStoreRead() [2/3]

template<typename T >
static void BinaryStoreRead ( T &  mem,
FILE *  f 
)
inlinestatic

Definition at line 65 of file BinaryStoreHelper.h.

66 {
67  const size_t read = std::fread(&mem, sizeof(T), 1, f);
68  assert(read == 1);
69  UNUSED_PARAM1(read);
70 }
float f
Definition: P4_F32vec4.h:20

◆ BinaryStoreRead() [3/3]

template<typename T >
static void BinaryStoreRead ( T *&  offsetPtr,
char *  mem,
FILE *  f 
)
inlinestatic

Definition at line 73 of file BinaryStoreHelper.h.

74 {
75  int offset;
76  const size_t read = std::fread(&offset, sizeof(int), 1, f);
77  assert(read == 1);
78  UNUSED_PARAM1(read);
79  offsetPtr = reinterpret_cast<T *>(mem + offset);
80 }
float f
Definition: P4_F32vec4.h:20

◆ BinaryStoreWrite() [1/3]

template<typename T >
static void BinaryStoreWrite ( const T *  mem,
int  count,
FILE *  f 
)
inlinestatic

Definition at line 31 of file BinaryStoreHelper.h.

32 {
33  const int written = std::fwrite(mem, sizeof(T), count, f);
34  assert(written == count);
35  UNUSED_PARAM1(written);
36 }
float f
Definition: P4_F32vec4.h:20

◆ BinaryStoreWrite() [2/3]

template<typename T >
static void BinaryStoreWrite ( const T &  mem,
FILE *  f 
)
inlinestatic

Definition at line 39 of file BinaryStoreHelper.h.

40 {
41  const size_t written = std::fwrite(&mem, sizeof(T), 1, f);
42  assert(written == 1);
43  UNUSED_PARAM1(written);
44 }
float f
Definition: P4_F32vec4.h:20

◆ BinaryStoreWrite() [3/3]

static void BinaryStoreWrite ( const void *  offsetPtr,
const void *  mem,
FILE *  f 
)
inlinestatic

Definition at line 46 of file BinaryStoreHelper.h.

47 {
48  const int offset = static_cast<const char *>(offsetPtr) - static_cast<const char *>(mem);
49  const size_t written = std::fwrite(&offset, sizeof(int), 1, f);
50  assert(written == 1);
51  UNUSED_PARAM1(written);
52 }
float f
Definition: P4_F32vec4.h:20