#include "stdafx.h"
#include "War3TypesAndConstants.h"
#include "War3StrID.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CWar3StrID::CWar3StrID()
{
	int i;
	for (i = 0; i <= WAR3STRID_MAXCHAR; i++)
	{
		strID[i] = '\0';
	}
}

CWar3StrID::~CWar3StrID()
{

}


char* CWar3StrID::GetStrID()
{
	return strID;
}


void CWar3StrID::SetStrID(const char acNewID[])
{
	int i;
	for (i = 0; i < WAR3STRID_MAXCHAR; i++)
	{
		strID[i] = acNewID[i];
	}
	strID[WAR3STRID_MAXCHAR] = '\0';
}


BOOL CWar3StrID::operator ==(const CWar3StrID &otherStrID) const
{
	BOOL ret = TRUE;
	int i = 0;
	while ((i < WAR3STRID_MAXCHAR) && (TRUE == ret))
	{
		if (strID[i] != otherStrID.strID[i])
		{
			ret = FALSE;
		}
		i++;
	}
	return ret;
}


BOOL CWar3StrID::operator ==(const char acStrID[]) const
{
	BOOL ret = TRUE;
	int i = 0;
	if (strID[0] == NULL)
		return ret;
	while ((i < WAR3STRID_MAXCHAR) && (TRUE == ret))
	{
		if (strID[i] != acStrID[i])
		{
			ret = FALSE;
		}
		i++;
	}
	return ret;
}


BOOL CWar3StrID::operator !=(const CWar3StrID &otherStrID) const
{
	BOOL ret = FALSE;
	int i = 0;
	while ((i < WAR3STRID_MAXCHAR) && (FALSE == ret))
	{
		if (strID[i] != otherStrID.strID[i])
		{
			ret = TRUE;
		}
		i++;
	}
	return ret;
}


BOOL CWar3StrID::operator !=(const char acStrID[]) const
{
	BOOL ret = FALSE;
	int i = 0;
	if (strID[i] == NULL)
		return ret;
	while ((i < WAR3STRID_MAXCHAR) && (FALSE == ret))
	{
		if (strID[i] != acStrID[i])
		{
			ret = TRUE;
		}
		i++;
	}
	return ret;
}


void CWar3StrID::operator =(const char acStrID[])
{
	SetStrID(acStrID);
}


char CWar3StrID::operator [](int nIndex) const
{
	if ((nIndex < WAR3STRID_MAXCHAR) && (nIndex >= 0))
	{
		return strID[nIndex];
	}
	else
	{
		return '\0';
	}
}

CWar3StrID::CWar3StrID(const char acStrID[])
{
	SetStrID(acStrID);
}
