// Retrieve a list of key names of the specified section DWORD CIni::GetKeyNames(LPCTSTR lpSection, LPTSTR lpBuffer, DWORD dwBufSize) const { if (lpBuffer != NULL) *lpBuffer = _T('\0'); if (lpSection == NULL) return 0; STR_LIMIT sl; sl.lpTarget = lpBuffer; sl.dwRemain = dwBufSize; sl.dwTotalCopied = 0; const DWORD LEN = GetKeyLines(lpSection, NULL, 0); if (LEN == 0) return 0; LPTSTR psz = new TCHAR[LEN + 1]; GetKeyLines(lpSection, psz, LEN); ParseDNTString(psz, __KeyPairProc, (LPVOID)(&sl)); delete [] psz; if (lpBuffer != NULL) lpBuffer[sl.dwTotalCopied] = _T('\0'); return sl.dwTotalCopied; }
// Retrieve a list of key names of the specified section void CIni::GetKeyNames(LPCTSTR lpSection, CStringArray *pArray) const { if (pArray == NULL) return; pArray->RemoveAll(); const DWORD LEN = GetKeyNames(lpSection, NULL, 0); LPTSTR psz = new TCHAR[LEN + 1]; GetKeyNames(lpSection, psz, LEN); ParseDNTString(psz, __SubStrAdd, (LPVOID)pArray); delete [] psz; }
void CIni::GetSectionNames(CStringArray *pArray) const { if (pArray != NULL) pArray->RemoveAll(); const DWORD LEN = GetSectionNames(NULL, 0); if (LEN == 0) return; LPTSTR psz = new TCHAR[LEN + 1]; GetSectionNames(psz, LEN); ParseDNTString(psz, __SubStrAdd, pArray); delete [] psz; }
void CIni::GetArray(LPCTSTR lpSection, LPCTSTR lpKey, CStringArray *pArray, LPCTSTR lpDelimiter, BOOL bTrimString) const { if (pArray != NULL) pArray->RemoveAll(); const DWORD LEN = GetArray(lpSection, lpKey, NULL, 0, lpDelimiter); if (LEN == 0) return; LPTSTR psz = new TCHAR[LEN + 3]; GetArray(lpSection, lpKey, psz, LEN + 2, lpDelimiter); ParseDNTString(psz, __SubStrAdd, (LPVOID)pArray); delete [] psz; }
// Retrieve a list of key-lines(key-pairs) of the specified section void SFIni::GetKeyLines(LPCTSTR lpSection, CStringArray *pArray) const { if (pArray != NULL) pArray->RemoveAll(); const DWORD LEN = GetKeyLines(lpSection, NULL, 0); if (LEN == 0) return; LPTSTR psz = new TCHAR[LEN + 1]; GetKeyLines(lpSection, psz, LEN); ParseDNTString(psz, __SubStrAdd, pArray); delete [] psz; }
BOOL CIni::IsSectionExist(LPCTSTR lpSection) const { if (lpSection == NULL) return FALSE; // first get the section name list, then check if lpSection exists // in the list. const DWORD LEN = GetSectionNames(NULL, 0); if (LEN == 0) return FALSE; LPTSTR psz = new TCHAR[LEN + 1]; GetSectionNames(psz, LEN); BOOL RES = !ParseDNTString(psz, __SubStrCompare, (LPVOID)lpSection); delete [] psz; return RES; }