LicenseSpring C++ SDK 7.31.0
Easily add Software Licensing to your application
LicenseSpring::LicenseFileStorageBase Class Reference

Base class that saves license in a file, implements ILicenseStorage interface. More...

#include <LicenseSpring/LicenseFileStorage.h>

Inheritance diagram for LicenseSpring::LicenseFileStorageBase:
LicenseSpring::LicenseStorage LicenseSpring::FileStorageWithLock LicenseSpring::LicenseFileStorage LicenseSpring::LicenseFileStorageEx

Public Types

using ptr_t = std::shared_ptr< LicenseFileStorageBase >
 
- Public Types inherited from LicenseSpring::LicenseStorage
using ptr_t = std::shared_ptr< LicenseStorage >
 

Public Member Functions

 LicenseFileStorageBase (const std::wstring &licensePath=std::wstring())
 Constructor for LicenseFileStorageBase object. More...
 
void saveLicense (const std::string &data) override
 Saves given license data string to the file. More...
 
std::string loadLicense () override
 Load license from file. More...
 
void clear () override
 Removes local license file. More...
 
void setLicenseFileName (const std::wstring &name)
 Setter for license filename with extension (optional). Default filename is License.key. More...
 
void setLicenseFolderPath (const std::wstring &path)
 Setter for folder path where License file is being stored. More...
 
const std::wstring & licenseFileName () const
 Getter for license filename with extension (optional). More...
 
const std::wstring & licenseFolderPath () const
 Getter for folder path where License file is being stored. More...
 
std::wstring licenseFilePath () const
 Getter for path to the license file. More...
 
- Public Member Functions inherited from LicenseSpring::LicenseStorage
virtual void saveLicense (const std::string &licenseData)=0
 Save license data somewhere. More...
 
virtual std::string loadLicense ()=0
 Load license data. More...
 
virtual void clear ()=0
 Removes local license data. More...
 
virtual ~LicenseStorage ()
 Destructor for LicenseStorage object. More...
 

Static Public Member Functions

static ptr_t create (const std::wstring &licensePath=std::wstring())
 Allocates and constructs a LicenseFileStorageBase object and passes args to LicenseFileStorageBase(). More...
 

Protected Member Functions

std::wstring prepareRead () const
 Prepare to read license file. More...
 
std::wstring prepareWrite () const
 Prepare to write license file. More...
 
std::string readLicense (const std::wstring &filePath) const
 Reads license from file. More...
 
void writeLicense (const std::wstring &filePath, const std::string &data) const
 Writes given license data string to the file. More...
 

Protected Attributes

std::wstring m_folderPath
 
std::wstring m_fileName
 

Detailed Description

Base class that saves license in a file, implements ILicenseStorage interface.

This class does not use any techniques for file access synchronization so it is not thread safe.

Definition at line 20 of file LicenseFileStorage.h.

Member Typedef Documentation

◆ ptr_t

Constructor & Destructor Documentation

◆ LicenseFileStorageBase()

LicenseSpring::LicenseFileStorageBase::LicenseFileStorageBase ( const std::wstring &  licensePath = std::wstring())

Constructor for LicenseFileStorageBase object.

Parameters
licensePathThe path that license folder path will be set to

Member Function Documentation

◆ create()

static ptr_t LicenseSpring::LicenseFileStorageBase::create ( const std::wstring &  licensePath = std::wstring())
static

Allocates and constructs a LicenseFileStorageBase object and passes args to LicenseFileStorageBase().

Parameters
licensePathThe path that license folder path will be set to
Returns
A shared_ptr object that owns and stores a pointer to a newly allocated LicenseFileStorageBase object.

◆ saveLicense()

void LicenseSpring::LicenseFileStorageBase::saveLicense ( const std::string &  data)
overridevirtual

Saves given license data string to the file.

Parameters
dataLicense data string

Implements LicenseSpring::LicenseStorage.

Reimplemented in LicenseSpring::LicenseFileStorage, LicenseSpring::LicenseFileStorageEx, and LicenseSpring::FileStorageWithLock.

◆ loadLicense()

std::string LicenseSpring::LicenseFileStorageBase::loadLicense ( )
overridevirtual

Load license from file.

Returns
Encrypted license data.

Implements LicenseSpring::LicenseStorage.

Reimplemented in LicenseSpring::LicenseFileStorage, LicenseSpring::LicenseFileStorageEx, and LicenseSpring::FileStorageWithLock.

◆ clear()

void LicenseSpring::LicenseFileStorageBase::clear ( )
overridevirtual

◆ setLicenseFileName()

void LicenseSpring::LicenseFileStorageBase::setLicenseFileName ( const std::wstring &  name)

Setter for license filename with extension (optional). Default filename is License.key.

Parameters
nameNew license filename

◆ setLicenseFolderPath()

void LicenseSpring::LicenseFileStorageBase::setLicenseFolderPath ( const std::wstring &  path)

Setter for folder path where License file is being stored.

Parameters
pathNew license folder path

◆ licenseFileName()

const std::wstring & LicenseSpring::LicenseFileStorageBase::licenseFileName ( ) const

Getter for license filename with extension (optional).

Default filename is License.key.

Returns
License filename with extension.

◆ licenseFolderPath()

const std::wstring & LicenseSpring::LicenseFileStorageBase::licenseFolderPath ( ) const

Getter for folder path where License file is being stored.

Returns
License folder path.

◆ licenseFilePath()

std::wstring LicenseSpring::LicenseFileStorageBase::licenseFilePath ( ) const

Getter for path to the license file.

Returns
Absolute path to the license file.

◆ prepareRead()

std::wstring LicenseSpring::LicenseFileStorageBase::prepareRead ( ) const
protected

Prepare to read license file.

Returns
Absolute path to the license file or empty string if file does not exist.

◆ prepareWrite()

std::wstring LicenseSpring::LicenseFileStorageBase::prepareWrite ( ) const
protected

Prepare to write license file.

Also creates corresponding folders if they do not exist.

Returns
Absolute path to the license file.

◆ readLicense()

std::string LicenseSpring::LicenseFileStorageBase::readLicense ( const std::wstring &  filePath) const
protected

Reads license from file.

Parameters
filePathAbsolute path to the license file
Returns
Encrypted license data.

◆ writeLicense()

void LicenseSpring::LicenseFileStorageBase::writeLicense ( const std::wstring &  filePath,
const std::string &  data 
) const
protected

Writes given license data string to the file.

Parameters
filePathAbsolute path to the license file
dataLicense data string

Member Data Documentation

◆ m_folderPath

std::wstring LicenseSpring::LicenseFileStorageBase::m_folderPath
protected

Definition at line 67 of file LicenseFileStorage.h.

◆ m_fileName

std::wstring LicenseSpring::LicenseFileStorageBase::m_fileName
protected

Definition at line 68 of file LicenseFileStorage.h.


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