Lagrange
strings.h
1/*
2 * Copyright 2020 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/api.h>
15
16// clang-format off
17#include <lagrange/utils/warnoff.h>
18#include <spdlog/fmt/fmt.h>
19#include <lagrange/utils/warnon.h>
20// clang-format on
21
22#include <string>
23#include <string_view>
24#include <utility>
25#include <vector>
26
27namespace lagrange {
28
33
42LA_CORE_API std::vector<std::string> string_split(const std::string& str, char delimiter);
43
54LA_CORE_API bool starts_with(std::string_view str, std::string_view prefix);
55
66LA_CORE_API bool ends_with(std::string_view str, std::string_view suffix);
67
77LA_CORE_API std::string to_lower(std::string str);
78
88LA_CORE_API std::string to_upper(std::string str);
89
102template <typename... Args>
103std::string string_format(fmt::format_string<Args...> format, Args&&... args)
104{
105 // TODO: Remove this string_format in our next major release...
106 #if FMT_VERSION >= 90100
107 return fmt::format(fmt::runtime(format), std::forward<Args>(args)...);
108 #else
109 return fmt::format(format, std::forward<Args>(args)...);
110 #endif
111}
112
114
115} // namespace lagrange
LA_CORE_API std::string to_lower(std::string str)
Convert a string to lowercase.
Definition: strings.cpp:43
std::string string_format(fmt::format_string< Args... > format, Args &&... args)
Format args according to the format string fmt, and return the result as a string.
Definition: strings.h:103
LA_CORE_API std::string to_upper(std::string str)
Convert a string to uppercase.
Definition: strings.cpp:51
LA_CORE_API bool ends_with(std::string_view str, std::string_view suffix)
Checks if the string ends with the given suffix.
Definition: strings.cpp:31
LA_CORE_API std::vector< std::string > string_split(const std::string &str, char delimiter)
Split a std::string using a prescribed delimiter.
Definition: strings.cpp:20
LA_CORE_API bool starts_with(std::string_view str, std::string_view prefix)
Checks if the string begins with the given prefix.
Definition: strings.cpp:38
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Definition: project.cpp:27