From f705b647a11a7d45d7aff22d68a64e58a182b119 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 28 Mar 2012 15:08:41 -0700 Subject: [PATCH] Get a field as a string. --- src/SerializedObject.cpp | 7 +++++++ src/SerializedObject.h | 1 + src/SerializedTransaction.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index 2050604b50..e27ce55d28 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -254,6 +254,13 @@ void STObject::makeFieldAbsent(SOE_Field field) clearFlag(mType[index]->e_flags); } +std::string STObject::getFieldString(SOE_Field field) const +{ + const SerializedType* rf=peekAtPField(field); + if(!rf) throw std::runtime_error("Field not found"); + return rf->getText(); +} + unsigned char STObject::getValueFieldU8(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); diff --git a/src/SerializedObject.h b/src/SerializedObject.h index e48c989c0b..10f4585b73 100644 --- a/src/SerializedObject.h +++ b/src/SerializedObject.h @@ -87,6 +87,7 @@ public: // these throw if the field type doesn't match, or return default values if the // field is optional but not present + std::string getFieldString(SOE_Field field) const; unsigned char getValueFieldU8(SOE_Field field) const; uint16 getValueFieldU16(SOE_Field field) const; uint32 getValueFieldU32(SOE_Field field) const; diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index 186f1f4510..644634d8f6 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -48,6 +48,7 @@ public: const std::vector& peekSigningAccount() const; std::vector& peekSigningAccount(); void setSigningAccount(const std::vector& s); + std::string getTransactionType() const { return mFormat->t_name; } // inner transaction functions uint16 getFlags() const; @@ -65,6 +66,7 @@ public: SerializedType& getITField(SOE_Field field); // inner transaction field value functions + std::string getITFieldString(SOE_Field field) const { return mInnerTxn.getFieldString(field); } unsigned char getITFieldU8(SOE_Field field) const { return mInnerTxn.getValueFieldU8(field); } uint16 getITFieldU16(SOE_Field field) const { return mInnerTxn.getValueFieldU16(field); } uint32 getITFieldU32(SOE_Field field) const { return mInnerTxn.getValueFieldU32(field); }