mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
binVector Binary File Format

A simple binary file format for storing vectors of data on disk. More...

A simple binary file format for storing vectors of data on disk.

The binVector file format is very simple: the first 8 bytes contain a unit64_t integer which specifies the type of the data. The second 8 bytes contain a uint64_t integer which specifies the length L of the data vector. The remaining L*sizeof(dataT) bytes contain the data.

The suggested extension for BinVector files is ".binv".

Typedefs

typedef uint64_t mx::ioutils::binVTypeT
 The type of binVector type codes. More...
 

Enumerations

enum  : binVTypeT
 The pre-defined type codes for binVector. More...
 

Functions

template<typename dataT >
binVTypeT mx::ioutils::binVectorTypeCode ()
 Get the integer type code corresponding to the type. More...
 
template<typename dataT >
int mx::ioutils::readBinVector (std::vector< dataT > &vec, const std::string &fname)
 Read a BinVector file from disk. More...
 
template<typename dataT >
int mx::ioutils::writeBinVector (const std::string &fname, std::vector< dataT > &vec)
 Write a BinVector file to disk. More...
 

Typedef Documentation

◆ binVTypeT

typedef uint64_t mx::ioutils::binVTypeT

The type of binVector type codes.

Definition at line 62 of file binVector.hpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : binVTypeT

The pre-defined type codes for binVector.

Definition at line 73 of file binVector.hpp.

Function Documentation

◆ binVectorTypeCode()

template<typename dataT >
binVTypeT mx::ioutils::binVectorTypeCode ( )

Get the integer type code corresponding to the type.

Returns
an integer which uniquely identifies the type.
Template Parameters
dataTis the type

◆ readBinVector()

template<typename dataT >
int mx::ioutils::readBinVector ( std::vector< dataT > &  vec,
const std::string &  fname 
)

Read a BinVector file from disk.

Note
dataT must match what was stored in the file.
Returns
0 on success.
-1 if an error occurs.
Parameters
[out]vecvec is a vector which will be resized and populated.
[in]fnamefname is the name (full-path) of the file.

Definition at line 240 of file binVector.hpp.

Referenced by mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::getGridFreq(), and mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::getGridPSD().

◆ writeBinVector()

template<typename dataT >
int mx::ioutils::writeBinVector ( const std::string &  fname,
std::vector< dataT > &  vec 
)

Write a BinVector file to disk.

Returns
0 on success.
-1 if an error occurs.
Parameters
[in]fnamefname is the name (full-path) of the file.
[in]vecvec is the vector which will be written to disk.

Definition at line 334 of file binVector.hpp.

Referenced by mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::makePSDGrid().