/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/System/Implementation/EnvironmentVariableUtils.cpp
65 строк
2 KB
Ingrater
Clang-format fixes and update to 18.1.1 (#1234)
10 мар 2024, 15:51
Не верифицирован
10 мар 2024, 15:51
2f16acf
Код
Авторство
О чём код?
#include <Foundation/FoundationPCH.h> #include <Foundation/Logging/Log.h> #include <Foundation/Strings/StringBuilder.h> #include <Foundation/System/EnvironmentVariableUtils.h> #include <Foundation/Threading/Mutex.h> #include <Foundation/Utilities/ConversionUtils.h> // The POSIX functions are not thread safe by definition. static ezMutex s_EnvVarMutex; ezString ezEnvironmentVariableUtils::GetValueString(ezStringView sName, ezStringView sDefault /*= nullptr*/) { EZ_ASSERT_DEV(!sName.IsEmpty(), "Null or empty name passed to ezEnvironmentVariableUtils::GetValueString()"); EZ_LOCK(s_EnvVarMutex); return GetValueStringImpl(sName, sDefault); } ezResult ezEnvironmentVariableUtils::SetValueString(ezStringView sName, ezStringView sValue) { EZ_LOCK(s_EnvVarMutex); return SetValueStringImpl(sName, sValue); } ezInt32 ezEnvironmentVariableUtils::GetValueInt(ezStringView sName, ezInt32 iDefault /*= -1*/) { EZ_LOCK(s_EnvVarMutex); ezString value = GetValueString(sName); if (value.IsEmpty()) return iDefault; ezInt32 iRetVal = 0; if (ezConversionUtils::StringToInt(value, iRetVal).Succeeded()) return iRetVal; else return iDefault; } ezResult ezEnvironmentVariableUtils::SetValueInt(ezStringView sName, ezInt32 iValue) { ezStringBuilder sb; sb.SetFormat("{}", iValue); return SetValueString(sName, sb); } bool ezEnvironmentVariableUtils::IsVariableSet(ezStringView sName) { EZ_LOCK(s_EnvVarMutex); return IsVariableSetImpl(sName); } ezResult ezEnvironmentVariableUtils::UnsetVariable(ezStringView sName) { EZ_LOCK(s_EnvVarMutex); return UnsetVariableImpl(sName); }