예제 #1
0
void GProfile::ExecuteAllNotifications()
{
	if (!m_pTreeNotify)	// this can only happen if you DetatchNotification()
		return;

	GListIterator itSections(&m_lstSections);
	while ( itSections() )
	{
		GProfileSection *pSection = (GProfileSection *)itSections++;

		GListIterator itNVP(&pSection->m_lstNVP);
		while (itNVP())
		{
			GProfileEntry *pNVP = (GProfileEntry *)itNVP++;

			GString strKey(pSection->m_strName);
			strKey << pNVP->m_strName;
			strKey.MakeUpper();
			fnChangeNotify fn  = (fnChangeNotify)m_pTreeNotify->search(strKey);
			if (fn)
			{
				fn(pSection->m_strName, pNVP->m_strName, pNVP->m_strValue);
			}
		}
	}
}
예제 #2
0
// Serialize memory config
// Returns the number of bytes written to the destination on success or 0 for failure.
long GProfile::WriteCurrentConfigHelper(const char *pzPathAndFileName, GString *pDest, const char *pzSection/*=0*/, bool bWriteXML/*=0*/)
{
	GString strLocalDest;
	GString *strConfigData = (pDest) ? pDest : &strLocalDest;

	try
	{
		if (bWriteXML)
		{
		    *strConfigData << "<configuration>";
		}

		GListIterator itSections(&m_lstSections);
		while ( itSections() )
		{
			GProfileSection *pSection = (GProfileSection *)itSections++;
			if (pzSection)
			{
				if( pSection->m_strName.CompareNoCase(pzSection) != 0)
				{
					continue;
				}
			}
			if (bWriteXML)
			{
				pSection->ToXML(strConfigData, 1);
			}
			else
			{
				(*strConfigData) << "[" << pSection->m_strName << "]\r\n";

				GListIterator itNVP(&pSection->m_lstNVP);
				while (itNVP())
				{
					GProfileEntry *pNVP = (GProfileEntry *)itNVP++;
					(*strConfigData) << pNVP->m_strName << "=" << pNVP->m_strValue << "\r\n";
				}
				if (itSections())
					(*strConfigData) << "\r\n\r\n";
			}
		}
		if (bWriteXML)
		{
		    *strConfigData << "\r\n</configuration>";
		}

		if (pzPathAndFileName)
			strConfigData->ToFile(pzPathAndFileName);

		return (long)strConfigData->Length();
	}
	catch(GException &)
	{
		// most likely due to invalid path or file name.
		return 0;	
	}
	return 0; // can't get here
}
예제 #3
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
// function retrieves the names of all sections
void GProfile::GetSectionNames(GStringList *lpList)
{
	Load();

	if (lpList)
	{
		GListIterator itSections(&m_lstSections);
		while (itSections())
		{
			Section *pSection = (Section *)itSections++;
			lpList->AddLast(pSection->m_strName);
		}
	}
}
예제 #4
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
GProfile::Section *GProfile::FindSection(const char *szSection)
{
	Load();

	Section *pRet = 0;

	GListIterator itSections(&m_lstSections);
	while ( itSections() && (!pRet))
	{
		Section *pSection = (Section *)itSections++;

		if (pSection->m_strName.CompareNoCase(szSection) == 0)
			pRet = pSection;
	}

	return pRet;
}
예제 #5
0
파일: GProfile.cpp 프로젝트: gbaumgart/vt
void GProfile::Destroy()
{
	GListIterator itSections(&m_lstSections);
	while (itSections())
	{
		Section *pSection = (Section *)itSections++;

		GListIterator itNVP(&pSection->m_lstNVP);
		while (itNVP())
		{
			NameValuePair *pNVP = (NameValuePair *)itNVP++;
			delete pNVP;
		}

		delete pSection;
	}

	m_lstSections.RemoveAll();
}
예제 #6
0
void GProfile::Destroy()
{
	GListIterator itSections(&m_lstSections);
	while (itSections())
	{
		GProfileSection *pSection = (GProfileSection *)itSections++;

		GListIterator itNVP(&pSection->m_lstNVP);
		while (itNVP())
		{
			GProfileEntry *pNVP = (GProfileEntry *)itNVP++;
			delete pNVP;
		}

		delete pSection;
	}

	m_lstSections.RemoveAll();
}