Permalink
Browse files

added mapping function for native types

  • Loading branch information...
jpihl committed Oct 27, 2017
1 parent 8ec14f7 commit 5baba9c6220c31cb646f81d580ca982ca9d36710
Showing with 36 additions and 2 deletions.
  1. +0 −1 examples/simple_reader/simple_reader.cpp
  2. +1 −1 src/bitter/reader.hpp
  3. +35 −0 src/bitter/to_type.hpp
@@ -10,7 +10,6 @@
int main()
{
uint32_t value = 0x8028041U;
auto reader = bitter::lsb0_reader<bitter::u32, 1, 7, 8, 16>(value);
@@ -33,7 +33,7 @@ class reader
bit_field<typename DataType::type, field_size_in_bits<Index, Sizes...>()>;
/// @brief Reader constructor
/// DataType must be either uint8_t, uint16_t, uint32_t, or uint64_t
/// DataType must be either u8, u16, u24, u32, u40, u48, u56, or u64
reader(typename DataType::type value) :
m_value(value)
{
@@ -0,0 +1,35 @@
// Copyright (c) Steinwurf ApS 2016.
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
#pragma once
#include <cstdint>
#include "types.hpp"
namespace bitter
{
template<class NativeType>
struct to_type;
template<>
struct to_type<uint8_t>
{
using value = u8;
};
template<>
struct to_type<uint16_t>
{
using value = u16;
};
template<>
struct to_type<uint32_t>
{
using value = u32;
};
template<>
struct to_type<uint64_t>
{
using value = u64;
};
}

0 comments on commit 5baba9c

Please sign in to comment.