コード例 #1
0
LPDATAFILETREE vmsDataFile::CreateSection(LPCSTR pszSection, LPDATAFILETREE ptRoot)
{
	if (ptRoot == NULL)
		ptRoot = m_tData;

	if (pszSection == NULL || *pszSection == 0)
		return ptRoot;

	fsString strS;
	while (*pszSection && *pszSection != '\\' && *pszSection != '/')
		strS += *pszSection++;

	if (*pszSection)
		pszSection++;

	if (strS != "")
	for (int i = 0; i < ptRoot->GetLeafCount (); i++)
	{
		LPDATAFILETREE ptLeaf = ptRoot->GetLeaf (i);
		if (ptLeaf->GetData ().vt.empty () && ptLeaf->GetData ().strName == strS) 
			return CreateSection (pszSection, ptLeaf);
	}

	
	
	LPDATAFILETREE ptLeaf = ptRoot->AddLeaf (vmsDataFileItem ());
	ptLeaf->GetData ().strName = strS;
	return CreateSection (pszSection, ptLeaf);
}
コード例 #2
0
LPDATAFILEITEM vmsDataFile::CreateItem(LPDATAFILETREE pSection, LPCSTR pszItemName)
{
	LPDATAFILETREE ptLeaf = FindItem (NULL, pszItemName, pSection);
	if (ptLeaf == NULL)
	{
		ptLeaf = pSection->AddLeaf (vmsDataFileItem ());
		ptLeaf->GetData ().strName = pszItemName;
	}
	return &ptLeaf->GetData ().vt;
}
コード例 #3
0
void vmsDataFile::LoadFromFile(vmsFile &file, LPDATAFILETREE ptRoot)
{
	ASSERT (ptRoot != NULL);

	LoadFromFile (file, ptRoot->GetData ());

	if (ptRoot->GetData ().vt.empty () == false)
		return;	

	int cLeafs;
	file.ReadInt (cLeafs);

	for (int i = 0; i < cLeafs; i++)
		LoadFromFile (file, ptRoot->AddLeaf (vmsDataFileItem ()));
}
コード例 #4
0
bool vmsDataFile::LoadFromBuffer(LPBYTE& pbtCurrentPos, LPBYTE pbtBuffer, DWORD dwBufferSizeSize, LPDATAFILETREE ptRoot)
{
	ASSERT (ptRoot != NULL);

	if (!LoadFromBuffer (pbtCurrentPos, pbtBuffer, dwBufferSizeSize, ptRoot->GetData ()))
		return false;

	if (ptRoot->GetData ().vt.empty () == false) {
		return true;	
	}

	int cLeafs;
	if (!getVarFromBuffer(cLeafs, pbtCurrentPos, pbtBuffer, dwBufferSizeSize))
		return false;

	for (int i = 0; i < cLeafs; i++) {
		if (!LoadFromBuffer (pbtCurrentPos, pbtBuffer, dwBufferSizeSize, ptRoot->AddLeaf (vmsDataFileItem ())))
			return false;
	}

	return true;
}