Serializing Settings to the Registry
Objective Edit doesn’t have a separate function that performs serialization. However, if you would like to serialize the current font and color settings of the language to the registry, several Objective Edit functions enable saving the settings into the registry in customized ways.
Saving Settings
1. Specify where the language will be saved by calling SECEDIT_REG_WRITER(key).
2. From then on, anytime you call SECEditLangConfig::WriteLanguage(language), the information will be saved into your registry.
NOTE >> SECEDIT_REG_WRITER only modifies the memory and calls a new(); it does not actually save anything until WriteLanguage() is called.
Reading Settings Back
Assume you need to read from a registry with key name KEY1 and you want to write to a registry with key name KEY2 at the end. The language you are using is named Custom. Here’s what you can do:
1. In your CMyApp::InitInstance(), register this language at any point before the ShowWindow() function call:
SECEDIT_REGISTER_LANGUAGE(_T("Custom"),
SECEDIT_REG_READER(KEY1), SECEDIT_REG_WRITER(KEY2));
2. To read the information back from the registry, in your Document class
m_Edit.SetLanguage(_T(''Custom''));
will invoke reading language from KEY1.
Also
SECEditLangConfig* pLang = static_cast<SECEditLangConfig*>(m_Edit.GetLangPtr());
pLang->WriteLanguage(_T("Custom"));
will invoke writing language to KEY2.
NOTE >> In other classes, you will have to use GetEdit() instead of m_Edit.
The second parameter of
SECEDIT_REGISTER_LANGUAGE can be any of the Reader macros. (Refer to
Table 9.) The third parameter can be any of the Writer macros (
Table 8). For example, if you want to read from an
.ini file named ''reader.ini'' instead of KEY1, you can say:
SECEDIT_REGISTER_LANGUAGE(_T("Custom"),
SECEDIT_INI_READER(_T(''.//reader.ini'')),
SECEDIT_REG_WRITER(KEY2));
You can also specify that if the registry does not have such entry, it should use your custom language resource/file instead. If you want to specify two sources to read from at the same time, for example, read from file first, if that fails, then read from a registry, you can call one of the combinational macros (
Table 10):
SECEDIT_INI_REG_READER(filename, KEY)
(Use this as the second parameter for SECEDIT_REGISTER_LANGUAGE.)
SECEDIT Macros
Other similar macros you may be interested in are:
Table 8 – Writer Macros
Writer Macros | Definition |
SECEDIT_INI_WRITER(file) | write to .ini file |
SECEDIT_BIN_WRITER(file) | write to bin |
SECEDIT_REG_WRITER(key) | write to registry |
Table 9 – Reader Macros
Reader Macros | Definition |
SECEDIT_INI_READER(file) | read from .ini file |
SECEDIT_BIN_READER(file) | read from bin |
SECEDIT_REG_READER(key) | read from registry |
SECEDIT_RES_READER(resid) | read from resource |
Table 10 – Composite Reader Macros
Composite Reader Macros | Definition |
SECEDIT_INI_REG_READER (file,key) | read from .ini first, then registry |
SECEDIT_BIN_REG_READER (file,key) | read bin first, then registry |
SECEDIT_RES_REG_READER (resid,key) | read resource first, then registry |
Obtain more information about using these macros from the SECEditLangConfig.h header file that contains them.