ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
lang
system
environment.hpp
Go to the documentation of this file.
1
/** ************************************************************************************************
2
* \file
3
* This header file is part of sub-namespace # alib::lang::system of module \alib_basecamp of
4
* the \aliblong.
5
*
6
* \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
7
* Published under \ref mainpage_license "Boost Software License".
8
**************************************************************************************************/
9
#ifndef HPP_ALIB_CAMP_ENVIRONMENT
10
#define HPP_ALIB_CAMP_ENVIRONMENT 1
11
12
#if !defined (HPP_ALIB_STRINGS_ASTRING)
13
# include "
alib/strings/astring.hpp
"
14
#endif
15
16
ALIB_ASSERT_MODULE
(CAMP)
17
18
#if !defined (HPP_ALIB_STRINGS_CSTRING)
19
# include "
alib/strings/cstring.hpp
"
20
#endif
21
22
namespace
alib
{
namespace
lang::system {
23
24
/** ************************************************************************************************
25
* Simple struct providing one static method that reads an environment variable into an
26
* \alib string type.
27
*
28
* While under posix compatible operating systems, environment variable names are
29
* case sensitive, under Microsoft windows they are not.
30
**************************************************************************************************/
31
struct
EnvironmentVariables
32
{
33
/** ************************************************************************************************
34
* Reads an environment variable into an \alib string.
35
*
36
* \attention
37
* 1. While under posix compatible operating systems, environment variable names are
38
* case sensitive, under Microsoft windows they are not.
39
* \attention
40
* 2. As documented with
41
* \https{std::getenv,en.cppreference.com/w/cpp/utility/program/getenv}, the operation is
42
* not thread safe against changes of the environment in parallel threads.
43
*
44
* @param varName The name of the variable to be retrieved.
45
* @param target An AString to write the result to.
46
* @param targetData If \c CurrentData::Keep, the parameter \p{target} is not cleared
47
* before the result is written. Defaults to \c CurrentData::Clear.
48
* @return \c true if variable was found.
49
**************************************************************************************************/
50
ALIB_API
static
51
bool
Get
(
const
CString
& varName,
52
AString
& target,
53
lang::CurrentData
targetData =
lang::CurrentData::Clear
);
54
};
55
56
}
// namespace alib[:: lang::system]
57
58
/// Type alias in namespace \b alib.
59
using
EnvironmentVariables
=
lang::system::EnvironmentVariables
;
60
61
}
// namespace [alib]
62
63
#endif
// HPP_ALIB_CAMP_ENVIRONMENT
astring.hpp
alib::strings::TAString< character >
alib::strings::TCString< character >
cstring.hpp
ALIB_ASSERT_MODULE
#define ALIB_ASSERT_MODULE(modulename)
Definition
alib.hpp:190
ALIB_API
#define ALIB_API
Definition
alib.hpp:538
alib::lang::CurrentData
CurrentData
Definition
commonenumdefs.hpp:110
alib::lang::CurrentData::Clear
@ Clear
Chooses to clear existing data.
alib::lang::ContainerOp::Get
@ Get
Denotes to search data.
alib
Definition
alib.cpp:57
alib::lang::system::EnvironmentVariables
Definition
environment.hpp:32