AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
strings.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13#include <AUI/Common/AString.h>
14#include <AUI/Common/AStringVector.h>
15#include <glm/glm.hpp>
16#include <cstring>
17#include "types.h"
18
19#include <fmt/format.h>
20
21namespace aui {
22
23 namespace detail {
24 template<typename T, typename EnableIf = void>
25 struct fmt {
26 template<typename T2>
27 static decltype(auto) process(T2&& arg) {
28 return std::forward<T2>(arg);
29 }
30 };
31
32 template<typename T>
33 struct fmt<T, std::enable_if_t<std::is_base_of_v<AString, T>>> {
34 template<typename T2>
35 static decltype(auto) process(T2&& arg) {
36 return arg.toStdString();
37 }
38 };
39 }
40
47 template <typename... Args>
48 inline AString format(std::string_view f, Args&&... args) {
49 return fmt::format(fmt::runtime(f), detail::fmt<std::decay_t<Args>>::process(std::forward<Args>(args))...);
50 }
51}
52
53template<typename... Args>
54inline AString AString::format(Args&& ... args) const {
55 return aui::format(toStdString(), std::forward<Args>(args)...);
56}
57
58
60 std::string_view string;
61
62 template<typename... Args>
63 inline AString operator()(Args&& ... args) {
64 return aui::format(string, std::forward<Args>(args)...);
65 }
66};
67
77inline AStringFormatHelper operator""_format(const char* str, size_t len)
78{
79 return {std::string_view(str, len)};
80}
Represents a Unicode character string.
Definition: AString.h:37
std::string toStdString() const noexcept
Definition: AString.cpp:338
API_AUI_CORE const ACommandLineArgs & args() noexcept
Definition: OSAndroid.cpp:29
Definition: strings.h:59
Definition: strings.h:25