std::string STObject::getFieldString (SField::ref field) const { const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); return rf->getText (); }
uint32 STObject::getFlags (void) const { const STUInt32* t = dynamic_cast<const STUInt32*> (peekAtPField (sfFlags)); if (!t) return 0; return t->getValue (); }
bool STObject::hasMatchingEntry (const SerializedType& t) { const SerializedType* o = peekAtPField (t.getFName ()); if (!o) return false; return t == *o; }
Blob STObject::getFieldVL (SField::ref field) const { const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id == STI_NOTPRESENT) return Blob (); // optional field not present const STVariableLength* cf = dynamic_cast<const STVariableLength*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); return cf->getValue (); }
unsigned char STObject::getFieldU8 (SField::ref field) const { const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id == STI_NOTPRESENT) return 0; // optional field not present const STUInt8* cf = dynamic_cast<const STUInt8*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); return cf->getValue (); }
const STVector256& STObject::getFieldV256 (SField::ref field) const { static STVector256 empty; const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id == STI_NOTPRESENT) return empty; // optional field not present const STVector256* cf = dynamic_cast<const STVector256*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); return *cf; }
RippleAddress STObject::getFieldAccount (SField::ref field) const { const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id == STI_NOTPRESENT) return RippleAddress (); // optional field not present const STAccount* cf = dynamic_cast<const STAccount*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); return cf->getValueNCA (); }
const STArray& STObject::getFieldArray (SField::ref field) const { static STArray empty; const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id == STI_NOTPRESENT) return empty; const STArray* cf = dynamic_cast<const STArray*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); return *cf; }
AccountID STObject::getAccountID (SField const& field) const { auto rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); AccountID account; if (rf->getSType () != STI_NOTPRESENT) { const STAccount* cf = dynamic_cast<const STAccount*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); cf->getValueH160 (account); } return account; }
uint160 STObject::getFieldAccount160 (SField::ref field) const { uint160 a; const SerializedType* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); SerializedTypeID id = rf->getSType (); if (id != STI_NOTPRESENT) { const STAccount* cf = dynamic_cast<const STAccount*> (rf); if (!cf) throw std::runtime_error ("Wrong field type"); cf->getValueH160 (a); } return a; }