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,
19
const
std::string & separators,
20
std::vector<std::string> & result )
21
{
22
std::string::size_type start_p, end_p;
23
start_p = 0;
24
do
25
{
26
end_p = text.find_first_of(separators,start_p);
27
if
(end_p == std::string::npos)
28
{
29
end_p = text.length();
30
}
31
result.push_back( text.substr( start_p, end_p - start_p ) );
32
start_p = text.find_first_not_of( separators, end_p );
33
}
34
while
( start_p != std::string::npos );
35
}
36
37
int
38
ers::read_from_environment
(
const
char
* name,
int
default_value )
39
{
40
int
value = default_value;
41
const
char
* env = ::getenv( name );
42
if
( env )
43
{
44
if
( sscanf( env,
"%d"
, &value ) != 1 )
45
{
46
ERS_INTERNAL_ERROR
(
"Wrong value \""
<< env
47
<<
"\" is given for the \""
<< name <<
"\" environment"
)
48
}
49
}
50
return
value;
51
}
52
53
const
char
*
54
ers::read_from_environment
(
const
char
* name,
const
char
* default_value )
55
{
56
const
char
* env = ::getenv( name );
57
return
( env ? env : default_value);
58
}
59
60
61
Util.hpp
macro.hpp
ERS_INTERNAL_ERROR
#define ERS_INTERNAL_ERROR(message)
Definition
macro.hpp:63
ers::read_from_environment
int read_from_environment(const char *name, int default_value)
Definition
Util.cpp:38
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.17.0