X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2Fe2apv1sim%2Fricsim%2Fsrc%2FASN1%2Fasn%2Fvalue_traits.hpp;fp=e2sim%2Fe2apv1sim%2Fricsim%2Fsrc%2FASN1%2Fasn%2Fvalue_traits.hpp;h=4b67374f78492703ee9a0a1a73a2c4955bcd1e2d;hp=0000000000000000000000000000000000000000;hb=3ebf932d23dcbec9ed19f4a51f9d00a0a54f5124;hpb=6896318f2b4ff01b4a88b16019c3dc93b0b693f5 diff --git a/e2sim/e2apv1sim/ricsim/src/ASN1/asn/value_traits.hpp b/e2sim/e2apv1sim/ricsim/src/ASN1/asn/value_traits.hpp new file mode 100755 index 0000000..4b67374 --- /dev/null +++ b/e2sim/e2apv1sim/ricsim/src/ASN1/asn/value_traits.hpp @@ -0,0 +1,187 @@ +#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_