# Frost::File Class Reference

A tool to input some data. More...

`#include <frost_utils_file.h>`

List of all members.

## Public Types

enum | FileType { IO, I, O }

## Public Member Functions

| File (const s_str &sName, const FileType &mType=IO, const s_bool &bBinary=false)
| Call that constructor to open a file.
| ~File ()
| Destructor.
void | Close ()
| Call that function when you're done reading.
s_bool | IsOpen ()
| Checks if the file has been found and opened.
s_bool | IsValid ()
| Checks if the file can still be read.
s_uint | GetLength ()
| Returns this file's number of character.
const s_str | GetName () const
| Returns this file's name.
s_str | GetLine ()
| Returns the next line.
s_uint | GetReadPos ()
| Returns the reading position in the file.
void | SetReadPos (const s_uint &uiPos)
| Sets the reading position in the file.
s_uint | GetWritePos ()
| Returns the writing position in the file.
void | SetWritePos (const s_uint &uiPos)
| Sets the writing position in the file.
string_element | Get ()
| Returns the next character.
void | Read (s_str &sBuffer, const s_uint &uiSize)
| Extracts a block of unformated data.
void | Read (string_element *sBuffer, const s_uint &uiSize)
| Extracts a block of unformated data.
void | Read (void *pBuffer, const s_uint &uiSize)
| Extracts a block of unformated data.
template<class T >
void | Read (T &mObject)
| Fills an object.
void | Write (const string_element *sBuffer, const s_uint &uiSize)
| Writes down a char array into the file.
void | Write (const void *pBuffer, const s_uint &uiSize)
| Writes down some data into the file.
template<class T >
void | Write (const T *pTable, const s_uint &uiNum)
| Writes a table into the file.
template<class T >
void | Write (const T &mObject)
| Writes an object into the file.
void | Write (const string_element &cChar)
| Writes down a single char into the file.
void | Write (const s_str &sLine)
| Writes the content of the provided string into the file.
void | WriteLine (const s_str &sLine)
| Writes the content of the provided string and go to the next line.
void | Flush ()
| Forces writing everything to the file.
void | SetTabCharacter (const s_str &sTabStr)
| Sets the tabulation string.
const s_str & | GetTabCharacter () const
| Returns the tabulation string.
void | AddTab ()
| Adds a tabulation string.
void | RemoveTab ()
| Removes a tabulation string.
void | RemoveAllTabs ()
| Removes all tabulation strings.

## Static Public Member Functions

static s_bool | Exists (const s_str &sFileName)
| Checks if a file exists.

## Static Public Attributes

static const s_str | CLASS_NAME = "File"

## Private Attributes

file_stream | mFile_
| The file stream object.
s_str | sName_
| The name of this file.
s_str | sTabStr_
| The tabbing string.
s_uint | uiTabCount_
| The total tabbing.

## Detailed Description

A tool to input some data.

Built upon std::fstream, this class offers almost the exact same possibilities. The main difference is that this class can use Frost's data type.

Definition at line 27 of file frost_utils_file.h.

## Member Enumeration Documentation

enum Frost::File::FileType

Enumerator:

  IO |
  I | Input - Output.
  O | Input. Output

Definition at line 31 of file frost_utils_file.h.

## Constructor & Destructor Documentation

Frost::File::File | ( | const s_str & | sName,
|  | const FileType & | mType = `IO`,
|  | const s_bool & | bBinary = `false` |
| ) |  |  |

Call that constructor to open a file.

Parameters:

  | sName | The file's name
  | mType | How to open this file, see FileType
  | bBinary | 'false' if the file is plain text

Definition at line 14 of file frost_utils_file.cpp.

Frost::File::~File | ( |  | ) |

Destructor.

Note:
  Automatically closes the file.

Definition at line 48 of file frost_utils_file.cpp.

## Member Function Documentation

void Frost::File::AddTab | ( |  | ) |

Adds a tabulation string.

Note:
  Calling this function increments the tab counter.
  When WriteLine() is called, the tabulation string is written in front of each line, as many time as you've called this function.

Definition at line 202 of file frost_utils_file.cpp.

void Frost::File::Close | ( |  | ) |

Call that function when you're done reading.

Definition at line 53 of file frost_utils_file.cpp.

s_bool Frost::File::Exists | ( | const s_str & | sFileName | ) | `[static]`

Checks if a file exists.

Parameters:

  | sFileName | The name of the file

Returns:
  'true' if the file exists, 'false' otherwise

Definition at line 182 of file frost_utils_file.cpp.

void Frost::File::Flush | ( |  | ) |

Forces writing everything to the file.

Definition at line 177 of file frost_utils_file.cpp.

string_element Frost::File::Get | ( |  | ) |

Returns the next character.

Returns:
  The next character

Definition at line 114 of file frost_utils_file.cpp.

s_uint Frost::File::GetLength | ( |  | ) |

Returns this file's number of character.

Returns:
  This file's character count

Definition at line 68 of file frost_utils_file.cpp.

s_str Frost::File::GetLine | ( |  | ) |

Returns the next line.

Returns:
  The next line

Definition at line 84 of file frost_utils_file.cpp.

const s_str Frost::File::GetName | ( |  | ) | const

Returns this file's name.

Returns:
  This file's name

Definition at line 79 of file frost_utils_file.cpp.

s_uint Frost::File::GetReadPos | ( |  | ) |

Returns the reading position in the file.

Returns:
  The position of the currently read character in the file

Definition at line 94 of file frost_utils_file.cpp.

const s_str & Frost::File::GetTabCharacter | ( |  | ) | const

Returns the tabulation string.

Returns:
  The tabulation string

Note:
  Default is 4 spaces : " "

Definition at line 197 of file frost_utils_file.cpp.

s_uint Frost::File::GetWritePos | ( |  | ) |

Returns the writing position in the file.

Returns:
  The position of the currently written character in the file

Definition at line 104 of file frost_utils_file.cpp.

s_bool Frost::File::IsOpen | ( |  | ) |

Checks if the file has been found and opened.

Returns:
  'true' if the file has been succesfuly opened

Definition at line 58 of file frost_utils_file.cpp.

s_bool Frost::File::IsValid | ( |  | ) |

Checks if the file can still be read.

Returns:
  'true' if the file has been successfuly opened and if it has not yet reached its end.

Definition at line 63 of file frost_utils_file.cpp.

template<class T >

void Frost::File::Read | ( | T & | mObject | ) | `[inline]`

Fills an object.

Parameters:

  `[out]` | mObject | The object to fill

Note:
  The object provided should only contain POD types and no pointers.

Definition at line 129 of file frost_utils_file.h.

void Frost::File::Read | ( | void * | pBuffer,
|  | const s_uint & | uiSize |
| ) |  |  |

Extracts a block of unformated data.

Parameters:

  `[out]` | pBuffer | A pointer to the object/array to fill
  | uiSize | The number of character to extract

Definition at line 134 of file frost_utils_file.cpp.

void Frost::File::Read | ( | string_element * | sBuffer,
|  | const s_uint & | uiSize |
| ) |  |  |

Extracts a block of unformated data.

Parameters:

  `[out]` | sBuffer | A buffer string object
  | uiSize | The number of character to extract

Definition at line 129 of file frost_utils_file.cpp.

void Frost::File::Read | ( | s_str & | sBuffer,
|  | const s_uint & | uiSize |
| ) |  |  |

Extracts a block of unformated data.

Parameters:

  `[out]` | sBuffer | A buffer string object
  | uiSize | The number of character to extract

Definition at line 121 of file frost_utils_file.cpp.

void Frost::File::RemoveAllTabs | ( |  | ) |

Removes all tabulation strings.

Note:
  Calling this function sets the tab counter to zero.
  See AddTab() for more infos.

Definition at line 213 of file frost_utils_file.cpp.

void Frost::File::RemoveTab | ( |  | ) |

Removes a tabulation string.

Note:
  Calling this function decrements the tab counter.
  See AddTab() for more infos.

Definition at line 207 of file frost_utils_file.cpp.

void Frost::File::SetReadPos | ( | const s_uint & | uiPos | ) |

Sets the reading position in the file.

Parameters:

  | uiPos | The new position

Definition at line 99 of file frost_utils_file.cpp.

void Frost::File::SetTabCharacter | ( | const s_str & | sTabStr | ) |

Sets the tabulation string.

Parameters:

  | sTabStr | The tabulation string

Note:
  Default is 4 spaces : " "

Definition at line 192 of file frost_utils_file.cpp.

void Frost::File::SetWritePos | ( | const s_uint & | uiPos | ) |

Sets the writing position in the file.

Parameters:

  | uiPos | The new position

Definition at line 109 of file frost_utils_file.cpp.

void Frost::File::Write | ( | const s_str & | sLine | ) |

Writes the content of the provided string into the file.

Parameters:

  | sLine | The string to write

Definition at line 154 of file frost_utils_file.cpp.

void Frost::File::Write | ( | const string_element & | cChar | ) |

Writes down a single char into the file.

Parameters:

  | cChar | The char to write down

Note:
  This function changes the writing position

Definition at line 149 of file frost_utils_file.cpp.

template<class T >

void Frost::File::Write | ( | const T & | mObject | ) | `[inline]`

Writes an object into the file.

Parameters:

  | mObject | The object to write

Note:
  This function changes the writing position

Definition at line 163 of file frost_utils_file.h.

template<class T >

void Frost::File::Write | ( | const T * | pTable,
|  | const s_uint & | uiNum |
| ) |  |  | `[inline]`

Writes a table into the file.

Parameters:

  | pTable | The table to write

Note:
  This function changes the writing position

Definition at line 153 of file frost_utils_file.h.

void Frost::File::Write | ( | const void * | pBuffer,
|  | const s_uint & | uiSize |
| ) |  |  |

Writes down some data into the file.

Parameters:

  | pBuffer | The object/array to write
  | uiSize | The object's size

Note:
  This function changes the writing position

Definition at line 144 of file frost_utils_file.cpp.

void Frost::File::Write | ( | const string_element * | sBuffer,
|  | const s_uint & | uiSize |
| ) |  |  |

Writes down a char array into the file.

Parameters:

  | sBuffer | The char array
  | uiSize | The number of char to write to the file

Note:
  This function changes the writing position

Definition at line 139 of file frost_utils_file.cpp.

void Frost::File::WriteLine | ( | const s_str & | sLine | ) |

Writes the content of the provided string and go to the next line.

Parameters:

  | sLine | The string to write

Note:
  This function automatically adds the line jump.

Definition at line 159 of file frost_utils_file.cpp.

## Member Data Documentation

const s_str Frost::File::CLASS_NAME = "File"`[static]`

Definition at line 226 of file frost_utils_file.h.

file_stream Frost::File::mFile_`[private]`

The file stream object.

Definition at line 231 of file frost_utils_file.h.

s_str Frost::File::sName_`[private]`

The name of this file.

Definition at line 233 of file frost_utils_file.h.

s_str Frost::File::sTabStr_`[private]`

The tabbing string.

Definition at line 235 of file frost_utils_file.h.

s_uint Frost::File::uiTabCount_`[private]`

The total tabbing.

Definition at line 237 of file frost_utils_file.h.

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

- D:/Programmation/Sources/Tensor2/Utils/include/frost_utils_file.h
- D:/Programmation/Sources/Tensor2/Utils/src/frost_utils_file.cpp