[*] ROXTL now has AuRONString

[*] Envvars: empty value is now valid
This commit is contained in:
Reece Wilson 2024-04-28 13:22:47 +01:00
parent 54904957f2
commit 7e9a9417db
5 changed files with 79 additions and 23 deletions

View File

@ -281,16 +281,6 @@ namespace Aurora::Memory
}
}
inline bool operator==(const CppHeapWrapper &heap)
{
return this->GetHeapRaw() == heap.GetHeapRaw();
}
template <class T>
inline bool operator==(const CppHeapWrapper<T> &heap)
{
return this->GetHeapRaw() == heap.GetHeapRaw();
}
private:
// should be sizeof(void *) * 4 = [pHeap, pControlBlock, pParent, pSingleThreadChild]
// nor not. it doesnt matter.
@ -306,3 +296,10 @@ namespace Aurora::Memory
friend struct detail::AccessorICantEven;
};
}
template <class T, class Z>
inline bool operator==(const Aurora::Memory::CppHeapWrapper<T> &lhs,
const Aurora::Memory::CppHeapWrapper<Z> &rhs) noexcept
{
return lhs.GetHeapRaw() == rhs.GetHeapRaw();
}

View File

@ -67,6 +67,12 @@ namespace Aurora::Memory
this->length = str.size();
}
MemoryView(const AuRONString &str)
{
this->ptr = str.data();
this->length = str.size();
}
MemoryView(const AuString &str)
{
this->ptr = str.data();
@ -127,6 +133,13 @@ namespace Aurora::Memory
this->length = Z * sizeof(T);
}
template<typename T, int Z>
constexpr MemoryView(AuArray<T, Z> &view)
{
this->ptr = view.begin();
this->length = Z * sizeof(T);
}
template<typename T>
constexpr MemoryView(T *start, T *end)
{
@ -453,13 +466,38 @@ namespace Aurora::Memory
outVariable = 0;
}
template<typename T, int Z>
constexpr MemoryViewStream(AuArray<T, Z> &view,
AuUInt &length) :
MemoryView<Readonly_b>(view),
outVariable(length)
{
outVariable = 0;
}
template<typename T, typename AuEnableIf<AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value>::type* = nullptr>
constexpr MemoryViewStream(T &list) : MemoryView<Readonly_b>(list), outVariable(unused)
{
outVariable = 0;
}
constexpr MemoryViewStream(const AuString &str) : MemoryView<Readonly_b>(str), outVariable(unused)
constexpr MemoryViewStream(const AuString &str) :
MemoryView<Readonly_b>(str),
outVariable(unused)
{
outVariable = 0;
}
constexpr MemoryViewStream(const AuROString &str) :
MemoryView<Readonly_b>(str),
outVariable(unused)
{
outVariable = 0;
}
constexpr MemoryViewStream(const AuRONString &str) :
MemoryView<Readonly_b>(str),
outVariable(unused)
{
outVariable = 0;
}

View File

@ -30,9 +30,9 @@
namespace Aurora::Process
{
AUKN_SYM AuList<AuPair<AuString, AuString>> EnvironmentGetAll();
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuString &key);
AUKN_SYM bool EnvironmentSetOne(const AuString &key, const AuString &value);
AUKN_SYM bool EnvironmentRemoveOne(const AuString &key);
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuRONString &key);
AUKN_SYM bool EnvironmentSetOne(const AuRONString &key, const AuRONString &value);
AUKN_SYM bool EnvironmentRemoveOne(const AuRONString &key);
AUKN_SYM bool EnvironmentRemoveMany(const AuList<AuString> &list);
AUKN_SYM bool EnvironmentSetMany(const AuList<AuPair<AuString, AuString>> &list);
}

View File

@ -54,8 +54,14 @@ namespace Aurora::Process
return ret;
}
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuString &key)
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuRONString &key)
{
if (key.empty())
{
SysPushErrorArg("Missing key");
return {};
}
auto keyString = AuLocale::ConvertFromUTF8(key);
if (keyString.empty())
@ -102,12 +108,19 @@ namespace Aurora::Process
return AuLocale::ConvertFromWChar(temp.c_str());
}
AUKN_SYM bool EnvironmentSetOne(const AuString &key, const AuString &value)
AUKN_SYM bool EnvironmentSetOne(const AuRONString &key,
const AuRONString &value)
{
auto keyString = AuLocale::ConvertFromUTF8(key);
auto valString = AuLocale::ConvertFromUTF8(value);
if (keyString.empty() || valString.empty())
if (key.empty())
{
SysPushErrorArg("Missing key");
return false;
}
if (keyString.empty() || (valString.empty() && !value.empty()))
{
return false;
}
@ -116,10 +129,16 @@ namespace Aurora::Process
valString.c_str());
}
AUKN_SYM bool EnvironmentRemoveOne(const AuString &key)
AUKN_SYM bool EnvironmentRemoveOne(const AuRONString &key)
{
std::wstring keyString;
if (key.empty())
{
SysPushErrorArg("Missing key");
return false;
}
if ((keyString = AuLocale::ConvertFromUTF8(key)).size())
{
return ::SetEnvironmentVariableW(keyString.c_str(), nullptr);

View File

@ -37,7 +37,7 @@ namespace Aurora::Process
return ret;
}
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuString &key)
AUKN_SYM AuOptional<AuString> EnvironmentGetOne(const AuRONString &key)
{
AU_LOCK_GUARD(gEnvMutex);
@ -51,7 +51,7 @@ namespace Aurora::Process
return pValue ? AuString(pValue) : AuOptional<AuString> {};
}
AUKN_SYM bool EnvironmentSetOne(const AuString &key, const AuString &value)
AUKN_SYM bool EnvironmentSetOne(const AuRONString &key, const AuRONString &value)
{
AU_LOCK_GUARD(gEnvMutex);
@ -61,16 +61,18 @@ namespace Aurora::Process
return false;
}
#if 0
if (value.empty())
{
SysPushErrorArg("Missing value");
return false;
}
#endif
return ::setenv(key.c_str(), value.c_str(), 1) == 0;
}
AUKN_SYM bool EnvironmentRemoveOne(const AuString &key)
AUKN_SYM bool EnvironmentRemoveOne(const AuRONString &key)
{
AU_LOCK_GUARD(gEnvMutex);