Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | /// @file codegen/String.h | ||
5 | /// | ||
6 | /// @authors Nick Avramoussis | ||
7 | /// | ||
8 | /// @brief Provides the class definition for the equivalent IR representation | ||
9 | /// and logic for strings in AX. | ||
10 | /// | ||
11 | |||
12 | #ifndef OPENVDB_AX_CODEGEN_STRING_HAS_BEEN_INCLUDED | ||
13 | #define OPENVDB_AX_CODEGEN_STRING_HAS_BEEN_INCLUDED | ||
14 | |||
15 | #include <openvdb/version.h> | ||
16 | #include <openvdb/Types.h> | ||
17 | |||
18 | #include <cstring> | ||
19 | #include <cstdlib> | ||
20 | #include <cassert> | ||
21 | |||
22 | namespace openvdb { | ||
23 | OPENVDB_USE_VERSION_NAMESPACE | ||
24 | namespace OPENVDB_VERSION_NAME { | ||
25 | |||
26 | namespace ax { | ||
27 | namespace codegen { | ||
28 | |||
29 | /// @brief An extremely basic but native representation of a string class with | ||
30 | /// SSO support. This exists to provide an interface between the AX C++ API | ||
31 | /// and backend IR string logic. It is not designed to fulfill any other use | ||
32 | /// and should very rarely be used directly. | ||
33 | struct String | ||
34 | { | ||
35 | static constexpr int64_t SSO_LENGTH = 16; // Should never be less than 2 | ||
36 | static_assert(SSO_LENGTH >= 2, "SSO should be greater than or equal to 2"); | ||
37 | |||
38 | 1397767 | String() : String("", 0) {} | |
39 | /// Construct from null terminated character string | ||
40 | 31 | String(const char* str) : String(str, std::strlen(str)) {} | |
41 | 49171 | String(const std::string& str) : String(str.c_str(), str.size()) {} | |
42 | 1446998 | String(const char* str, const int64_t size) | |
43 | 1446998 | { | |
44 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1446998 times.
|
1446998 | assert(str != nullptr); |
45 | 1446998 | this->ptr = this->SSO; // for the isLocal check in alloc | |
46 | this->reset(str, size); | ||
47 | 1446998 | } | |
48 | 1397775 | ~String() { if (!this->isLocal()) std::free(ptr); } | |
49 | |||
50 | 3 | String(const String& other) : String(other.ptr, other.len) {} | |
51 | |||
52 | /////////////////////////////////////////////////////////////////////////// | ||
53 | |||
54 |
24/43✓ Branch 1 taken 1 times.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 47 times.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
|
779 | const std::string str() const { return std::string(this->ptr, this->len); } |
55 |
123/246✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 15 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 1 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 1 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 16 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 1 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 1 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 1 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 32 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 1 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 1 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 1 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 1 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 1 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 1 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 1 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 1 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 1 times.
✗ Branch 167 not taken.
✓ Branch 169 taken 1 times.
✗ Branch 170 not taken.
✓ Branch 172 taken 1 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 1 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 1 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 1 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 15 times.
✗ Branch 185 not taken.
✓ Branch 187 taken 1 times.
✗ Branch 188 not taken.
✓ Branch 190 taken 1 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 1 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 1 times.
✗ Branch 197 not taken.
✓ Branch 199 taken 15 times.
✗ Branch 200 not taken.
✓ Branch 202 taken 1 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 1 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 1 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 16 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 1 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 1 times.
✗ Branch 218 not taken.
✓ Branch 220 taken 1 times.
✗ Branch 221 not taken.
✓ Branch 223 taken 1 times.
✗ Branch 224 not taken.
✓ Branch 226 taken 1 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 1 times.
✗ Branch 230 not taken.
✓ Branch 232 taken 1 times.
✗ Branch 233 not taken.
✓ Branch 235 taken 1 times.
✗ Branch 236 not taken.
✓ Branch 238 taken 1 times.
✗ Branch 239 not taken.
✓ Branch 241 taken 1 times.
✗ Branch 242 not taken.
✓ Branch 244 taken 1 times.
✗ Branch 245 not taken.
✓ Branch 247 taken 1 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 1 times.
✗ Branch 251 not taken.
✓ Branch 253 taken 1 times.
✗ Branch 254 not taken.
✓ Branch 256 taken 1 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 1 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 1 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 1 times.
✗ Branch 266 not taken.
✓ Branch 268 taken 1 times.
✗ Branch 269 not taken.
✓ Branch 271 taken 1 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 1 times.
✗ Branch 275 not taken.
✓ Branch 277 taken 1 times.
✗ Branch 278 not taken.
✓ Branch 280 taken 1 times.
✗ Branch 281 not taken.
✓ Branch 283 taken 16 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 1 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 1 times.
✗ Branch 290 not taken.
✓ Branch 292 taken 1 times.
✗ Branch 293 not taken.
✓ Branch 295 taken 16 times.
✗ Branch 296 not taken.
✓ Branch 298 taken 1 times.
✗ Branch 299 not taken.
✓ Branch 301 taken 1 times.
✗ Branch 302 not taken.
✓ Branch 304 taken 1 times.
✗ Branch 305 not taken.
✓ Branch 307 taken 1 times.
✗ Branch 308 not taken.
✓ Branch 310 taken 1 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 1 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 1 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 16 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 1 times.
✗ Branch 323 not taken.
✓ Branch 325 taken 1 times.
✗ Branch 326 not taken.
✓ Branch 328 taken 1 times.
✗ Branch 329 not taken.
✓ Branch 331 taken 1 times.
✗ Branch 332 not taken.
✓ Branch 334 taken 1 times.
✗ Branch 335 not taken.
✓ Branch 337 taken 1 times.
✗ Branch 338 not taken.
✓ Branch 340 taken 1 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 14 times.
✗ Branch 344 not taken.
✓ Branch 346 taken 1 times.
✗ Branch 347 not taken.
✓ Branch 349 taken 1 times.
✗ Branch 350 not taken.
✓ Branch 352 taken 1 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 1 times.
✗ Branch 356 not taken.
✓ Branch 358 taken 1 times.
✗ Branch 359 not taken.
✓ Branch 361 taken 15 times.
✗ Branch 362 not taken.
✓ Branch 364 taken 1 times.
✗ Branch 365 not taken.
✓ Branch 367 taken 1 times.
✗ Branch 368 not taken.
|
298 | const char* c_str() const { return this->ptr; } |
56 |
35/68✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
|
146 | int64_t size() const { return this->len; } |
57 |
111/336✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 49170 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1376256 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 21504 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 1 times.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 1 times.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 1 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 1 times.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 1 times.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✓ Branch 79 taken 1 times.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✓ Branch 83 taken 1 times.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 1 times.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✓ Branch 96 taken 1 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 1 times.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1 times.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✓ Branch 109 taken 1 times.
✓ Branch 110 taken 1 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 1 times.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✓ Branch 157 taken 1 times.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✓ Branch 160 taken 1 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 1 times.
✓ Branch 164 taken 1 times.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 167 taken 1 times.
✗ Branch 168 not taken.
✓ Branch 169 taken 1 times.
✓ Branch 171 taken 1 times.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✓ Branch 174 taken 1 times.
✗ Branch 175 not taken.
✓ Branch 176 taken 1 times.
✓ Branch 178 taken 1 times.
✗ Branch 179 not taken.
✓ Branch 181 taken 1 times.
✗ Branch 182 not taken.
✓ Branch 184 taken 1 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 1 times.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✓ Branch 189 taken 1 times.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✗ Branch 192 not taken.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✓ Branch 207 taken 1 times.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✓ Branch 210 taken 1 times.
✓ Branch 212 taken 1 times.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✓ Branch 215 taken 1 times.
✓ Branch 217 taken 1 times.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✓ Branch 220 taken 1 times.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✓ Branch 228 taken 3 times.
✓ Branch 230 taken 1 times.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✓ Branch 233 taken 1 times.
✓ Branch 235 taken 1 times.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✓ Branch 238 taken 1 times.
✓ Branch 240 taken 1 times.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✓ Branch 243 taken 1 times.
✓ Branch 245 taken 1 times.
✗ Branch 246 not taken.
✓ Branch 247 taken 1 times.
✗ Branch 248 not taken.
✓ Branch 250 taken 1 times.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 1 times.
✓ Branch 255 taken 1 times.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✓ Branch 258 taken 1 times.
✓ Branch 260 taken 1 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 1 times.
✗ Branch 263 not taken.
✓ Branch 265 taken 1 times.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✓ Branch 268 taken 1 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 1 times.
✓ Branch 272 taken 1 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 1 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 1 times.
✗ Branch 277 not taken.
✓ Branch 279 taken 1 times.
✗ Branch 280 not taken.
✓ Branch 282 taken 1 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 1 times.
✗ Branch 285 not taken.
✓ Branch 286 taken 1 times.
✗ Branch 287 not taken.
✓ Branch 289 taken 1 times.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✓ Branch 292 taken 1 times.
✓ Branch 294 taken 1 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 1 times.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✓ Branch 299 taken 1 times.
✓ Branch 301 taken 1 times.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✓ Branch 304 taken 1 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 1 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 1 times.
✓ Branch 310 taken 1 times.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✓ Branch 313 taken 1 times.
✗ Branch 314 not taken.
✓ Branch 315 taken 1 times.
✗ Branch 316 not taken.
✓ Branch 317 taken 1 times.
✓ Branch 318 taken 1 times.
✗ Branch 319 not taken.
✓ Branch 321 taken 1 times.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✓ Branch 324 taken 1 times.
✗ Branch 325 not taken.
✓ Branch 326 taken 1 times.
✓ Branch 327 taken 1 times.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✗ Branch 354 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
|
89571505 | bool isLocal() const { return this->ptr == this->SSO; } |
58 | void clear() { this->reset("", 0); } | ||
59 | |||
60 | // operators | ||
61 | |||
62 |
17/34✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 131073 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 43 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
|
131131 | inline operator const char*() const { return this->ptr; } |
63 | |||
64 | 88124749 | const String& operator=(const std::string& str) | |
65 | { | ||
66 | this->reset(str.c_str(), str.size()); | ||
67 | 88124749 | return *this; | |
68 | } | ||
69 | |||
70 | 7016965 | const String& operator=(const String& other) | |
71 | { | ||
72 | 7016965 | this->reset(other.ptr, other.len); | |
73 | 7016965 | return *this; | |
74 | } | ||
75 | |||
76 | bool operator==(const String& other) const | ||
77 | { | ||
78 |
10/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 6216047 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6216047 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6216047 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 6215791 times.
✓ Branch 21 taken 256 times.
✓ Branch 22 taken 48913 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 48913 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 48913 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 12294 times.
✓ Branch 31 taken 36619 times.
|
6411699 | return std::strcmp(this->ptr, other.ptr) == 0; |
79 | } | ||
80 | |||
81 | bool operator!=(const String& other) const | ||
82 | { | ||
83 | return !this->operator==(other); | ||
84 | } | ||
85 | |||
86 | 3 | String operator+(const String& other) const | |
87 | { | ||
88 | String s; | ||
89 | 3 | s.alloc(this->size() + other.size()); | |
90 | 3 | std::memcpy(s.ptr, this->c_str(), this->size()); | |
91 | 3 | std::memcpy(s.ptr + this->size(), other.c_str(), other.size()); | |
92 | 3 | return s; | |
93 | } | ||
94 | |||
95 | /////////////////////////////////////////////////////////////////////////// | ||
96 | /////////////////////////////////////////////////////////////////////////// | ||
97 | |||
98 | // Internal methods and members. These should never be used directly, but | ||
99 | // remain public for C bindings in StringFunction (allowing for behaviour | ||
100 | // coupling with the IR implementations). | ||
101 | |||
102 | inline void reset(const char* str, const int64_t size) | ||
103 | { | ||
104 | 96588712 | this->alloc(size); | |
105 | 96588712 | std::memcpy(this->ptr, str, size); | |
106 | } | ||
107 | |||
108 | 96595083 | inline void alloc(const size_t size) | |
109 | { | ||
110 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 96595083 times.
|
96595083 | if (!this->isLocal()) std::free(this->ptr); |
111 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 96595069 times.
|
96595083 | if (size > SSO_LENGTH-1) this->ptr = static_cast<char*>(std::malloc(size + 1)); |
112 | 96595069 | else this->ptr = this->SSO; | |
113 | 96595083 | this->ptr[size] = '\0'; | |
114 | 96595083 | this->len = size; | |
115 | 96595083 | } | |
116 | |||
117 | char* ptr = nullptr; | ||
118 | char SSO[SSO_LENGTH]; | ||
119 | int64_t len = 0; | ||
120 | }; | ||
121 | |||
122 | } // namespace codegen | ||
123 | } // namespace ax | ||
124 | |||
125 | template<> inline ax::codegen::String zeroVal<ax::codegen::String>() { return ""; } | ||
126 | |||
127 | } // namespace OPENVDB_VERSION_NAME | ||
128 | } // namespace openvdb | ||
129 | |||
130 | #endif // OPENVDB_AX_CODEGEN_STRING_HAS_BEEN_INCLUDED | ||
131 | |||
132 |