DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
ers
src
Util.cpp
Go to the documentation of this file.
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
ers::tokenize
(
const
std::string& text,
const
std::string& separators, std::vector<std::string>& result)
19
{
20
std::string::size_type start_p, end_p;
21
start_p = 0;
22
do
{
23
end_p = text.find_first_of(separators, start_p);
24
if
(end_p == std::string::npos) {
25
end_p = text.length();
26
}
27
result.push_back(text.substr(start_p, end_p - start_p));
28
start_p = text.find_first_not_of(separators, end_p);
29
}
while
(start_p != std::string::npos);
30
}
31
32
int
33
ers::read_from_environment
(
const
char
* name,
int
default_value)
34
{
35
int
value = default_value;
36
const
char
* env = ::getenv(name);
37
if
(env) {
38
if
(sscanf(env,
"%d"
, &value) != 1) {
39
ERS_INTERNAL_ERROR
(
"Wrong value \""
<< env <<
"\" is given for the \""
<< name <<
"\" environment"
)
40
}
41
}
42
return
value;
43
}
44
45
const
char
*
46
ers::read_from_environment
(
const
char
* name,
const
char
* default_value)
47
{
48
const
char
* env = ::getenv(name);
49
return
(env ? env : default_value);
50
}
Util.hpp
macro.hpp
ERS_INTERNAL_ERROR
#define ERS_INTERNAL_ERROR(message)
Definition
macro.hpp:71
ers::read_from_environment
int read_from_environment(const char *name, int default_value)
Definition
Util.cpp:33
ers::tokenize
void tokenize(const std::string &text, const std::string &separators, std::vector< std::string > &tokens)
Definition
Util.cpp:18
Generated on
for DUNE-DAQ by
1.18.0