-
Notifications
You must be signed in to change notification settings - Fork 4
/
Samples_xmlHandler.cpp
156 lines (135 loc) · 5.77 KB
/
Samples_xmlHandler.cpp
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/***********************************************************************
created: 31/5/2012
author: Lukas E Meindl
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#include "Samples_xmlHandler.h"
#include "CEGUI/Exceptions.h"
#include "CEGUI/Logger.h"
#include "CEGUI/XMLAttributes.h"
#include "SamplesFramework.h"
#include "Sample.h"
#include "SampleData.h"
const String Samples_xmlHandler::ElementName("Samples");
const String SampleDataHandler::ElementName("SampleDefinition");
const String SampleDataHandler::NameAttribute("name");
const String SampleDataHandler::SummaryAttribute("summary");
const String SampleDataHandler::DescriptionAttribute("description");
const String SampleDataHandler::CreditsAttribute("credits");
const String SampleDataHandler::SampleTypeAttribute("type");
const String SampleDataHandler::SampleTypeCppModule("C++ Module");
const String SampleDataHandler::SampleTypeLua("Lua");
const String SampleDataHandler::SampleTypePython("Python");
//----------------------------------------------------------------------------//
Samples_xmlHandler::Samples_xmlHandler(SamplesFramework* samplesFramework)
: d_samplesFramework(samplesFramework)
{}
//----------------------------------------------------------------------------//
Samples_xmlHandler::~Samples_xmlHandler()
{}
//----------------------------------------------------------------------------//
const String& Samples_xmlHandler::getSchemaName() const
{
return SamplesFramework::XMLSchemaName;
}
//----------------------------------------------------------------------------//
void Samples_xmlHandler::elementStartLocal(const String& element,
const XMLAttributes& attributes)
{
if (element == ElementName)
{
CEGUI_LOGINSANE("===== Begin Animations parsing =====");
}
else if (element == SampleDataHandler::ElementName)
{
d_chainedHandler = new SampleDataHandler(attributes, "", d_samplesFramework);
}
else
Logger::getSingleton().logEvent("Animation_xmlHandler::elementStart: "
"<" + element + "> is invalid at this location.", Errors);
}
//----------------------------------------------------------------------------//
void Samples_xmlHandler::elementEndLocal(const String& element)
{
if (element == ElementName)
{
CEGUI_LOGINSANE("===== End Animations parsing =====");
}
else
Logger::getSingleton().logEvent("Animation_xmlHandler::elementEnd: "
"</" + element + "> is invalid at this location.", Errors);
}
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
SampleDataHandler::SampleDataHandler(
const XMLAttributes& attributes,
const String& name_prefix,
SamplesFramework* samplesFramework)
: d_samplesFramework(samplesFramework)
{
const String sampleName(attributes.getValueAsString(NameAttribute));
const String summary(attributes.getValueAsString(SummaryAttribute));
const String description(attributes.getValueAsString(DescriptionAttribute));
const String sampleType(attributes.getValueAsString(SampleTypeAttribute));
const String credits(attributes.getValueAsString(CreditsAttribute));
CEGUI_LOGINSANE(
"Defining sample named: " +
sampleName +
" Summary: " +
summary +
" Description: " +
description +
" Sample Type: " +
sampleType +
" Credits: " +
credits
);
SampleType sampleTypeEnum;
if (sampleType == SampleTypeCppModule)
sampleTypeEnum = ST_Module;
else if(sampleType == SampleTypePython)
sampleTypeEnum = ST_Python;
else
sampleTypeEnum = ST_Lua;
d_samplesFramework->addSampleDataCppModule(sampleName, summary, description, sampleTypeEnum, credits);
}
//----------------------------------------------------------------------------//
SampleDataHandler::~SampleDataHandler()
{
}
//----------------------------------------------------------------------------//
void SampleDataHandler::elementStartLocal(
const String& element,
const XMLAttributes& attributes)
{
Logger::getSingleton().logEvent(
"AnimationDefinitionHandler::elementStart: "
"<" + element + "> is invalid at this location.", Errors);
}
void SampleDataHandler::elementEndLocal(const String& element)
{
// set completed status when we encounter our own end element
if (element == ElementName)
d_completed = true;
}