diff options
| author | Alan Conway <aconway@apache.org> | 2008-10-07 17:24:24 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-10-07 17:24:24 +0000 |
| commit | 071fff099bd18bbbadbb90e344052ef877cefc32 (patch) | |
| tree | cb6c0fa042221a57c92abec8078103a0b48e281b /qpid/cpp/rubygen | |
| parent | 9d29dc4fc9aeecab7023fc09ac239e5dbfd2ea1f (diff) | |
| download | qpid-python-071fff099bd18bbbadbb90e344052ef877cefc32.tar.gz | |
Rename size() to encodedSize() for encoded types to allow std collection interfaces for types like FieldTable and Array.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702551 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/rubygen')
| -rw-r--r-- | qpid/cpp/rubygen/framing.0-10/structs.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/qpid/cpp/rubygen/framing.0-10/structs.rb b/qpid/cpp/rubygen/framing.0-10/structs.rb index 70b08a0da3..eb935d06b4 100644 --- a/qpid/cpp/rubygen/framing.0-10/structs.rb +++ b/qpid/cpp/rubygen/framing.0-10/structs.rb @@ -44,6 +44,12 @@ class StructGen < CppGen "timestamp"=>8 } + StringSizeMap={ + "LongString"=>4, + "MediumString"=>2, + "ShortString"=>1 + } + SizeType={ 1=>"Octet", 2=>"Short", @@ -171,13 +177,10 @@ class StructGen < CppGen genl "total += #{size};//#{f.cppname}" elsif (f.cpptype.name == "SequenceNumberSet") genl "total += #{f.cppname}.encodedSize();" - 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());" + elsif (size = StringSizeMap[f.cpptype.encoded]) + genl "total += #{size} + #{f.cppname}.size();" + else + genl "total += #{f.cppname}.encodedSize();" end end end @@ -442,7 +445,7 @@ EOS 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 @@ EOS return total; } -uint32_t #{classname}::size() const -{ +uint32_t #{classname}::encodedSize() const { uint32_t total = bodySize(); EOS if (s.kind_of? AmqpStruct) |
