#ifndef _STDEX_VALUE_TRAITS_HPP_INCLUDED_ #define _STDEX_VALUE_TRAITS_HPP_INCLUDED_ /****************************************************************************** * * Copyright (c) 2019 AT&T Intellectual Property. * Copyright (c) 2018-2019 Nokia. * * Licensed 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 #include #include #include #include #include "type_defs.h" namespace stdex { namespace value { namespace mpl = boost::mpl; //NOTE! length is in bits typedef mpl::int_<8> _8; typedef mpl::int_<16> _16; typedef mpl::int_<24> _24; typedef mpl::int_<32> _32; typedef mpl::int_<40> _40; typedef mpl::int_<48> _48; typedef mpl::int_<56> _56; typedef mpl::int_<64> _64; template struct bits_to_bytes : mpl::int_< (num_bits + 7) / 8 > {}; /****************************************************************************** * Class: value::traits * Description: select min integer type to fit LEN bits * Notes: LEN is positive integer type (mpl::int_) = number of bits ******************************************************************************/ template struct traits; template struct traits >::type > { typedef _8 value_length; typedef u8 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _16 value_length; typedef u16 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _24 value_length; typedef u32 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _32 value_length; typedef u32 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _40 value_length; typedef u64 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _48 value_length; typedef u64 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _56 value_length; typedef u64 value_type; typedef value_type param_type; }; template struct traits, mpl::less_equal > >::type > { typedef _64 value_length; typedef u64 value_type; typedef value_type param_type; }; template struct traits >::type > { typedef LEN value_length; struct value_type {u8 value[bits_to_bytes::value];}; typedef value_type const& param_type; }; //template //struct traits // >::type //> //{ // typedef LEN value_length; // struct value_type {unsigned char value[LEN::value/8];}; // typedef value_type const& param_type; // //}; /****************************************************************************** * Class: value::traits_c * Description: select min integer type to fit BITS bits * Notes: N is positive integer value = number of bits ******************************************************************************/ template struct traits_c : traits > { }; } //end: namespace value } //end: namespace stdex #ifdef _MSC_VER #pragma component( mintypeinfo, off ) #endif #endif //_STDEX_VALUE_TRAITS_HPP_INCLUDED_