/** * @file XTPPropExchangeIniFile.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPPROPEXCHANGEINIFILE_H__) # define __XTPPROPEXCHANGEINIFILE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPPropExchangeIniFile is CXTPPropExchange derived class. * The CXTPPropExchangeIniFile class allows you to save a complex network of objects in a ini * file that persists after those objects are deleted. Later you can load the objects from * persistent storage, reconstituting them in memory. This process of making data persistent is * called 'serialization.' * * Example: *
* CXTPPropExchangeIniFile px(TRUE, 0, _T("Settings"));
* if (px.LoadFromFile(m_strIniFileName))
* {
* m_wndTaskPanel.GetGroups()->DoPropExchange(&px);
* }
*
*/
class _XTP_EXT_CLASS CXTPPropExchangeIniFile : public CXTPPropExchange
{
/** @cond */
DECLARE_DYNAMIC(CXTPPropExchangeIniFile)
/** @endcond */
public:
/**
* @brief
* Constructs CXTPPropExchangeIniFile a object.
* @param bLoading A flag that specifies whether objects will be loaded from or
* stored.
* @param lpszParentSection Root section. Can be NULL.
* @param lpszSection Points to a null-terminated string that specifies the section
* containing the entry.
*/
CXTPPropExchangeIniFile(BOOL bLoading, LPCTSTR lpszParentSection, LPCTSTR lpszSection);
/**
* @brief
* Destroys a CXTPPropExchangeIniFile object, handles cleanup and
* deallocation.
*/
~CXTPPropExchangeIniFile();
/**
* @brief
* Exchanges a property between a storage medium and the control.
* @param pszPropName The name of the property being exchanged.
* @param vtProp A symbol specifying the type of the property being
* exchanged.
* @param pvProp A pointer to the property's value.
* @param pvDefault Pointer to a default value for the property.
* @details
* Possible values of properties are:
* * Symbol Property Type * ------------- ------------- * VT_I2 short * VT_I4 long * VT_BOOL BOOL * VT_BSTR CString * VT_CY CY * VT_R4 float * VT_R8 double ** @return * Nonzero if the exchange was successful; 0 if unsuccessful. */ virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp, void* pvProp, const void* pvDefault = NULL); /** * @brief * This method creates new section for text base storages (CXTPPropExchangeXMLNode and * CXTPPropExchangeRegistry) * @param lpszSection The name of the section. * @return * CXTPPropExchange pointer to new section. You must delete this pointer or use * CXTPPropExchangeSection to manage it. * * Example: *
* CXTPPropExchangeSection pxTaskPanel(px.GetSection(_T("TaskPanel")));
* m_wndTaskPanel.GetGroups()->DoPropExchange(&pxTaskPanel);
*
*/
virtual CXTPPropExchange* GetSection(LPCTSTR lpszSection);
/**
* @brief
* This method is called before exchange properties.
* @return
* TRUE if storage ready to exchange properties.
*/
virtual BOOL OnBeforeExchange();
/**
* @brief
* Saves an ini file to the specified location.
* @param strFileName Destination file name.
*/
void SaveToFile(LPCTSTR strFileName);
/**
* @brief
* Loads the contents of an existing ini file.
* @param lpszFileName A CString value that contains the name of a file to be loaded
* @return
* TRUE if successful; otherwise 0.
*/
BOOL LoadFromFile(LPCTSTR lpszFileName);
/**
* @brief
* Assign ini file to CXTPPropExchangeIniFile class.
* @param lpszFileName A CString value that contains the name of a file to be loaded/saved
*/
void AssignFile(LPCTSTR lpszFileName);
/**
* @brief
* Call this method to free section information before storing
*/
virtual void EmptySection();
protected:
CString m_strSectionName; /**< Section name. */
CString m_strFileName; /**< Temporary file name. */
BOOL m_bTempFile; /**< TRUE if temporary file was created. */
};
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
/** @cond */
#endif // !defined(__XTPPROPEXCHANGEINIFILE_H__)
/** @endcond */