1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2023 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #include "upb_generator/reflection/names.h" 9 10 #include <string> 11 12 #include "absl/strings/str_replace.h" 13 #include "absl/strings/string_view.h" 14 15 namespace upb { 16 namespace generator { 17 18 namespace { 19 ToCIdent(absl::string_view str)20std::string ToCIdent(absl::string_view str) { 21 return absl::StrReplaceAll(str, {{".", "_"}, {"/", "_"}, {"-", "_"}}); 22 } 23 24 } // namespace 25 ReflectionGetMessageSymbol(absl::string_view full_name)26std::string ReflectionGetMessageSymbol(absl::string_view full_name) { 27 return ToCIdent(full_name) + "_getmsgdef"; 28 } ReflectionFileSymbol(absl::string_view filename)29std::string ReflectionFileSymbol(absl::string_view filename) { 30 return ToCIdent(filename) + "_upbdefinit"; 31 } 32 33 } // namespace generator 34 } // namespace upb 35