Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse #381

Merged
merged 83 commits into from
Jun 10, 2020
Merged

Parse #381

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
a0dd6ea
move class
stephenegriffin May 29, 2020
94a8aae
inherit smartviewparser from block
stephenegriffin May 29, 2020
8d088bf
remove data from svp
stephenegriffin May 29, 2020
eb3314b
remove redundant passthru
stephenegriffin May 29, 2020
0900b98
Remove setRoot
stephenegriffin May 29, 2020
e2fcf7b
relocate binaryparser
stephenegriffin May 29, 2020
290bfdc
start converting blockString
stephenegriffin May 30, 2020
b6fcd30
remove dead code
stephenegriffin May 30, 2020
3fbe42e
broke build - fix it
stephenegriffin May 30, 2020
c49a33a
shift more towards svp model
stephenegriffin May 30, 2020
9875d01
convert blockStringW more
stephenegriffin May 30, 2020
0b4e07e
shift constructor to maker
stephenegriffin May 30, 2020
c08659d
remove another constructor
stephenegriffin May 30, 2020
7cc6e10
remove extra size/offset calculations
stephenegriffin May 30, 2020
7318f6b
remove constructor
stephenegriffin May 30, 2020
7107547
undo uninitentional change
stephenegriffin May 30, 2020
58748fb
switch more manual creation to factory function
stephenegriffin May 30, 2020
cb94317
start converting blockBytes
stephenegriffin May 30, 2020
73229ea
finish converting blockBytes
stephenegriffin May 30, 2020
fdf94b1
start converting blockT
stephenegriffin May 30, 2020
f96b4df
remove extra template
stephenegriffin May 30, 2020
3af6f3b
change var name
stephenegriffin May 30, 2020
82d2f5f
kill source_t logic
stephenegriffin May 31, 2020
370b180
move some parsing down to parse
stephenegriffin May 31, 2020
026bc97
simplify
stephenegriffin May 31, 2020
ac71739
simplify
stephenegriffin May 31, 2020
47b2f48
begin converting blockPV
stephenegriffin May 31, 2020
7fbe78a
remove dead code
stephenegriffin May 31, 2020
beb052e
convert blockRes
stephenegriffin May 31, 2020
6767ab9
convert PropertyName
stephenegriffin May 31, 2020
79fcf48
add comments
stephenegriffin May 31, 2020
844f758
Make parseBlocks truly optional
stephenegriffin May 31, 2020
1edd56a
remove set var
stephenegriffin May 31, 2020
23206fd
remove another set var
stephenegriffin May 31, 2020
517cbfc
remove another set
stephenegriffin May 31, 2020
6fe9e9a
Move isSet down to smartViewParser
stephenegriffin May 31, 2020
aaab14e
hide parse
stephenegriffin May 31, 2020
5b3156a
start simplifying out empty blocks
stephenegriffin May 31, 2020
31bd7cb
simplify more
stephenegriffin May 31, 2020
6b2627a
move a couple data members down
stephenegriffin Jun 1, 2020
756a86c
convert most blocks to svp
stephenegriffin Jun 2, 2020
18b34cd
start moving factories out of class
stephenegriffin Jun 5, 2020
6b3358e
eliminate another std::make_shared<block>
stephenegriffin Jun 5, 2020
6108a64
eliminate another
stephenegriffin Jun 5, 2020
9d25afb
remove another make
stephenegriffin Jun 6, 2020
c8bb733
remove some more makes
stephenegriffin Jun 6, 2020
9dba8a5
start moving code down to block
stephenegriffin Jun 7, 2020
776d687
Move isSet down to block
stephenegriffin Jun 7, 2020
30bfc6e
move constants down
stephenegriffin Jun 7, 2020
ddcd8c0
remove another make
stephenegriffin Jun 7, 2020
d8591cc
move parse down
stephenegriffin Jun 8, 2020
c88e867
move ensureParsed down
stephenegriffin Jun 8, 2020
8404fec
move parse templates down
stephenegriffin Jun 8, 2020
736bca7
remove dead override
stephenegriffin Jun 8, 2020
f9dd445
move toString to cpp
stephenegriffin Jun 8, 2020
8f49384
split toString implementations
stephenegriffin Jun 8, 2020
44a7a13
move tostring down
stephenegriffin Jun 9, 2020
ce40ba2
eliminate smartviewparser class
stephenegriffin Jun 9, 2020
448e810
make private
stephenegriffin Jun 9, 2020
1f15136
hide more
stephenegriffin Jun 9, 2020
ad1e8db
simplify toString
stephenegriffin Jun 9, 2020
55ea29c
remove another toStringInternal
stephenegriffin Jun 9, 2020
395c8ed
remove another
stephenegriffin Jun 9, 2020
7bd8a57
remove toStringInternal
stephenegriffin Jun 9, 2020
70f45c8
rename
stephenegriffin Jun 9, 2020
8f03b7e
cleanup
stephenegriffin Jun 9, 2020
2174d6f
cleanups
stephenegriffin Jun 9, 2020
b080752
simplify and cleanup
stephenegriffin Jun 9, 2020
b0fc3a1
cleanup
stephenegriffin Jun 9, 2020
ccf8090
simplify
stephenegriffin Jun 9, 2020
d1ac98f
fix typo
stephenegriffin Jun 9, 2020
f63fc31
remove dead constructor
stephenegriffin Jun 9, 2020
c92dd77
rebuild block::addHeader
stephenegriffin Jun 9, 2020
6235e80
rewrite addBlankLine
stephenegriffin Jun 9, 2020
b9b1d3e
recreate addlabeled func
stephenegriffin Jun 9, 2020
95363c5
remove extra includes
stephenegriffin Jun 9, 2020
bab6a25
move all the create stuff back to block
stephenegriffin Jun 9, 2020
25a86a2
simplify EntryIdStruct
stephenegriffin Jun 10, 2020
d9b4b74
constants
stephenegriffin Jun 10, 2020
daec909
remove virtual
stephenegriffin Jun 10, 2020
55efed1
remove comment
stephenegriffin Jun 10, 2020
0c28485
mass re-org
stephenegriffin Jun 10, 2020
1661610
rename m_Parser
stephenegriffin Jun 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions UI/ViewPane/SmartViewPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ namespace viewpane

const auto iStructType = static_cast<parserType>(GetDropDownSelectionValue());
auto szSmartViewArray = std::vector<std::wstring>{};
treeData = std::make_shared<smartview::block>();
treeData = smartview::block::create();
auto svp = smartview::GetSmartViewParser(iStructType, nullptr);
auto source = 0;
for (auto& bin : m_bins)
Expand All @@ -191,22 +191,21 @@ namespace viewpane
{
svp->init(bin.size(), bin.data());
parsedData = svp->toString();
auto node = svp->getBlock();
node->setSource(source++);
svp->setSource(source++);
if (m_bins.size() == 1)
{
treeData = node;
treeData = svp;
}
else
{
treeData->addChild(node);
treeData->addChild(svp);
}
}

if (parsedData.empty())
{
parsedData =
smartview::InterpretBinaryAsString(SBinary{static_cast<ULONG>(bin.size()), bin.data()}, iStructType, nullptr);
parsedData = smartview::InterpretBinaryAsString(
SBinary{static_cast<ULONG>(bin.size()), bin.data()}, iStructType, nullptr);
}

szSmartViewArray.push_back(parsedData);
Expand Down
4 changes: 2 additions & 2 deletions UI/ViewPane/SmartViewPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <UI/ViewPane/DropDownPane.h>
#include <UI/ViewPane/SplitterPane.h>
#include <UI/ViewPane/TreePane.h>
#include <core/smartview/smartViewParser.h>
#include <core/smartview/block/block.h>

enum class parserType;

Expand Down Expand Up @@ -39,7 +39,7 @@ namespace viewpane
int iEditHeight) override; // height of an edit control

std::vector<std::vector<BYTE>> m_bins;
std::shared_ptr<smartview::block> treeData = std::make_shared<smartview::block>();
std::shared_ptr<smartview::block> treeData = smartview::block::create();
std::shared_ptr<SplitterPane> m_Splitter;
std::shared_ptr<TreePane> m_TreePane;
bool m_bHasData{false};
Expand Down
Binary file modified UnitTest/SmartViewTestData/Out/12-propdef-out5.dat
Binary file not shown.
Binary file modified UnitTest/SmartViewTestData/Out/18-sf-out6.dat
Binary file not shown.
Binary file modified UnitTest/SmartViewTestData/Out/25-NickName-out3.dat
Binary file not shown.
13 changes: 5 additions & 8 deletions UnitTest/tests/blocktest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace blocktest
TEST_CLASS_INITIALIZE(initialize) { unittest::init(); }
TEST_METHOD(Test_block)
{
auto block1 = std::make_shared<smartview::block>(L"test");
auto block2 = std::make_shared<smartview::block>(L"block2");
auto block3 = std::make_shared<smartview::block>(L"");
auto block1 = smartview::block::create(L"test");
auto block2 = smartview::block::create(L"block2");
auto block3 = smartview::block::create(L"");
Assert::AreEqual(block1->isHeader(), true);
block1->setSize(5);
Assert::AreEqual(block1->isHeader(), false);
Expand Down Expand Up @@ -52,8 +52,7 @@ namespace blocktest

block1->addBlankLine();
block1->addLabeledChild(L"Label: ", block2);
Assert::AreEqual(
block1->toString(), std::wstring(L"hello world this that\r\nblock2\r\n\r\nLabel: block2\r\n"));
Assert::AreEqual(block1->toString(), std::wstring(L"hello world this that\r\nblock2\r\n\r\nLabel: block2"));

Assert::AreEqual(block3->hasData(), false);
block3->addChild(block1);
Expand All @@ -67,15 +66,13 @@ namespace blocktest
{
auto block1 = std::make_shared<smartview::blockStringA>();
Assert::AreEqual(block1->isSet(), false);
auto block2 = std::make_shared<smartview::blockStringA>(std::string("test"), 4, 5);
Assert::AreEqual(block2->length(), size_t(4));
}

TEST_METHOD(Test_blockStringW)
{
auto block1 = std::make_shared<smartview::blockStringW>();
Assert::AreEqual(block1->isSet(), false);
auto block2 = std::make_shared<smartview::blockStringW>(std::wstring(L"test"), 4, 5);
auto block2 = smartview::blockStringW::parse(std::wstring(L"test"), 4, 5);
Assert::AreEqual(block2->length(), size_t(4));
}
};
Expand Down
6 changes: 3 additions & 3 deletions core/core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@
<ClInclude Include="res\Resource.h" />
<ClInclude Include="smartview\AdditionalRenEntryIDs.h" />
<ClInclude Include="smartview\AppointmentRecurrencePattern.h" />
<ClInclude Include="smartview\binaryParser.h" />
<ClInclude Include="smartview\block\scratchBlock.h" />
<ClInclude Include="smartview\block\binaryParser.h" />
<ClInclude Include="smartview\block\block.h" />
<ClInclude Include="smartview\block\blockBytes.h" />
<ClInclude Include="smartview\block\blockPV.h" />
Expand All @@ -602,7 +603,6 @@
<ClInclude Include="smartview\SearchFolderDefinition.h" />
<ClInclude Include="smartview\SIDBin.h" />
<ClInclude Include="smartview\SmartView.h" />
<ClInclude Include="smartview\smartViewParser.h" />
<ClInclude Include="smartview\TaskAssigners.h" />
<ClInclude Include="smartview\TimeZone.h" />
<ClInclude Include="smartview\TimeZoneDefinition.h" />
Expand Down Expand Up @@ -680,7 +680,7 @@
<ClCompile Include="smartview\SearchFolderDefinition.cpp" />
<ClCompile Include="smartview\SIDBin.cpp" />
<ClCompile Include="smartview\SmartView.cpp" />
<ClCompile Include="smartview\smartViewParser.cpp" />
<ClCompile Include="smartview\block\block.cpp" />
<ClCompile Include="smartview\TaskAssigners.cpp" />
<ClCompile Include="smartview\TimeZone.cpp" />
<ClCompile Include="smartview\TimeZoneDefinition.cpp" />
Expand Down
18 changes: 9 additions & 9 deletions core/core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@
<ClInclude Include="mapi\mapiStoreFunctions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="smartview\binaryParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mapi\processor\mapiProcessor.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -252,9 +249,6 @@
<ClInclude Include="utility\cli.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="smartview\smartViewParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sortlistdata\binaryData.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -306,6 +300,12 @@
<ClInclude Include="smartview\block\blockPV.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="smartview\block\binaryParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="smartview\block\scratchBlock.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="utility\strings.cpp">
Expand Down Expand Up @@ -488,9 +488,6 @@
<ClCompile Include="utility\cli.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="smartview\smartViewParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sortlistdata\binaryData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -533,6 +530,9 @@
<ClCompile Include="smartview\SPropValueStruct.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="smartview\block\block.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\MFCMapi.rc2">
Expand Down
22 changes: 10 additions & 12 deletions core/smartview/AdditionalRenEntryIDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ namespace smartview
{
WORD wPersistDataCount = 0;
// Run through the parser once to count the number of PersistData structs
while (m_Parser->getSize() >= 2 * sizeof(WORD))
while (parser->getSize() >= 2 * sizeof(WORD))
{
const auto& wPersistID = blockT<WORD>::parse(m_Parser);
const auto& wDataElementSize = blockT<WORD>::parse(m_Parser);
const auto& wPersistID = blockT<WORD>::parse(parser);
const auto& wDataElementSize = blockT<WORD>::parse(parser);
// Must have at least wDataElementSize bytes left to be a valid data element
if (m_Parser->getSize() < *wDataElementSize) break;
if (parser->getSize() < *wDataElementSize) break;

m_Parser->advance(*wDataElementSize);
parser->advance(*wDataElementSize);
wPersistDataCount++;
if (wPersistID == PersistData::PERISIST_SENTINEL) break;
}

// Now we parse for real
m_Parser->rewind();
parser->rewind();

if (wPersistDataCount && wPersistDataCount < _MaxEntriesSmall)
{
m_ppdPersistData.reserve(wPersistDataCount);
for (WORD iPersistElement = 0; iPersistElement < wPersistDataCount; iPersistElement++)
{
m_ppdPersistData.emplace_back(std::make_shared<PersistData>(m_Parser));
m_ppdPersistData.emplace_back(std::make_shared<PersistData>(parser));
}
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ namespace smartview

void AdditionalRenEntryIDs::parseBlocks()
{
setRoot(L"Additional Ren Entry IDs\r\n");
setText(L"Additional Ren Entry IDs\r\n");
addHeader(L"PersistDataCount = %1!d!", m_ppdPersistData.size());

if (!m_ppdPersistData.empty())
Expand All @@ -102,10 +102,9 @@ namespace smartview
{
terminateBlock();
addBlankLine();
auto element = std::make_shared<block>();
auto element = create(L"Persist Element %1!d!:\r\n", iPersistElement);
addChild(element);

element->setText(L"Persist Element %1!d!:\r\n", iPersistElement);
element->addChild(
persistData->wPersistID,
L"PersistID = 0x%1!04X! = %2!ws!\r\n",
Expand All @@ -122,8 +121,7 @@ namespace smartview
for (const auto& dataElement : persistData->ppeDataElement)
{
element->terminateBlock();
auto de =
std::make_shared<block>(strings::formatmessage(L"DataElement: %1!d!\r\n", iDataElement));
auto de = create(L"DataElement: %1!d!\r\n", iDataElement);
element->addChild(de);

de->addChild(
Expand Down
4 changes: 2 additions & 2 deletions core/smartview/AdditionalRenEntryIDs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <core/smartview/smartViewParser.h>
#include <core/smartview/block/block.h>
#include <core/smartview/block/blockBytes.h>
#include <core/smartview/block/blockT.h>

Expand Down Expand Up @@ -27,7 +27,7 @@ namespace smartview
PersistData(const std::shared_ptr<binaryParser>& parser);
};

class AdditionalRenEntryIDs : public smartViewParser
class AdditionalRenEntryIDs : public block
{
private:
void parse() override;
Expand Down
39 changes: 19 additions & 20 deletions core/smartview/AppointmentRecurrencePattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,50 +119,49 @@ namespace smartview

void AppointmentRecurrencePattern::parse()
{
m_RecurrencePattern.smartViewParser::parse(m_Parser, false);
m_RecurrencePattern = block::parse<RecurrencePattern>(parser, false);

m_ReaderVersion2 = blockT<DWORD>::parse(m_Parser);
m_WriterVersion2 = blockT<DWORD>::parse(m_Parser);
m_StartTimeOffset = blockT<DWORD>::parse(m_Parser);
m_EndTimeOffset = blockT<DWORD>::parse(m_Parser);
m_ExceptionCount = blockT<WORD>::parse(m_Parser);
m_ReaderVersion2 = blockT<DWORD>::parse(parser);
m_WriterVersion2 = blockT<DWORD>::parse(parser);
m_StartTimeOffset = blockT<DWORD>::parse(parser);
m_EndTimeOffset = blockT<DWORD>::parse(parser);
m_ExceptionCount = blockT<WORD>::parse(parser);

if (*m_ExceptionCount && *m_ExceptionCount == *m_RecurrencePattern.m_ModifiedInstanceCount &&
if (*m_ExceptionCount && *m_ExceptionCount == *m_RecurrencePattern->m_ModifiedInstanceCount &&
*m_ExceptionCount < _MaxEntriesSmall)
{
m_ExceptionInfo.reserve(*m_ExceptionCount);
for (WORD i = 0; i < *m_ExceptionCount; i++)
{
m_ExceptionInfo.emplace_back(std::make_shared<ExceptionInfo>(m_Parser));
m_ExceptionInfo.emplace_back(std::make_shared<ExceptionInfo>(parser));
}
}

m_ReservedBlock1Size = blockT<DWORD>::parse(m_Parser);
m_ReservedBlock1 = blockBytes::parse(m_Parser, *m_ReservedBlock1Size, _MaxBytes);
m_ReservedBlock1Size = blockT<DWORD>::parse(parser);
m_ReservedBlock1 = blockBytes::parse(parser, *m_ReservedBlock1Size, _MaxBytes);

if (*m_ExceptionCount && *m_ExceptionCount == *m_RecurrencePattern.m_ModifiedInstanceCount &&
if (*m_ExceptionCount && *m_ExceptionCount == *m_RecurrencePattern->m_ModifiedInstanceCount &&
*m_ExceptionCount < _MaxEntriesSmall && !m_ExceptionInfo.empty())
{
for (WORD i = 0; i < *m_ExceptionCount; i++)
{
m_ExtendedException.emplace_back(std::make_shared<ExtendedException>(
m_Parser, *m_WriterVersion2, *m_ExceptionInfo[i]->OverrideFlags));
m_ExtendedException.emplace_back(
std::make_shared<ExtendedException>(parser, *m_WriterVersion2, *m_ExceptionInfo[i]->OverrideFlags));
}
}

m_ReservedBlock2Size = blockT<DWORD>::parse(m_Parser);
m_ReservedBlock2 = blockBytes::parse(m_Parser, *m_ReservedBlock2Size, _MaxBytes);
m_ReservedBlock2Size = blockT<DWORD>::parse(parser);
m_ReservedBlock2 = blockBytes::parse(parser, *m_ReservedBlock2Size, _MaxBytes);
}

void AppointmentRecurrencePattern::parseBlocks()
{
setRoot(m_RecurrencePattern.getBlock());
addChild(m_RecurrencePattern);
terminateBlock();

auto arpBlock = std::make_shared<block>();
auto arpBlock = create(L"Appointment Recurrence Pattern: \r\n");
addChild(arpBlock);

arpBlock->setText(L"Appointment Recurrence Pattern: \r\n");
arpBlock->addChild(m_ReaderVersion2, L"ReaderVersion2: 0x%1!08X!\r\n", m_ReaderVersion2->getData());
arpBlock->addChild(m_WriterVersion2, L"WriterVersion2: 0x%1!08X!\r\n", m_WriterVersion2->getData());
arpBlock->addChild(
Expand All @@ -184,7 +183,7 @@ namespace smartview
auto i = 0;
for (const auto& info : m_ExceptionInfo)
{
auto exception = std::make_shared<block>();
auto exception = create();
m_ExceptionCount->addChild(exception);

exception->addChild(
Expand Down Expand Up @@ -331,7 +330,7 @@ namespace smartview
auto i = UINT{};
for (const auto& ee : m_ExtendedException)
{
auto exception = std::make_shared<block>();
auto exception = create();
arpBlock->addChild(exception);

if (*m_WriterVersion2 >= 0x00003009)
Expand Down
6 changes: 3 additions & 3 deletions core/smartview/AppointmentRecurrencePattern.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <core/smartview/smartViewParser.h>
#include <core/smartview/block/block.h>
#include <core/smartview/RecurrencePattern.h>
#include <core/smartview/block/blockStringA.h>
#include <core/smartview/block/blockStringW.h>
Expand Down Expand Up @@ -66,13 +66,13 @@ namespace smartview
// =====================
// This structure specifies a recurrence pattern for a calendar object
// including information about exception property values.
class AppointmentRecurrencePattern : public smartViewParser
class AppointmentRecurrencePattern : public block
{
private:
void parse() override;
void parseBlocks() override;

RecurrencePattern m_RecurrencePattern;
std::shared_ptr<RecurrencePattern> m_RecurrencePattern;
std::shared_ptr<blockT<DWORD>> m_ReaderVersion2 = emptyT<DWORD>();
std::shared_ptr<blockT<DWORD>> m_WriterVersion2 = emptyT<DWORD>();
std::shared_ptr<blockT<DWORD>> m_StartTimeOffset = emptyT<DWORD>();
Expand Down