LCOV - code coverage report
Current view: top level - libs/bsw/cpp2someip/include/someip - SomeIpStreamer.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 12 12
Test Date: 2026-09-11 12:05:06 Functions: 100.0 % 9 9

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2026 Accenture
       3              :  *
       4              :  * This program and the accompanying materials are made available under the
       5              :  * terms of the Apache License Version 2.0 which is available at
       6              :  * https://www.apache.org/licenses/LICENSE-2.0
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  ********************************************************************************/
      10              : 
      11              : #pragma once
      12              : 
      13              : #include "someip/SomeIpConstants.h"
      14              : 
      15              : #include <cstdint>
      16              : 
      17              : namespace someip
      18              : {
      19              : /**
      20              :  * A base class for read and writing Some/IP types.
      21              :  */
      22              : class SomeIpStreamer
      23              : {
      24              : public:
      25          172 :     SomeIpStreamer() : _errorCode(ErrorCode::SOMEIP_OK), _typeFieldSize(4U), _bigEndian(true) {}
      26              : 
      27              :     /**
      28              :      * Returns true if the underlying serializer or parser is in a good state.
      29              :      */
      30         2081 :     bool isGood() const { return _errorCode == ErrorCode::SOMEIP_OK; }
      31              : 
      32              :     /**
      33              :      * Marks this stream as bad.
      34              :      */
      35           24 :     void setFailure() { _errorCode = ErrorCode::SOMEIP_ERROR; }
      36              : 
      37              :     /**
      38              :      * Sets the stream state to the specified error state.
      39              :      *
      40              :      * \param errorCode The error state.
      41              :      */
      42            3 :     void setFailure(ErrorCode const errorCode)
      43              :     {
      44            3 :         if (errorCode != ErrorCode::SOMEIP_OK)
      45              :         {
      46            2 :             _errorCode = errorCode;
      47              :         }
      48            3 :     }
      49              : 
      50              :     /**
      51              :      * Returns the current errors state.
      52              :      */
      53          170 :     ErrorCode getStatus() const { return _errorCode; }
      54              : 
      55              :     /** Sets the streamer encoding to big endian */
      56           91 :     void bigEndian() { _bigEndian = true; }
      57              : 
      58              :     /** Sets the streamer encoding to little endian */
      59           15 :     void littleEndian() { _bigEndian = false; }
      60              : 
      61              :     /** Returns the current type field size attribute */
      62            3 :     uint8_t getTypeFieldSize() const { return _typeFieldSize; }
      63              : 
      64              :     /** Sets the type field size attribute */
      65            6 :     void setTypeFieldSize(uint8_t const fieldSize) { _typeFieldSize = fieldSize; }
      66              : 
      67              : protected:
      68              :     ErrorCode _errorCode;
      69              :     uint8_t _typeFieldSize;
      70              :     bool _bigEndian;
      71              : };
      72              : 
      73              : void validate(SomeIpStreamer& streamer, bool result);
      74              : 
      75              : } // namespace someip
        

Generated by: LCOV version 2.0-1