MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / atPointerImpl

Function atPointerImpl

include/sonic/dom/genericnode.h:1136–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1134
1135 template <typename StringType>
1136 NodeType* atPointerImpl(const GenericJsonPointer<StringType>& pointer) const {
1137 const NodeType* re = downCast();
1138 for (auto& node : pointer) {
1139 if (node.IsStr()) {
1140 if (re->IsObject()) {
1141 auto m = re->FindMember(node.GetStr());
1142 if (m != re->MemberEnd()) {
1143 re = &(m->value);
1144 continue;
1145 }
1146 }
1147 return nullptr;
1148 } else { // Json Pointer node is number
1149 if (re->IsArray()) {
1150 int idx = node.GetNum();
1151 if (idx >= 0 && idx < static_cast<int>(re->Size())) {
1152 re = &(re->operator[]((size_t)idx));
1153 continue;
1154 }
1155 }
1156 return nullptr;
1157 }
1158 }
1159 return const_cast<NodeType*>(re);
1160 }
1161};
1162
1163} // namespace sonic_json

Callers 1

AtPointerFunction · 0.85

Calls 7

downCastFunction · 0.85
IsStrMethod · 0.80
IsObjectMethod · 0.80
FindMemberMethod · 0.80
IsArrayMethod · 0.80
GetNumMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected