Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
OperatorRegistry.cpp
Go to the documentation of this file.
1/**
2 * @file OperatorRegistry.cpp
3 * @brief Implementation of OperatorRegistry — hardcoded operator lists.
4 * @author Olympe Engine
5 * @date 2026-03-14
6 *
7 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
8 */
9
10#include "OperatorRegistry.h"
11
12#include <algorithm>
13
14namespace Olympe {
15
16// ---------------------------------------------------------------------------
17// Static data
18// ---------------------------------------------------------------------------
19
20static const std::vector<std::string> s_mathOperators = {"+", "-", "*", "/", "%"};
21static const std::vector<std::string> s_comparisonOperators = {"==", "!=", "<", "<=", ">", ">="};
22
23// ---------------------------------------------------------------------------
24// OperatorRegistry
25// ---------------------------------------------------------------------------
26
27const std::vector<std::string>& OperatorRegistry::GetMathOperators()
28{
29 return s_mathOperators;
30}
31
32const std::vector<std::string>& OperatorRegistry::GetComparisonOperators()
33{
35}
36
37bool OperatorRegistry::IsValidMathOperator(const std::string& op)
38{
39 for (size_t i = 0; i < s_mathOperators.size(); ++i)
40 {
41 if (s_mathOperators[i] == op)
42 return true;
43 }
44 return false;
45}
46
48{
49 for (size_t i = 0; i < s_comparisonOperators.size(); ++i)
50 {
51 if (s_comparisonOperators[i] == op)
52 return true;
53 }
54 return false;
55}
56
57std::string OperatorRegistry::GetDisplayName(const std::string& op)
58{
59 if (op == "+") return "Add (+)";
60 if (op == "-") return "Subtract (-)";
61 if (op == "*") return "Multiply (*)";
62 if (op == "/") return "Divide (/)";
63 if (op == "%") return "Modulo (%)";
64 if (op == "==") return "Equal (==)";
65 if (op == "!=") return "Not Equal (!=)";
66 if (op == "<") return "Less Than (<)";
67 if (op == "<=") return "Less or Equal (<=)";
68 if (op == ">") return "Greater Than (>)";
69 if (op == ">=") return "Greater or Equal (>=)";
70 return op;
71}
72
73} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Hardcoded lists of math and comparison operators for dropdown editors.
static bool IsValidMathOperator(const std::string &op)
Returns true if the given symbol is a valid math operator.
static bool IsValidComparisonOperator(const std::string &op)
Returns true if the given symbol is a valid comparison operator.
static std::string GetDisplayName(const std::string &op)
Returns a human-readable display name for an operator.
static const std::vector< std::string > & GetComparisonOperators()
Returns the list of supported comparison operator symbols.
static const std::vector< std::string > & GetMathOperators()
Returns the list of supported math operator symbols.
< Provides AssetID and INVALID_ASSET_ID
static const std::vector< std::string > s_comparisonOperators
static const std::vector< std::string > s_mathOperators