1#ifndef LS_LICENSE_FILE_STORAGE_H
2#define LS_LICENSE_FILE_STORAGE_H
7#pragma warning( disable : 4251 )
14namespace boost {
namespace interprocess {
class permissions; } }
23 using ptr_t = std::shared_ptr<LicenseFileStorageBase>;
28 static ptr_t create(
const std::wstring& licensePath = std::wstring() );
82 std::string
readLicense(
const std::wstring& filePath )
const;
87 void writeLicense(
const std::wstring& filePath,
const std::string& data )
const;
96 using ptr_t = std::shared_ptr<LicenseFileStorage>;
101 static ptr_t create(
const std::wstring& licensePath = std::wstring() );
129 using ptr_t = std::shared_ptr<LicenseFileStorageEx>;
135 static ptr_t create(
const std::string& appName,
const std::wstring& licensePath = std::wstring() );
186 uint32_t m_lockTimeout;
187 boost::interprocess::permissions* m_perm;
197 using ptr_t = std::shared_ptr<FileStorageWithLock>;
202 static ptr_t create(
const std::wstring& licensePath = std::wstring() );
238 uint32_t m_attemptsCount;
239 uint32_t m_waitTimeout;
244#pragma warning( pop )
#define LS_API
Macros that expands to dllexport, dllimport or nothing on non Windows platforms or in case of static ...
Class that saves license in a file, derived from LicenseFileStorageBase class.
void setAttemptsCount(uint32_t count)
Set file lock operation attempts count.
static ptr_t create(const std::wstring &licensePath=std::wstring())
Allocates and constructs a FileStorageWithLock object and passes args to FileStorageWithLock().
void setWaitTimeout(uint32_t timeout)
Set timeout in milliseconds between file lock attempts.
uint32_t waitTimeout() const
Get timeout in milliseconds between file lock attempts.
void clear() override
Removes local license file.
FileStorageWithLock(const std::wstring &licensePath=std::wstring())
FileStorageWithLock constructor.
void saveLicense(const std::string &data) override
Saves given license data string to the file.
std::string loadLicense() override
Load license from file.
uint32_t attemptsCount() const
Get file lock operation attempts count.
Base class that saves license in a file, implements ILicenseStorage interface.
static ptr_t create(const std::wstring &licensePath=std::wstring())
Allocates and constructs a LicenseFileStorageBase object and passes args to LicenseFileStorageBase().
void clear() override
Removes local license file.
std::string loadLicense() override
Load license from file.
const std::wstring & licenseFolderPath() const
Getter for folder path where License file is being stored.
std::string readLicense(const std::wstring &filePath) const
Reads license from file.
void setLicenseFileName(const std::wstring &name)
Setter for license filename with extension (optional). Default filename is License....
const std::wstring & licenseFileName() const
Getter for license filename with extension (optional).
LicenseFileStorageBase(const std::wstring &licensePath=std::wstring())
Constructor for LicenseFileStorageBase object.
void saveLicense(const std::string &data) override
Saves given license data string to the file.
std::wstring m_folderPath
void setLicenseFolderPath(const std::wstring &path)
Setter for folder path where License file is being stored.
std::wstring licenseFilePath() const
Getter for path to the license file.
std::shared_ptr< LicenseFileStorageBase > ptr_t
void writeLicense(const std::wstring &filePath, const std::string &data) const
Writes given license data string to the file.
std::wstring prepareWrite() const
Prepare to write license file.
std::wstring prepareRead() const
Prepare to read license file.
Class that saves license in a file, derived from LicenseFileStorageBase class.
void setLockTimeout(uint32_t timeout)
Set timeout in milliseconds for trylock.
void setPermissionsUnrestricted()
Sets permissions to unrestricted access: null DACL for windows or 0666 for UNIX.
void setPermissionsUnix(int permissions)
Set platform dependent permission (Unix like systems).
void saveLicense(const std::string &data) override
Saves given license data string to the file.
uint32_t lockTimeout() const
Get trylock timeout in milliseconds.
static ptr_t create(const std::string &appName, const std::wstring &licensePath=std::wstring())
Allocates and constructs a LicenseFileStorageEx object and passes args to LicenseFileStorageEx().
void clear() override
Removes local license file.
void setPermissionsDefault()
Sets permissions to default values: null security attributes pointer for Windows or 0644 for UNIX.
void setPermissionsWin(void *permissions)
Set platform dependent permission (Windows).
std::string loadLicense() override
Load license from file.
~LicenseFileStorageEx() override
Destructor for LicenseFileStorageEx object.
LicenseFileStorageEx(const std::string &appName, const std::wstring &licensePath=std::wstring())
LicenseFileStorageEx constructor.
Class that saves license in a file, derived from LicenseFileStorageBase class.
LicenseFileStorage(const std::wstring &licensePath=std::wstring())
Constructor for LicenseFileStorage object.
void saveLicense(const std::string &data) override
Saves given license data string to the file.
std::string loadLicense() override
Load license from file.
static ptr_t create(const std::wstring &licensePath=std::wstring())
Allocates and constructs a LicenseFileStorage object and passes args to LicenseFileStorage().
void clear() override
Removes local license file.
LicenseStorage interface.