string.hpp (1376B)
1 /* ReaPack: Package manager for REAPER 2 * Copyright (C) 2015-2025 Christian Fillion 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef REAPACK_STRING_HPP 19 #define REAPACK_STRING_HPP 20 21 #include <sstream> 22 #include <string> 23 24 namespace String { 25 namespace ImplDetail { 26 void imbueStream(std::ostream &); 27 }; 28 29 #ifdef __GNUC__ 30 __attribute__((format(printf, 1, 2))) 31 #endif 32 std::string format(const char *fmt, ...); 33 34 std::string indent(const std::string &); 35 std::string stripRtf(const std::string &); 36 37 template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> 38 std::string number(const T v) 39 { 40 std::ostringstream stream; 41 ImplDetail::imbueStream(stream); 42 stream << v; 43 return stream.str(); 44 }; 45 } 46 47 #endif