ALib C++ Library
Library Version: 2511 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 if ( targetData == lang::CurrentData::Clear )
45 target.Reset();
46
47 if ( name.IsEmpty() )
48 return false;
49
50 ALIB_STRINGS_TO_NARROW( name, nName, 512 )
52 nchar* env= std::getenv( nName );
54
55 if( env != nullptr ) {
56 target._( NString( env ) );
57 return true;
58 }
59 return false;
60}
61
62}} // namespace [alib::system]
TAString & _(const TAppendable &src)
constexpr bool IsEmpty() const
Definition string.inl:365
#define ALIB_WARNINGS_RESTORE
Definition alib.inl:719
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
#define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE
Definition alib.inl:634
@ 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:475
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2198
characters::nchar nchar
Type alias in namespace alib.
static ALIB_DLL bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)