SUNphi  1.0
SUNphi::File Class Reference

File access, with functionalities to open and close, write/read. More...

#include <File.hpp>

Inheritance diagram for SUNphi::File:
SUNphi::Logger

Public Types

enum  RealFormat { GENERAL =0, FIXED =1, ENGINEER =2 }
 Print mode for double/float.
 

Public Member Functions

void open (const char *path, const char *mode, const bool crashIfFail=true)
 Open a file, crashing if impossible. More...
 
bool isOpen () const
 Check if open.
 
void close ()
 Close.
 
int getRc () const
 Returns rc.
 
Fileoperator<< (const char &c)
 Prints a char. More...
 
Fileoperator<< (const int32_t &i)
 Prints an integer. More...
 
Fileoperator<< (const uint32_t &i)
 Prints an unsigned integer. More...
 
Fileoperator<< (const int64_t &l)
 Prints a long integer. More...
 
Fileoperator<< (const uint64_t &l)
 Prints a long unsigned integer. More...
 
Fileoperator<< (const double &d)
 Prints a double. More...
 
template<typename T >
Fileoperator<< (const T *p)
 Prints a pointer. More...
 
template<typename T >
Fileoperator* (T &&t)
 Prints after putting a space. More...
 
Fileoperator<< (const char *str)
 Prints a string.
 
Fileoperator<< (const std::string &str)
 Prints a c++ string.
 
template<int MAX_LENGTH = 256>
FileprintVariadicMessage (const char *format, va_list ap)
 Print a C-style variadic message. More...
 
 ~File ()
 Destroy.
 

Public Attributes

int realPrecision {6}
 Precision to print real number.
 
bool alwaysPrintSign {false}
 Flag to determine whether print always or not the sign.
 
bool alwaysPrintZero {false}
 Flag to determine whether print always or not the zero.
 
RealFormat realFormat {RealFormat::GENERAL}
 Format mode for real number.
 

Private Attributes

FILE * file {nullptr}
 Raw file pointer.
 
int rc {0}
 Returned value of last i/o function.
 

Detailed Description

File access, with functionalities to open and close, write/read.

Definition at line 79 of file File.hpp.

Member Function Documentation

void SUNphi::File::open ( const char *  path,
const char *  mode,
const bool  crashIfFail = true 
)
inline

Open a file, crashing if impossible.

Parameters
pathPath to open
modeMode used to open
crashIfFailCrash or not if failing

Definition at line 90 of file File.hpp.

template<typename T >
File& SUNphi::File::operator* ( T &&  t)
inline

Prints after putting a space.

Parameters
tObject to be printed

Definition at line 235 of file File.hpp.

File& SUNphi::File::operator<< ( const char &  c)
inline

Prints a char.

Parameters
cChar to write

Definition at line 152 of file File.hpp.

File& SUNphi::File::operator<< ( const int32_t &  i)
inline

Prints an integer.

Parameters
iInteger to write

Definition at line 163 of file File.hpp.

File& SUNphi::File::operator<< ( const uint32_t &  i)
inline

Prints an unsigned integer.

Parameters
iUnsigned integer to write

Definition at line 173 of file File.hpp.

File& SUNphi::File::operator<< ( const int64_t &  l)
inline

Prints a long integer.

Parameters
lLong integer to write

Definition at line 183 of file File.hpp.

File& SUNphi::File::operator<< ( const uint64_t &  l)
inline

Prints a long unsigned integer.

Parameters
lLong unsigned integer to write

Definition at line 193 of file File.hpp.

File& SUNphi::File::operator<< ( const double &  d)
inline

Prints a double.

String to print real numbers

The first component is signed or not The second component is the format

Definition at line 203 of file File.hpp.

template<typename T >
File& SUNphi::File::operator<< ( const T *  p)
inline

Prints a pointer.

Parameters
pPointer to be printed

Definition at line 224 of file File.hpp.

template<int MAX_LENGTH = 256>
File& SUNphi::File::printVariadicMessage ( const char *  format,
va_list  ap 
)
inline

Print a C-style variadic message.

Message to be printed

Resulting length if the space had been enough

Check if it was truncated

Parameters
formatFormat to print
apVariadic part

Definition at line 260 of file File.hpp.


The documentation for this class was generated from the following file: