Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+05816baf74,g1ec0fe41b4+f536777771,g1fd858c14a+a9301854fb,g35bb328faa+fcb1d3bbc8,g4af146b050+a5c07d5b1d,g4d2262a081+6e5fcc2a4e,g53246c7159+fcb1d3bbc8,g56a49b3a55+9c12191793,g5a012ec0e7+3632fc3ff3,g60b5630c4e+ded28b650d,g67b6fd64d1+ed4b5058f4,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g8352419a5c+fcb1d3bbc8,g87b7deb4dc+7b42cf88bf,g8852436030+e5453db6e6,g89139ef638+ed4b5058f4,g8e3bb8577d+d38d73bdbd,g9125e01d80+fcb1d3bbc8,g94187f82dc+ded28b650d,g989de1cb63+ed4b5058f4,g9d31334357+ded28b650d,g9f33ca652e+50a8019d8c,gabe3b4be73+1e0a283bba,gabf8522325+fa80ff7197,gb1101e3267+d9fb1f8026,gb58c049af0+f03b321e39,gb665e3612d+2a0c9e9e84,gb89ab40317+ed4b5058f4,gcf25f946ba+e5453db6e6,gd6cbbdb0b4+bb83cc51f8,gdd1046aedd+ded28b650d,gde0f65d7ad+941d412827,ge278dab8ac+d65b3c2b70,ge410e46f29+ed4b5058f4,gf23fb2af72+b7cae620c0,gf5e32f922b+fcb1d3bbc8,gf67bdafdda+ed4b5058f4,w.2025.16
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
string_utils.h
Go to the documentation of this file.
1#ifndef LSST_GAUSS2D_STRING_UTILS_H
2#define LSST_GAUSS2D_STRING_UTILS_H
3
4#include <algorithm>
5#include <memory>
6#include <set>
7#include <sstream>
8#include <stdexcept>
9#include <string>
10#include <vector>
11
12namespace lsst::gauss2d {
13
22template <typename T, typename R>
23std::string replace_all(std::string target, T token, R replacement) {
24 auto pos = target.find(token, 0);
25 const auto n_token = token.size();
26 const auto n_replace = replacement.size();
27 while (pos != std::string::npos) {
28 target.replace(pos, n_token, replacement);
29 pos += n_replace;
30 pos = target.find(token, pos);
31 }
32 return target;
33}
34
42template <typename T>
44 auto pos = target.find(token, 0);
45 const auto n_token = token.size();
46 while (pos != std::string::npos) {
47 target.replace(pos, n_token, "");
48 pos = target.find(token, pos);
49 }
50 return target;
51}
52
54 const std::string token,
55 const std::string replacement);
57 std::string_view token,
58 const std::string replacement);
60 const std::string token,
61 std::string_view replacement);
63 std::string_view token,
64 std::string_view replacement);
65
67template std::string replace_all_none<std::string_view>(std::string target, std::string_view token);
68} // namespace lsst::gauss2d
69
70#endif
T find(T... args)
std::string replace_all_none(std::string target, T token)
Replace a token inside a target string with nothing.
template std::string replace_all_none< const std::string >(std::string target, const std::string token)
template std::string replace_all< const std::string, const std::string >(std::string target, const std::string token, const std::string replacement)
template std::string replace_all< const std::string, std::string_view >(std::string target, const std::string token, std::string_view replacement)
template std::string replace_all< std::string_view, const std::string >(std::string target, std::string_view token, const std::string replacement)
std::string replace_all(std::string target, T token, R replacement)
Replace a token inside a target string with another string.
template std::string replace_all_none< std::string_view >(std::string target, std::string_view token)
template std::string replace_all< std::string_view, std::string_view >(std::string target, std::string_view token, std::string_view replacement)
T replace(T... args)