コード例 #1
0
ファイル: IniFile.cpp プロジェクト: chrisoldwood/WCL
size_t CIniFile::ReadSection(const tchar* pszSection, CStrArray& astrKeys, CStrArray& astrValues)
{
	ASSERT(pszSection);

	CStrArray astrEntries;

	// Read all the entries...
	if (ReadSection(pszSection, astrEntries))
	{
		// Split all entries.
		for (size_t i = 0; i < astrEntries.Size(); ++i)
		{
			// Split into key and value.
			CString strEntry = astrEntries[i];
			size_t  nLength  = strEntry.Length();
			size_t  nSepPos  = strEntry.Find(TXT('='));

			// Key set AND value set?
			if ( (nSepPos > 0) && ((nLength-nSepPos-1) > 0) )
			{
				astrKeys.Add(strEntry.Left(nSepPos));
				astrValues.Add(strEntry.Right(nLength-nSepPos-1));
			}
		}
	}

	ASSERT(astrKeys.Size() == astrValues.Size());

	return astrKeys.Size();
}
コード例 #2
0
ファイル: IniFile.cpp プロジェクト: chrisoldwood/WCL
size_t CIniFile::ReadSection(const tchar* pszSection, CStrArray& astrEntries)
{
	ASSERT(pszSection);

	// Allocate initial buffer.
	size_t nChars     = 1024;
	tchar* pszEntries = static_cast<tchar*>(alloca(Core::numBytes<tchar>(nChars+1)));

	// Read all entries, reallocating if necessary...
	while (::GetPrivateProfileSection(pszSection, pszEntries, static_cast<DWORD>(nChars), m_strPath) >= (nChars-2))
	{
		// Double the buffer size.
		nChars    *= 2;
		pszEntries = static_cast<tchar*>(alloca(Core::numBytes<tchar>(nChars+1)));
	}

	// For all strings.
	while (*pszEntries != TXT('\0'))
	{
		astrEntries.Add(pszEntries);
		pszEntries += tstrlen(pszEntries) + 1;
	}

	return astrEntries.Size();
}
コード例 #3
0
ファイル: LinkCache.cpp プロジェクト: chrisoldwood/NetDDE
void CLinkCache::Purge(const CDDEConv* pConv)
{
	typedef CLinksMap::iterator LinksIter;

	CStrArray astrLinks;

	// Format the cache entry prefix for the conversation.
	CString strPrefix = CString::Fmt(TXT("%s|%s!"), pConv->Service().c_str(), pConv->Topic().c_str());
	size_t  nLength   = strPrefix.Length();

	// Find all links for the conversation...
	for (LinksIter it = m_oLinks.begin(); it != m_oLinks.end(); ++it)
	{
		const CString& strLink = it->first;

		if (tstrnicmp(strLink, strPrefix, nLength) == 0)
		{
			// Delete value, but remember key.
			astrLinks.Add(strLink);
			delete it->second;
		}
	}

	// Purge all matching links...
	for (size_t i = 0; i < astrLinks.Size(); ++i)
		m_oLinks.erase(astrLinks[i]);
}
コード例 #4
0
ファイル: IniFile.cpp プロジェクト: chrisoldwood/WCL
void CIniFile::WriteStrings(const tchar* pszSection, const tchar* pszEntry, tchar cSep, const CStrArray& astrValues)
{
	ASSERT(pszSection != nullptr);
	ASSERT(pszEntry   != nullptr);

	CString str;

	// Build string list.
	for (size_t i = 0; i < astrValues.Size(); ++i)
	{
		if (i != 0)
			str += cSep;

		str += astrValues[i];
	}

	WriteString(pszSection, pszEntry, str);
}