DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
okssystem
src
Environment.cpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS system source for the DUNE DAQ project.
3
// Fork baseline commit: system-00-00-20 (2020-09-25).
4
// Renamed since fork: yes (from src/Environment.cxx to src/Environment.cpp).
5
6
/*
7
* Environment.cxx
8
* ers
9
*
10
* Created by Matthias Wiesmann on 11.01.05.
11
* Copyright 2005 CERN. All rights reserved.
12
*
13
*/
14
15
#include <stdlib.h>
16
17
#include "
okssystem/Environment.hpp
"
18
#include "
okssystem/exceptions.hpp
"
19
20
using namespace
OksSystem
;
21
27
28
void
29
OksSystem::Environment::set
(
const
std::string& key,
const
std::string& value)
30
{
31
const
char
* c_key = key.c_str();
32
const
char
* c_value = value.c_str();
33
const
int
status = ::setenv(c_key, c_value, 1);
34
if
(status < 0) {
35
std::string message =
"while setting "
+ key +
" to "
+ value;
36
throw
OksSystemCallIssue(
ERS_HERE
, errno,
"setenv"
, message.c_str());
37
}
38
}
// set
39
44
45
void
46
OksSystem::Environment::set
(
const
std::map<std::string, std::string>& values)
47
{
48
for
(std::map<std::string, std::string>::const_iterator pos = values.begin(); pos != values.end(); ++pos) {
49
set
(pos->first, pos->second);
50
}
// for
51
}
// set
52
57
58
std::string
59
OksSystem::Environment::get
(
const
std::string& key)
60
{
61
const
char
* c_value = ::getenv(key.c_str());
62
if
(c_value == 0)
63
return
std::string();
64
return
std::string(c_value);
65
}
// get
Environment.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
OksSystem
Definition
Descriptor.hpp:22
OksSystem::Environment::get
static std::string get(const std::string &key)
get a environnement variable
Definition
Environment.cpp:59
OksSystem::Environment::set
static void set(const std::string &key, const std::string &value)
sets an environnement variable
Definition
Environment.cpp:29
exceptions.hpp
Generated on
for DUNE-DAQ by
1.18.0