GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
InstructionValidator.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2025 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 
8 #include <vector>
9 
10 namespace gd {
11 class Platform;
12 class ProjectScopedContainers;
13 class ObjectsContainersList;
14 class Instruction;
15 class InstructionMetadata;
16 class String;
17 } // namespace gd
18 
19 namespace gd {
20 
25 struct GD_CORE_API ParameterValidationResult {
26  bool isValid = true;
27  bool hasDeprecationWarning = false;
28 
29  ParameterValidationResult() = default;
30  ParameterValidationResult(bool isValid_, bool hasDeprecationWarning_)
31  : isValid(isValid_), hasDeprecationWarning(hasDeprecationWarning_) {}
32 
33  bool IsValid() const { return isValid; }
34  bool HasDeprecationWarning() const { return hasDeprecationWarning; }
35 };
36 
37 class GD_CORE_API InstructionValidator {
38 public:
46  static ParameterValidationResult ValidateParameter(
47  const gd::Platform &platform,
48  const gd::ProjectScopedContainers projectScopedContainers,
49  const gd::Instruction &instruction, const InstructionMetadata &metadata,
50  std::size_t parameterIndex, const gd::String &value);
51 
57  static bool
58  IsParameterValid(const gd::Platform &platform,
59  const gd::ProjectScopedContainers projectScopedContainers,
60  const gd::Instruction &instruction,
61  const InstructionMetadata &metadata,
62  std::size_t parameterIndex, const gd::String &value);
63 
69  static bool
70  HasDeprecationWarnings(const gd::Platform &platform,
71  const gd::ProjectScopedContainers projectScopedContainers,
72  const gd::Instruction &instruction,
73  const InstructionMetadata &metadata,
74  std::size_t parameterIndex, const gd::String &value);
75 
76  static gd::String GetRootVariableName(const gd::String &name);
77 
78 private:
79  static bool
80  HasRequiredBehaviors(const gd::Instruction &instruction,
81  const gd::InstructionMetadata &instructionMetadata,
82  std::size_t objectParameterIndex,
83  const gd::ObjectsContainersList &objectsContainersList);
84 };
85 
86 } // namespace gd
An instruction is a member of an event: It can be a condition or an action.
Definition: Instruction.h:30
Describe user-friendly information about an instruction (action or condition), its parameters and the...
Definition: InstructionMetadata.h:39
Definition: InstructionValidator.h:37
A list of objects containers, useful for accessing objects in a scoped way, along with methods to acc...
Definition: ObjectsContainersList.h:29
Base class for implementing a platform.
Definition: Platform.h:42
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:35
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24
Result of parameter validation containing both validity status and deprecation warning.
Definition: InstructionValidator.h:25