From 21bb574e969f5f27285e326ea41a7117b11ec9e5 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 8 Apr 2012 19:56:48 -0700 Subject: [PATCH] Having a function in a base class that's widely overloaded called 'getType' is a bad idea. Change it to 'getSType'. --- src/SerializedObject.cpp | 54 ++++++++++++++++++------------------- src/SerializedObject.h | 2 +- src/SerializedTransaction.h | 4 +-- src/SerializedTypes.cpp | 2 +- src/SerializedTypes.h | 26 +++++++++--------- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index c09e67904d..07bf10772a 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -175,7 +175,7 @@ bool STObject::isEquivalent(const SerializedType& t) const boost::ptr_vector::const_iterator it2=v->mData.begin(), end2=v->mData.end(); while((it1!=end1) && (it2!=end2)) { - if(it1->getType() != it2->getType()) return false; + if(it1->getSType() != it2->getSType()) return false; if(!it1->isEquivalent(*it2)) return false; ++it1; ++it2; @@ -223,7 +223,7 @@ bool STObject::isFieldPresent(SOE_Field field) const { int index=getFieldIndex(field); if(index==-1) return false; - return peekAtIndex(field).getType()==STI_OBJECT; + return peekAtIndex(field).getSType()==STI_OBJECT; } bool STObject::setFlag(int f) @@ -256,7 +256,7 @@ void STObject::makeFieldPresent(SOE_Field field) { int index=getFieldIndex(field); if(index==-1) throw std::runtime_error("Field not found"); - if(peekAtIndex(field).getType()!=STI_OBJECT) return; + if(peekAtIndex(field).getSType()!=STI_OBJECT) return; mData.replace(index, makeDefaultObject(mType[index]->e_id, mType[index]->e_name)); setFlag(mType[index]->e_flags); } @@ -265,7 +265,7 @@ void STObject::makeFieldAbsent(SOE_Field field) { int index=getFieldIndex(field); if(index==-1) throw std::runtime_error("Field not found"); - if(peekAtIndex(field).getType()==STI_OBJECT) return; + if(peekAtIndex(field).getSType()==STI_OBJECT) return; mData.replace(index, new STObject(mType[index]->e_name)); clearFlag(mType[index]->e_flags); } @@ -281,7 +281,7 @@ unsigned char STObject::getValueFieldU8(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return 0; // optional field not present const STUInt8 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -292,7 +292,7 @@ uint16 STObject::getValueFieldU16(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return 0; // optional field not present const STUInt16 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -303,7 +303,7 @@ uint32 STObject::getValueFieldU32(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return 0; // optional field not present const STUInt32 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -314,7 +314,7 @@ uint64 STObject::getValueFieldU64(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return 0; // optional field not present const STUInt64 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -325,7 +325,7 @@ uint160 STObject::getValueFieldH160(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return uint160(); // optional field not present const STHash160 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -336,7 +336,7 @@ uint256 STObject::getValueFieldH256(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return uint256(); // optional field not present const STHash256 *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -347,7 +347,7 @@ std::vector STObject::getValueFieldVL(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return std::vector(); // optional field not present const STVariableLength *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -358,7 +358,7 @@ std::vector STObject::getValueFieldTL(SOE_Field field) const { const SerializedType* rf=peekAtPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) return std::vector(); // optional field not present const STTaggedList *cf=dynamic_cast(rf); if(!cf) throw std::runtime_error("Wrong field type"); @@ -369,12 +369,12 @@ void STObject::setValueFieldU8(SOE_Field field, unsigned char v) { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STUInt8* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -385,12 +385,12 @@ void STObject::setValueFieldU16(SOE_Field field, uint16 v) { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STUInt16* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -401,12 +401,12 @@ void STObject::setValueFieldU32(SOE_Field field, uint32 v) { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STUInt32* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -417,12 +417,12 @@ void STObject::setValueFieldU64(SOE_Field field, uint64 v) { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STUInt64* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -433,12 +433,12 @@ void STObject::setValueFieldH160(SOE_Field field, const uint160& v) { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STHash160* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -449,12 +449,12 @@ void STObject::setValueFieldVL(SOE_Field field, const std::vector { SerializedType* rf=getPField(field); if(!rf) throw std::runtime_error("Field not found"); - SerializedTypeID id=rf->getType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STVariableLength* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -465,12 +465,12 @@ void STObject::setValueFieldTL(SOE_Field field, const std::vectorgetType(); + SerializedTypeID id=rf->getSType(); if(id==STI_OBJECT) { makeFieldPresent(field); rf=getPField(field); - id=rf->getType(); + id=rf->getSType(); } STTaggedList* cf=dynamic_cast(rf); if(!cf) throw(std::runtime_error("Wrong field type")); @@ -483,7 +483,7 @@ Json::Value STObject::getJson(int options) const int index=1; for(boost::ptr_vector::const_iterator it=mData.begin(), end=mData.end(); it!=end; ++it, ++index) { - if(it->getType()!=STI_NOTPRESENT) + if(it->getSType()!=STI_NOTPRESENT) { if(it->getName()==NULL) ret[boost::lexical_cast(index)]=it->getText(); diff --git a/src/SerializedObject.h b/src/SerializedObject.h index 16dc182858..89273571f1 100644 --- a/src/SerializedObject.h +++ b/src/SerializedObject.h @@ -56,7 +56,7 @@ public: virtual ~STObject() { ; } int getLength() const; - SerializedTypeID getType() const { return STI_OBJECT; } + SerializedTypeID getSType() const { return STI_OBJECT; } STObject* duplicate() const { return new STObject(*this); } virtual bool isEquivalent(const SerializedType& t) const; diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index 3f64589549..5ec8ca7001 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -26,7 +26,7 @@ public: // STObject functions int getLength() const; - SerializedTypeID getType() const { return STI_TRANSACTION; } + SerializedTypeID getSType() const { return STI_TRANSACTION; } SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); } std::string getFullText() const; std::string getText() const; @@ -63,7 +63,7 @@ public: // inner transaction field functions int getITFieldIndex(SOE_Field field) const; int getITFieldCount() const; - const SerializedType& peekITField(SOE_Field field); + const SerializedType& peekITField(SOE_Field field) const; SerializedType& getITField(SOE_Field field); // inner transaction field value functions diff --git a/src/SerializedTypes.cpp b/src/SerializedTypes.cpp index a7527b332e..4e3c1f2331 100644 --- a/src/SerializedTypes.cpp +++ b/src/SerializedTypes.cpp @@ -9,7 +9,7 @@ std::string SerializedType::getFullText() const { std::string ret; - if(getType()!=STI_NOTPRESENT) + if(getSType()!=STI_NOTPRESENT) { if(name!=NULL) { diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index 3c43e1aadd..5e894e1511 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -35,7 +35,7 @@ public: const char *getName() const { return name; } virtual int getLength() const { return 0; } - virtual SerializedTypeID getType() const { return STI_NOTPRESENT; } + virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; } virtual SerializedType* duplicate() const { return new SerializedType(name); } virtual std::string getFullText() const; @@ -50,9 +50,9 @@ public: virtual bool isEquivalent(const SerializedType& t) const { return true; } bool operator==(const SerializedType& t) const - { return (getType()==t.getType()) && isEquivalent(t); } + { return (getSType()==t.getSType()) && isEquivalent(t); } bool operator!=(const SerializedType& t) const - { return (getType()!=t.getType()) || !isEquivalent(t); } + { return (getSType()!=t.getSType()) || !isEquivalent(t); } }; class STUInt8 : public SerializedType @@ -67,7 +67,7 @@ public: static STUInt8* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 1; } - SerializedTypeID getType() const { return STI_UINT8; } + SerializedTypeID getSType() const { return STI_UINT8; } STUInt8* duplicate() const { return new STUInt8(name, value); } std::string getText() const; void add(Serializer& s) const { s.add8(value); } @@ -92,7 +92,7 @@ public: static STUInt16* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 2; } - SerializedTypeID getType() const { return STI_UINT16; } + SerializedTypeID getSType() const { return STI_UINT16; } STUInt16* duplicate() const { return new STUInt16(name, value); } std::string getText() const; void add(Serializer& s) const { s.add16(value); } @@ -117,7 +117,7 @@ public: static STUInt32* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 4; } - SerializedTypeID getType() const { return STI_UINT32; } + SerializedTypeID getSType() const { return STI_UINT32; } STUInt32* duplicate() const { return new STUInt32(name, value); } std::string getText() const; void add(Serializer& s) const { s.add32(value); } @@ -142,7 +142,7 @@ public: static STUInt64* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 8; } - SerializedTypeID getType() const { return STI_UINT64; } + SerializedTypeID getSType() const { return STI_UINT64; } STUInt64* duplicate() const { return new STUInt64(name, value); } std::string getText() const; void add(Serializer& s) const { s.add64(value); } @@ -168,7 +168,7 @@ public: static STHash128* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 20; } - SerializedTypeID getType() const { return STI_HASH128; } + SerializedTypeID getSType() const { return STI_HASH128; } STHash128* duplicate() const { return new STHash128(name, value); } virtual std::string getText() const; void add(Serializer& s) const { s.add128(value); } @@ -194,7 +194,7 @@ public: static STHash160* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 20; } - SerializedTypeID getType() const { return STI_HASH160; } + SerializedTypeID getSType() const { return STI_HASH160; } STHash160* duplicate() const { return new STHash160(name, value); } virtual std::string getText() const; void add(Serializer& s) const { s.add160(value); } @@ -220,7 +220,7 @@ public: static STHash256* construct(SerializerIterator&, const char *name=NULL); int getLength() const { return 32; } - SerializedTypeID getType() const { return STI_HASH256; } + SerializedTypeID getSType() const { return STI_HASH256; } STHash256* duplicate() const { return new STHash256(name, value); } std::string getText() const; void add(Serializer& s) const { s.add256(value); } @@ -247,7 +247,7 @@ public: static STVariableLength* construct(SerializerIterator&, const char *name=NULL); int getLength() const; - virtual SerializedTypeID getType() const { return STI_VL; } + virtual SerializedTypeID getSType() const { return STI_VL; } virtual STVariableLength* duplicate() const { return new STVariableLength(name, value); } virtual std::string getText() const; void add(Serializer& s) const { s.addVL(value); } @@ -272,7 +272,7 @@ public: STAccount() { ; } static STAccount* construct(SerializerIterator&, const char *name=NULL); - SerializedTypeID getType() const { return STI_ACCOUNT; } + SerializedTypeID getSType() const { return STI_ACCOUNT; } virtual STAccount* duplicate() const { return new STAccount(name, value); } std::string getText() const; @@ -295,7 +295,7 @@ public: static STTaggedList* construct(SerializerIterator&, const char *name=NULL); int getLength() const; - SerializedTypeID getType() const { return STI_TL; } + SerializedTypeID getSType() const { return STI_TL; } STTaggedList* duplicate() const { return new STTaggedList(name, value); } std::string getText() const; void add(Serializer& s) const { if(s.addTaggedList(value)<0) throw(0); }