R-Type  2
Doom but in better
Loading...
Searching...
No Matches
ToString.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** toString.hpp
6*/
7
17#pragma once
18#include <map>
19#include <set>
20#include <vector>
21#include <string>
22#include <utility>
23#include <unordered_set>
24#include <unordered_map>
25
26#include "ActiveScreen.hpp"
35
36namespace Recoded
37{
38
51 const std::string myToString(bool value);
52
68 template <typename T>
69 const std::string myToString(const T &value)
70 {
71 return std::to_string(value);
72 };
73
96 template <typename T1, typename T2>
97 const std::string myToString(const std::pair<T1, T2> &value)
98 {
99 return "( x: " + myToString(value.first) + ", y: " + myToString(value.second) + ")";
100 };
101
102
118 template<typename Key, typename Value>
119 std::string myToString(const std::map<Key, Value> &map)
120 {
121 std::string result = "{ ";
122 typename std::map<Key, Value>::const_iterator it = map.begin();
123 for (; it != map.end(); ++it) {
124 result += "'" + Recoded::myToString(it->first) + "' : '" + Recoded::myToString(it->second) + "'";
125 if (std::next(it) != map.end())
126 result += ", ";
127 }
128 result += " }";
129 return result;
130 }
131
146 template<typename T>
147 std::string myToString(const std::set<T> &set)
148 {
149 std::string result = "{ ";
150 for (typename std::set<T>::const_iterator it = set.begin(); it != set.end();) {
151 result += "'" + Recoded::myToString(*it) + "'";
152 if (++it != set.end())
153 result += ", ";
154 }
155 result += " }";
156 return result;
157 }
158
173 template<typename T>
174 const std::string myToString(const std::vector<T> &set)
175 {
176 std::string result = "[ ";
177 typename std::vector<T>::const_iterator it = set.begin();
178 for (; it != set.end(); ++it) {
179 result += "'" + Recoded::myToString(*it) + "'";
180 if (std::next(it) != set.end())
181 result += ", ";
182 }
183 result += " ]";
184 return result;
185 }
186
202 template<typename Key, typename Value>
203 std::string myToString(const std::unordered_map<Key, Value> &map)
204 {
205 std::string result = "{ ";
206 typename std::unordered_map<Key, Value>::const_iterator it = map.begin(); // Correct variable name
207 for (; it != map.end(); ++it) {
208 result += "'" + Recoded::myToString(it->first) + "' : '" + Recoded::myToString(it->second) + "'";
209 if (std::next(it) != map.end()) // Avoid trailing comma
210 result += ", ";
211 }
212 result += " }";
213 return result;
214 }
215
230 template<typename T>
231 const std::string myToString(const std::unordered_set<T> &set)
232 {
233 std::string result = "{ ";
234 typename std::unordered_set<T>::const_iterator it = set.begin();
235 for (; it != set.end(); ++it) {
236 result += "'" + Recoded::myToString(*it) + "'";
237 if (std::next(it) != set.end())
238 result += ", ";
239 }
240 result += " }";
241 return result;
242 }
243
255 const std::string myToString(const ActiveScreen &item);
256
268 const std::string myToString(const GUI::ECS::GameComponents::Package &item);
269
281 const std::string myToString(const GUI::ECS::GameComponents::Package_t &item);
282
294 const std::string myToString(const GUI::ECS::GameComponents::EntityType &item);
295
307 const std::string myToString(const GUI::ECS::GameComponents::ECSPackage &item);
308
320 const std::string myToString(const GUI::ECS::GameComponents::ECSPackage_t &item);
321
333 const std::string myToString(const GUI::ECS::GameComponents::EntityActions &item);
334
346 const std::string myToString(const GUI::ECS::GameComponents::EntityActions_t &item);
347
359 const std::string myToString(const GUI::ECS::GameComponents::EntityActionType &item);
360
368 const std::string myToString(const GUI::ECS::Systems::ActiveShape &shape);
369
377 const std::string myToString(const GUI::Network::MessageType &messageType);
378
386 const std::string myToString(const GUI::Network::MessageInfo &messageInfo);
387
395 const std::string myToString(const GUI::Network::MessageNode &messageNode);
396}
ActiveScreen
This is the enum class in charge of the window switcher code. This enum allows the mainloop of the pr...
File in charge of containing the active shape enum the one in charge of tracking the type of shape st...
messageType
Enum representing the different types of game messages.
Enum for the different types of messages that can be eschanged with the server.
ActiveShape
Enum representing different types of shapes managed by the ShapeComponent.
MessageType
Enum for the different message types in the UDP protocol.
const std::string myToString(const Rect< RectType > &rectangle)
Converts a Rect<T> object to its string representation.
Definition Rect.hpp:223
lib set(SERVER_SOURCES main.cpp src/server.cpp src/client_manager.cpp src/game_manager.cpp) add_executable(r-type_server $
A structure containing information about a game message.