11#include <pxr/base/tf/stringUtils.h>
12#include <pxr/base/tf/unicodeUtils.h>
13#include <pxr/usd/usd/prim.h>
14#include <pxr/usd/usd/stage.h>
20 if (
name.is_empty()) {
25 const bool has_leading_digit = std::isdigit(
name[0]);
32 if (has_leading_digit) {
40 offset +=
name.size();
41 return pxr::TfMakeValidIdentifier({buf.
data(), offset});
44 for (
auto cp : pxr::TfUtf8CodePointView{
name}) {
45 constexpr pxr::TfUtf8CodePoint cp_underscore = pxr::TfUtf8CodePointFromAscii(
'_');
46 const bool cp_allowed = first ? (cp == cp_underscore || pxr::TfIsUtf8CodePointXidStart(cp)) :
47 pxr::TfIsUtf8CodePointXidContinue(cp);
58 return {buf.
data(), offset};
63 std::string unique_path = path;
65 while (stage->GetPrimAtPath(pxr::SdfPath(unique_path)).IsValid()) {
66 unique_path = path + std::to_string(suffix++);
69 return pxr::SdfPath(unique_path);
size_t BLI_str_utf8_from_unicode(unsigned int c, char *dst, size_t dst_maxncpy) ATTR_NONNULL(2)
constexpr int64_t size() const
constexpr MutableSpan take_back(const int64_t n) const
constexpr T * data() const
constexpr void copy_from(Span< T > values) const
pxr::SdfPath get_unique_path(pxr::UsdStageRefPtr stage, const std::string &path)
std::string make_safe_name(const StringRef name, bool allow_unicode)