void vmsDataFile::get_Value(LPCSTR pszSection, LPCSTR pszValueName, LPBYTE &pbValue, UINT &nValueSize) { LPDATAFILETREE item = FindItem (pszSection, pszValueName); if (item && item->GetData ().vt.type () != VVT_EMPTY) { pbValue = item->GetData ().vt; nValueSize = item->GetData ().vt.bytebuffersize (); } }
bool vmsDataFile::get_Value(LPCSTR pszSection, LPCSTR pszValueName, LPCSTR &pszValue) { LPDATAFILETREE item = FindItem (pszSection, pszValueName); if (item) { pszValue = item->GetData ().vt; return true; } return false; }
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; }
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); }
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 ())); }
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; }
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; }
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)); } }
void vmsDataFile::get_Value(LPCSTR pszSection, LPCSTR pszValueName, LPCSTR &pszValue) { LPDATAFILETREE item = FindItem (pszSection, pszValueName); if (item) pszValue = item->GetData ().vt; }