Audacity 3.2.0
HexHelpers.h
Go to the documentation of this file.
1#pragma once
2
3/*!********************************************************************
4
5 Audacity: A Digital Audio Editor
6
7 @file HexHelpers.h
8 @brief Define helper functions for hex-to-num conversion.
9
10 Dmitry Vedenko
11 **********************************************************************/
12
13#include <cstdint>
14#include <cassert>
15#include <cctype>
16
17namespace audacity
18{
19
20inline uint8_t HexCharToNum (char c) noexcept
21{
22 assert (std::isxdigit (c) != 0);
23
24 if ('0' <= c && c <= '9')
25 return c - '0';
26 else if ('A' <= c && c <= 'F')
27 return c - 'A' + 10;
28 else if ('a' <= c && c <= 'f')
29 return c - 'a' + 10;
30
31 return 0;
32}
33
34}
uint8_t HexCharToNum(char c) noexcept
Definition: HexHelpers.h:20