jaffarCommon
Loading...
Searching...
No Matches
Classes | Functions
file.hpp File Reference

Contains common functions related to file manipulation. More...

#include <cstdio>
#include <cstring>
#include <fstream>
#include <functional>
#include <map>
#include <memory>
#include <sstream>
#include <string>
Include dependency graph for file.hpp:

Go to the source code of this file.

Classes

class  jaffarCommon::file::MemoryFile
 
class  jaffarCommon::file::MemoryFileDirectory
 

Functions

static __JAFFAR_COMMON__INLINE__ std::string jaffarCommon::file::slurp (std::ifstream &in)
 
static __JAFFAR_COMMON__INLINE__ bool jaffarCommon::file::loadStringFromFile (std::string &dst, const std::string &fileName)
 
static __JAFFAR_COMMON__INLINE__ bool jaffarCommon::file::saveStringToFile (const std::string &src, const std::string &fileName)
 

Detailed Description

Contains common functions related to file manipulation.

Function Documentation

◆ loadStringFromFile()

static __JAFFAR_COMMON__INLINE__ bool jaffarCommon::file::loadStringFromFile ( std::string &  dst,
const std::string &  fileName 
)
static

Reads an entire file into a string

Parameters
[out]dstThe output string onto which to save the read file
[in]fileNameThe name of the file to read
Returns
Whether the load operation succeded (true) or failed (fail)

◆ saveStringToFile()

static __JAFFAR_COMMON__INLINE__ bool jaffarCommon::file::saveStringToFile ( const std::string &  src,
const std::string &  fileName 
)
static

Write a string into a file

Parameters
[in]srcThe source string to save into the file
[in]fileNameThe name of the file to write to
Returns
Whether the save operation succeded (true) or failed (fail)

◆ slurp()

static __JAFFAR_COMMON__INLINE__ std::string jaffarCommon::file::slurp ( std::ifstream &  in)
static

Function to read an entire input file file into a standard string

Taken from https://stackoverflow.com/questions/116038/how-do-i-read-an-entire-file-into-a-stdstring-in-c/116220#116220

Parameters
[in]inThe input file file
Returns
The produced string containing the entire input from the file