TRegistry::Update reads a configuration stream and writes the entries to the Windows Registry. TRegistry::Validate reads the same configuration stream and verifies that the Windows Registry contains the same entries.
:::C++
//
/// Walks through an input stream and uses basekey\\key\\key=data lines to set
/// registry entries.
///
/// Has named value support in the form: basekey\\key\\key|valuename=data
//
void TRegistry::Update(TRegKey& baseKey, tistream& in)
[...]
//
/// Walks through an input stream and uses basekey\\key\\key=data lines to check
/// registry entries.
/// Returns the number of differences. Zero means a complete match.
///
/// Has named value support in the following form: basekey\\key\\key|valuename=data
//
int TRegistry::Validate(TRegKey& baseKey, tistream& in)
[...]
However, Update fails to write named values at all — it only works for the default values associated with each key (which was all 16-bit Windows supported, before introducing named values in 32-bit Windows; ref. TheOldNewThing). Also, it fails to write the default value for the base key — it assumes a subkey is always specified (i.e. "basekey=data" fails).
For example:
:::C++
auto s = tstringstream{};
#if 0 // This simple test should work for 6.44.9 and earlier.
s << _T("OWLNext_RegTest\\Key1=Key1DefaultText\n")
<< _T("OWLNext_RegTest\\Key2 = Key2DefaultText\n")
<< _T("OWLNext_RegTest\\Key3 = Key3DefaultText\n");
#else // This tougher test fails on 6.44.9 and earlier.
s << _T("OWLNext_RegTest=DefaultText\n")
<< _T("OWLNext_RegTest|Value1=Text1\n")
<< _T("OWLNext_RegTest|Value2 = Text2\n")
<< _T("OWLNext_RegTest|Value3 = Text3\n")
<< _T("OWLNext_RegTest\\Key1 = Key1DefaultText\n")
<< _T("OWLNext_RegTest\\Key1|Key1Value1=Key1Text1\n")
<< _T("OWLNext_RegTest\\Key1|Key1Value2 = Key1Text2\n")
<< _T("OWLNext_RegTest\\Key1|Key1Value3 = Key1Text3\n");
#endif
auto testKey = TRegKey{HKEY_CURRENT_USER, _T("OWLNext_RegTest")};
TRegistry::Update(testKey, s);
s.clear();
s.seekg(0);
const auto diff = TRegistry::Validate(testKey, s);
Note that the OWLNext code for these functions remains largely unchanged since OWL 5, so these issues do not appear to be regressions in OWLNext. Hence I presume the need for these functions is minimal, if existent at all. I have a fix in the making, but perhaps we should deprecate these functions on the trunk?
Feature Requests: #151
Wiki: Coding_Standards
Wiki: OWLNext_Stable_Releases
A test case was added to "examples/classes" in [r4809] and merged into 6.44 [r4810].
A fix for this issue was committed to the trunk [r4811], and it has been merged into 6.44 [r4812] and Owlet [r4813].
Related
Commit: [r4809]
Commit: [r4810]
Commit: [r4811]
Commit: [r4812]
Commit: [r4813]
Last edit: Vidar Hasfjord 2020-04-17