\hypertarget{dbc__decoder_8cpp_source}{}\doxysection{dbc\+\_\+decoder.\+cpp}
\mbox{\hyperlink{dbc__decoder_8cpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00001}00001 \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00002}00002 \textcolor{comment}{ * @file dbc\_decoder.cpp}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00003}00003 \textcolor{comment}{ * @brief}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00004}00004 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00005}00005 \textcolor{comment}{ * Created: 2026-\/03-\/13}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00006}00006 \textcolor{comment}{ * Author: Deeaitch (Dim. Himro)}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00007}00007 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00008}00008 \textcolor{comment}{ * Licensed under the MIT License.}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00009}00009 \textcolor{comment}{ * See LICENSE file in the project root for full license text.}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00010}00010 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00011}00011 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00012}00012 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{dbc__decoder_8h}{dbc\_decoder.h}}"{}}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00013}00013 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00014}\mbox{\hyperlink{classDbcDecoder_ab2cfb2fb711c95d3a29365546b89f3da}{00014}} \textcolor{keyword}{const} \mbox{\hyperlink{structDecodeFrame}{DecodeFrame}} *\mbox{\hyperlink{classDbcDecoder_ab2cfb2fb711c95d3a29365546b89f3da}{DbcDecoder::FindFrame}} (\textcolor{keyword}{const} \mbox{\hyperlink{structDecodeDatabase}{DecodeDatabase}} \&database,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00015}00015     std::uint32\_t canId,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00016}00016     \textcolor{keywordtype}{bool} isExtended)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00017}00017   \textcolor{keyword}{const} \mbox{\hyperlink{structFrameKey}{FrameKey}} key (canId, isExtended);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00018}00018   \textcolor{keyword}{const} std::unordered\_map<FrameKey, std::size\_t, FrameKeyHasher>::const\_iterator it =}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00019}00019     database.\mbox{\hyperlink{structDecodeDatabase_ae4fd1351008bb0dce337821a849100c5}{frameIndexByKey}}.find (key);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00020}00020 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00021}00021   \textcolor{keywordflow}{if} (it == database.\mbox{\hyperlink{structDecodeDatabase_ae4fd1351008bb0dce337821a849100c5}{frameIndexByKey}}.end())}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00022}00022     \textcolor{keywordflow}{return} \textcolor{keyword}{nullptr};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00023}00023 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00024}00024   \textcolor{keyword}{const} std::size\_t index = it-\/>second;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00025}00025   \textcolor{keywordflow}{if} (index >= database.\mbox{\hyperlink{structDecodeDatabase_a2bd4ddfc2602c1de4e12a373bfc93072}{frames}}.size())}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00026}00026     \textcolor{keywordflow}{return} \textcolor{keyword}{nullptr};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00027}00027 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00028}00028   \textcolor{keywordflow}{return} \&database.\mbox{\hyperlink{structDecodeDatabase_a2bd4ddfc2602c1de4e12a373bfc93072}{frames}}[index];}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00029}00029 \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00031}\mbox{\hyperlink{classDbcDecoder_a345951ffe5d943a70d3a1ea1f39e74f7}{00031}} \mbox{\hyperlink{structDecodedFrameValue}{DecodedFrameValue}} \mbox{\hyperlink{classDbcDecoder_a345951ffe5d943a70d3a1ea1f39e74f7}{DbcDecoder::Decode}} (\textcolor{keyword}{const} \mbox{\hyperlink{structDecodeDatabase}{DecodeDatabase}} \&database,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00032}00032                                       \textcolor{keyword}{const} \mbox{\hyperlink{structRawCanFrame}{RawCanFrame}} \&frame)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00033}00033   \mbox{\hyperlink{structDecodedFrameValue}{DecodedFrameValue}} result;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00034}00034   \textcolor{keyword}{const} \mbox{\hyperlink{structDecodeFrame}{DecodeFrame}} *definition = \mbox{\hyperlink{classDbcDecoder_ab2cfb2fb711c95d3a29365546b89f3da}{FindFrame}} (database, frame.\mbox{\hyperlink{structRawCanFrame_a2d0e7fa0e3d5c20bbed55ed8f7888ff4}{canId}}, frame.\mbox{\hyperlink{structRawCanFrame_a462193d275adc1dba8bd18ffa0e36bb7}{isExtended}});}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00035}00035 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00036}00036   \textcolor{keywordflow}{if} (definition == \textcolor{keyword}{nullptr})}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00037}00037     \textcolor{keywordflow}{return} result;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00039}00039   result.\mbox{\hyperlink{structDecodedFrameValue_a60dda1cc352d2c8087f0bdbc81dd266c}{definition}} = definition;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00040}00040   result.\mbox{\hyperlink{structDecodedFrameValue_a4f51c31110dba1f73a763c596372beb0}{valid}} = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00041}00041 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00042}00042   \textcolor{keywordflow}{for} (std::size\_t signalIndex = 0U; signalIndex < definition-\/>\mbox{\hyperlink{structDecodeFrame_a372afd9e74f1ae33f85cb4acfd3e2036}{signals}}.size(); ++signalIndex) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00043}00043     \textcolor{keyword}{const} \mbox{\hyperlink{structDecodeSignal}{DecodeSignal}} \&signal = definition-\/>\mbox{\hyperlink{structDecodeFrame_a372afd9e74f1ae33f85cb4acfd3e2036}{signals}}[signalIndex];}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00044}00044     \mbox{\hyperlink{structDecodedSignalValue}{DecodedSignalValue}} decoded;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00045}00045     std::uint64\_t unsignedValue = 0U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00047}00047     decoded.\mbox{\hyperlink{structDecodedSignalValue_acadc3b3bb21dd6b0412d342c7e6b20d7}{definition}} = \&signal;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00048}00048 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00049}00049     \textcolor{keywordflow}{if} (!\mbox{\hyperlink{classDbcDecoder_a2a8a99b1107543be6fd1b3f891130bf5}{ExtractUnsigned}} (frame.\mbox{\hyperlink{structRawCanFrame_a0acb487612104c99c9907344c035df83}{data}}, signal, unsignedValue)) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00050}00050       decoded.\mbox{\hyperlink{structDecodedSignalValue_aac0ed361af545cde48d0e6f41a859686}{valid}} = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00051}00051       result.\mbox{\hyperlink{structDecodedFrameValue_a8440e0e5d7953102095b029f522022d3}{signals}}.push\_back (decoded);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00052}00052       \textcolor{keywordflow}{continue};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00053}00053     \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00054}00054 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00055}00055     \textcolor{keywordflow}{if} (signal.\mbox{\hyperlink{structDecodeSignal_a9d37638129263b8902ba5be59baf39a8}{valueType}} == \mbox{\hyperlink{decode__database_8h_ad9971b6ef33e02ba2c75d19c1d2518a1a71fed0c3428bf1a2e19af257c4bac379}{ValueType::Signed}})}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00056}00056       decoded.\mbox{\hyperlink{structDecodedSignalValue_a5138b825940e34689f7b3891627ee9ec}{rawValue}} = \mbox{\hyperlink{classDbcDecoder_a41e89e343338088d27e46773fa52df42}{SignExtend}} (unsignedValue, signal.\mbox{\hyperlink{structDecodeSignal_acd4ef5ee30421d117b5756854302debb}{length}});}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00057}00057     \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00058}00058       decoded.\mbox{\hyperlink{structDecodedSignalValue_a5138b825940e34689f7b3891627ee9ec}{rawValue}} = \textcolor{keyword}{static\_cast<}std::int64\_t\textcolor{keyword}{>} (unsignedValue);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00060}00060     decoded.\mbox{\hyperlink{structDecodedSignalValue_a6847d05b3cb00d5e0f6c611968f57978}{physicalValue}} =}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00061}00061       (\textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{double}\textcolor{keyword}{>} (decoded.\mbox{\hyperlink{structDecodedSignalValue_a5138b825940e34689f7b3891627ee9ec}{rawValue}}) * signal.\mbox{\hyperlink{structDecodeSignal_a428c39913a366a8476dd291061354391}{factor}}) + signal.\mbox{\hyperlink{structDecodeSignal_a92db637af4e224a0ae70173050dc3f74}{offset}};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00062}00062     decoded.\mbox{\hyperlink{structDecodedSignalValue_aac0ed361af545cde48d0e6f41a859686}{valid}} = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00063}00063 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00064}00064     result.\mbox{\hyperlink{structDecodedFrameValue_a8440e0e5d7953102095b029f522022d3}{signals}}.push\_back (decoded);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00065}00065   \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00067}00067   \textcolor{keywordflow}{return} result;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00068}00068 \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00069}00069 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00070}\mbox{\hyperlink{classDbcDecoder_a2a8a99b1107543be6fd1b3f891130bf5}{00070}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{classDbcDecoder_a2a8a99b1107543be6fd1b3f891130bf5}{DbcDecoder::ExtractUnsigned}} (\textcolor{keyword}{const} std::vector<std::uint8\_t> \&data,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00071}00071                                   \textcolor{keyword}{const} \mbox{\hyperlink{structDecodeSignal}{DecodeSignal}} \&signal,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00072}00072                                   std::uint64\_t \&value) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00073}00073   \textcolor{keywordflow}{if} ((signal.\mbox{\hyperlink{structDecodeSignal_acd4ef5ee30421d117b5756854302debb}{length}} == 0U) || (signal.\mbox{\hyperlink{structDecodeSignal_acd4ef5ee30421d117b5756854302debb}{length}} > 64U))}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00074}00074     \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00075}00075 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00076}00076   \textcolor{keywordflow}{if} (signal.\mbox{\hyperlink{structDecodeSignal_abdc4c4bb4a67a6d61d6ca81e8a52833d}{byteOrder}} == \mbox{\hyperlink{decode__database_8h_aaeb92d42f5a6e27b8ba19f18d69d142baff97a9fdede09eaf6e1c8ec9f6a61dd5}{ByteOrder::Intel}})}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00077}00077     \textcolor{keywordflow}{return} \mbox{\hyperlink{classDbcDecoder_aba130165c1a73bb4cd3a0454f415d872}{ExtractIntel}} (data, signal.\mbox{\hyperlink{structDecodeSignal_aaf5d7527ddf65b6355c2b4f3626df22d}{startBit}}, signal.\mbox{\hyperlink{structDecodeSignal_acd4ef5ee30421d117b5756854302debb}{length}}, value);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00079}00079   \textcolor{keywordflow}{return} \mbox{\hyperlink{classDbcDecoder_aede690734148c3d538105d5a2f7ee0a9}{ExtractMotorola}} (data, signal.\mbox{\hyperlink{structDecodeSignal_aaf5d7527ddf65b6355c2b4f3626df22d}{startBit}}, signal.\mbox{\hyperlink{structDecodeSignal_acd4ef5ee30421d117b5756854302debb}{length}}, value);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00080}00080 \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00082}\mbox{\hyperlink{classDbcDecoder_aba130165c1a73bb4cd3a0454f415d872}{00082}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{classDbcDecoder_aba130165c1a73bb4cd3a0454f415d872}{DbcDecoder::ExtractIntel}} (\textcolor{keyword}{const} std::vector<std::uint8\_t> \&data,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00083}00083                                std::uint32\_t startBit,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00084}00084                                std::uint32\_t length,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00085}00085                                std::uint64\_t \&value) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00086}00086   value = 0U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00087}00087 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00088}00088   \textcolor{keywordflow}{for} (std::uint32\_t bitIndex = 0U; bitIndex < length; ++bitIndex) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00089}00089     \textcolor{keyword}{const} std::uint32\_t absoluteBit = startBit + bitIndex;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00090}00090     \textcolor{keyword}{const} std::uint32\_t byteIndex = absoluteBit / 8U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00091}00091     \textcolor{keyword}{const} std::uint32\_t bitInByte = absoluteBit \% 8U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00092}00092 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00093}00093     \textcolor{keywordflow}{if} (byteIndex >= data.size())}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00094}00094       \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00095}00095 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00096}00096     \textcolor{keyword}{const} std::uint64\_t bitValue =}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00097}00097       (\textcolor{keyword}{static\_cast<}std::uint64\_t\textcolor{keyword}{>} ((data[byteIndex] >> bitInByte) \& 0x01U) << bitIndex);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00099}00099     value |= bitValue;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00100}00100   \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00102}00102   \textcolor{keywordflow}{return} \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00103}00103 \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00104}00104 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00105}\mbox{\hyperlink{classDbcDecoder_aede690734148c3d538105d5a2f7ee0a9}{00105}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{classDbcDecoder_aede690734148c3d538105d5a2f7ee0a9}{DbcDecoder::ExtractMotorola}} (\textcolor{keyword}{const} std::vector<std::uint8\_t> \&data,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00106}00106                                   std::uint32\_t startBit,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00107}00107                                   std::uint32\_t length,}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00108}00108                                   std::uint64\_t \&value) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00109}00109   \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00110}00110 \textcolor{comment}{   * DBC Motorola bit numbering:}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00111}00111 \textcolor{comment}{   * -\/ startBit points to the most significant bit of the signal}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00112}00112 \textcolor{comment}{   * -\/ inside a byte, bit numbering goes 7..0}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00113}00113 \textcolor{comment}{   * -\/ crossing byte boundary moves to the next byte, bit 7}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00114}00114 \textcolor{comment}{   */}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00115}00115 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00116}00116   value = 0U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00117}00117 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00118}00118   std::int32\_t currentBit = \textcolor{keyword}{static\_cast<}std::int32\_t\textcolor{keyword}{>} (startBit);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00119}00119 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00120}00120   \textcolor{keywordflow}{for} (std::uint32\_t bitIndex = 0U; bitIndex < length; ++bitIndex) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00121}00121     \textcolor{keywordflow}{if} (currentBit < 0)}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00122}00122       \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00123}00123 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00124}00124     \textcolor{keyword}{const} std::uint32\_t absoluteBit = \textcolor{keyword}{static\_cast<}std::uint32\_t\textcolor{keyword}{>} (currentBit);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00125}00125     \textcolor{keyword}{const} std::uint32\_t byteIndex = absoluteBit / 8U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00126}00126     \textcolor{keyword}{const} std::uint32\_t bitFromMsb = absoluteBit \% 8U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00127}00127     \textcolor{keyword}{const} std::uint32\_t bitInByte = 7U -\/ bitFromMsb;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00128}00128 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00129}00129     \textcolor{keywordflow}{if} (byteIndex >= data.size())}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00130}00130       \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00131}00131 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00132}00132     value <<= 1U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00133}00133     value |= \textcolor{keyword}{static\_cast<}std::uint64\_t\textcolor{keyword}{>} ((data[byteIndex] >> bitInByte) \& 0x01U);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00134}00134 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00135}00135     \textcolor{keywordflow}{if} ((absoluteBit \% 8U) == 7U)}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00136}00136       currentBit = \textcolor{keyword}{static\_cast<}std::int32\_t\textcolor{keyword}{>} ((byteIndex + 1U) * 8U);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00137}00137     \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00138}00138       -\/-\/currentBit;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00139}00139   \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00140}00140 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00141}00141   \textcolor{keywordflow}{return} \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00142}00142 \}}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00143}00143 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00144}\mbox{\hyperlink{classDbcDecoder_a41e89e343338088d27e46773fa52df42}{00144}} std::int64\_t \mbox{\hyperlink{classDbcDecoder_a41e89e343338088d27e46773fa52df42}{DbcDecoder::SignExtend}} (std::uint64\_t value, std::uint32\_t bitLength) \{}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00145}00145   \textcolor{keywordflow}{if} ((bitLength == 0U) || (bitLength >= 64U))}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00146}00146     \textcolor{keywordflow}{return} \textcolor{keyword}{static\_cast<}std::int64\_t\textcolor{keyword}{>} (value);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00147}00147 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00148}00148   \textcolor{keyword}{const} std::uint64\_t signMask = (\textcolor{keyword}{static\_cast<}std::uint64\_t\textcolor{keyword}{>} (1U) << (bitLength -\/ 1U));}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00149}00149   \textcolor{keyword}{const} std::uint64\_t valueMask = (\textcolor{keyword}{static\_cast<}std::uint64\_t\textcolor{keyword}{>} (1U) << bitLength) -\/ 1U;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00150}00150 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00151}00151   value \&= valueMask;}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00152}00152 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00153}00153   \textcolor{keywordflow}{if} ((value \& signMask) == 0U)}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00154}00154     \textcolor{keywordflow}{return} \textcolor{keyword}{static\_cast<}std::int64\_t\textcolor{keyword}{>} (value);}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00155}00155 }
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00156}00156   \textcolor{keywordflow}{return} \textcolor{keyword}{static\_cast<}std::int64\_t\textcolor{keyword}{>} (value | (\string~valueMask));}
\DoxyCodeLine{\Hypertarget{dbc__decoder_8cpp_source_l00157}00157 \}}

\end{DoxyCode}
