@@ -15,7 +15,8 @@ namespace kvpp {
1515template <typename V>
1616concept KV1ValueType = std::convertible_to<V, std::string_view>
1717 || std::same_as<V, bool >
18- || std::same_as<V, int >
18+ || std::same_as<V, int32_t >
19+ || std::same_as<V, int64_t >
1920 || std::same_as<V, float >;
2021
2122template <typename S, typename K>
@@ -38,9 +39,17 @@ class KV1ElementBase {
3839 if constexpr (std::convertible_to<V, std::string_view>) {
3940 return this ->value ;
4041 } else if constexpr (std::same_as<V, bool >) {
41- return static_cast <bool >(this ->getValue <int >());
42- } else if constexpr (std::same_as<V, int >) {
42+ return static_cast <bool >(this ->getValue <int32_t >());
43+ } else if constexpr (std::same_as<V, int32_t >) {
44+ if (this ->value .length () == 10 && this ->value .starts_with (" 0x" ) && sourcepp::parser::text::isNumber (this ->value .substr (2 ))) {
45+ return std::stoi (std::string{this ->value .substr (2 )}, nullptr , 16 );
46+ }
4347 return std::stoi (std::string{this ->value });
48+ } else if constexpr (std::same_as<V, int64_t >) {
49+ if (this ->value .length () == 18 && this ->value .starts_with (" 0x" ) && sourcepp::parser::text::isNumber (this ->value .substr (2 ))) {
50+ return std::stoll (std::string{this ->value .substr (2 )}, nullptr , 16 );
51+ }
52+ return std::stoll (std::string{this ->value });
4453 } else if constexpr (std::same_as<V, float >) {
4554 return std::stof (std::string{this ->value });
4655 }
@@ -206,7 +215,7 @@ class KV1ElementWritable : public KV1ElementBase<S, KV1ElementWritable<S>> {
206215 void setValue (V value_) {
207216 if constexpr (std::convertible_to<V, std::string_view>) {
208217 this ->value = std::string_view{value_};
209- } else if constexpr (std::same_as<V, bool > || std::same_as<V, int > || std::same_as<V, float >) {
218+ } else {
210219 this ->setValue (std::to_string (value_));
211220 }
212221 }
0 commit comments