Scid  4.6.5
Public Member Functions | List of all members
Filebuf Class Reference

Adds some helper functions to std::filebuf: More...

#include <filebuf.h>

Inheritance diagram for Filebuf:
Inheritance graph
[legend]
Collaboration diagram for Filebuf:
Collaboration graph
[legend]

Public Member Functions

errorT Open (const char *filename, fileModeT fmode)
 Opens a file. More...
 
size_t getline (char *str, size_t count)
 Equivalent to std::fstream::getline, but faster (no sentry [27.7.2.1.3]). More...
 
byte ReadOneByte ()
 Reads a 8-bit unsigned integer. More...
 
uint16_t ReadTwoBytes ()
 Reads a 16-bit unsigned integer. More...
 
uint32_t ReadThreeBytes ()
 Reads a 24-bit unsigned integer. More...
 
uint32_t ReadFourBytes ()
 Reads a 32-bit unsigned integer. More...
 
int WriteOneByte (byte value)
 Writes a 8-bit unsigned integer. More...
 
int WriteTwoBytes (uint32_t value)
 Writes a 16-bit unsigned integer. More...
 
int WriteThreeBytes (uint32_t value)
 Writes a 24-bit unsigned integer. More...
 
int WriteFourBytes (uint32_t value)
 Writes a 32-bit unsigned integer. More...
 

Detailed Description

Adds some helper functions to std::filebuf:

Definition at line 35 of file filebuf.h.

Member Function Documentation

size_t Filebuf::getline ( char *  str,
size_t  count 
)
inline

Equivalent to std::fstream::getline, but faster (no sentry [27.7.2.1.3]).

Extracts characters from *this and stores them in successive locations of the array whose first element is pointed to by str, until the end of line ('\n' char) or the end of file condition occurs. The '\n' char is not stored into str, and a null character, even in case of errors, is appended.

Typical usage:

while (file.getline(buf, sizeof buf)) {
// use buf
}
if (file.sgetc() != EOF) // error
Parameters
strpointer to the character string to store the characters to
countsize of character string pointed to by str
Returns
  • the number of characters read, including the '\n' char
  • 0 on failure or if the buffer is too small.

Definition at line 86 of file filebuf.h.

errorT Filebuf::Open ( const char *  filename,
fileModeT  fmode 
)
inline

Opens a file.

Parameters
filenamepath to the file to be opened.
fmodeopen the file for reading, writing, or both.
Returns
OK on success, an errorT code on failure.

Definition at line 43 of file filebuf.h.

uint32_t Filebuf::ReadFourBytes ( )
inline

Reads a 32-bit unsigned integer.

This function do not check for errors or EOF.

Definition at line 129 of file filebuf.h.

byte Filebuf::ReadOneByte ( )
inline

Reads a 8-bit unsigned integer.

This function do not check for errors or EOF.

Definition at line 111 of file filebuf.h.

uint32_t Filebuf::ReadThreeBytes ( )
inline

Reads a 24-bit unsigned integer.

This function do not check for errors or EOF.

Definition at line 123 of file filebuf.h.

uint16_t Filebuf::ReadTwoBytes ( )
inline

Reads a 16-bit unsigned integer.

This function do not check for errors or EOF.

Definition at line 117 of file filebuf.h.

int Filebuf::WriteFourBytes ( uint32_t  value)
inline

Writes a 32-bit unsigned integer.

Returns
the number of characters successfully written.

Definition at line 161 of file filebuf.h.

int Filebuf::WriteOneByte ( byte  value)
inline

Writes a 8-bit unsigned integer.

Returns
the number of characters successfully written.

Definition at line 135 of file filebuf.h.

int Filebuf::WriteThreeBytes ( uint32_t  value)
inline

Writes a 24-bit unsigned integer.

Returns
the number of characters successfully written.

Definition at line 152 of file filebuf.h.

int Filebuf::WriteTwoBytes ( uint32_t  value)
inline

Writes a 16-bit unsigned integer.

Returns
the number of characters successfully written.

Definition at line 144 of file filebuf.h.


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