Debian Codegraph @

melder/STR.h

raw
1 #pragma once
2 /* STR.h
3 *
4 * Copyright (C) 1992-2018,2020,2021,2024-2026 Paul Boersma
5 *
6 * This code is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or (at
9 * your option) any later version.
10 *
11 * This code is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this work. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 autostring8 hex_STR8 (conststring8 str, uint64 key = 0);
21 autostring32 hex_STR (conststring32 str, uint64 key = 0);
22
23 autostring32 flatten_STR (constSTRVEC const& value, conststring32 separator); // TODO: make available in Formulas
24
25 autostring32 horizontal_STR (constSTRVEC const& value);
26
27 autostring32 left_STR (conststring32 str, integer newLength = 1);
28
29 autostring32 lowerCase_STR (conststring32 str);
30 autostring32 lowerCamelCase_STR (conststring32 str);
31 autostring32 lowerSnakeCase_STR (conststring32 str);
32
33 autostring32 mid_STR (conststring32 str, integer startingPosition_1, integer numberOfCharacters = 1);
34
35 autostring32 padLeft_STR (conststring32 str, integer width, conststring32 pad = U" ");
36 autostring32 padRight_STR (conststring32 str, integer width, conststring32 pad = U" ");
37
38 autostring32 padOrTruncateLeft_STR (conststring32 str, integer width, conststring32 pad = U" ");
39 autostring32 padOrTruncateRight_STR (conststring32 str, integer width, conststring32 pad = U" ");
40
41 autostring32 quote_doubleSTR (conststring32 str);
42
43 /**
44 Look for occurrences of `search` in `str`, and replace them with `replace`.
45 */
46 autostring32 replace_STR (conststring32 str, conststring32 search,
47 conststring32 replace, integer maximumNumberOfReplacements,
48 integer *out_numberOfReplacements = nullptr);
49
50 /**
51 Search and replace `maximumNumberOfReplacements` times in `string` on
52 the basis of regular expressions.
53 If maximumNumberOfReplacements <= 0, the interpreted `replaceRE` replaces *all* occurrences.
54 `search_compiled` is an efficient representation of the search regex and
55 is the result of the compileRE-function which should be called before this function.
56 The number of actual replacements performed is returned in `out_numberOfReplacements`.
57 */
58 autostring32 replace_regex_STR (conststring32 string, regexp *search_compiled,
59 conststring32 replace_regex, integer maximumNumberOfReplacements,
60 integer *out_numberOfReplacements = nullptr);
61
62 autostring32 right_STR (conststring32 str, integer newLength = 1);
63
64 autostring32 truncateLeft_STR (conststring32 str, integer width);
65 autostring32 truncateRight_STR (conststring32 str, integer width);
66
67 autostring8 unhex_STR8 (conststring8 str, uint64 key = 0);
68 autostring32 unhex_STR (conststring32 str, uint64 key = 0);
69
70 autostring32 upperCase_STR (conststring32 str);
71 autostring32 upperCamelCase_STR (conststring32 str);
72 autostring32 upperSnakeCase_STR (conststring32 str);
73
74 autostring32 vertical_STR (constSTRVEC const& strvec);
75
76 /* End of file STR.h */