As a step towards using standard STL collection interfaces for things
like framing::FieldTable and Array, and towards greater clarity in
general, I'd like to rename size() for encoded types as encodedSize().
size() is used in STL to mean the size of a container. Since some of our
encoded types are also containers (FieldTable, Array), our non-standard
use of size() and count() is confusing.

I've got it done in a working copy. Anyone have objections? 

Diff attached.


Index: src/tests/SessionState.cpp
===================================================================
--- src/tests/SessionState.cpp	(revision 702220)
+++ src/tests/SessionState.cpp	(working copy)
@@ -85,7 +85,7 @@
 }
 
 // Send frame & return size of frame.
-size_t send(qpid::SessionState& s, const AMQFrame& f) { s.senderRecord(f); return f.size(); }
+size_t send(qpid::SessionState& s, const AMQFrame& f) { s.senderRecord(f); return f.encodedSize(); }
 // Send transfer command with no content.
 size_t transfer0(qpid::SessionState& s) { return send(s, transferFrame(false)); }
 // Send transfer frame with single content frame.
@@ -116,8 +116,8 @@
                            bind(transfer1Char, ref(s), _1));
 }
 
-size_t contentFrameSize(size_t n=1) { return AMQFrame(in_place<AMQContentBody>()).size() + n; }
-size_t transferFrameSize() { return AMQFrame(in_place<MessageTransferBody>()).size(); }
+size_t contentFrameSize(size_t n=1) { return AMQFrame(in_place<AMQContentBody>()).encodedSize() + n; }
+size_t transferFrameSize() { return AMQFrame(in_place<MessageTransferBody>()).encodedSize(); }
 
 // ==== qpid::SessionState test classes
 
Index: src/tests/FieldTable.cpp
===================================================================
--- src/tests/FieldTable.cpp	(revision 702220)
+++ src/tests/FieldTable.cpp	(working copy)
@@ -69,11 +69,11 @@
         FieldTable c;
         c = a;
         
-        char* buff = static_cast<char*>(::alloca(c.size()));
-        Buffer wbuffer(buff, c.size());
+        char* buff = static_cast<char*>(::alloca(c.encodedSize()));
+        Buffer wbuffer(buff, c.encodedSize());
         wbuffer.put(c);
 
-        Buffer rbuffer(buff, c.size());
+        Buffer rbuffer(buff, c.encodedSize());
         rbuffer.get(d);
         BOOST_CHECK_EQUAL(c, d);
         BOOST_CHECK(string("CCCC") == c.getString("A"));
Index: src/tests/HeaderTest.cpp
===================================================================
--- src/tests/HeaderTest.cpp	(revision 702220)
+++ src/tests/HeaderTest.cpp	(working copy)
@@ -39,7 +39,7 @@
 
     Buffer rbuffer(buff, 100);
     AMQHeaderBody body2;
-    body2.decode(rbuffer, body.size());
+    body2.decode(rbuffer, body.encodedSize());
     MessageProperties* props =
         body2.get<MessageProperties>(true);
     BOOST_CHECK_EQUAL(
Index: src/tests/Frame.cpp
===================================================================
--- src/tests/Frame.cpp	(revision 702220)
+++ src/tests/Frame.cpp	(working copy)
@@ -33,7 +33,7 @@
     Frame f(42, AMQContentBody("foobar"));
     AMQBody* body=f.getBody();
     BOOST_CHECK(dynamic_cast<AMQContentBody*>(body));
-    Buffer b(f.size());
+    Buffer b(f.encodedSize();
     f.encode(b);
     b.flip();
     Frame g;
@@ -50,7 +50,7 @@
         42, QueueDeclareBody(ProtocolVersion(), 1, "q", "altex",
                              true, false, true, false, true, args));
     BOOST_CHECK_EQUAL(f.getChannel(), 42);
-    Buffer b(f.size());
+    Buffer b(f.encodedSize();
     f.encode(b);
     b.flip();
     Frame g;
Index: src/qpid/cluster/OutputInterceptor.cpp
===================================================================
--- src/qpid/cluster/OutputInterceptor.cpp	(revision 702220)
+++ src/qpid/cluster/OutputInterceptor.cpp	(working copy)
@@ -40,7 +40,7 @@
     Locker l(lock); 
     next->send(f);
     if (!parent.isCatchUp())
-        sent += f.size();
+        sent += f.encodedSize();
 }
 
 void OutputInterceptor::activateOutput() {
Index: src/qpid/cluster/Event.cpp
===================================================================
--- src/qpid/cluster/Event.cpp	(revision 702220)
+++ src/qpid/cluster/Event.cpp	(working copy)
@@ -50,7 +50,7 @@
 
 Event Event::control(const framing::AMQBody& body, const ConnectionId& cid, uint32_t id) {
     framing::AMQFrame f(body);
-    Event e(CONTROL, cid, f.size(), id);
+    Event e(CONTROL, cid, f.encodedSize(), id);
     Buffer buf(e);
     f.encode(buf);
     return e;
Index: src/qpid/framing/AMQFrame.h
===================================================================
--- src/qpid/framing/AMQFrame.h	(revision 702220)
+++ src/qpid/framing/AMQFrame.h	(working copy)
@@ -78,7 +78,7 @@
 
     void encode(Buffer& buffer) const; 
     bool decode(Buffer& buffer); 
-    uint32_t size() const;
+    uint32_t encodedSize() const;
 
     // 0-10 terminology: first/last frame (in segment) first/last segment (in assembly)
 
Index: src/qpid/framing/FieldValue.h
===================================================================
--- src/qpid/framing/FieldValue.h	(revision 702220)
+++ src/qpid/framing/FieldValue.h	(working copy)
@@ -65,7 +65,7 @@
     class Data {
       public:
         virtual ~Data() {};
-        virtual uint32_t size() const = 0;        
+        virtual uint32_t encodedSize() const = 0;        
         virtual void encode(Buffer& buffer) = 0;
         virtual void decode(Buffer& buffer) = 0;
         virtual bool operator==(const Data&) const = 0;
@@ -83,7 +83,7 @@
     void setType(uint8_t type);
     uint8_t getType();
     Data& getData() { return *data; }
-    uint32_t size() const { return 1 + data->size(); };
+    uint32_t encodedSize() const { return 1 + data->encodedSize(); };
     bool empty() const { return data.get() == 0; } 
     void encode(Buffer& buffer);
     void decode(Buffer& buffer);
@@ -137,7 +137,7 @@
         }
         octets[0] = (uint8_t) (0xFF & v);
     }
-    uint32_t size() const { return width; }
+    uint32_t encodedSize() const { return width; }
     void encode(Buffer& buffer) { buffer.putRawData(octets, width); }
     void decode(Buffer& buffer) { buffer.getRawData(octets, width); }
     bool operator==(const Data& d) const {
@@ -168,7 +168,7 @@
 class FixedWidthValue<0> : public FieldValue::Data {
   public:
     // Implicit default constructor is fine
-    uint32_t size() const { return 0; }
+    uint32_t encodedSize() const { return 0; }
     void encode(Buffer&) {};
     void decode(Buffer&) {};
     bool operator==(const Data& d) const {
@@ -186,7 +186,7 @@
     VariableWidthValue() {}
     VariableWidthValue(const std::vector<uint8_t>& data) : octets(data) {}
     VariableWidthValue(const uint8_t* start, const uint8_t* end) : octets(start, end) {}
-    uint32_t size() const { return lenwidth + octets.size(); } 
+    uint32_t encodedSize() const { return lenwidth + octets.size(); } 
     void encode(Buffer& buffer) {
         buffer.putUInt<lenwidth>(octets.size());
         buffer.putRawData(&octets[0], octets.size());
@@ -219,7 +219,7 @@
     T& getValue() { return value; }
     const T& getValue() const { return value; }
 
-    uint32_t size() const { return value.size(); } 
+    uint32_t encodedSize() const { return value.encodedSize(); } 
 
     void encode(Buffer& buffer) {
         value.encode(buffer);
Index: src/qpid/framing/AMQFrame.cpp
===================================================================
--- src/qpid/framing/AMQFrame.cpp	(revision 702220)
+++ src/qpid/framing/AMQFrame.cpp	(working copy)
@@ -37,8 +37,8 @@
 
 void AMQFrame::setMethod(ClassId c, MethodId m) { body = new BodyHolder(c,m); }
 
-uint32_t AMQFrame::size() const {
-    return frameOverhead() + body->size();
+uint32_t AMQFrame::encodedSize() const {
+    return frameOverhead() + body->encodedSize();
 }
 
 uint32_t AMQFrame::frameOverhead() {
@@ -60,7 +60,7 @@
     uint8_t flags = (bof ? 0x08 : 0) | (eof ? 0x04 : 0) | (bos ? 0x02 : 0) | (eos ? 0x01 : 0);
     buffer.putOctet(flags);
     buffer.putOctet(getBody()->type());
-    buffer.putShort(size());
+    buffer.putShort(encodedSize());
     buffer.putOctet(0);
     buffer.putOctet(0x0f & track);
     buffer.putShort(channel);    
Index: src/qpid/framing/ProtocolInitiation.h
===================================================================
--- src/qpid/framing/ProtocolInitiation.h	(revision 702220)
+++ src/qpid/framing/ProtocolInitiation.h	(working copy)
@@ -41,7 +41,7 @@
     virtual ~ProtocolInitiation();
     virtual void encode(Buffer& buffer) const; 
     virtual bool decode(Buffer& buffer); 
-    inline virtual uint32_t size() const { return 8; }
+    inline virtual uint32_t encodedSize() const { return 8; }
     inline uint8_t getMajor() const { return version.getMajor(); }
     inline uint8_t getMinor() const { return version.getMinor(); }
     inline ProtocolVersion getVersion() const { return version; }
Index: src/qpid/framing/FieldTable.h
===================================================================
--- src/qpid/framing/FieldTable.h	(revision 702220)
+++ src/qpid/framing/FieldTable.h	(working copy)
@@ -52,7 +52,7 @@
     typedef ValueMap::iterator iterator;
 
     ~FieldTable();
-    uint32_t size() const;
+    uint32_t encodedSize() const;
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer);
 
Index: src/qpid/framing/ModelMethod.h
===================================================================
--- src/qpid/framing/ModelMethod.h	(revision 702220)
+++ src/qpid/framing/ModelMethod.h	(working copy)
@@ -35,7 +35,7 @@
     virtual ~ModelMethod() {}
     virtual void encodeHeader(Buffer& buffer) const { header.encode(buffer); }
     virtual void decodeHeader(Buffer& buffer, uint32_t size=0) { header.decode(buffer, size); }
-    virtual uint32_t headerSize() const { return header.size(); } 
+    virtual uint32_t headerSize() const { return header.encodedSize(); } 
     virtual bool isSync() const { return header.getSync(); }
     virtual void setSync(bool on) const { header.setSync(on); }
     Header& getHeader() { return header; } 
Index: src/qpid/framing/HeaderProperties.h
===================================================================
--- src/qpid/framing/HeaderProperties.h	(revision 702220)
+++ src/qpid/framing/HeaderProperties.h	(working copy)
@@ -33,7 +33,7 @@
     public:
 	inline virtual ~HeaderProperties(){}
 	virtual uint8_t classId() const = 0;
-	virtual uint32_t size() const = 0;
+	virtual uint32_t encodedSize() const = 0;
 	virtual void encode(Buffer& buffer) const = 0;
 	virtual void decode(Buffer& buffer, uint32_t size) = 0;
     };
Index: src/qpid/framing/AMQHeaderBody.h
===================================================================
--- src/qpid/framing/AMQHeaderBody.h	(revision 702220)
+++ src/qpid/framing/AMQHeaderBody.h	(working copy)
@@ -41,9 +41,9 @@
     template <class T> struct OptProps { boost::optional<T> props; };
     template <class Base, class T>
     struct PropSet : public Base, public OptProps<T> {
-        uint32_t size() const {
+        uint32_t encodedSize() const {
             const boost::optional<T>& p=this->OptProps<T>::props;
-            return (p ? p->size() : 0) + Base::size();
+            return (p ? p->encodedSize() : 0) + Base::encodedSize();
         }
         void encode(Buffer& buffer) const {
             const boost::optional<T>& p=this->OptProps<T>::props;
@@ -68,7 +68,7 @@
     };
 
     struct Empty {
-        uint32_t size() const { return 0; }
+        uint32_t encodedSize() const { return 0; }
         void encode(Buffer&) const {};
         bool decode(Buffer&, uint32_t, uint16_t) const { return false; };
         void print(std::ostream&) const {}
@@ -83,7 +83,7 @@
 
     inline uint8_t type() const { return HEADER_BODY; }
 
-    uint32_t size() const;
+    uint32_t encodedSize() const;
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer, uint32_t size);
     uint64_t getContentLength() const;
Index: src/qpid/framing/SequenceNumber.h
===================================================================
--- src/qpid/framing/SequenceNumber.h	(revision 702220)
+++ src/qpid/framing/SequenceNumber.h	(working copy)
@@ -56,7 +56,7 @@
 
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer);
-    uint32_t size() const;   
+    uint32_t encodedSize() const;   
 
     template <class S> void serialize(S& s) { s(value); }
 };    
Index: src/qpid/framing/FieldTable.cpp
===================================================================
--- src/qpid/framing/FieldTable.cpp	(revision 702220)
+++ src/qpid/framing/FieldTable.cpp	(working copy)
@@ -31,11 +31,11 @@
 
 FieldTable::~FieldTable() {}
 
-uint32_t FieldTable::size() const {
+uint32_t FieldTable::encodedSize() const {
     uint32_t len(4/*size field*/ + 4/*count field*/);
     for(ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) {
         // shortstr_len_byte + key size + value size
-	len += 1 + (i->first).size() + (i->second)->size();
+	len += 1 + (i->first).size() + (i->second)->encodedSize();
     }
     return len;
 }
@@ -161,7 +161,7 @@
 }
 
 void FieldTable::encode(Buffer& buffer) const{    
-    buffer.putLong(size() - 4);
+    buffer.putLong(encodedSize() - 4);
     buffer.putLong(values.size());
     for (ValueMap::const_iterator i = values.begin(); i!=values.end(); ++i) {
         buffer.putShortString(i->first);
Index: src/qpid/framing/AMQContentBody.h
===================================================================
--- src/qpid/framing/AMQContentBody.h	(revision 702220)
+++ src/qpid/framing/AMQContentBody.h	(working copy)
@@ -39,7 +39,7 @@
     inline uint8_t type() const { return CONTENT_BODY; };
     inline const string& getData() const { return data; }
     inline string& getData() { return data; }
-    uint32_t size() const;
+    uint32_t encodedSize() const;
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer, uint32_t size);
     void print(std::ostream& out) const;
Index: src/qpid/framing/AMQMethodBody.h
===================================================================
--- src/qpid/framing/AMQMethodBody.h	(revision 702220)
+++ src/qpid/framing/AMQMethodBody.h	(working copy)
@@ -54,7 +54,7 @@
         return amqpClassId()==T::CLASS_ID && amqpMethodId()==T::METHOD_ID;
     }
 
-    virtual uint32_t size() const = 0;
+    virtual uint32_t encodedSize() const = 0;
     virtual uint8_t type() const { return METHOD_BODY; }
 
     virtual bool isSync() const { return false; /*only ModelMethods can have the sync flag set*/ }
Index: src/qpid/framing/AMQHeaderBody.cpp
===================================================================
--- src/qpid/framing/AMQHeaderBody.cpp	(revision 702220)
+++ src/qpid/framing/AMQHeaderBody.cpp	(working copy)
@@ -22,8 +22,8 @@
 #include "qpid/Exception.h"
 #include "qpid/log/Statement.h"
 
-uint32_t qpid::framing::AMQHeaderBody::size() const {
-    return properties.size();
+uint32_t qpid::framing::AMQHeaderBody::encodedSize() const {
+    return properties.encodedSize();
 }
 
 void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const {
@@ -52,7 +52,7 @@
 
 void qpid::framing::AMQHeaderBody::print(std::ostream& out) const
 {
-    out << "header (" << size() << " bytes)";
+    out << "header (" << encodedSize() << " bytes)";
     out << "; properties={";
     properties.print(out);
     out << "}";
Index: src/qpid/framing/Array.cpp
===================================================================
--- src/qpid/framing/Array.cpp	(revision 702220)
+++ src/qpid/framing/Array.cpp	(working copy)
@@ -42,11 +42,11 @@
 } 
 
 
-uint32_t Array::size() const {
+uint32_t Array::encodedSize() const {
     //note: size is only included when used as a 'top level' type
     uint32_t len(4/*size*/ + 1/*type*/ + 4/*count*/);
     for(ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) {
-	len += (*i)->getData().size();
+	len += (*i)->getData().encodedSize();
     }
     return len;
 }
@@ -65,7 +65,7 @@
 }
 
 void Array::encode(Buffer& buffer) const{
-    buffer.putLong(size() - 4);//size added only when array is a top-level type
+    buffer.putLong(encodedSize() - 4);//size added only when array is a top-level type
     buffer.putOctet(typeOctet);
     buffer.putLong(count());
     for (ValueVector::const_iterator i = values.begin(); i!=values.end(); ++i) {
@@ -87,9 +87,9 @@
         FieldValue dummy;
         dummy.setType(typeOctet);
         available = buffer.available();
-        if (available < count * dummy.getData().size()) {
+        if (available < count * dummy.getData().encodedSize()) {
             throw IllegalArgumentException(QPID_MSG("Not enough data for array, expected " 
-                                                << count << " items of " << dummy.getData().size()
+                                                << count << " items of " << dummy.getData().encodedSize()
                                                 << " bytes each  but only " << available << " bytes available"));
         }
         
Index: src/qpid/framing/AMQHeartbeatBody.h
===================================================================
--- src/qpid/framing/AMQHeartbeatBody.h	(revision 702220)
+++ src/qpid/framing/AMQHeartbeatBody.h	(working copy)
@@ -32,7 +32,7 @@
 {
 public:
     virtual ~AMQHeartbeatBody();
-    inline uint32_t size() const { return 0; }
+    inline uint32_t encodedSize() const { return 0; }
     inline uint8_t type() const { return HEARTBEAT_BODY; }
     inline void encode(Buffer& ) const {}
     inline void decode(Buffer& , uint32_t /*size*/) {}
Index: src/qpid/framing/SequenceNumber.cpp
===================================================================
--- src/qpid/framing/SequenceNumber.cpp	(revision 702220)
+++ src/qpid/framing/SequenceNumber.cpp	(working copy)
@@ -90,7 +90,7 @@
     value = buffer.getLong();
 }
 
-uint32_t SequenceNumber::size() const {
+uint32_t SequenceNumber::encodedSize() const {
     return 4;
 }
 
Index: src/qpid/framing/SendContent.cpp
===================================================================
--- src/qpid/framing/SendContent.cpp	(revision 702220)
+++ src/qpid/framing/SendContent.cpp	(working copy)
@@ -34,13 +34,13 @@
        real frame size, hence substract -1 from frameOverhead()*/
     uint16_t maxContentSize = maxFrameSize - (AMQFrame::frameOverhead() - 1);
     const AMQContentBody* body(f.castBody<AMQContentBody>()); 
-    if (body->size() > maxContentSize) {
+    if (body->encodedSize() > maxContentSize) {
         uint32_t offset = 0;
-        for (int chunk = body->size() / maxContentSize; chunk > 0; chunk--) {
-            sendFragment(*body, offset, maxContentSize, first && offset == 0, last && offset + maxContentSize == body->size());
+        for (int chunk = body->encodedSize() / maxContentSize; chunk > 0; chunk--) {
+            sendFragment(*body, offset, maxContentSize, first && offset == 0, last && offset + maxContentSize == body->encodedSize());
             offset += maxContentSize;
         }
-        uint32_t remainder = body->size() % maxContentSize;
+        uint32_t remainder = body->encodedSize() % maxContentSize;
         if (remainder) {
             sendFragment(*body, offset, remainder, first && offset == 0, last);
         }
Index: src/qpid/framing/SequenceSet.cpp
===================================================================
--- src/qpid/framing/SequenceSet.cpp	(revision 702220)
+++ src/qpid/framing/SequenceSet.cpp	(working copy)
@@ -56,7 +56,7 @@
     }
 }
 
-uint32_t SequenceSet::size() const {
+uint32_t SequenceSet::encodedSize() const {
     return 2 /*size field*/ + (rangesSize() * RANGE_SIZE);
 }
 
Index: src/qpid/framing/AMQContentBody.cpp
===================================================================
--- src/qpid/framing/AMQContentBody.cpp	(revision 702220)
+++ src/qpid/framing/AMQContentBody.cpp	(working copy)
@@ -27,7 +27,7 @@
 qpid::framing::AMQContentBody::AMQContentBody(const string& _data) : data(_data){
 }
 
-uint32_t qpid::framing::AMQContentBody::size() const{
+uint32_t qpid::framing::AMQContentBody::encodedSize() const{
     return data.size();
 }
 void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{
@@ -39,6 +39,6 @@
 
 void qpid::framing::AMQContentBody::print(std::ostream& out) const
 {
-    out << "content (" << size() << " bytes)";
+    out << "content (" << encodedSize() << " bytes)";
     out << " " << data.substr(0,16) << "...";
 }
Index: src/qpid/framing/BodyHolder.h
===================================================================
--- src/qpid/framing/BodyHolder.h	(revision 702220)
+++ src/qpid/framing/BodyHolder.h	(working copy)
@@ -69,7 +69,7 @@
 
     void encode(Buffer&) const;
     void decode(uint8_t frameType, Buffer&, uint32_t=0);
-    uint32_t size() const;
+    uint32_t encodedSize() const;
 
     /** Return body pointer or 0 if empty. */
     AMQBody* get() { return blob.get(); }
Index: src/qpid/framing/AMQBody.h
===================================================================
--- src/qpid/framing/AMQBody.h	(revision 702220)
+++ src/qpid/framing/AMQBody.h	(working copy)
@@ -52,7 +52,7 @@
 
     virtual void encode(Buffer& buffer) const = 0;
     virtual void decode(Buffer& buffer, uint32_t=0) = 0;
-    virtual uint32_t size() const = 0;
+    virtual uint32_t encodedSize() const = 0;
 
     virtual void print(std::ostream& out) const = 0;
     virtual void accept(AMQBodyConstVisitor&) const = 0;
Index: src/qpid/framing/AMQCommandControlBody.h
===================================================================
--- src/qpid/framing/AMQCommandControlBody.h	(revision 702220)
+++ src/qpid/framing/AMQCommandControlBody.h	(working copy)
@@ -43,7 +43,7 @@
     virtual void decode(Buffer& buffer, uint32_t=0) {
         Codec::decode(buffer.getIterator(), static_cast<T&>(*this));
     }
-    virtual uint32_t size() const {
+    virtual uint32_t encodedSize() const {
         Codec::size(buffer.getIterator(), static_cast<const T&>(*this));
     }
 
Index: src/qpid/framing/Uuid.h
===================================================================
--- src/qpid/framing/Uuid.h	(revision 702220)
+++ src/qpid/framing/Uuid.h	(working copy)
@@ -64,8 +64,8 @@
     // boost::array gives us ==, < etc.
 
     void encode(framing::Buffer& buf) const;
-    
     void decode(framing::Buffer& buf);
+    uint32_t encodedSize() const { return size(); }
 
     /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
     std::string str();
Index: src/qpid/framing/frame_functors.h
===================================================================
--- src/qpid/framing/frame_functors.h	(revision 702220)
+++ src/qpid/framing/frame_functors.h	(working copy)
@@ -36,7 +36,7 @@
     uint64_t size;
 public:
     SumFrameSize() : size(0) {}
-    void operator()(const AMQFrame& f) { size += f.size(); }
+    void operator()(const AMQFrame& f) { size += f.encodedSize(); }
     uint64_t getSize() { return size; }
 };
 
@@ -45,7 +45,7 @@
     uint64_t size;
 public:
     SumBodySize() : size(0) {}
-    void operator()(const AMQFrame& f) { size += f.getBody()->size(); }
+    void operator()(const AMQFrame& f) { size += f.getBody()->encodedSize(); }
     uint64_t getSize() { return size; }
 };
 
Index: src/qpid/framing/Array.h
===================================================================
--- src/qpid/framing/Array.h	(revision 702220)
+++ src/qpid/framing/Array.h	(working copy)
@@ -39,7 +39,7 @@
     typedef boost::shared_ptr<FieldValue> ValuePtr;
     typedef std::vector<ValuePtr> ValueVector;
 
-    uint32_t size() const;
+    uint32_t encodedSize() const;
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer);
 
Index: src/qpid/framing/AMQDataBlock.h
===================================================================
--- src/qpid/framing/AMQDataBlock.h	(revision 702220)
+++ src/qpid/framing/AMQDataBlock.h	(working copy)
@@ -32,7 +32,7 @@
     virtual ~AMQDataBlock() {}
     virtual void encode(Buffer& buffer) const = 0; 
     virtual bool decode(Buffer& buffer) = 0; 
-    virtual uint32_t size() const = 0;
+    virtual uint32_t encodedSize() const = 0;
 };
 
 }
Index: src/qpid/framing/SequenceSet.h
===================================================================
--- src/qpid/framing/SequenceSet.h	(revision 702220)
+++ src/qpid/framing/SequenceSet.h	(working copy)
@@ -39,7 +39,7 @@
     
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer);
-    uint32_t size() const;   
+    uint32_t encodedSize() const;   
 
     bool contains(const SequenceNumber& s) const;
     void add(const SequenceNumber& s);
Index: src/qpid/framing/BodyHolder.cpp
===================================================================
--- src/qpid/framing/BodyHolder.cpp	(revision 702220)
+++ src/qpid/framing/BodyHolder.cpp	(working copy)
@@ -64,12 +64,12 @@
     get()->decode(buffer, size);
 }
 
-uint32_t BodyHolder::size() const {
+uint32_t BodyHolder::encodedSize() const {
     const AMQMethodBody* method=getMethod();
     if (method) 
-        return sizeof(ClassId)+sizeof(MethodId)+method->size();
+        return sizeof(ClassId)+sizeof(MethodId)+method->encodedSize();
     else
-        return get()->size();
+        return get()->encodedSize();
 }
 
 }} // namespace qpid::framing
Index: src/qpid/broker/Exchange.cpp
===================================================================
--- src/qpid/broker/Exchange.cpp	(revision 702220)
+++ src/qpid/broker/Exchange.cpp	(working copy)
@@ -111,7 +111,7 @@
     return name.size() + 1/*short string size*/
         + 1 /*durable*/
         + getType().size() + 1/*short string size*/
-        + args.size(); 
+        + args.encodedSize(); 
 }
 
 ManagementObject* Exchange::GetManagementObject (void) const
Index: src/qpid/broker/Queue.cpp
===================================================================
--- src/qpid/broker/Queue.cpp	(revision 702220)
+++ src/qpid/broker/Queue.cpp	(working copy)
@@ -648,7 +648,7 @@
 
 uint32_t Queue::encodedSize() const
 {
-    return name.size() + 1/*short string size octet*/ + settings.size();
+    return name.size() + 1/*short string size octet*/ + settings.encodedSize();
 }
 
 Queue::shared_ptr Queue::decode(QueueRegistry& queues, framing::Buffer& buffer)
Index: src/qpid/broker/Connection.cpp
===================================================================
--- src/qpid/broker/Connection.cpp	(revision 702220)
+++ src/qpid/broker/Connection.cpp	(working copy)
@@ -107,7 +107,7 @@
     if (mgmtObject != 0)
     {
         mgmtObject->inc_framesToClient();
-        mgmtObject->inc_bytesToClient(frame.size());
+        mgmtObject->inc_bytesToClient(frame.encodedSize());
     }
 }
 
@@ -116,7 +116,7 @@
     if (mgmtObject != 0)
     {
         mgmtObject->inc_framesFromClient();
-        mgmtObject->inc_bytesFromClient(frame.size());
+        mgmtObject->inc_bytesFromClient(frame.encodedSize());
     }
 }
 
Index: src/qpid/SessionState.cpp
===================================================================
--- src/qpid/SessionState.cpp	(revision 702220)
+++ src/qpid/SessionState.cpp	(working copy)
@@ -61,7 +61,7 @@
         if (f.isLastSegment() && f.isLastFrame()) 
             ++command;          // Single-frame command.
         else
-            offset += f.size();
+            offset += f.encodedSize();
     }
     else {                      // continuation frame for partial command
         if (offset == 0)
@@ -77,7 +77,7 @@
             // that the relationship of fragment offsets to the replay
             // list can be computed more easily.
             // 
-            offset += f.size();
+            offset += f.encodedSize();
         }
     }
 }
@@ -116,9 +116,9 @@
     QPID_LOG_IF(debug, f.getMethod(), getId() << ": sent cmd " << sender.sendPoint.command << ": " << *f.getMethod());
     stateful = true;
     if (timeout) sender.replayList.push_back(f);
-    sender.unflushedSize += f.size();
-    sender.bytesSinceKnownCompleted += f.size();
-    sender.replaySize += f.size();
+    sender.unflushedSize += f.encodedSize();
+    sender.bytesSinceKnownCompleted += f.encodedSize();
+    sender.replaySize += f.encodedSize();
     sender.incomplete += sender.sendPoint.command;
     sender.sendPoint.advance(f);
     if (config.replayHardLimit && config.replayHardLimit < sender.replaySize) 
@@ -153,9 +153,9 @@
     while (i != sender.replayList.end() && sender.replayPoint.command < confirmed.command) {
         sender.replayPoint.advance(*i);
         assert(sender.replayPoint <= sender.sendPoint);
-        sender.replaySize -= i->size();
+        sender.replaySize -= i->encodedSize();
         if (sender.replayPoint > sender.flushPoint) 
-            sender.unflushedSize -= i->size();
+            sender.unflushedSize -= i->encodedSize();
         ++i;
     }
     if (sender.replayPoint > sender.flushPoint)
@@ -186,7 +186,7 @@
     if (isControl(f)) return true; // Ignore control frames.
     stateful = true;
     receiver.expected.advance(f);
-    receiver.bytesSinceKnownCompleted += f.size();
+    receiver.bytesSinceKnownCompleted += f.encodedSize();
     bool firstTime = receiver.expected > receiver.received;
     if (firstTime) {
         receiver.received = receiver.expected;
Index: src/qpid/amqp_0_10/Connection.cpp
===================================================================
--- src/qpid/amqp_0_10/Connection.cpp	(revision 702220)
+++ src/qpid/amqp_0_10/Connection.cpp	(working copy)
@@ -78,15 +78,15 @@
         QPID_LOG(trace, "SENT " << identifier << " INIT(" << pi << ")");
     }
     size_t frameSize=0;
-    while (!frameQueue.empty() && ((frameSize=frameQueue.front().size()) <= out.available())) {
+    while (!frameQueue.empty() && ((frameSize=frameQueue.front().encodedSize()) <= out.available())) {
         frameQueue.front().encode(out);
         QPID_LOG(trace, "SENT [" << identifier << "]: " << frameQueue.front());
         frameQueue.pop_front();
         buffered -= frameSize;
         if (frameQueue.empty() && out.available() > 0) connection->doOutput(); 
     }
-    assert(frameQueue.empty() || frameQueue.front().size() <= size);
-    if (!frameQueue.empty() && frameQueue.front().size() > size)
+    assert(frameQueue.empty() || frameQueue.front().encodedSize() <= size);
+    if (!frameQueue.empty() && frameQueue.front().encodedSize() > size)
         throw InternalErrorException(QPID_MSG("Could not write frame, too large for buffer."));
     return out.getPosition();
 }
@@ -108,7 +108,7 @@
         Mutex::ScopedLock l(frameQueueLock);
 	if (!frameQueueClosed)
             frameQueue.push_back(f);
-        buffered += f.size();
+        buffered += f.encodedSize();
     }
     activateOutput();
 }
Index: src/qpid/client/RdmaConnector.cpp
===================================================================
--- src/qpid/client/RdmaConnector.cpp	(revision 702220)
+++ src/qpid/client/RdmaConnector.cpp	(working copy)
@@ -349,7 +349,7 @@
     size_t bytesWritten = 0;
     while (aio->writable() && aio->bufferAvailable() && !frames.empty()) {
         const AMQFrame* frame = &frames.front();        
-        uint32_t size = frame->size();
+        uint32_t size = frame->encodedSize();
         while (size <= encode.available()) {
             frame->encode(encode);
             frames.pop_front();
@@ -358,7 +358,7 @@
             if (frames.empty())
                 break;
             frame = &frames.front();        
-            size = frame->size();
+            size = frame->encodedSize();
         }
         lastEof -= framesEncoded;
         writeOne();
@@ -392,7 +392,7 @@
     Rdma::Buffer* buff = aio->getBuffer();
     framing::Buffer out(buff->bytes, buff->byteCount);
     data.encode(out);
-    buff->dataCount = data.size();
+    buff->dataCount = data.encodedSize();
     aio->queueWrite(buff);
 }
 
Index: src/qpid/client/SessionImpl.cpp
===================================================================
--- src/qpid/client/SessionImpl.cpp	(revision 702220)
+++ src/qpid/client/SessionImpl.cpp	(working copy)
@@ -427,13 +427,13 @@
 
 void SessionImpl::handleOut(AMQFrame& frame) // user thread
 {
-    connection->expand(frame.size(), true);
+    connection->expand(frame.encodedSize(), true);
     channel.handle(frame);
 }
 
 void SessionImpl::proxyOut(AMQFrame& frame) // network thread
 {
-    connection->expand(frame.size(), false);
+    connection->expand(frame.encodedSize(), false);
     channel.handle(frame);
 }
 
@@ -523,7 +523,7 @@
 
 void SessionImpl::expected(const framing::SequenceSet& commands, const framing::Array& fragments)
 {
-    if (!commands.empty() || fragments.size()) {
+    if (!commands.empty() || fragments.encodedSize()) {
         throw NotImplementedException("Session resumption not yet supported");
     }
 }
Index: src/qpid/client/Connector.cpp
===================================================================
--- src/qpid/client/Connector.cpp	(revision 702220)
+++ src/qpid/client/Connector.cpp	(working copy)
@@ -318,7 +318,7 @@
     size_t bytesWritten(0);
     for (size_t i = 0; i < lastEof; ++i) {
         AMQFrame& frame = frames[i];
-        uint32_t size = frame.size();
+        uint32_t size = frame.encodedSize();
         if (size > encode.available()) writeOne();
         assert(size <= encode.available());
         frame.encode(encode);
@@ -368,7 +368,7 @@
     AsynchIO::BufferBase* buff = new Buff(maxFrameSize);
     framing::Buffer out(buff->bytes, buff->byteCount);
     data.encode(out);
-    buff->dataCount = data.size();
+    buff->dataCount = data.encodedSize();
     aio->queueWrite(buff);
 }
 
Index: src/qpid/sys/AsynchIOHandler.cpp
===================================================================
--- src/qpid/sys/AsynchIOHandler.cpp	(revision 702220)
+++ src/qpid/sys/AsynchIOHandler.cpp	(working copy)
@@ -70,7 +70,7 @@
         buff = new Buff;
     framing::Buffer out(buff->bytes, buff->byteCount);
     data.encode(out);
-    buff->dataCount = data.size();
+    buff->dataCount = data.encodedSize();
     aio->queueWrite(buff);
 }
 
Index: src/qpid/sys/RdmaIOPlugin.cpp
===================================================================
--- src/qpid/sys/RdmaIOPlugin.cpp	(revision 702220)
+++ src/qpid/sys/RdmaIOPlugin.cpp	(working copy)
@@ -100,7 +100,7 @@
     Rdma::Buffer* buff = aio->getBuffer();
     framing::Buffer out(buff->bytes, buff->byteCount);
     data.encode(out);
-    buff->dataCount = data.size();
+    buff->dataCount = data.encodedSize();
     aio->queueWrite(buff);
 }
 
Index: rubygen/framing.0-10/structs.rb
===================================================================
--- rubygen/framing.0-10/structs.rb	(revision 702220)
+++ rubygen/framing.0-10/structs.rb	(working copy)
@@ -44,6 +44,12 @@
     "timestamp"=>8
   }
 
+  StringSizeMap={
+    "LongString"=>4,
+    "MediumString"=>2,
+    "ShortString"=>1
+  }
+  
   SizeType={
     1=>"Octet",
     2=>"Short",
@@ -171,13 +177,10 @@
         genl "total += #{size};//#{f.cppname}"
       elsif (f.cpptype.name == "SequenceNumberSet")
         genl "total += #{f.cppname}.encodedSize();"
+      elsif (size = StringSizeMap[f.cpptype.encoded])
+        genl "total += #{size} + #{f.cppname}.size();"
       else 
-        encoded = f.cpptype.encoded
-        gen "total += ("
-        gen "4 + " if encoded == "LongString"
-        gen "2 + " if encoded == "MediumString"
-        gen "1 + " if encoded == "ShortString"
-        genl "#{f.cppname}.size());"
+        genl "total += #{f.cppname}.encodedSize();"
       end
     end
   end
@@ -442,7 +445,7 @@
     void decode(Buffer&, uint32_t=0);
     void encodeStructBody(Buffer&) const;
     void decodeStructBody(Buffer&, uint32_t=0);
-    uint32_t size() const;
+    uint32_t encodedSize() const;
     uint32_t bodySize() const;
     void print(std::ostream& out) const;
 }; /* class #{classname} */
@@ -546,8 +549,7 @@
     return total;
 }
 
-uint32_t #{classname}::size() const
-{
+uint32_t #{classname}::encodedSize() const {
     uint32_t total = bodySize();
 EOS
         if (s.kind_of? AmqpStruct)

Reply via email to