Tie the STAccount class to the NewcoinAddress code.

This commit is contained in:
JoelKatz
2012-04-23 15:58:27 -07:00
parent 3a09455e6c
commit 44afa8fcf9
2 changed files with 14 additions and 0 deletions

View File

@@ -350,6 +350,17 @@ uint256 STObject::getValueFieldH256(SOE_Field field) const
return cf->getValue();
}
NewcoinAddress STObject::getValueFieldAccount(SOE_Field field) const
{
const SerializedType* rf = peekAtPField(field);
if (!rf) throw std::runtime_error("Field not found");
SerializedTypeID id = rf->getSType();
if (id == STI_OBJECT) return NewcoinAddress(); // optional field not present
const STAccount* cf = dynamic_cast<const STAccount *>(rf);
if (!cf) throw std::runtime_error("Wrong field type");
return cf->getValueNCA();
}
std::vector<unsigned char> STObject::getValueFieldVL(SOE_Field field) const
{
const SerializedType* rf = peekAtPField(field);

View File

@@ -102,6 +102,7 @@ public:
uint64 getValueFieldU64(SOE_Field field) const;
uint160 getValueFieldH160(SOE_Field field) const;
uint256 getValueFieldH256(SOE_Field field) const;
NewcoinAddress getValueFieldAccount(SOE_Field field) const;
std::vector<unsigned char> getValueFieldVL(SOE_Field field) const;
std::vector<TaggedListItem> getValueFieldTL(SOE_Field field) const;
@@ -114,6 +115,8 @@ public:
void setValueFieldVL(SOE_Field field, const std::vector<unsigned char>&);
void setValueFieldTL(SOE_Field field, const std::vector<TaggedListItem>&);
void setValueFieldAccount(SOE_Field field, const uint160&);
void setValueFieldAccount(SOE_Field field, const NewcoinAddress& addr)
{ setValueFieldAccount(field, addr.getAccountID()); }
bool isFieldPresent(SOE_Field field) const;
void makeFieldPresent(SOE_Field field);