summaryrefslogtreecommitdiffhomepage
path: root/vendor/toml++/impl/std_string.inl
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-24 09:15:17 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-24 09:15:17 +0100
commita3ea256d00e5aac45574c7c8b076b60630f73a95 (patch)
treed639c686922140ee0465b27964ce4d2b854b68b7 /vendor/toml++/impl/std_string.inl
parentbb11d32131e786b40550375005b12bcb31cf25d7 (diff)
feat! refactor! Breaking changes of the NeBuild system.
Working on a TOML backend, refactored source code namespace. And add 'toml++' vendor library. See commit details. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'vendor/toml++/impl/std_string.inl')
-rw-r--r--vendor/toml++/impl/std_string.inl99
1 files changed, 99 insertions, 0 deletions
diff --git a/vendor/toml++/impl/std_string.inl b/vendor/toml++/impl/std_string.inl
new file mode 100644
index 0000000..a20d662
--- /dev/null
+++ b/vendor/toml++/impl/std_string.inl
@@ -0,0 +1,99 @@
+//# This file is a part of toml++ and is subject to the the terms of the MIT license.
+//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
+//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
+// SPDX-License-Identifier: MIT
+#pragma once
+
+//# {{
+#include "preprocessor.hpp"
+#if !TOML_IMPLEMENTATION
+#error This is an implementation-only header.
+#endif
+//# }}
+
+#if TOML_WINDOWS
+#include "std_string.hpp"
+#ifndef _WINDOWS_
+#if TOML_INCLUDE_WINDOWS_H
+#include <Windows.h>
+#else
+
+extern "C" __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int CodePage,
+ unsigned long dwFlags,
+ const wchar_t* lpWideCharStr,
+ int cchWideChar,
+ char* lpMultiByteStr,
+ int cbMultiByte,
+ const char* lpDefaultChar,
+ int* lpUsedDefaultChar);
+
+extern "C" __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage,
+ unsigned long dwFlags,
+ const char* lpMultiByteStr,
+ int cbMultiByte,
+ wchar_t* lpWideCharStr,
+ int cchWideChar);
+
+#endif // TOML_INCLUDE_WINDOWS_H
+#endif // _WINDOWS_
+#include "header_start.hpp"
+
+TOML_IMPL_NAMESPACE_START
+{
+ TOML_EXTERNAL_LINKAGE
+ std::string narrow(std::wstring_view str)
+ {
+ if (str.empty())
+ return {};
+
+ std::string s;
+ const auto len =
+ ::WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr);
+ if (len)
+ {
+ s.resize(static_cast<size_t>(len));
+ ::WideCharToMultiByte(65001,
+ 0,
+ str.data(),
+ static_cast<int>(str.length()),
+ s.data(),
+ len,
+ nullptr,
+ nullptr);
+ }
+ return s;
+ }
+
+ TOML_EXTERNAL_LINKAGE
+ std::wstring widen(std::string_view str)
+ {
+ if (str.empty())
+ return {};
+
+ std::wstring s;
+ const auto len = ::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
+ if (len)
+ {
+ s.resize(static_cast<size_t>(len));
+ ::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
+ }
+ return s;
+ }
+
+#if TOML_HAS_CHAR8
+
+ TOML_EXTERNAL_LINKAGE
+ std::wstring widen(std::u8string_view str)
+ {
+ if (str.empty())
+ return {};
+
+ return widen(std::string_view{ reinterpret_cast<const char*>(str.data()), str.length() });
+ }
+
+#endif // TOML_HAS_CHAR8
+}
+TOML_IMPL_NAMESPACE_END;
+
+#include "header_end.hpp"
+#endif // TOML_WINDOWS