December 1998
Intermediate to advanced
482 pages
12h 14m
English
This sample was based on an early beta version of the Generic Conduit and may not compile with the version available to you. For a more current version of the sample, see http://www.oreilly.com/ catalog/palmprog/.
We have derived a new class from CPcMgr, because we want to support the same a tab-delimited text format we used with the alternative conduit classes. Here is our new class:
class CSalesPcMgr: public CPcMgr
{
public:
CSalesPcMgr(CPLogging *pLogging, char *szDbName,
TCHAR *pFileName = NULL, TCHAR *pDirName = NULL,
DWORD dwGenericFlags,
eSyncTypes syncType = eDoNothing);
protected:
virtual long StoreDB(void);
virtual long RetrieveDB(void);
};Our constructor just initializes the base class:
CSalesPcMgr::CSalesPcMgr(CPLogging *pLogging, char *szDbName,
TCHAR *pFileName, TCHAR *pDirName,
DWORD dwGenericFlags, eSyncTypes syncType)
:CPcMgr(pLogging, szDbName, pFileName, pDirName, dwGenericFlags,
syncType)
{
}Our StoreDB routine writes the list of records in text-delimited format:
long CSalesPcMgr::StoreDB(void) { if ( !m_bNeedToSave) { // if no changes, don't waste time saving return 0; } long retval = OpenDB(); if (retval) return GEN_ERR_UNABLE_TO_SAVE; for (DWORD dwIndex = 0; (dwIndex < m_dwMaxRecordCount) && (!retval); dwIndex++){ if (!m_pRecordList[dwIndex]) // if there is no record, skip ahead continue; retval = WriteRecord(m_hFile, m_pRecordList[dwIndex]); if (retval != 0){ ...Read now
Unlock full access