GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventsVariableReplacer.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 #include <map>
8 #include <memory>
9 #include <unordered_map>
10 #include <unordered_set>
11 #include <vector>
12 
13 #include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
14 #include "GDCore/String.h"
15 namespace gd {
16 class BaseEvent;
17 class VariablesContainer;
18 class EventsList;
19 class Platform;
20 } // namespace gd
21 
22 namespace gd {
23 
30 class GD_CORE_API EventsVariableReplacer
32  public:
34  const gd::Platform &platform_,
35  const gd::VariablesContainer &targetVariablesContainer_,
36  const std::unordered_map<gd::String, gd::String> &oldToNewVariableNames_,
37  const std::unordered_set<gd::String> &removedVariableNames_)
38  : platform(platform_),
39  targetVariablesContainer(targetVariablesContainer_),
40  oldToNewVariableNames(oldToNewVariableNames_),
41  removedVariableNames(removedVariableNames_){};
42  virtual ~EventsVariableReplacer();
43 
44  private:
45  bool DoVisitInstruction(gd::Instruction &instruction,
46  bool isCondition) override;
47  bool DoVisitEventExpression(gd::Expression &expression,
48  const gd::ParameterMetadata &metadata) override;
49 
50  const gd::VariablesContainer *FindForcedVariablesContainerIfAny(
51  const gd::String &type, const gd::String &lastObjectName);
52 
53  const gd::Platform &platform;
54  const gd::VariablesContainer &targetVariablesContainer;
55  gd::String objectName;
56  const std::unordered_map<gd::String, gd::String> &oldToNewVariableNames;
57  const std::unordered_set<gd::String> &removedVariableNames;
58 };
59 
60 } // namespace gd
An events worker that will know about the context (the objects container). Useful for workers working...
Definition: ArbitraryEventsWorker.h:113
Replace in expressions and in parameters of actions or conditions, references to the name of a variab...
Definition: EventsVariableReplacer.h:31
Class representing an expression used as a parameter of a gd::Instruction. This class is nothing more...
Definition: Expression.h:30
An instruction is a member of an event: It can be a condition or an action.
Definition: Instruction.h:30
Describe a parameter of an instruction (action, condition) or of an expression: type,...
Definition: ParameterMetadata.h:27
Base class for implementing a platform.
Definition: Platform.h:42
String represents an UTF8 encoded string.
Definition: String.h:31
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:30
Definition: CommonTools.h:24