Initial setup for CLion
This commit is contained in:
104
anslicensing/license.h
Normal file
104
anslicensing/license.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "except.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class LicenseImpl {
|
||||
|
||||
friend class LicenseValidationResultT<char>;
|
||||
friend class LicenseValidationResultT<wchar_t>;
|
||||
|
||||
public:
|
||||
LicenseImpl():
|
||||
m_isLease(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CopyFrom(const LicenseImpl * src)
|
||||
{
|
||||
m_activationKey = src->m_activationKey;
|
||||
m_hardwareId = src->m_hardwareId;
|
||||
m_isLease = src->m_isLease;
|
||||
m_licenseKey = src->m_licenseKey;
|
||||
m_xmlLicense = src->m_xmlLicense;
|
||||
SetLicenseKeyValidationData(src->m_licenseKeyValidationData.data(), src->m_licenseKeyValidationData.size());
|
||||
}
|
||||
|
||||
void LoadXml(const char * xml);
|
||||
const char * SaveXml();
|
||||
|
||||
void LoadJson(const char * json);
|
||||
const char * SaveJson();
|
||||
|
||||
const char * GetLicenseKey() const
|
||||
{
|
||||
return m_licenseKey.c_str();
|
||||
}
|
||||
|
||||
void SetLicenseKey(const char * licenseKey)
|
||||
{
|
||||
m_licenseKey = licenseKey;
|
||||
}
|
||||
|
||||
void GetLicenseKeyValidationData(const void ** buf, int * len) const
|
||||
{
|
||||
*buf = m_licenseKeyValidationData.data();
|
||||
*len = m_licenseKeyValidationData.size();
|
||||
}
|
||||
|
||||
void SetLicenseKeyValidationData(const void* buf, int len)
|
||||
{
|
||||
if (buf && len > 0)
|
||||
{
|
||||
m_licenseKeyValidationData.resize(len);
|
||||
memcpy(m_licenseKeyValidationData.data(), buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_licenseKeyValidationData.clear();
|
||||
}
|
||||
}
|
||||
|
||||
const char * GetActivationKey() const
|
||||
{
|
||||
return m_activationKey.c_str();
|
||||
}
|
||||
|
||||
void SetActivationKey(const char * activationKey)
|
||||
{
|
||||
m_activationKey = activationKey;
|
||||
}
|
||||
|
||||
const char * GetHardwareId() const
|
||||
{
|
||||
return m_hardwareId.c_str();
|
||||
}
|
||||
|
||||
void SetHardwareId(const char * hardwareId)
|
||||
{
|
||||
m_hardwareId = hardwareId;
|
||||
}
|
||||
|
||||
bool IsLease() const
|
||||
{
|
||||
return m_isLease;
|
||||
}
|
||||
|
||||
void SetLease(bool isLease)
|
||||
{
|
||||
m_isLease = isLease;
|
||||
}
|
||||
|
||||
private:
|
||||
string m_licenseKey;
|
||||
string m_activationKey;
|
||||
string m_hardwareId;
|
||||
vector<unsigned char> m_licenseKeyValidationData;
|
||||
bool m_isLease;
|
||||
string m_xmlLicense;
|
||||
string m_jsonLicense;
|
||||
static const int m_version = 1;
|
||||
};
|
||||
Reference in New Issue
Block a user