Refactor project structure
This commit is contained in:
205
core/anslicensing/validator.cpp
Normal file
205
core/anslicensing/validator.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// Copyright (c) ANSCENTER. All rights reserved.
|
||||
//
|
||||
|
||||
#include "precomp.h"
|
||||
#include "anslicensing.h"
|
||||
#include "template.h"
|
||||
#include "bitstream.h"
|
||||
#include "base32.h"
|
||||
#include "base64.h"
|
||||
#include "sha1.h"
|
||||
#include "except.h"
|
||||
#include "uniconv.h"
|
||||
#include "validator.h"
|
||||
|
||||
namespace ANSCENTER {
|
||||
namespace Licensing {
|
||||
template<>
|
||||
KeyValidatorT<char>::KeyValidatorT():
|
||||
m_Impl( *new KeyValidatorImpl() )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<wchar_t>::KeyValidatorT():
|
||||
m_Impl( *new KeyValidatorImpl() )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<char>::KeyValidatorT(const LicenseTemplateT<char> * keyTemplate):
|
||||
m_Impl( *new KeyValidatorImpl(&keyTemplate->m_Impl) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<wchar_t>::KeyValidatorT(const LicenseTemplateT<wchar_t> * keyTemplate):
|
||||
m_Impl( *new KeyValidatorImpl(&keyTemplate->m_Impl) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<char>::~KeyValidatorT()
|
||||
{
|
||||
delete & m_Impl;
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<wchar_t>::~KeyValidatorT()
|
||||
{
|
||||
delete & m_Impl;
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<char> * KeyValidatorT<char>::Create()
|
||||
{
|
||||
return new KeyValidatorT<char>();
|
||||
}
|
||||
|
||||
template<>
|
||||
KeyValidatorT<wchar_t> * KeyValidatorT<wchar_t>::Create()
|
||||
{
|
||||
return new KeyValidatorT<wchar_t>();
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::Destroy(KeyValidatorT<char> * obj)
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::Destroy(KeyValidatorT<wchar_t> * obj)
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::SetKeyTemplate(const LicenseTemplateT<char> * templ)
|
||||
{
|
||||
m_Impl.SetKeyTemplate(&templ->m_Impl);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::SetKeyTemplate(const LicenseTemplateT<wchar_t> * templ)
|
||||
{
|
||||
m_Impl.SetKeyTemplate(&templ->m_Impl);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::SetValidationData(const char * fieldName, const void * buf, int len)
|
||||
{
|
||||
|
||||
m_Impl.SetValidationData(fieldName, buf, len);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::SetValidationData(const wchar_t * fieldName, const void * buf, int len)
|
||||
{
|
||||
m_Impl.SetValidationData(w2s(fieldName).c_str(), buf, len);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::SetValidationData(const char * fieldName, const char * data)
|
||||
{
|
||||
m_Impl.SetValidationData(fieldName, data);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::SetValidationData(const wchar_t * fieldName, const wchar_t * data)
|
||||
{
|
||||
|
||||
m_Impl.SetValidationData(w2s(fieldName).c_str(), w2s(data).c_str());
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::SetValidationData(const char * fieldName, int data)
|
||||
{
|
||||
|
||||
m_Impl.SetValidationData(fieldName, data);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::SetValidationData(const wchar_t * fieldName, int data)
|
||||
{
|
||||
m_Impl.SetValidationData(w2s(fieldName).c_str(), data);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::SetKey(const char * key)
|
||||
{
|
||||
m_Impl.SetKey(key);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::SetKey(const wchar_t * key)
|
||||
{
|
||||
m_Impl.SetKey(w2s(key).c_str());
|
||||
}
|
||||
|
||||
template<>
|
||||
bool KeyValidatorT<char>::IsKeyValid()
|
||||
{
|
||||
return m_Impl.IsKeyValid();
|
||||
}
|
||||
|
||||
template<>
|
||||
bool KeyValidatorT<wchar_t>::IsKeyValid()
|
||||
{
|
||||
return m_Impl.IsKeyValid();
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::QueryKeyData(const char * dataField, void * buf, int * len)
|
||||
{
|
||||
m_Impl.QueryKeyData(dataField, buf, len);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::QueryKeyData(const wchar_t * dataField, void * buf, int * len)
|
||||
{
|
||||
m_Impl.QueryKeyData(w2s(dataField).c_str(), buf, len);
|
||||
}
|
||||
|
||||
template<>
|
||||
int KeyValidatorT<char>::QueryIntKeyData(const char * dataField)
|
||||
{
|
||||
return m_Impl.QueryIntKeyData(dataField);
|
||||
}
|
||||
|
||||
template<>
|
||||
int KeyValidatorT<wchar_t>::QueryIntKeyData(const wchar_t * dataField)
|
||||
{
|
||||
return m_Impl.QueryIntKeyData(w2s(dataField).c_str());
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::QueryDateKeyData(const char * dataField, int * year, int * month, int * day)
|
||||
{
|
||||
m_Impl.QueryDateKeyData(dataField, year, month, day);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::QueryDateKeyData(const wchar_t * dataField, int * year, int * month, int * day)
|
||||
{
|
||||
m_Impl.QueryDateKeyData(w2s(dataField).c_str(), year, month, day);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<char>::QueryValidationData(const char * dataField, void * buf, int * len)
|
||||
{
|
||||
m_Impl.QueryValidationData(dataField, buf, len);
|
||||
}
|
||||
|
||||
template<>
|
||||
void KeyValidatorT<wchar_t>::QueryValidationData(const wchar_t * dataField, void * buf, int * len)
|
||||
{
|
||||
m_Impl.QueryValidationData((dataField) ? w2s(dataField).c_str() : NULL, buf, len);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user