Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_EnvVariables.hpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_ENVVARIABLES_HPP
11#define TEUCHOS_ENVVARIABLES_HPP
12
13#include <string>
14#include <string_view>
15
16namespace Teuchos {
17
44const char* getEnvironmentVariableValue(const char name[]);
45
47inline const char* getEnvironmentVariableValue(const std::string& name) {
48 return getEnvironmentVariableValue(name.c_str());
49}
50
73void setEnvironmentVariable(const char name[], const char value[], int overwrite);
74
76inline void setEnvironmentVariable(const std::string& name, const std::string& value, int overwrite) {
77 setEnvironmentVariable(name.c_str(), value.c_str(), overwrite);
78}
79
95void unsetEnvironmentVariable(const char name[]);
96
98inline void unsetEnvironmentVariable(const std::string& name) {
99 unsetEnvironmentVariable(name.c_str());
100}
101
102template <typename T>
103T getEnvironmentVariable(std::string_view environmentVariableName,
104 const T defaultValue);
105
106bool idempotentlyGetNamedEnvironmentVariableAsBool(
107 const char name[], bool &initialized, const char environmentVariableName[],
108 const bool defaultValue);
109
121template <typename T>
123 T &value, bool &initialized, std::string_view environmentVariableName,
124 const T defaultValue);
125
126} // namespace Teuchos
127
128#endif
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
void unsetEnvironmentVariable(const char name[])
Remove a process environment variable.
T idempotentlyGetEnvironmentVariable(T &value, bool &initialized, std::string_view environmentVariableName, const T defaultValue)
Read a variable from the environment. Example usage:
const char * getEnvironmentVariableValue(const char name[])
Read a process environment variable by name.
void setEnvironmentVariable(const char name[], const char value[], int overwrite)
Set a process environment variable.