OGLplus  (0.59.0) a C++ wrapper for rendering APIs

environment.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_ENVIRONMENT_HPP
10 #define EAGINE_ENVIRONMENT_HPP
11 
12 #include "string_span.hpp"
13 #include "valid_if/decl.hpp"
14 #include <cstdlib>
15 
16 namespace eagine {
17 //------------------------------------------------------------------------------
21 static inline auto get_environment_variable(string_view variable_name) noexcept
23  if(auto value = ::getenv(c_str(variable_name))) {
24  return {string_view(value), true};
25  }
26  return {};
27 }
28 //------------------------------------------------------------------------------
29 } // namespace eagine
30 
31 #endif // EAGINE_ENVIRONMENT_HPP
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static constexpr auto c_str(memory::basic_span< C, P, S > s) -> std::enable_if_t< std::is_convertible_v< memory::basic_span< C, P, S >, basic_string_span< C, P, S >>, basic_c_str< C, P, S >>
Functions that construct a basic_c_str from a basic_string_span.
Definition: string_span.hpp:226
Common code is placed in this namespace.
Definition: eagine.hpp:21
Primary template for conditionally valid values.
Definition: decl.hpp:49
static auto get_environment_variable(string_view variable_name) noexcept -> optionally_valid< string_view >
Returns the value in the specified environment variable.
Definition: environment.hpp:21

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).