MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getFieldName

Method getFieldName

valdi/src/valdi/android/AndroidValueMarshallerRegistry.cpp:54–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52FieldNameMap::~FieldNameMap() = default;
53
54Valdi::StringBox FieldNameMap::getFieldName(size_t fieldIndex,
55 const Valdi::StringBox& propertyName,
56 FieldNameMap::FieldType fieldType) const {
57 const auto& it = _map.find(fieldIndex);
58 if (it != _map.end()) {
59 return it->second;
60 }
61
62 switch (fieldType) {
63 case FieldType::Class:
64 return propertyName.prepend("_");
65 case FieldType::InterfaceMethod:
66 return propertyName;
67 case FieldType::InterfaceProperty: {
68 if (propertyName.hasPrefix("is") && propertyName.length() > 2 &&
69 static_cast<bool>(std::isupper(propertyName[2]))) {
70 return propertyName;
71 } else {
72 auto str = propertyName.toStringView();
73 std::string getterName = "get";
74 getterName += std::toupper(str[0]);
75 getterName += str.substr(1);
76
77 return Valdi::StringCache::getGlobal().makeString(std::move(getterName));
78 }
79 } break;
80 case FieldType::EnumCaseValue:
81 return propertyName;
82 }
83}
84
85void FieldNameMap::appendFieldName(size_t fieldIndex, const Valdi::StringBox& fieldName) {
86 _map[fieldIndex] = fieldName;

Calls 9

getGlobalFunction · 0.85
hasPrefixMethod · 0.80
substrMethod · 0.80
makeStringMethod · 0.80
endMethod · 0.65
prependMethod · 0.65
findMethod · 0.45
lengthMethod · 0.45
toStringViewMethod · 0.45

Tested by

no test coverage detected