LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SmartVersionFile Class Referencefinal

The SmartVersionFile class. More...

#include <smartversionfile.h>

+ Inheritance diagram for SmartVersionFile:
+ Collaboration diagram for SmartVersionFile:

Public Member Functions

 SmartVersionFile ()=delete
 
 SmartVersionFile (const SmartVersionFile &other)=delete
 
 SmartVersionFile (const FilePath &filepath, bool restore, bool readOnly)
 The constructor to open an existing version file. More...
 
 ~SmartVersionFile () noexcept
 The destructor. More...
 
const VersiongetVersion () const noexcept
 Get the content of the file. More...
 
void setVersion (const Version &version) noexcept
 Set the version of the file. More...
 
void save (bool toOriginal)
 Write all changes to the file system. More...
 
SmartVersionFileoperator= (const SmartVersionFile &rhs)=delete
 
- Public Member Functions inherited from SmartFile
 SmartFile ()=delete
 
 SmartFile (const SmartFile &other)=delete
 
 SmartFile (const FilePath &filepath, bool restore, bool readOnly, bool create)
 The constructor. More...
 
virtual ~SmartFile () noexcept
 The destructor. More...
 
const FilePathgetFilepath () const noexcept
 Get the filepath to the file which was passed to the constructor. More...
 
bool isRestored () const noexcept
 Check if this file was restored from a backup. More...
 
bool isReadOnly () const noexcept
 Check if this file was opened in read-only mode. More...
 
bool isCreated () const noexcept
 Check if this file is created and not yet saved to the harddisc. More...
 
void removeFile (bool original)
 Remove the file from the file system. More...
 
SmartFileoperator= (const SmartFile &rhs)=delete
 

Static Public Member Functions

static SmartVersionFilecreate (const FilePath &filepath, const Version &version)
 Create a new version file. More...
 

Protected Member Functions

 SmartVersionFile (const FilePath &filepath, const Version &newVersion)
 Constructor to create a new version file. More...
 
- Protected Member Functions inherited from SmartFile
const FilePathprepareSaveAndReturnFilePath (bool toOriginal)
 Prepare to save the file and return the filepath to the file. More...
 
void updateMembersAfterSaving (bool toOriginal) noexcept
 Update the member variables mIsRestored and mIsCreated after saving. More...
 

Static Protected Member Functions

static Version readVersionFromFile (const FilePath &filepath)
 

Protected Attributes

Version mVersion
 The version number of the file. More...
 
- Protected Attributes inherited from SmartFile
FilePath mFilePath
 The filepath which was passed to the constructor. More...
 
FilePath mTmpFilePath
 The filepath to the temporary file (mFilePath + '~') More...
 
FilePath mOpenedFilePath
 The filepath from where the content was loaded. More...
 
bool mIsRestored
 This variable determines whether the file was restored or not. More...
 
bool mIsReadOnly
 If true, the file is opened as read-only. More...
 
bool mIsCreated
 If true, the file was created and not yet written to the filesystem (so the file mFilePath does not yet exist!) More...
 

Detailed Description

The SmartVersionFile class.

Note
See class SmartFile for more information.
Author
ubruhin
Date
2016-08-06

Constructor & Destructor Documentation

SmartVersionFile ( )
delete

+ Here is the caller graph for this function:

SmartVersionFile ( const SmartVersionFile other)
delete
SmartVersionFile ( const FilePath filepath,
bool  restore,
bool  readOnly 
)

The constructor to open an existing version file.

This constructor tries to open an existing file and throws an exception if an error occurs.

Parameters
filepathSee SmartFile::SmartFile()
restoreSee SmartFile::SmartFile()
readOnlySee SmartFile::SmartFile()
Exceptions
ExceptionSee SmartFile::SmartFile()
~SmartVersionFile ( )
noexcept

The destructor.

Removes the temporary file (if existing)

SmartVersionFile ( const FilePath filepath,
const Version newVersion 
)
protected

Constructor to create a new version file.

Parameters
filepathSee SmartFile::SmartFile()
newVersionThe new version of the file
Exceptions
ExceptionSee SmartFile::SmartFile()

Member Function Documentation

const Version& getVersion ( ) const
inlinenoexcept

Get the content of the file.

Returns
The content of the file

+ Here is the caller graph for this function:

void setVersion ( const Version version)
inlinenoexcept

Set the version of the file.

Note
The version won't be written to the file until save() is called.
Parameters
versionThe new version of the file
void save ( bool  toOriginal)

Write all changes to the file system.

Parameters
toOriginalSpecifies whether the original or the backup file should be overwritten/created.
Exceptions
ExceptionIf an error occurs

+ Here is the call graph for this function:

SmartVersionFile& operator= ( const SmartVersionFile rhs)
delete
SmartVersionFile * create ( const FilePath filepath,
const Version version 
)
static

Create a new version file.

Note
This method will NOT immediately create the file! The file will be created after calling save().
Parameters
filepathThe filepath to the file to create (always to the original file, not to the backup file with "~" at the end of the filename!)
Returns
The SmartVersionFile object of the created file
Exceptions
ExceptionIf an error occurs

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Version readVersionFromFile ( const FilePath filepath)
staticprotected

+ Here is the call graph for this function:

Member Data Documentation

Version mVersion
protected

The version number of the file.


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