LCOV - code coverage report
Current view: top level - ers/src - Util.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 90.5 % 21 19
Test Date: 2026-10-11 15:05:20 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*
       2              :  * DUNE DAQ modification notice:
       3              :  * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
       4              :  * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
       5              :  * Renamed since fork: yes (from src/Util.cxx to src/Util.cpp).
       6              :  *
       7              :  * Original copyright:
       8              :  * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
       9              :  * Licensed under the Apache License, Version 2.0.
      10              :  */
      11              : 
      12              : #include <stdio.h>
      13              : 
      14              : #include <ers/internal/Util.hpp>
      15              : #include <ers/internal/macro.hpp>
      16              : 
      17              : void
      18           66 : ers::tokenize(const std::string& text, const std::string& separators, std::vector<std::string>& result)
      19              : {
      20           66 :   std::string::size_type start_p, end_p;
      21           66 :   start_p = 0;
      22          453 :   do {
      23          453 :     end_p = text.find_first_of(separators, start_p);
      24          453 :     if (end_p == std::string::npos) {
      25           66 :       end_p = text.length();
      26              :     }
      27          453 :     result.push_back(text.substr(start_p, end_p - start_p));
      28          453 :     start_p = text.find_first_not_of(separators, end_p);
      29          453 :   } while (start_p != std::string::npos);
      30           66 : }
      31              : 
      32              : int
      33           92 : ers::read_from_environment(const char* name, int default_value)
      34              : {
      35           92 :   int value = default_value;
      36           92 :   const char* env = ::getenv(name);
      37           92 :   if (env) {
      38            0 :     if (sscanf(env, "%d", &value) != 1) {
      39            0 :       ERS_INTERNAL_ERROR("Wrong value \"" << env << "\" is given for the \"" << name << "\" environment")
      40              :     }
      41              :   }
      42           92 :   return value;
      43              : }
      44              : 
      45              : const char*
      46          156 : ers::read_from_environment(const char* name, const char* default_value)
      47              : {
      48          156 :   const char* env = ::getenv(name);
      49          156 :   return (env ? env : default_value);
      50              : }
        

Generated by: LCOV version 2.0-1