NDEVR
API Documentation
EnvironmentalVariable.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Resource.h>
4#include <NDEVR/ResourceListener.h>
5#include <NDEVR/String.h>
6#include <NDEVR/Dictionary.h>
7#include <NDEVR/InfoPipe.h>
8namespace NDEVR
9{
10 class StringView;
11 class InfoPipe;
17 class NDEVR_BASE_API EnvironmentalVariable final : private ResourceListener
18 {
19 public:
24
25
36 static void SetUserEnvironmentalVariable(const StringView& label, const StringView& value, bool blocking = false, LogPtr log = LogPtr());
43 static void SetSystemEnvironmentalVariable(const StringView& label, const StringView& value, bool blocking = false, LogPtr log = LogPtr());
50 static void SetProgramEnvironmentalVariable(const StringView& label, const StringView& value);
67 const String& get();
73 private:
77 void fetchResource();
81 void onValueChanged() final override;
82 private:
86 Resource<String> m_resource;
90 String variable;
91 bool m_is_fetched = false;
92 bool m_is_fetching = false;
93 private:
94 static Dictionary<String, String> s_user_environment_variables;
95 static Dictionary<String, String> s_system_environment_variables;
96 static Dictionary<String, String> s_program_environment_variables;
97 };
98}
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
~EnvironmentalVariable()
Destructor.
static String ResolveEnvironmentalVariables(const StringView &string)
Returns a string where all environmental variables have been resolved.
const String & get()
Gets the current value of the environmental variable, fetching it from the OS if needed.
EnvironmentalVariable(const StringView &variable)
AllocConsole initializes standard input, standard output, and standard error handles for the new cons...
static String GetEnvironmentalVariable(const StringView &label)
Gets an environmental variable from the OS.
static void SetUserEnvironmentalVariable(const StringView &label, const StringView &value, bool blocking=false, LogPtr log=LogPtr())
Sets an environmental variable to the OS, in a seperate thread if possible.
void onValueChanged() final override
Called when the Resource value changes, propagating the new value to the OS environmental variable.
Resource< String > & resource()
Returns a reference to the underlying Resource that mirrors the environmental variable.
static void SetSystemEnvironmentalVariable(const StringView &label, const StringView &value, bool blocking=false, LogPtr log=LogPtr())
Sets an environmental variable to the OS, in a seperate thread if possible.
static void SetProgramEnvironmentalVariable(const StringView &label, const StringView &value)
Sets an environmental variable to the OS, in a seperate thread if possible.
A light-weight base class for Log that allows processes to update, without the need for additional in...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
ResourceListener()
Constructs a default ResourceListener.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
The primary namespace for the NDEVR SDK.