void vmsDataFile::SaveToFile(vmsFile &file, LPDATAFILETREE ptRoot) { ASSERT (ptRoot != NULL); SaveToFile (file, ptRoot->GetData ()); if (ptRoot->GetData ().vt.empty () == false) return; file.WriteInt (ptRoot->GetLeafCount ()); for (int i = 0; i < ptRoot->GetLeafCount (); i++) SaveToFile (file, ptRoot->GetLeaf (i)); }
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); }
LPDATAFILETREE vmsDataFile::FindItem(LPCSTR pszSection, LPCSTR pszValueName, LPDATAFILETREE ptRoot) { if (ptRoot == NULL) ptRoot = m_tData; fsString strS; if (pszSection && *pszSection) { while (*pszSection && *pszSection != '\\' && *pszSection != '/') strS += *pszSection++; if (*pszSection) pszSection++; } if (strS.IsEmpty () == FALSE) { for (int i = 0; i < ptRoot->GetLeafCount (); i++) { LPDATAFILETREE ptLeaf = ptRoot->GetLeaf (i); if (ptLeaf->GetData ().vt.empty () && ptLeaf->GetData ().strName == strS) return *pszSection || (pszValueName && *pszValueName) ? FindItem (pszSection, pszValueName, ptLeaf) : ptLeaf; } return NULL; } for (int i = 0; i < ptRoot->GetLeafCount (); i++) { LPDATAFILETREE ptLeaf = ptRoot->GetLeaf (i); if (ptLeaf->GetData ().vt.empty () == false && ptLeaf->GetData ().strName == pszValueName) return ptLeaf; } return NULL; }
void vmsDataFile::SaveToBuffer(LPBYTE& pbtCurrentPos, LPBYTE pbtBuffer, DWORD dwBufferSize, DWORD* pdwRequiredSize, LPDATAFILETREE ptRoot) { ASSERT (ptRoot != NULL); if (pbtBuffer == NULL) { SaveToBuffer (pbtCurrentPos, 0, 0, pdwRequiredSize, ptRoot->GetData ()); if (ptRoot->GetData ().vt.empty () == false) { return; } int nCount = ptRoot->GetLeafCount (); putVarToBuffer(nCount, pbtCurrentPos, 0, 0, pdwRequiredSize); for (int i = 0; i < ptRoot->GetLeafCount (); i++) { SaveToBuffer (pbtCurrentPos, 0, 0, pdwRequiredSize, ptRoot->GetLeaf (i)); } return; } SaveToBuffer (pbtCurrentPos, pbtBuffer, dwBufferSize, 0, ptRoot->GetData ()); if (ptRoot->GetData ().vt.empty () == false) { return; } int nCount = ptRoot->GetLeafCount (); putVarToBuffer(nCount, pbtCurrentPos, pbtBuffer, dwBufferSize, 0); for (int i = 0; i < ptRoot->GetLeafCount (); i++) { SaveToBuffer (pbtCurrentPos, pbtBuffer, dwBufferSize, 0, ptRoot->GetLeaf (i)); } }