Skip to content

Commit

Permalink
Add SetValueAndKey()
Browse files Browse the repository at this point in the history
  • Loading branch information
HaniAmmar committed Jun 30, 2024
1 parent 5fc8a76 commit f10d469
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Include/Value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,20 @@ struct Value {
}
}

void SetValueAndKey(SizeT index, const Value *&value, StringView<Char_T> &key) const noexcept {
if (IsObject()) {
const HAItem_T<Value, Char_T> *item = data_.VObject.GetItem(index);

value = nullptr;

if ((item != nullptr) && !(item->Value.IsUndefined())) {
const SizeT len = item->Key.Length();
value = &(item->Value);
key = StringView<Char_T>{item->Key.Storage(len), len};
}
}
}

// To get a pointer to a string value and its length.
template <typename Number_T>
bool SetCharAndLength(const Char_T *&key, Number_T &length) const noexcept {
Expand Down

0 comments on commit f10d469

Please sign in to comment.