DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
okssystem
src
Environment.cpp
Go to the documentation of this file.
1
/*
2
* Environment.cxx
3
* ers
4
*
5
* Created by Matthias Wiesmann on 11.01.05.
6
* Copyright 2005 CERN. All rights reserved.
7
*
8
*/
9
10
#include <stdlib.h>
11
12
#include "
okssystem/Environment.hpp
"
13
#include "
okssystem/exceptions.hpp
"
14
15
using namespace
OksSystem
;
16
23
void
OksSystem::Environment::set
(
const
std::string &key,
const
std::string &value) {
24
const
char
* c_key = key.c_str();
25
const
char
* c_value = value.c_str();
26
const
int
status = ::setenv(c_key,c_value,1);
27
if
(status<0) {
28
std::string message =
"while setting "
+ key +
" to "
+ value;
29
throw
OksSystemCallIssue(
ERS_HERE
, errno,
"setenv"
, message.c_str());
30
}
31
}
// set
32
38
void
OksSystem::Environment::set
(
const
std::map<std::string,std::string> &values) {
39
for
(std::map<std::string,std::string>::const_iterator pos = values.begin();pos!=values.end();++pos) {
40
set(pos->first,pos->second);
41
}
// for
42
}
// set
43
49
std::string
OksSystem::Environment::get
(
const
std::string &key) {
50
const
char
* c_value = ::getenv(key.c_str());
51
if
(c_value==0)
return
std::string();
52
return
std::string(c_value);
53
}
// get
54
Environment.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:130
OksSystem
Definition
Descriptor.hpp:17
OksSystem::Environment::get
static std::string get(const std::string &key)
get a environnement variable
Definition
Environment.cpp:49
OksSystem::Environment::set
static void set(const std::string &key, const std::string &value)
sets an environnement variable
Definition
Environment.cpp:23
exceptions.hpp
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0