Elaztek Developer Hub
Blamite Game Engine - Strings  00411.04.21.24.0017.blamite
A library containing general purpose utilities and classes for use in multiple projects.
converters.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <sail/sail.h>
5 #include <Windows.h>
6 
8 
9 #ifdef STRINGS_EXPORTS
10 #define STRINGS_API __declspec(dllexport)
11 #else
12 #define STRINGS_API __declspec(dllimport)
13 #endif
14 
15 #define bstof(x) BlamStrings::Converters::StringToFloat(x);
16 #define bstod(x) BlamStrings::Converters::StringToDouble(x);
17 #define bstoi(x) BlamStrings::Converters::StringToInt(x);
18 
19 
23 {
31  STRINGS_API std::wstring ConvertStringToWstring(std::string string);
32 
42  STRINGS_API std::string WstringToString(std::wstring wide_string);
43 
51  STRINGS_API std::string DwordToString(DWORD dword);
52 
68  STRINGS_API bool StringToBool(std::string string);
69 
86  STRINGS_API bool StringToBool(std::string string, bool default_value);
87 
98  STRINGS_API bool HexStringToChar(std::string hex, char* character);
99 
107  STRINGS_API float StringToFloat(std::string string);
108 
117  STRINGS_API float StringToFloat(std::string string, float default_value);
118 
126  STRINGS_API int StringToInt(std::string string);
127 
136  STRINGS_API int StringToInt(std::string string, int default_value);
137 
145  STRINGS_API int64_t StringToInt64(std::string string);
146 
155  STRINGS_API int64_t StringToInt64(std::string string, int64_t default_value);
156 
164  STRINGS_API double StringToDouble(std::string string);
165 
174  STRINGS_API double StringToDouble(std::string string, double default_value);
175 
185  STRINGS_API std::string BytesToString(void* bytes, int bytes_length, bool uppercase = false);
186 
196  STRINGS_API std::string BytesToString(void* bytes, int bytes_length, bool uppercase, bool reverse_byte_order);
197 
205  STRINGS_API bool IsStringInt(std::string string);
206 
214  STRINGS_API bool IsStringFloat(std::string string);
215 
223  STRINGS_API std::string BoolToString(bool value);
224 
235  STRINGS_API std::string FloatToString(float value, int max_decimals = -1);
236 
246  STRINGS_API BlamVector2 StringToVector2(std::string string, bool* result = nullptr);
247 
257  STRINGS_API BlamVector3 StringToVector3(std::string string, bool* result = nullptr);
258 
268  STRINGS_API BlamVector4 StringToVector4(std::string string, bool* result = nullptr);
269 
289  STRINGS_API bool HexStringToBytes(std::string hex_string, void** data, int* data_size, bool remove_terminator = true);
290 
300  STRINGS_API bool ConvertSailImagePixelFormat(sail_image** image_pointer, SailPixelFormat pixel_format);
301 }
logger.h
STRINGS_API
#define STRINGS_API
Definition: converters.h:12
BlamStrings::Utils::String::Split
STRINGS_API std::vector< std::string > Split(std::string string, std::string splitter)
Splits a string around any instance of a substring.
Definition: string.cpp:136
hooks.h
BlamStrings::Converters::StringToInt
STRINGS_API int StringToInt(std::string string)
Converts a string representation of an integer to an int.
Definition: converters.cpp:145
BlamStrings::Converters::BoolToString
STRINGS_API std::string BoolToString(bool value)
Converts a boolean value to a string.
Definition: converters.cpp:339
string.h
BlamStrings::Converters::ConvertStringToWstring
STRINGS_API std::wstring ConvertStringToWstring(std::string string)
Converts a String to a Wide String.
Definition: converters.cpp:15
BlamStrings::Logger::LogEvent
STRINGS_API void LogEvent(BlamBasicLogMessage message)
Logs an event to the logger.
Definition: logger.cpp:41
BlamVector3
Structure representing a 3D vector.
Definition: vector.h:83
BlamStrings::Converters::ConvertSailImagePixelFormat
STRINGS_API bool ConvertSailImagePixelFormat(sail_image **image_pointer, SailPixelFormat pixel_format)
Converts a Sail image to a specific pixel format.
Definition: converters.cpp:538
BlamStrings::Converters::WstringToString
STRINGS_API std::string WstringToString(std::wstring wide_string)
Converts a Wide String to a String.
Definition: converters.cpp:39
BlamStrings::Converters::StringToInt64
STRINGS_API int64_t StringToInt64(std::string string)
Converts a string representation of an integer to an int64_t.
Definition: converters.cpp:168
BlamStrings::Converters::DwordToString
STRINGS_API std::string DwordToString(DWORD dword)
Converts a DWORD to a string.
Definition: converters.cpp:60
BlamStrings::Utils::String::StartsWith
STRINGS_API bool StartsWith(std::string string, std::string starts_with, bool case_insensetive=false)
Determines whether or not a string starts with another string, case-insensetive.
Definition: string.cpp:7
BlamStrings::Converters
Namespace containing functions to convert between various types of variables.
Definition: converters.h:22
BlamVector4
Structure representing a 4D vector.
Definition: vector.h:165
BlamStrings::Utils::String::Replace
STRINGS_API std::string Replace(std::string orig, std::string to_replace, std::string replace_with)
Replaces part of a string with another string.
Definition: string.cpp:94
BlamStrings::Converters::IsStringInt
STRINGS_API bool IsStringInt(std::string string)
Checks whether or not a string is a valid representation of an integer.
Definition: converters.cpp:263
BlamStrings::Converters::StringToDouble
STRINGS_API double StringToDouble(std::string string)
Converts a string representation of a double to a double.
Definition: converters.cpp:191
BlamStrings::Converters::HexStringToChar
STRINGS_API bool HexStringToChar(std::string hex, char *character)
Converts a hexadecimal code to its respective character.
Definition: converters.cpp:91
BlamStrings::Converters::FloatToString
STRINGS_API std::string FloatToString(float value, int max_decimals=-1)
Converts a floating-point number to a string.
Definition: converters.cpp:349
BlamStrings::Converters::IsStringFloat
STRINGS_API bool IsStringFloat(std::string string)
Checks whether or not a string is a valid representation of a float.
Definition: converters.cpp:292
BlamStrings::Converters::BytesToString
STRINGS_API std::string BytesToString(void *bytes, int bytes_length, bool uppercase=false)
Converts a series of bytes to a string.
Definition: converters.cpp:214
BlamStrings::Converters::StringToBool
STRINGS_API bool StringToBool(std::string string)
Converts a string to a boolean.
Definition: converters.cpp:67
vector.h
uuids::to_string
std::basic_string< CharT, Traits, Allocator > to_string(uuid const &id)
Definition: uuid.h:581
BlamStrings::Converters::StringToVector4
STRINGS_API BlamVector4 StringToVector4(std::string string, bool *result=nullptr)
Converts a string to a 4D vector.
Definition: converters.cpp:461
BlamVector2
Structure representing a 2D vector.
Definition: vector.h:27
BlamStrings::Converters::StringToFloat
STRINGS_API float StringToFloat(std::string string)
Converts a string representation of a float to a float.
Definition: converters.cpp:122
converters.h
BlamStrings::Converters::StringToVector2
STRINGS_API BlamVector2 StringToVector2(std::string string, bool *result=nullptr)
Converts a string to a 2D vector.
Definition: converters.cpp:382
WSV_ERROR
#define WSV_ERROR
Macro for 'Error' log seveirty.
Definition: logger.h:23
BlamStrings::Utils::String::ContainsChar
STRINGS_API bool ContainsChar(std::string string, char contains)
Determines whether or not a string contains the specified character.
Definition: string.cpp:165
BlamLogLevel::Warning
@ Warning
Indicates a warning message. Not something critical, but something that could cause unexpected behavi...
BlamStrings::Converters::HexStringToBytes
STRINGS_API bool HexStringToBytes(std::string hex_string, void **data, int *data_size, bool remove_terminator=true)
Converts a hexadecimal string representation to bytes in memory.
Definition: converters.cpp:502
BlamStrings::Converters::StringToVector3
STRINGS_API BlamVector3 StringToVector3(std::string string, bool *result=nullptr)
Converts a string to a 3D vector.
Definition: converters.cpp:421