MVault 1.0.0
Simple c++ database
Loading...
Searching...
No Matches
ToString.h
1#pragma once
2
3#include <string>
4#include <cstdint>
5
6namespace mvlt
7{
75 template <class T>
76 std::string ToString(const T& data) noexcept
77 {
78 return "";
79 }
80
90 template <>
91 inline std::string ToString(const std::int64_t& data) noexcept
92 {
93 return std::to_string(data);
94 }
95
105 template <>
106 inline std::string ToString(const std::uint64_t& data) noexcept
107 {
108 return std::to_string(data);
109 }
110
120 template <>
121 inline std::string ToString(const std::int32_t& data) noexcept
122 {
123 return std::to_string(data);
124 }
125
135 template <>
136 inline std::string ToString(const std::uint32_t& data) noexcept
137 {
138 return std::to_string(data);
139 }
140
150 template <>
151 inline std::string ToString(const std::int16_t& data) noexcept
152 {
153 return std::to_string(data);
154 }
155
165 template <>
166 inline std::string ToString(const std::uint16_t& data) noexcept
167 {
168 return std::to_string(data);
169 }
170
180 template <>
181 inline std::string ToString(const std::int8_t& data) noexcept
182 {
183 return std::to_string(static_cast<std::int16_t>(data));
184 }
185
195 template <>
196 inline std::string ToString(const std::uint8_t& data) noexcept
197 {
198 return std::to_string(static_cast<std::uint16_t>(data));
199 }
200
210 template <>
211 inline std::string ToString(const bool& data) noexcept
212 {
213 if (data) return "true";
214 else return "false";
215 }
216
226 template <>
227 inline std::string ToString(const std::string& data) noexcept
228 {
229 return data;
230 }
231
241 template <>
242 inline std::string ToString(const float& data) noexcept
243 {
244 return std::to_string(data);
245 }
246
256 template <>
257 inline std::string ToString(const double& data) noexcept
258 {
259 return std::to_string(data);
260 }
261
263}
Iterator class for all library maps.
Definition Map.h:18
std::string ToString(const T &data) noexcept
A template method for providing an interface converting any type to a string.
Definition ToString.h:76