diff options
| author | Alan Conway <aconway@apache.org> | 2008-04-15 18:23:55 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-04-15 18:23:55 +0000 |
| commit | 04f90cff6570c8f035eaa2a86fa31ebd1caf3f0f (patch) | |
| tree | 4567305f8974177a74655738a694ff2bc167bc59 /cpp/src/qpid/amqp_0_10/Struct32.h | |
| parent | 2a0efe8231595bc6bb891b525427297ce446c20a (diff) | |
| download | qpid-python-04f90cff6570c8f035eaa2a86fa31ebd1caf3f0f.tar.gz | |
Correct Struct32 encoding: size/code/data.
Proper re-encoding for unknown struct codes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@648362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/amqp_0_10/Struct32.h')
| -rw-r--r-- | cpp/src/qpid/amqp_0_10/Struct32.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cpp/src/qpid/amqp_0_10/Struct32.h b/cpp/src/qpid/amqp_0_10/Struct32.h new file mode 100644 index 0000000000..662518efb8 --- /dev/null +++ b/cpp/src/qpid/amqp_0_10/Struct32.h @@ -0,0 +1,60 @@ +#ifndef QPID_AMQP_0_10_STRUCT32_H +#define QPID_AMQP_0_10_STRUCT32_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/amqp_0_10/StructHolder.h" + +namespace qpid { +namespace amqp_0_10 { + +class Struct32 : public StructHolder +{ + public: + Struct32() {} + + template <class T> explicit Struct32(const T& t) : StructHolder(t) {} + + template <class S> void serialize(S& s) { + s.split(*this); + StructHolder::serialize(s); + } + + template <class S> void encode(S& s) const { + s(contentSize()); + } + + template <class S> void decode(S& s) { + uint32_t contentSz; + s(contentSz); + s.setLimit(contentSz); + } + + private: + uint32_t contentSize() const { + return Codec::size(static_cast<const StructHolder&>(*this)); + } + +}; +}} // namespace qpid::amqp_0_10 + +#endif /*!QPID_AMQP_0_10_STRUCT32_H*/ |
