Debian Codegraph @

melder/melder_string32.h

raw symbols SCIP
1 #cxx . . $ `<file>/melder/melder_string32.h`/ifndef _melder_string32_h_
2 #define _melder_string32_h_cxx . . $ `melder/melder_string32.h:2:9`!
3 /* melder_string32.h
4 *
5 * Copyright (C) 1992-2020,2023 Paul Boersma
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 using char8cxx . . $ char8# = unsigned char;
22 using char16cxx . . $ char16# = char16_t;
23 using char32cxx . . $ char32# = char32_t;
24
25 /* USAGE: Constant strings.
26
27 For whole null-terminated strings whose contents will not be changed, use conststring32:
28 void writeString (conststring32 text);
29
30 For a pointer to a character in a conststring32, use "const char32 *".
31 This is appropriate if you need to cycle later:
32 const char32 *p = & text [0];
33 ...
34 p ++;
35 This is also appropriate for character searches:
36 const char32 *semicolonLocation = str32chr (text, U';');
37
38 For an array of characters, use "const char32 []":
39 void displayCharacters (const char32 characters []);
40 Such an array may or may not be null-terminated.
41 */
42 using conststring8cxx . . $ conststring8# = const char *;
43 using conststring16cxx . . $ conststring16# = const char16cxx . . $ char16# *;
44 using conststringWcxx . . $ conststringW# = const wchar_t *;
45 using conststring32cxx . . $ conststring32# = const char32cxx . . $ char32# *;
46
47 /* USAGE: Mutable strings.
48
49 For whole null-terminated strings whose contents will be changed, use mutablestring32:
50 void changeCase (mutablestring32 string);
51
52 For a pointer to a character in a mutablestring32, use "char32 *".
53 This is appropriate if you need to cycle later:
54 char32 *p = & string [0];
55 ...
56 p ++;
57 This is also appropriate for character searches:
58 char32 *semicolonLocation = str32chr (string, U';');
59
60 For an array of characters that will be changed, use "char32 []":
61 void modifyCodes (char32 codes []);
62 Such an array may or may not be null-terminated.
63 */
64 using mutablestring8cxx . . $ mutablestring8# = char *;
65 using mutablestring16cxx . . $ mutablestring16# = char16cxx . . $ char16# *;
66 using mutablestringWcxx . . $ mutablestringW# = wchar_t *;
67 using mutablestring32cxx . . $ mutablestring32# = char32cxx . . $ char32# *;
68
69 #define strequcxx . . $ `melder/melder_string32.h:69:9`! ! strcmp
70 #define strnequcxx . . $ `melder/melder_string32.h:70:9`! ! strncmp
71
72 template <class T>
73 class _autostringcxx . . $ _autostring# {
74 T *ptrcxx . . $ _autostring#ptr.;
75 public:
76 #if 1
77 _autostringcxx . . $ _autostring#`_autostring<T>`(49f6e7a06ebc5aa8). () : ptrcxx . . $ _autostring#ptr. (nullptr) {
78 //if (Melder_debug == 39) Melder_casual (U"autostring: zero constructor");
79 }
80 #else
81 _autostring () = default; // explicit default, so that it can be used in a union
82 #endif
83 explicit _autostringcxx . . $ _autostring#`_autostring<T>`(f153f132b2bc41c2). (integercxx . . $ integer# length, bool f = false) {
84 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = ( f ? Melder_malloc_fcxx . . $ `melder/melder_alloc.h:30:9`! (T, length + 1) : Melder_malloccxx . . $ `melder/melder_alloc.h:28:9`! (T, length + 1) );
85 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. [0] = '\0';
86 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. [length] = '\0';
87 }
88 //_autostring (T *string) : ptr (string) {
89 //if (Melder_debug == 39) Melder_casual (U"autostring: constructor from C-string ", Melder_pointer (ptr));
90 //}
91 ~cxx . . $ _autostring#`~_autostring<T>`(49f6e7a06ebc5aa8)._autostring () {
92 //if (Melder_debug == 39) Melder_casual (U"autostring: entering destructor ptr = ", Melder_pointer (ptr));
93 if (ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.) Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (ourcxx . . $ `melder/melder.h:42:9`! ptr);
94 //if (Melder_debug == 39) Melder_casual (U"autostring: leaving destructor");
95 }
96 template <class U> T& operatorcxx . . $ _autostring#`operator[]`(b190d49faf30c5be).[] (U i) {
97 return ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. [i];
98 }
99 T * getcxx . . $ _autostring#get(5a2a78a048fb49a8). () const {
100 return ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.;
101 }
102 #if 0
103 operator T* () const {
104 return our ptr;
105 }
106 #endif
107 /*T ** operator& () {
108 return & our ptr;
109 }*/
110 T * transfercxx . . $ _autostring#transfer(155dc7f103cdb9db). () {
111 T *tmp = ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.;
112 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = nullptr;
113 return tmp;
114 }
115 void resetcxx . . $ _autostring#reset(49f6e7a06ebc5aa8). () {
116 if (ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.)
117 Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (ourcxx . . $ `melder/melder.h:42:9`! ptr);
118 }
119 void resizecxx . . $ _autostring#resize(1624ee8275b10bda). (int64cxx . . $ int64# newLength) {
120 T *tmp = (T *) Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace). (ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr., (newLength + 1) * (int64cxx . . $ int64#) sizeof (T));
121 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = tmp;
122 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. [newLength] = '\0';
123 }
124 _autostring& operatorcxx . . $ _autostring#`operator=`(4b8b43ee8d62f835).= (const _autostring&) = delete; // disable copy assignment
125 _autostringcxx . . $ _autostring#`_autostring<T>`(38aa84dee236805c). (_autostring &) = delete; // disable copy constructor
126 template <class Y> _autostringcxx . . $ _autostring#`_autostring<T>`(3a4ddf040733beab). (_autostringcxx . . $ _autostring#<Y> &) = delete; // disable copy constructor
127 explicit operatorcxx . . $ _autostring#`operator bool`(3482b152b9333168). bool () const noexcept { return !! ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.; }
128 /*
129 Enable moving.
130 */
131 _autostringcxx . . $ _autostring#`_autostring<T>`(39021ecceedcc7d2). (_autostring&& other) noexcept { // enable move constructor
132 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = other.ptrcxx . . $ _autostring#ptr.;
133 other.ptrcxx . . $ _autostring#ptr. = nullptr;
134 }
135 _autostring& operatorcxx . . $ _autostring#`operator=`(f562943cbc4bcf37).= (_autostring&& other) noexcept { // enable move assignment
136 if (& other != this) {
137 if (ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr.) Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (ourcxx . . $ `melder/melder.h:42:9`! ptr);
138 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = other.ptrcxx . . $ _autostring#ptr.;
139 other.ptrcxx . . $ _autostring#ptr. = nullptr;
140 }
141 return *this;
142 }
143 _autostring&& movecxx . . $ _autostring#move(bd43c759570f178f). () noexcept {
144 return static_cast <_autostring&&> (*this);
145 }
146 void _zero_asInUnioncxx . . $ _autostring#_zero_asInUnion(49f6e7a06ebc5aa8). () {
147 ourcxx . . $ `melder/melder.h:42:9`! ptrcxx . . $ _autostring#ptr. = nullptr;
148 }
149 };
150
151 typedef _autostringcxx . . $ _autostring# <char> autostring8cxx . . $ autostring8#;
152 typedef _autostringcxx . . $ _autostring# <char16cxx . . $ char16#> autostring16cxx . . $ autostring16#;
153 typedef _autostringcxx . . $ _autostring# <wchar_t> autostringWcxx . . $ autostringW#;
154 typedef _autostringcxx . . $ _autostring# <char32cxx . . $ char32#> autostring32cxx . . $ autostring32#;
155
156 autostring32cxx . . $ autostring32# Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (conststring32cxx . . $ conststring32# string /* cattable */);
157 autostring32cxx . . $ autostring32# Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (conststring32cxx . . $ conststring32# string /* cattable */);
158 autostring32cxx . . $ autostring32# Melder_ndupcxx . . $ Melder_ndup(c02f217f21fae7fe). (conststring32cxx . . $ conststring32# string /* cattable */, integercxx . . $ integer# n);
159
160 /* End of file melder_string32.h */
161 #endif