1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
////////////////////////////////////////////////////////////////////////
// Copyright (c) Nehmulos 2011-2014
// This file is part of N0 Strain Serialization Library.
//
// N0Strain-Serialization-Library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// N0Strain-Serialization-Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with N0Strain-Serialization-Library. If not, see https://gnu.org/licenses/lgpl-3.0
////////////////////////////////////////////////////////////////////////
#include "PointerCollector.h"
namespace nw {
bool PointerCollector::skipsEmptyArrays = true;
PointerCollector::PointerCollector(DescribedObject* pointer) : Describer()
{
if(pointer != NULL)
{
unhandledPointers.push_back(pointer);
pointer->describeObject(this);
}
}
PointerCollector::~PointerCollector() {
}
void PointerCollector::close() {}
void PointerCollector::readFromFile(String filename) {}
bool PointerCollector::isInWriteMode() { return true; }
bool PointerCollector::isSilentCrawler() { return true; }
bool PointerCollector::push(String tagName) { return true;}
void PointerCollector::describeValueArray(String arrayName, unsigned int size) { describeArray("","",size); }
void PointerCollector::describeArray(String arrayName, String elementsName, unsigned int size)
{
//prepare a testrun if this testrun doesn't find pointers skip the array
N0PcArray newArray;
if(size == 0)
newArray.size = 0;
else if(skipsEmptyArrays)
newArray.size = 1;
else
newArray.size = size;
newArray.actualSize = size;
newArray.numberOfFoundPointersBeforeSearch = Describer::unhandledPointers.size();
openArrays.push(newArray);
}
bool PointerCollector::enterNextElement(unsigned int iterator)
{
if(iterator < openArrays.top().size)
{
return true;
}
else
{
//Is the actuall array bigger than 1 and does it contain pointers?
if(openArrays.top().size == 1 && openArrays.top().actualSize != 1)
{
//If pointers were found end go on searching
if(openArrays.top().numberOfFoundPointersBeforeSearch < Describer::unhandledPointers.size())
{
openArrays.top().size = openArrays.top().actualSize;
return true;
}
//otherwise end the testrun
}
openArrays.pop();
return false;
}
}
void PointerCollector::describeValue( Pointer ref)
{
if(ref != NULL)
{
DescribedObject* object = (DescribedObject*)ref;
if(!pointerIsKnown(object))
{
//if it wasn't found, yet, add it!
unhandledPointers.push_back(object); //Register this one
object->describeObject(this); //Search Contained Pointers
}
}
}
/* Serialize functions */
//Ignore everything, but pointers
void PointerCollector::describeName(String name) {}
void PointerCollector::describeValue(bool&) {}
void PointerCollector::describeValue(char&) {}
void PointerCollector::describeValue(unsigned char&) {}
void PointerCollector::describeValue(signed char&) {}
void PointerCollector::describeValue(short&) {}
void PointerCollector::describeValue(unsigned short&) {}
void PointerCollector::describeValue(int&) {}
void PointerCollector::describeValue(unsigned int&) {}
void PointerCollector::describeValue(long&) {}
void PointerCollector::describeValue(unsigned long&) {}
void PointerCollector::describeValue(float&) {}
void PointerCollector::describeValue(double&) {}
void PointerCollector::describeValue(long long&) {}
void PointerCollector::describeValue(long double&) {}
void PointerCollector::describeValue(String&) {}
void PointerCollector::describeBlob(String blobName, nw::Pointer binaryBlob, unsigned int blobSize) {}
void PointerCollector::comment(String text) {}
void PointerCollector::pop() {}
bool PointerCollector::conditionalPush(String tagname, bool& condition) { return true; }
} // namespace nw