SDFormat Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
FileOperations Class Reference

Singleton class to handle file operations. More...

#include <file_operations.h>

Collaboration diagram for FileOperations:
Collaboration graph

Public Member Functions

std::string OpenFileDialog ()
 Opens a dialog for the user to open a file on their filesystem.
 
std::string OpenDirectoryDialog ()
 Opens a dialog for the user to open a directory on their filesystem.
 
bool WriteFile (const std::string &file_path, const std::string &contents)
 writes a string to a file
 
bool WriteFile (const std::string &contents)
 writes a string to the currently opened file
 
void SetActiveFilePath (const std::string &file_path)
 Sets the active file path.
 

Static Public Member Functions

static FileOperationsGetSoleInstance ()
 The only method by which a FileOperations instance can be returned.
 

Private Member Functions

 FileOperations ()=default
 Prevent access to the constructor of this class.
 
 ~FileOperations ()=default
 Prevent access to the destructor of this class.
 
FileOperationsoperator= (const FileOperations &)=delete
 Prevent the assignment of one instance of FileOperations to another, ensuring there can only be one instance.
 
 FileOperations (const FileOperations &)=delete
 Delete the copy constructor of FileOperations, preventing copies of the reference the the sole instance from being made

 

Private Attributes

std::string active_file_path
 

Detailed Description

Singleton class to handle file operations.

Member Function Documentation

◆ GetSoleInstance()

FileOperations & FileOperations::GetSoleInstance ( )
static

The only method by which a FileOperations instance can be returned.

Returns
The sole instance of FileOperationsI

◆ OpenDirectoryDialog()

std::string FileOperations::OpenDirectoryDialog ( )

Opens a dialog for the user to open a directory on their filesystem.

Returns
An absolute directory path or an empty string

◆ OpenFileDialog()

std::string FileOperations::OpenFileDialog ( )

Opens a dialog for the user to open a file on their filesystem.

Returns
An absolute file path or an empty string

◆ SetActiveFilePath()

void FileOperations::SetActiveFilePath ( const std::string &  file_path)

Sets the active file path.

Parameters
[in]file_pathThe file path to set as the active path

◆ WriteFile() [1/2]

bool FileOperations::WriteFile ( const std::string &  contents)

writes a string to the currently opened file

Parameters
[in]contentsthe contents to write to the given file
Returns
true if successful

◆ WriteFile() [2/2]

bool FileOperations::WriteFile ( const std::string &  file_path,
const std::string &  contents 
)

writes a string to a file

Parameters
[in]file_paththe filepath of the file to write to
[in]contentsthe contents to write to the given file
Returns
true if successful

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