#include "precomp.h"
#include "anslicensing.h"
#include "uniconv.h"
#include "licensevalidationresult.h"

namespace ANSCENTER {
	namespace Licensing {

		template<>
		LicenseValidationResultT<char>::LicenseValidationResultT() :
			m_Impl(*new LicenseValidationResultImpl())
		{

		}

		template<>
		LicenseValidationResultT<wchar_t>::LicenseValidationResultT() :
			m_Impl(*new LicenseValidationResultImpl())
		{

		}

		template<>
		LicenseValidationResultT<char>::~LicenseValidationResultT()
		{
			delete & m_Impl;
		}

		template<>
		LicenseValidationResultT<wchar_t>::~LicenseValidationResultT()
		{
			delete & m_Impl;
		}

		template<>
		LicenseT<char> * LicenseValidationResultT<char>::GetLicense()
		{
			static LicenseT<char> result;
			
			LicenseImpl * resultImpl = m_Impl.GetLicense();

			if (!resultImpl) return NULL;

			result.m_Impl.CopyFrom(resultImpl);
	 
			return &result;
		}

		template<>
		LicenseT<wchar_t> * LicenseValidationResultT<wchar_t>::GetLicense()
		{
			static LicenseT<wchar_t> result;

			LicenseImpl * resultImpl = m_Impl.GetLicense();

			if (!resultImpl) return NULL;

			result.m_Impl.CopyFrom(resultImpl);

			return &result;
		}

		template<>
		bool LicenseValidationResultT<char>::IsLicenseExpired()
		{
			return m_Impl.IsLicenseExpired();
		}

		template<>
		bool LicenseValidationResultT<wchar_t>::IsLicenseExpired()
		{
			return m_Impl.IsLicenseExpired();
		}

		template<>
		bool LicenseValidationResultT<char>::IsPaymentRequired()
		{
			return m_Impl.IsPaymentRequired();
		}

		template<>
		bool LicenseValidationResultT<wchar_t>::IsPaymentRequired()
		{
			return m_Impl.IsPaymentRequired();
		}

		template<>
		int LicenseValidationResultT<char>::GetLicenseValidityDays()
		{
			return m_Impl.GetLicenseValidityDays();
		}

		template<>
		int LicenseValidationResultT<wchar_t>::GetLicenseValidityDays()
		{
			return m_Impl.GetLicenseValidityDays();
		}

		template<>
		void LicenseValidationResultT<char>::GetLicenseExpirationDate(int * year, int * month, int * day)
		{
			m_Impl.GetLicenseExpirationDate(year, month, day);
		}

		template<>
		void LicenseValidationResultT<wchar_t>::GetLicenseExpirationDate(int * year, int * month, int * day)
		{
			m_Impl.GetLicenseExpirationDate(year, month, day);
		}
	};
};
