FastEngine
0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
includes
FastEngine
extra
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
27
namespace
fge
28
{
29
30
class
Property;
31
32
namespace
string
33
{
34
42
FGE_API
bool
IsValidUtf8String
(std::string
const
& str);
43
51
FGE_API uint8_t
ToUint8
(std::string
const
& str);
59
FGE_API uint16_t
ToUint16
(std::string
const
& str);
67
FGE_API uint32_t
ToUint32
(std::string
const
& str);
75
FGE_API uint64_t
ToUint64
(std::string
const
& str);
83
FGE_API int8_t
ToInt8
(std::string
const
& str);
91
FGE_API int16_t
ToInt16
(std::string
const
& str);
99
FGE_API int32_t
ToInt32
(std::string
const
& str);
107
FGE_API int64_t
ToInt64
(std::string
const
& str);
108
116
FGE_API
unsigned
int
ToUint
(std::string
const
& str);
124
FGE_API
int
ToInt
(std::string
const
& str);
125
133
FGE_API
unsigned
long
long
int
ToUlong
(std::string
const
& str);
141
FGE_API
long
long
int
ToLong
(std::string
const
& str);
142
150
FGE_API
float
ToFloat
(std::string
const
& str);
158
FGE_API
double
ToDouble
(std::string
const
& str);
159
167
FGE_API
bool
ToBool
(std::string
const
& str);
180
FGE_API
void
*
ToPtr
(std::string
const
& str);
181
191
FGE_API fge::Vector2f
ToVec2f
(std::string
const
& str);
201
FGE_API fge::Vector2u
ToVec2u
(std::string
const
& str);
211
FGE_API fge::Vector2i
ToVec2i
(std::string
const
& str);
212
213
//Arithmetic type
214
224
FGE_API std::string
ToStr
(
bool
val);
232
FGE_API std::string
ToStr
(
char
val);
240
FGE_API std::string
ToStr
(
char16_t
val);
248
FGE_API std::string
ToStr
(
char32_t
val);
256
FGE_API std::string
ToStr
(
wchar_t
val);
257
265
FGE_API std::string
ToStr
(
signed
char
val);
273
FGE_API std::string
ToStr
(
short
int
val);
281
FGE_API std::string
ToStr
(
int
val);
289
FGE_API std::string
ToStr
(
long
int
val);
297
FGE_API std::string
ToStr
(
long
long
int
val);
298
306
FGE_API std::string
ToStr
(
unsigned
char
val);
314
FGE_API std::string
ToStr
(
unsigned
short
int
val);
322
FGE_API std::string
ToStr
(
unsigned
int
val);
330
FGE_API std::string
ToStr
(
unsigned
long
int
val);
338
FGE_API std::string
ToStr
(
unsigned
long
long
int
val);
339
347
FGE_API std::string
ToStr
(
float
val);
348
FGE_API std::string
ToStr
(
float
val,
unsigned
int
precision,
bool
keepExtraZeros =
false
);
356
FGE_API std::string
ToStr
(
double
val);
357
FGE_API std::string
ToStr
(
double
val,
unsigned
int
precision,
bool
keepExtraZeros =
false
);
365
FGE_API std::string
ToStr
(
long
double
val);
366
FGE_API std::string
ToStr
(
long
double
val,
unsigned
int
precision,
bool
keepExtraZeros =
false
);
367
368
//Pointer
380
FGE_API std::string
ToStr
(
void
* val);
392
FGE_API std::string
ToStr
(
void
const
* val);
393
403
template
<
class
T>
404
std::string
ToStr
(std::optional<T>
const
& val);
405
406
//Classes
407
417
FGE_API std::string
ToStr
(fge::Vector2f
const
& val);
427
FGE_API std::string
ToStr
(fge::Vector2u
const
& val);
437
FGE_API std::string
ToStr
(fge::Vector2i
const
& val);
438
448
FGE_API std::string
ToStr
(fge::Vector3f
const
& val);
458
FGE_API std::string
ToStr
(fge::Vector3i
const
& val);
459
469
FGE_API std::string
ToStr
(
fge::Property
const
& val);
470
480
template
<
class
T>
481
std::string
ToStr
(std::list<T>
const
& val,
char
separator =
' '
);
491
template
<
class
T>
492
std::string
ToStr
(std::vector<T>
const
& val,
char
separator =
' '
);
493
503
FGE_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
fge::Property
A class that can store any type of data.
Definition
C_property.hpp:54
fge::string::ToPtr
FGE_API void * ToPtr(std::string const &str)
Convert a string to a pointer (address)
fge::string::IsValidUtf8String
FGE_API bool IsValidUtf8String(std::string const &str)
Check if the provided string has valid utf8 encoded chars.
fge::string::ToInt64
FGE_API int64_t ToInt64(std::string const &str)
Convert efficiently a string to an int64_t.
fge::string::ToBool
FGE_API bool ToBool(std::string const &str)
Convert efficiently a string to a bool.
fge::string::ToVec2i
FGE_API fge::Vector2i ToVec2i(std::string const &str)
Convert a string to a vector2<int>
fge::string::ToUint16
FGE_API uint16_t ToUint16(std::string const &str)
Convert efficiently a string to an uint16_t.
fge::string::ToVec2u
FGE_API fge::Vector2u ToVec2u(std::string const &str)
Convert a string to a vector2<unsigned int>
fge::string::ToFloat
FGE_API float ToFloat(std::string const &str)
Convert efficiently a string to a float.
fge::string::ToDouble
FGE_API double ToDouble(std::string const &str)
Convert efficiently a string to a double.
fge::string::Split
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::string::ToInt8
FGE_API int8_t ToInt8(std::string const &str)
Convert efficiently a string to an int8_t.
fge::string::ToUint
FGE_API unsigned int ToUint(std::string const &str)
Convert efficiently a string to an unsigned int.
fge::string::ToInt
FGE_API int ToInt(std::string const &str)
Convert efficiently a string to an int.
fge::string::ToUint32
FGE_API uint32_t ToUint32(std::string const &str)
Convert efficiently a string to an uint32_t.
fge::string::ToUint64
FGE_API uint64_t ToUint64(std::string const &str)
Convert efficiently a string to an uint64_t.
fge::string::ToInt32
FGE_API int32_t ToInt32(std::string const &str)
Convert efficiently a string to an int32_t.
fge::string::ToLong
FGE_API long long int ToLong(std::string const &str)
Convert efficiently a string to an long long int.
fge::string::ToStr
FGE_API std::string ToStr(bool val)
Convert efficiently a boolean to a string.
fge::string::ToUint8
FGE_API uint8_t ToUint8(std::string const &str)
Convert efficiently a string to an uint8_t.
fge::string::ToVec2f
FGE_API fge::Vector2f ToVec2f(std::string const &str)
Convert a string to a vector2<float>
fge::string::ToInt16
FGE_API int16_t ToInt16(std::string const &str)
Convert efficiently a string to an int16_t.
fge::string::ToUlong
FGE_API unsigned long long int ToUlong(std::string const &str)
Convert efficiently a string to an unsigned long long int.
Generated by
1.12.0