BinaryReader.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef BinaryReader_H
6 #define BinaryReader_H
7 #include<fstream>
8 #include<iostream>
9 #include<string>
10 
16 {
17 public:
18 
22  explicit BinaryReader(std::string);
23 
27  ~BinaryReader();
28 
32  std::string readString(unsigned int numChar);
33 
37  double readDouble(unsigned int size);
38 
42  unsigned int readUnsignedInt(unsigned int size);
43 
47  double readFloat(unsigned int size);
48 
52  void ignoreChar(unsigned int size);
53 
54 private:
55 
60 
64  void closeFile();
65 
67  std::ifstream binaryFile_;
68 
69 };
70 #endif
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
This gives functionality to read information from binary formats like STL etc. This class is complete...
Definition: BinaryReader.h:16
double readFloat(unsigned int size)
read the next so many bytes as a double (not in this case they were saves as a float orgainlly)
Definition: BinaryReader.cc:85
void ignoreChar(unsigned int size)
read and ignore the next number of characters
Definition: BinaryReader.cc:110
~BinaryReader()
Destructor, simple closes the file.
Definition: BinaryReader.cc:26
std::ifstream binaryFile_
The pointer for the binary file.
Definition: BinaryReader.h:67
BinaryReader(std::string)
Default constuction, requires to users to prove the name of the file that will be opened.
Definition: BinaryReader.cc:18
unsigned int readUnsignedInt(unsigned int size)
read the next so many bytes as a unsined int
Definition: BinaryReader.cc:98
void closeFile()
close the file with fileName
Definition: BinaryReader.cc:34
double readDouble(unsigned int size)
read the next so many bytes as a double
Definition: BinaryReader.cc:71
std::string readString(unsigned int numChar)
reads the next so many Characters (bytes) as a std::string
Definition: BinaryReader.cc:57
void openFile(std::string fileName)
opens the file with fileName
Definition: BinaryReader.cc:43
string fileName
Definition: UniformPSDSelfTest.py:10
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286