| 52 | FieldNameMap::~FieldNameMap() = default; |
| 53 | |
| 54 | Valdi::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 | |
| 85 | void FieldNameMap::appendFieldName(size_t fieldIndex, const Valdi::StringBox& fieldName) { |
| 86 | _map[fieldIndex] = fieldName; |
no test coverage detected