MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / validate_node_name

Method validate_node_name

core/string/ustring.cpp:5379–5420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5377}
5378
5379String String::validate_node_name() const {
5380 const char32_t *cn = ptr();
5381 if (cn == nullptr) {
5382 return String();
5383 }
5384 bool valid = true;
5385 uint32_t idx = 0;
5386 while (cn[idx]) {
5387 const char32_t *c = invalid_node_name_characters;
5388 while (*c) {
5389 if (cn[idx] == *c) {
5390 valid = false;
5391 break;
5392 }
5393 c++;
5394 }
5395 if (!valid) {
5396 break;
5397 }
5398 idx++;
5399 }
5400
5401 if (valid) {
5402 return *this;
5403 }
5404
5405 String validated = *this;
5406 char32_t *nn = validated.ptrw();
5407 while (nn[idx]) {
5408 const char32_t *c = invalid_node_name_characters;
5409 while (*c) {
5410 if (nn[idx] == *c) {
5411 nn[idx] = '_';
5412 break;
5413 }
5414 c++;
5415 }
5416 idx++;
5417 }
5418
5419 return validated;
5420}
5421
5422String String::get_basename() const {
5423 int pos = rfind_char('.');

Callers 12

set_nameMethod · 0.80
_gen_unique_nameMethod · 0.80
_gen_unique_nameMethod · 0.80
_node_addedMethod · 0.80
on_spawn_receiveMethod · 0.80
update_dialogMethod · 0.80
rename_nodeMethod · 0.80
_add_animation_typeMethod · 0.80
test_string.hFile · 0.80

Calls 2

StringClass · 0.70
ptrwMethod · 0.45

Tested by

no test coverage detected