ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
environment.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
7#include "alib_precompile.hpp"
8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14// ====================================== Global Fragment ======================================
17
18#if !DOXYGEN
19# if defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
20# include <unistd.h>
21# elif defined( _WIN32 )
22# include <direct.h>
23# else
24# pragma message ("Unknown Platform in file: " __FILE__ )
25# endif
26#endif // !DOXYGEN
27// =========================================== Module ==========================================
28#if ALIB_C20_MODULES
29 module ALib.System;
30# if ALIB_STRINGS
31 import ALib.Strings;
32# endif
33#else
34# include "ALib.Strings.H"
35# include "ALib.System.H"
36#endif
37// ====================================== Implementation =======================================
38namespace alib { namespace system {
39
40
42 AString& target,
43 lang::CurrentData targetData )
44{
45 if ( targetData == lang::CurrentData::Clear )
46 target.Reset();
47
48 if ( name.IsEmpty() )
49 return false;
50
51 ALIB_STRINGS_TO_NARROW( name, nName, 512 )
53 nchar* env= std::getenv( nName );
55
56 if( env != nullptr )
57 {
58 target._( NString( env ) );
59 return true;
60 }
61 return false;
62}
63
64}} // namespace [alib::system]
TAString & _(const TAppendable &src)
constexpr bool IsEmpty() const
Definition string.inl:367
#define ALIB_WARNINGS_RESTORE
Definition alib.inl:705
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
#define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE
Definition alib.inl:624
@ Clear
Chooses to clear existing data.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
strings::TCString< character > CString
Type alias in namespace alib.
Definition cstring.inl:503
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2390
characters::nchar nchar
Type alias in namespace alib.
static ALIB_DLL bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)