LCOV - code coverage report
Current view: top level - datadog - parse_util.h (source / functions) Hit Total Coverage
Test: filtered.info Lines: 2 2 100.0 %
Date: 2024-01-03 20:30:12 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : // This component provides parsing-related miscellanea.
       4             : 
       5             : #include <cstddef>
       6             : #include <cstdint>
       7             : 
       8             : #include "expected.h"
       9             : #include "string_view.h"
      10             : 
      11             : namespace datadog {
      12             : namespace tracing {
      13             : 
      14             : // Return a `string_view` over the specified range of characters `[begin, end)`.
      15       32980 : inline StringView range(const char* begin, const char* end) {
      16       32980 :   return StringView{begin, std::size_t(end - begin)};
      17             : }
      18             : 
      19             : // Remove leading and trailing whitespace (as determined by `std::isspace`) from
      20             : // the specified `input`.
      21             : StringView strip(StringView input);
      22             : 
      23             : // Return a non-negative integer parsed from the specified `input` with respect
      24             : // to the specified `base`, or return an `Error` if no such integer can be
      25             : // parsed. It is an error unless all of `input` is consumed by the parse.
      26             : // Leading and trailing whitespace are not ignored.
      27             : Expected<std::uint64_t> parse_uint64(StringView input, int base);
      28             : Expected<int> parse_int(StringView input, int base);
      29             : 
      30             : // Return a floating point number parsed from the specified `input`, or return
      31             : // an `Error` if not such number can be parsed. It is an error unless all of
      32             : // `input` is consumed by the parse. Leading and trailing whitespace are not
      33             : // ignored.
      34             : Expected<double> parse_double(StringView input);
      35             : 
      36             : // Return whether the specified `prefix` is a prefix of the specified `subject`.
      37             : bool starts_with(StringView subject, StringView prefix);
      38             : 
      39             : // Convert the specified `text` to lower case in-place.
      40             : void to_lower(std::string& text);
      41             : 
      42             : }  // namespace tracing
      43             : }  // namespace datadog

Generated by: LCOV version 1.16