AvroParse.hh

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #ifndef avro_AvroParse_hh__
00020 #define avro_AvroParse_hh__
00021 
00022 #include <boost/static_assert.hpp>
00023 #include "AvroTraits.hh"
00024 #include "ResolvingReader.hh"
00025 
00029 
00030 namespace avro {
00031     
00034 
00035 template <typename Reader, typename T>
00036 void parse(Reader &p, T& val)
00037 {
00038     parse(p, val, is_serializable<T>());
00039 }
00040 
00041 template <typename T>
00042 void parse(ResolvingReader &p, T& val)
00043 {
00044     translatingParse(p, val, is_serializable<T>());
00045 }
00046 
00048 
00049 template <typename Reader, typename T>
00050 void parse(Reader &p, T& val, const boost::false_type &)
00051 {
00052     BOOST_STATIC_ASSERT(sizeof(T)==0);
00053 }
00054 
00055 template <typename Reader, typename T>
00056 void translatingParse(Reader &p, T& val, const boost::false_type &)
00057 {
00058     BOOST_STATIC_ASSERT(sizeof(T)==0);
00059 }
00060 
00061 // @{
00062 
00064 
00065 
00066 template <typename Reader, typename T>
00067 void parse(Reader &p, T &val, const boost::true_type &) {
00068     p.readValue(val);
00069 }
00070 
00071 template <typename Reader>
00072 void parse(Reader &p, std::vector<uint8_t> &val, const boost::true_type &) {
00073     p.readBytes(val);
00074 }
00075 
00076 template<typename T>
00077 void translatingParse(ResolvingReader &p, T& val, const boost::true_type &) {
00078     p.parse(val);
00079 }
00080 
00081 // @}
00082 
00083 } // namespace avro
00084 
00085 #endif