-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathVCConfiguration.cpp
More file actions
96 lines (77 loc) · 2.73 KB
/
VCConfiguration.cpp
File metadata and controls
96 lines (77 loc) · 2.73 KB
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
#include "pch.h"
#include "VCConfiguration.h"
#include "Project.h"
using namespace pugi;
using namespace std;
//
// Copies value from path first step to xml node.
//
void ReflectCopyValue(ReflectPath& path, xml_node node)
{
ReflectPathStep& step = path.steps[0];
FieldInfo* fi = step.typeInfo->GetField(step.propertyName);
CStringW value = fi->fieldType->ToString((char*)step.instance->ReflectGetInstance() + fi->offset);
node.text().set(value);
}
//
// Reconstructs xml path from our class structure to xml nodes.
//
void ReflectCopy(ReflectPath& path, xml_node toNode)
{
xml_node current = toNode;
for (size_t i = path.steps.size(); i-- > 0; )
{
ReflectPathStep& step = path.steps[i];
// Field map, which specified in which order fields should be. 0,1 ... and so on.
auto&& mapFields = step.instance->mapFieldToIndex;
if (step.instance->propertyName.length() == 0 && step.instance->GetParent() != nullptr)
mapFields = step.instance->GetParent()->mapFieldToIndex;
wstring name = as_wide(step.propertyName);
xml_node next = current.child(name.c_str());
if (next.empty())
{
int newNodeFieldIndex = mapFields[step.propertyName];
xml_node node = current.first_child();
xml_node insertBefore;
for (; !node.empty(); node = node.next_sibling())
{
int currentNodeFieldIndex = mapFields[as_utf8(node.name()).c_str()];
if (newNodeFieldIndex > currentNodeFieldIndex)
continue;
insertBefore = node;
break;
}
if (insertBefore.empty())
next = current.append_child(name.c_str());
else
next = current.insert_child_before(name.c_str(), insertBefore);
}
current = next;
}
ReflectCopyValue(path, current);
}
void VCConfiguration::OnAfterSetProperty(ReflectPath& path)
{
xml_node current;
ReflectPathStep& lastStep = path.steps.back();
if (lastStep.typeInfo->name == "GeneralConf")
{
if (lastStep.typeInfo->GetField(lastStep.propertyName) - lastStep.typeInfo->GetField("ConfigurationType") >= 0)
{
current = pgConfigurationNode;
}
else
{
if (pgNode.empty())
pgNode = project->selectProjectNodes(L"PropertyGroup", L"", configurationName.c_str(), platform.c_str());
current = pgNode;
}
}
else
{
if (idgConfNode.empty())
idgConfNode = project->selectProjectNodes(L"ItemDefinitionGroup", L"", configurationName.c_str(), platform.c_str());
current = idgConfNode;
}
ReflectCopy(path, current);
}