Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid/framing/variant.h

Go to the documentation of this file.
00001 #ifndef QPID_FRAMING_VARIANT_H
00002 #define QPID_FRAMING_VARIANT_H
00003 
00004 /*
00005  * Licensed to the Apache Software Foundation (ASF) under one
00006  * or more contributor license agreements.  See the NOTICE file
00007  * distributed with this work for additional information
00008  * regarding copyright ownership.  The ASF licenses this file
00009  * to you under the Apache License, Version 2.0 (the
00010  * "License"); you may not use this file except in compliance
00011  * with the License.  You may obtain a copy of the License at
00012  *
00013  *   http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing,
00016  * software distributed under the License is distributed on an
00017  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00018  * KIND, either express or implied.  See the License for the
00019  * specific language governing permissions and limitations
00020  * under the License.
00021  *
00022  */
00023 
00027 #include <boost/variant.hpp>
00028 
00029 namespace qpid {
00030 namespace framing {
00031 class Buffer;
00032 
00037 template <class R=void>
00038 struct NoBlankVisitor : public boost::static_visitor<R> {
00039     R foundBlank() const {
00040         assert(0);
00041         throw Exception(QPID_MSG("Invalid variant value."));
00042     }
00043     R operator()(const boost::blank&) const { return foundBlank(); }
00044     R operator()(boost::blank&) const { return foundBlank(); }
00045 };
00046 
00047 
00048 }} // qpid::framing
00049 
00050 
00054 #define QPID_USING_NOBLANK(R) using ::qpid::framing::NoBlankVisitor<R>::operator()
00055 
00056 namespace qpid {
00057 namespace framing {
00058 
00060 template <class R> struct ConvertVisitor : public NoBlankVisitor<R> {
00061     QPID_USING_NOBLANK(R);
00062     template <class T> R operator()(T& t) const { return t; }
00063 };
00064 
00066 template <class R> struct AddressVisitor : public NoBlankVisitor<R> {
00067     QPID_USING_NOBLANK(R);
00068     template <class T> R operator()(T& t) const { return &t; }
00069 };
00070 
00072 template<class V>
00073 struct ApplyVisitor : public NoBlankVisitor<typename V::result_type> {
00074     QPID_USING_NOBLANK(typename V::result_type);
00075     const V& visitor;
00076     ApplyVisitor(const V& v) : visitor(v) {}
00077     template <class T> typename V::result_type operator()(T& t) const {
00078         return boost::apply_visitor(visitor, t);
00079     }
00080 };
00081 
00083 template <class Visitor, class Visitable>
00084 typename Visitor::result_type applyApplyVisitor(const Visitor& visitor, Visitable& visitable) {
00085     return boost::apply_visitor(ApplyVisitor<Visitor>(visitor), visitable);
00086 }
00087 
00088 }} // namespace qpid::framing
00089 
00090     
00091 #endif  

Qpid C++ API Reference
Generated on Tue Dec 8 15:39:48 2009 for Qpid C++ Client API by doxygen 1.4.7