XLL+ Class Library

CXlOperCache::Restore

Restore the contents of the cache from a file

[C++]
bool Restore(
   const CString& fileName
);

Parameters

fileName

The full path of a file. The file should have been written using CXlOperCache::Save.

Return value

The fuction returns true if the operation was successful, or false it fails for any reason.

Note that the function is deemed to have succeeded if the file cannot be found.

Remarks

This method is implemented inline in xlserialize.h so that it can easily be used as the basis for your own more sophisiticated implementations, such as a shared cache.

Example

You can save the cache to disk when the XLL closes and restore it each time the XLL is opened.

You should implement the OnXllOpenEx() and OnXllClose() overrideable methods of the application class, to restore and save the cache.

The code below shows how to do this:

CAvgOptApp : public CXllApp {
    ...
    CString m_strCacheFile;
    ...
};

BOOL CAvgOptApp::OnXllOpenEx()
{
    // Calculate the full path of the cache data file.
    // This is the same as the add-in, with the extension "dat".
    m_strCacheFile = CXllApp::GetXllName();
    m_strCacheFile = m_strCacheFile.Left(m_strCacheFile.GetLength() - 3) + "dat";

    // Restore cache
    m_cache.Restore(m_strCacheFile);

    return TRUE;
}

void CAvgOptApp::OnXllClose()
{
    m_cache.Save(m_strCacheFile);
}

Requirements

Header: xlserialize.h

See Also

CXlOperCache Class | CXlOperCache Methods