Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+a3f7a6a005,g07dc498a13+5ab4d22ec3,g0fba68d861+870ee37b31,g1409bbee79+5ab4d22ec3,g1a7e361dbc+5ab4d22ec3,g1fd858c14a+11200c7927,g20f46db602+25d63fd678,g35bb328faa+fcb1d3bbc8,g4d2262a081+cc8af5cafb,g4d39ba7253+6b9d64fe03,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+6b9d64fe03,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8048e755c2+a1301e4c20,g8852436030+a750987b4a,g89139ef638+5ab4d22ec3,g89e1512fd8+a86d53a4aa,g8d6b6b353c+6b9d64fe03,g9125e01d80+fcb1d3bbc8,g989de1cb63+5ab4d22ec3,g9f33ca652e+38ca901d1a,ga9baa6287d+6b9d64fe03,gaaedd4e678+5ab4d22ec3,gabe3b4be73+1e0a283bba,gb1101e3267+aa269f591c,gb58c049af0+f03b321e39,gb90eeb9370+af74afe682,gc741bbaa4f+7f5db660ea,gcf25f946ba+a750987b4a,gd315a588df+b78635c672,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+5839af1903,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,w.2025.11
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)