FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
extra_string.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_EXTRA_STRING_HPP_INCLUDED
18#define _FGE_EXTRA_STRING_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_vector.hpp"
22#include <list>
23#include <optional>
24#include <string>
25#include <vector>
26
27namespace fge
28{
29
30class Property;
31
32namespace string
33{
34
42FGE_API bool IsValidUtf8String(std::string const& str);
43
51FGE_API uint8_t ToUint8(std::string const& str);
59FGE_API uint16_t ToUint16(std::string const& str);
67FGE_API uint32_t ToUint32(std::string const& str);
75FGE_API uint64_t ToUint64(std::string const& str);
83FGE_API int8_t ToInt8(std::string const& str);
91FGE_API int16_t ToInt16(std::string const& str);
99FGE_API int32_t ToInt32(std::string const& str);
107FGE_API int64_t ToInt64(std::string const& str);
108
116FGE_API unsigned int ToUint(std::string const& str);
124FGE_API int ToInt(std::string const& str);
125
133FGE_API unsigned long long int ToUlong(std::string const& str);
141FGE_API long long int ToLong(std::string const& str);
142
150FGE_API float ToFloat(std::string const& str);
158FGE_API double ToDouble(std::string const& str);
159
167FGE_API bool ToBool(std::string const& str);
180FGE_API void* ToPtr(std::string const& str);
181
191FGE_API fge::Vector2f ToVec2f(std::string const& str);
201FGE_API fge::Vector2u ToVec2u(std::string const& str);
211FGE_API fge::Vector2i ToVec2i(std::string const& str);
212
213//Arithmetic type
214
224FGE_API std::string ToStr(bool val);
232FGE_API std::string ToStr(char val);
240FGE_API std::string ToStr(char16_t val);
248FGE_API std::string ToStr(char32_t val);
256FGE_API std::string ToStr(wchar_t val);
257
265FGE_API std::string ToStr(signed char val);
273FGE_API std::string ToStr(short int val);
281FGE_API std::string ToStr(int val);
289FGE_API std::string ToStr(long int val);
297FGE_API std::string ToStr(long long int val);
298
306FGE_API std::string ToStr(unsigned char val);
314FGE_API std::string ToStr(unsigned short int val);
322FGE_API std::string ToStr(unsigned int val);
330FGE_API std::string ToStr(unsigned long int val);
338FGE_API std::string ToStr(unsigned long long int val);
339
347FGE_API std::string ToStr(float val);
348FGE_API std::string ToStr(float val, unsigned int precision, bool keepExtraZeros = false);
356FGE_API std::string ToStr(double val);
357FGE_API std::string ToStr(double val, unsigned int precision, bool keepExtraZeros = false);
365FGE_API std::string ToStr(long double val);
366FGE_API std::string ToStr(long double val, unsigned int precision, bool keepExtraZeros = false);
367
368//Pointer
380FGE_API std::string ToStr(void* val);
392FGE_API std::string ToStr(void const* val);
393
403template<class T>
404std::string ToStr(std::optional<T> const& val);
405
406//Classes
407
417FGE_API std::string ToStr(fge::Vector2f const& val);
427FGE_API std::string ToStr(fge::Vector2u const& val);
437FGE_API std::string ToStr(fge::Vector2i const& val);
438
448FGE_API std::string ToStr(fge::Vector3f const& val);
458FGE_API std::string ToStr(fge::Vector3i const& val);
459
469FGE_API std::string ToStr(fge::Property const& val);
470
480template<class T>
481std::string ToStr(std::list<T> const& val, char separator = ' ');
491template<class T>
492std::string ToStr(std::vector<T> const& val, char separator = ' ');
493
503FGE_API std::size_t Split(std::string const& str, std::vector<std::string>& output, char separator);
504
505} // namespace string
506} // namespace fge
507
508#include "extra_string.inl"
509
510#endif // _FGE_EXTRA_STRING_HPP_INCLUDED
A class that can store any type of data.
Definition C_property.hpp:54
FGE_API void * ToPtr(std::string const &str)
Convert a string to a pointer (address)
FGE_API bool IsValidUtf8String(std::string const &str)
Check if the provided string has valid utf8 encoded chars.
FGE_API int64_t ToInt64(std::string const &str)
Convert efficiently a string to an int64_t.
FGE_API bool ToBool(std::string const &str)
Convert efficiently a string to a bool.
FGE_API fge::Vector2i ToVec2i(std::string const &str)
Convert a string to a vector2<int>
FGE_API uint16_t ToUint16(std::string const &str)
Convert efficiently a string to an uint16_t.
FGE_API fge::Vector2u ToVec2u(std::string const &str)
Convert a string to a vector2<unsigned int>
FGE_API float ToFloat(std::string const &str)
Convert efficiently a string to a float.
FGE_API double ToDouble(std::string const &str)
Convert efficiently a string to a double.
FGE_API std::size_t Split(std::string const &str, std::vector< std::string > &output, char separator)
Split a string into a vector of string.
FGE_API int8_t ToInt8(std::string const &str)
Convert efficiently a string to an int8_t.
FGE_API unsigned int ToUint(std::string const &str)
Convert efficiently a string to an unsigned int.
FGE_API int ToInt(std::string const &str)
Convert efficiently a string to an int.
FGE_API uint32_t ToUint32(std::string const &str)
Convert efficiently a string to an uint32_t.
FGE_API uint64_t ToUint64(std::string const &str)
Convert efficiently a string to an uint64_t.
FGE_API int32_t ToInt32(std::string const &str)
Convert efficiently a string to an int32_t.
FGE_API long long int ToLong(std::string const &str)
Convert efficiently a string to an long long int.
FGE_API std::string ToStr(bool val)
Convert efficiently a boolean to a string.
FGE_API uint8_t ToUint8(std::string const &str)
Convert efficiently a string to an uint8_t.
FGE_API fge::Vector2f ToVec2f(std::string const &str)
Convert a string to a vector2<float>
FGE_API int16_t ToInt16(std::string const &str)
Convert efficiently a string to an int16_t.
FGE_API unsigned long long int ToUlong(std::string const &str)
Convert efficiently a string to an unsigned long long int.