LCOV - code coverage report
Current view: top level - src - Buffer.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 7 11 63.6 %
Date: 2025-04-27 01:14:20 Functions: 11 16 68.8 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            : ** Copyright (C) 2023 Sylvain Fargier
       3                 :            : **
       4                 :            : ** This software is provided 'as-is', without any express or implied
       5                 :            : ** warranty.  In no event will the authors be held liable for any damages
       6                 :            : ** arising from the use of this software.
       7                 :            : **
       8                 :            : ** Permission is granted to anyone to use this software for any purpose,
       9                 :            : ** including commercial applications, and to alter it and redistribute it
      10                 :            : ** freely, subject to the following restrictions:
      11                 :            : **
      12                 :            : ** 1. The origin of this software must not be misrepresented; you must not
      13                 :            : **    claim that you wrote the original software. If you use this software
      14                 :            : **    in a product, an acknowledgment in the product documentation would be
      15                 :            : **    appreciated but is not required.
      16                 :            : ** 2. Altered source versions must be plainly marked as such, and must not be
      17                 :            : **    misrepresented as being the original software.
      18                 :            : ** 3. This notice may not be removed or altered from any source distribution.
      19                 :            : **
      20                 :            : ** Created on: 2023-12-16T11:47:05
      21                 :            : ** Author: Sylvain Fargier <fargier.sylvain@gmail.com>
      22                 :            : */
      23                 :            : 
      24                 :            : #include "Buffer.hpp"
      25                 :            : 
      26                 :            : namespace ccut {
      27                 :            : 
      28                 :            : #define GEN_ENDIAN_CONV(x)                            \
      29                 :            :     template<>                                        \
      30                 :            :     uint##x##_t htobe<uint##x##_t>(uint##x##_t value) \
      31                 :            :     {                                                 \
      32                 :            :         return htobe##x(value);                       \
      33                 :            :     }                                                 \
      34                 :            :     template<>                                        \
      35                 :            :     uint##x##_t betoh<uint##x##_t>(uint##x##_t value) \
      36                 :            :     {                                                 \
      37                 :            :         return be##x##toh(value);                     \
      38                 :            :     }                                                 \
      39                 :            :     template<>                                        \
      40                 :            :     uint##x##_t htole<uint##x##_t>(uint##x##_t value) \
      41                 :            :     {                                                 \
      42                 :            :         return htole##x(value);                       \
      43                 :            :     }                                                 \
      44                 :            :     template<>                                        \
      45                 :            :     uint##x##_t letoh<uint##x##_t>(uint##x##_t value) \
      46                 :            :     {                                                 \
      47                 :            :         return le##x##toh(value);                     \
      48                 :            :     }
      49                 :            : 
      50                 :         89 : GEN_ENDIAN_CONV(16)
      51                 :         42 : GEN_ENDIAN_CONV(32)
      52                 :          2 : GEN_ENDIAN_CONV(64)
      53                 :            : 
      54                 :            : #undef GEN_ENDIAN_CONV
      55                 :            : 
      56                 :            : template<>
      57                 :          0 : uint8_t htobe<uint8_t>(uint8_t value)
      58                 :            : {
      59                 :          0 :     return value;
      60                 :            : }
      61                 :            : 
      62                 :            : template<>
      63                 :         59 : uint8_t htole<uint8_t>(uint8_t value)
      64                 :            : {
      65                 :         59 :     return value;
      66                 :            : }
      67                 :            : 
      68                 :            : template<>
      69                 :         40 : uint8_t letoh<uint8_t>(uint8_t value)
      70                 :            : {
      71                 :         40 :     return value;
      72                 :            : }
      73                 :            : 
      74                 :            : template<>
      75                 :          0 : uint8_t betoh<uint8_t>(uint8_t value)
      76                 :            : {
      77                 :          0 :     return value;
      78                 :            : }
      79                 :            : 
      80                 :            : } // namespace ccut

Generated by: LCOV version 1.14