LCOV - code coverage report
Current view: top level - src - char_utils.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 14 14 100.0 %
Date: 2026-07-14 21:28:07 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 34 100.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2011-2026 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #ifndef EXESS_SRC_CHAR_UTILS_H
       5                 :            : #define EXESS_SRC_CHAR_UTILS_H
       6                 :            : 
       7                 :            : #include "attributes.h"
       8                 :            : 
       9                 :            : #include <stdbool.h>
      10                 :            : 
      11                 :            : /// Return true if `c` lies within [`min`...`max`] (inclusive)
      12                 :            : static inline EXESS_I_NONBLOCKING bool
      13                 :    2628529 : in_range(const int c, const int min, const int max)
      14                 :            : {
      15   [ +  +  +  + ]:    2628529 :   return (c >= min && c <= max);
      16                 :            : }
      17                 :            : 
      18                 :            : /// Return true if `c` is a whitespace character according to XSD
      19                 :            : static inline EXESS_I_NONBLOCKING bool
      20                 :     288692 : is_space(const int c)
      21                 :            : {
      22   [ +  +  +  +  :     288692 :   return c == '\t' || c == '\n' || c == '\r' || c == ' ';
             +  +  +  + ]
      23                 :            : }
      24                 :            : 
      25                 :            : /// ALPHA ::= [A-Za-z]
      26                 :            : static inline EXESS_I_NONBLOCKING bool
      27                 :      44121 : is_alpha(const int c)
      28                 :            : {
      29   [ +  +  +  + ]:      44121 :   return in_range(c, 'A', 'Z') || in_range(c, 'a', 'z');
      30                 :            : }
      31                 :            : 
      32                 :            : /// DIGIT ::= [0-9]
      33                 :            : static inline EXESS_I_NONBLOCKING bool
      34                 :    2557493 : is_digit(const int c)
      35                 :            : {
      36                 :    2557493 :   return in_range(c, '0', '9');
      37                 :            : }
      38                 :            : 
      39                 :            : /// HEXDIG ::= DIGIT | "A" | "B" | "C" | "D" | "E" | "F"
      40                 :            : static inline EXESS_I_NONBLOCKING bool
      41                 :         41 : is_hexdig(const int c)
      42                 :            : {
      43   [ +  +  +  + ]:         41 :   return is_digit(c) || in_range(c, 'A', 'F');
      44                 :            : }
      45                 :            : 
      46                 :            : /// BASE64 ::= ALPHA | DIGIT | "+" | "/" | "="
      47                 :            : static inline EXESS_I_NONBLOCKING bool
      48                 :      44121 : is_base64(const int c)
      49                 :            : {
      50   [ +  +  +  +  :      44121 :   return is_alpha(c) || is_digit(c) || c == '+' || c == '/' || c == '=';
          +  +  +  +  +  
                      + ]
      51                 :            : }
      52                 :            : 
      53                 :            : /// SIGN ::= "+" | "-"
      54                 :            : static inline EXESS_I_NONBLOCKING bool
      55                 :      26661 : is_sign(const int c)
      56                 :            : {
      57   [ +  +  +  + ]:      26661 :   return c == '+' || c == '-';
      58                 :            : }
      59                 :            : 
      60                 :            : #endif // EXESS_SRC_CHAR_UTILS_H

Generated by: LCOV version 1.16