DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
19
20using namespace OksSystem;
21
27
28void OksSystem::Environment::set(const std::string &key, const std::string &value) {
29 const char* c_key = key.c_str();
30 const char* c_value = value.c_str();
31 const int status = ::setenv(c_key,c_value,1);
32 if (status<0) {
33 std::string message = "while setting " + key + " to " + value;
34 throw OksSystemCallIssue( ERS_HERE, errno, "setenv", message.c_str());
35 }
36} // set
37
42
43void OksSystem::Environment::set(const std::map<std::string,std::string> &values) {
44 for(std::map<std::string,std::string>::const_iterator pos = values.begin();pos!=values.end();++pos) {
45 set(pos->first,pos->second);
46 } // for
47} // set
48
53
54std::string OksSystem::Environment::get(const std::string &key) {
55 const char* c_value = ::getenv(key.c_str());
56 if (c_value==0) return std::string();
57 return std::string(c_value);
58} // get
59
#define ERS_HERE
static std::string get(const std::string &key)
get a environnement variable
static void set(const std::string &key, const std::string &value)
sets an environnement variable