summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorAnsariel <ansariel.hiller@phoenixviewer.com>2024-02-21 16:49:48 +0100
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-02-21 19:02:58 +0200
commit3ffe63b8a4e8a3ceda3f6d204e4b5bb0c80d0870 (patch)
tree80eebe22b53d48161fa92a62991275b2e2dae5ce /indra/llcommon
parent0fb52bd372aad468c890fc57f4ae3b8be7dad463 (diff)
Convert remaining BOOLs in llxml and introduce std::string_view
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llstring.cpp14
-rw-r--r--indra/llcommon/llstring.h15
2 files changed, 15 insertions, 14 deletions
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 6e6797312b..bdd4c2c4bb 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -765,7 +765,7 @@ std::wstring windows_message<std::wstring>(DWORD error)
return out.str();
}
-boost::optional<std::wstring> llstring_getoptenv(const std::string& key)
+std::optional<std::wstring> llstring_getoptenv(const std::string& key)
{
auto wkey = ll_convert_string_to_wide(key);
// Take a wild guess as to how big the buffer should be.
@@ -783,8 +783,8 @@ boost::optional<std::wstring> llstring_getoptenv(const std::string& key)
// did that (ultimately) succeed?
if (n)
{
- // great, return populated boost::optional
- return boost::optional<std::wstring>(&buffer[0]);
+ // great, return populated std::optional
+ return std::make_optional<std::wstring>(&buffer[0]);
}
// not successful
@@ -795,7 +795,7 @@ boost::optional<std::wstring> llstring_getoptenv(const std::string& key)
LL_WARNS() << "GetEnvironmentVariableW('" << key << "') failed: "
<< windows_message<std::string>(last_error) << LL_ENDL;
}
- // return empty boost::optional
+ // return empty std::optional
return {};
}
@@ -806,12 +806,12 @@ boost::optional<std::string> llstring_getoptenv(const std::string& key)
auto found = getenv(key.c_str());
if (found)
{
- // return populated boost::optional
- return boost::optional<std::string>(found);
+ // return populated std::optional
+ return std::make_optional<std::string>(found);
}
else
{
- // return empty boost::optional
+ // return empty std::optional
return {};
}
}
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index f2741a0e1f..6893b8ebff 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -28,8 +28,9 @@
#define LL_LLSTRING_H
#include <boost/call_traits.hpp>
-#include <boost/optional/optional.hpp>
+#include <optional>
#include <string>
+#include <string_view>
#include <cstdio>
#include <cwchar> // std::wcslen()
//#include <locale>
@@ -345,7 +346,7 @@ public:
* (key is always UTF-8)
* detect absence by (! return value)
*/
- static boost::optional<string_type> getoptenv(const std::string& key);
+ static std::optional<string_type> getoptenv(const std::string& key);
static void addCRLF(string_type& string);
static void removeCRLF(string_type& string);
@@ -819,11 +820,11 @@ STRING windows_message() { return windows_message<STRING>(GetLastError()); }
//@}
-LL_COMMON_API boost::optional<std::wstring> llstring_getoptenv(const std::string& key);
+LL_COMMON_API std::optional<std::wstring> llstring_getoptenv(const std::string& key);
#else // ! LL_WINDOWS
-LL_COMMON_API boost::optional<std::string> llstring_getoptenv(const std::string& key);
+LL_COMMON_API std::optional<std::string> llstring_getoptenv(const std::string& key);
#endif // ! LL_WINDOWS
@@ -1773,17 +1774,17 @@ bool LLStringUtilBase<T>::endsWith(
// static
template<class T>
-auto LLStringUtilBase<T>::getoptenv(const std::string& key) -> boost::optional<string_type>
+auto LLStringUtilBase<T>::getoptenv(const std::string& key) -> std::optional<string_type>
{
auto found(llstring_getoptenv(key));
if (found)
{
- // return populated boost::optional
+ // return populated std::optional
return { ll_convert<string_type>(*found) };
}
else
{
- // empty boost::optional
+ // empty std::optional
return {};
}
}