Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
cetlib
cetlib
getenv.cc
Go to the documentation of this file.
1
// ======================================================================
2
//
3
// getenv: Obtain value of environment variable; throw if none such
4
//
5
// ======================================================================
6
7
#include "
cetlib/getenv.h
"
8
9
#include "cetlib_except/exception.h"
10
#include <cstdlib>
11
12
// ======================================================================
13
14
std::string
15
cet::getenv
(
std::string
const
&
name
)
16
{
17
char
const
*
p
=
std::getenv
(name.c_str());
18
if
(p ==
nullptr
) {
19
throw
cet::exception
{
"getenv"
}
20
<<
"Can't find an environment variable named \""
<< name <<
'\"'
;
21
}
22
return
p
;
23
}
24
25
std::string
26
cet::getenv
(
std::string
const
&
name
, std::nothrow_t)
27
{
28
char
const
*
p
=
std::getenv
(name.c_str());
29
if
(p ==
nullptr
) {
30
p =
""
;
31
}
32
return
p
;
33
}
name
static QCString name
Definition:
declinfo.cpp:673
string
std::string string
Definition:
nybbler.cc:12
cet::getenv
std::string getenv(std::string const &name)
Definition:
getenv.cc:15
test.p
p
Definition:
test.py:223
getenv.h
fhicl::exception
cet::coded_exception< error, detail::translate > exception
Definition:
exception.h:33
Generated by
1.8.11