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 | a653ebe5bdfad1d44a576d2ab23f7e6ea80ba96f (patch) | |
tree | cf778054e9316b643d84c95dbe88ba72810f49cf /cpp/rubygen/framing.0-10 | |
parent | 4eb2dca5b9ae07228f542cd798b44cc44ea96c09 (diff) | |
download | qpid-python-a653ebe5bdfad1d44a576d2ab23f7e6ea80ba96f.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/qpid@702551 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen/framing.0-10')
-rw-r--r-- | cpp/rubygen/framing.0-10/structs.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/cpp/rubygen/framing.0-10/structs.rb b/cpp/rubygen/framing.0-10/structs.rb index 70b08a0da3..eb935d06b4 100644 --- a/cpp/rubygen/framing.0-10/structs.rb +++ b/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) |