Example #1
0
BOOL CLocationList::InitList(const char * pszFileList)
{
	TString strA, strB;
	TFile file;
	CLocation * loc = NULL;

	// try to open
	if (file.Open(pszFileList, "r") == FALSE)
	{
		InitInternal();
		m_bModified = TRUE;
		return FALSE;
	}

	// read file
	while(file.ReadPropertyLine(strA, strB))
	{
		if (loc == NULL)
		{
			loc = new CLocation;
			if (loc == NULL)
				break;
		}

		if (strA == "@create")
		{
			AddTail(loc);
			loc = NULL;
		}
		else if (strA == "@city")
		{
			loc->m_strCity = strB.c_str();
		}
		else if (strA == "@country")
		{
			loc->m_strCountry = strB.c_str();
		}
		else if (strA == "@lat")
		{
			loc->m_fLatitude = atof(strB);
		}
		else if (strA == "@long")
		{
			loc->m_fLongitude = atof(strB.c_str());
		}
		else if (strA == "@timezone")
		{
			loc->m_fTimezone = atof(strB.c_str());
		}
		else if (strA == "@dst")
		{
			loc->m_nDST = atoi(strB.c_str());
		}

	}

	// zatvara subor
	file.Close();

	return TRUE;
}