MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Erase

Function Erase

Source/ThirdParty/rapidjson/pointer.h:833–871  ·  view source on GitHub ↗

Erase a value in a subtree. ! \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. \return Whether the resolved value is found and erased. \note Erasing with an empty pointer \c Pointer(""), i.e. the root, always fail and return false. */

Source from the content-addressed store, hash-verified

831 \note Erasing with an empty pointer \c Pointer(""), i.e. the root, always fail and return false.
832 */
833 bool Erase(ValueType& root) const {
834 RAPIDJSON_ASSERT(IsValid());
835 if (tokenCount_ == 0) // Cannot erase the root
836 return false;
837
838 ValueType* v = &root;
839 const Token* last = tokens_ + (tokenCount_ - 1);
840 for (const Token *t = tokens_; t != last; ++t) {
841 switch (v->GetType()) {
842 case kObjectType:
843 {
844 typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
845 if (m == v->MemberEnd())
846 return false;
847 v = &m->value;
848 }
849 break;
850 case kArrayType:
851 if (t->index == kPointerInvalidIndex || t->index >= v->Size())
852 return false;
853 v = &((*v)[t->index]);
854 break;
855 default:
856 return false;
857 }
858 }
859
860 switch (v->GetType()) {
861 case kObjectType:
862 return v->EraseMember(GenericStringRef<Ch>(last->name, last->length));
863 case kArrayType:
864 if (last->index == kPointerInvalidIndex || last->index >= v->Size())
865 return false;
866 v->Erase(v->Begin() + last->index);
867 return true;
868 default:
869 return false;
870 }
871 }
872
873private:
874 //! Clone the content from rhs to this.

Callers

nothing calls this directly

Calls 8

FindMemberMethod · 0.80
MemberEndMethod · 0.80
EraseMemberMethod · 0.80
EraseMethod · 0.80
IsValidFunction · 0.70
GetTypeMethod · 0.45
SizeMethod · 0.45
BeginMethod · 0.45

Tested by

no test coverage detected