23 #ifndef EDSP_SYSTEM_HPP 24 #define EDSP_SYSTEM_HPP 26 #include <edsp/core/internal/config.hpp> 29 #include <edsp/meta/expects.hpp> 30 #include <edsp/meta/is_null.hpp> 31 #include <edsp/meta/empty.hpp> 34 namespace edsp {
inline namespace core {
52 return stream <<
"Microsoft Windows OS";
54 return stream <<
"Linux distribution";
56 return stream <<
"Free BSD distribution";
58 return stream <<
"Mac OS X system";
60 return stream <<
"iOS system";
62 return stream <<
"Android system";
81 return stream <<
"x86 architecture";
83 return stream <<
"x64 architecture";
85 return stream <<
"arm architecture";
105 return stream <<
"gcc";
107 return stream <<
"clang";
109 return stream <<
"mvsc";
118 #if defined(COMPILER_GNU) && !defined(COMPILER_CLANG) 120 #elif defined(COMPILER_CLANG) 122 #elif defined(COMPILER_MVSC) 132 #if defined(OS_WINDOWS) 134 #elif defined(OS_LINUX) 136 #elif defined(OS_MACOS) 138 #elif defined(OS_IOS) 140 #elif defined(OS_FREEBSD) 142 #elif defined(OS_ANDROID) 152 #if defined(PROCESSOR_X86_32) 154 #elif defined(PROCESSOR_X86_64) 156 #elif defined(PROCESSOR_ARM) 174 InvalidArgument = EINVAL,
184 static edsp::expected<std::string, SystemEnvironmentError>
185 get_env(
const edsp::string_view& variable_name) noexcept {
186 std::lock_guard<std::mutex> lock(mutex());
187 const char* env_p = std::getenv(variable_name.data());
188 if (meta::empty(variable_name)) {
189 return edsp::make_unexpected(SystemEnvironmentError::Empty);
191 if (!meta::is_null(env_p)) {
194 return edsp::make_unexpected(SystemEnvironmentError::NotFound);
207 const edsp::string_view& variable_value,
bool overwrite =
true) noexcept {
208 std::lock_guard<std::mutex> lock(mutex());
209 if (meta::empty(variable_name)) {
210 return SystemEnvironmentError::Empty;
212 const auto result = setenv(meta::data(variable_name), meta::data(variable_value), overwrite);
222 static bool exist(
const edsp::string_view& variable_name) noexcept {
223 std::lock_guard<std::mutex> lock(mutex());
224 return !meta::is_null(std::getenv(meta::data(variable_name)));
234 static std::mutex& mutex() {
235 static std::mutex environment_mutex;
236 return environment_mutex;
242 #endif //EDSP_SYSTEM_HPP
static bool exist(const edsp::string_view &variable_name) noexcept
Checks if a variable name is defined in the system environment.
Definition: system.hpp:222
processors
Represents the architecture of the processor running the library.
Definition: system.hpp:71
Definition: system.hpp:115
Definition: system.hpp:173
systems
Represents the OS running the library.
Definition: system.hpp:39
static constexpr processors processor() noexcept
Definition: system.hpp:151
Definition: system.hpp:172
logger & red(logger &stream)
Updates the logger output color to red.
Definition: logger.hpp:325
Definition: system.hpp:165
static edsp::expected< std::string, SystemEnvironmentError > get_env(const edsp::string_view &variable_name) noexcept
Searches in the system environment for the value of the variable name.
Definition: system.hpp:185
SystemEnvironmentError
Definition: system.hpp:170
static constexpr systems os() noexcept
Definition: system.hpp:131
static SystemEnvironmentError set_env(const edsp::string_view &variable_name, const edsp::string_view &variable_value, bool overwrite=true) noexcept
Shall update or add a variable in the environment of the calling process.
Definition: system.hpp:206
Definition: logger.hpp:40
static constexpr compilers compiler() noexcept
Definition: system.hpp:117
logger & endc(logger &stream)
End of color, styled streaming.
Definition: logger.hpp:407
compilers
Represents the type of Operative System running the library.
Definition: system.hpp:95
Definition: amplifier.hpp:29
logger & operator<<(logger &stream, fft_lib lib)
Definition: library_info.hpp:38