summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fud_result.hpp2
-rw-r--r--include/fud_string.hpp9
-rw-r--r--include/libfud.hpp36
3 files changed, 24 insertions, 23 deletions
diff --git a/include/fud_result.hpp b/include/fud_result.hpp
index 9c69800..e4e36cf 100644
--- a/include/fud_result.hpp
+++ b/include/fud_result.hpp
@@ -24,7 +24,7 @@
namespace fud {
template<typename T, typename E>
-class Result {
+class [[nodiscard]] Result {
public:
using ResultType = Result<T, E>;
static ResultType okay(const T& okay)
diff --git a/include/fud_string.hpp b/include/fud_string.hpp
index 5229f26..f7e4813 100644
--- a/include/fud_string.hpp
+++ b/include/fud_string.hpp
@@ -47,6 +47,11 @@ class String {
return m_length;
}
+ [[nodiscard]] constexpr bool empty() const
+ {
+ return m_length == 0;
+ }
+
[[nodiscard]] constexpr size_t size() const
{
return m_length + 1;
@@ -89,6 +94,8 @@ class String {
[[nodiscard]] FudStatus nullTerminate();
+ [[nodiscard]] std::optional<utf8> back();
+
[[nodiscard]] constexpr size_t remainingLength() const
{
if (m_length >= m_capacity) {
@@ -136,7 +143,7 @@ class StringView {
}
StringView(size_t strLen, const char* strData) :
- m_length(strLen), // line break
+ m_length(strLen), // line break
m_data{reinterpret_cast<const utf8*>(strData)} // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
{
}
diff --git a/include/libfud.hpp b/include/libfud.hpp
index ceb1b20..a0b2909 100644
--- a/include/libfud.hpp
+++ b/include/libfud.hpp
@@ -18,31 +18,25 @@
#ifndef LIBFUD_HPP
#define LIBFUD_HPP
-#include "fud_status.hpp" // IWYU pragma: export
+#include "fud_status.hpp"
+#include "fud_result.hpp"
+#include "fud_string.hpp"
-#include "fud_result.hpp" // IWYU pragma: export
-
-#include "fud_memory.hpp" // IWYU pragma: export
-
-#include "fud_assert.hpp" // IWYU pragma: export
-
-#include "fud_array.hpp" // IWYU pragma: export
-
-#include "fud_c_file.hpp" // IWYU pragma: export
-
-#include "fud_fud_type_traits.hpp" // IWYU pragma: export
-
-#include "fud_string.hpp" // IWYU pragma: export
-
-#include "fud_unique_array.hpp" // IWYU pragma: export
+namespace fud {
-#include "fud_utf8.hpp" // IWYU pragma: export
+Result<String, FudStatus> getEnv(const char* name);
-#include "fud_utf8_iterator.hpp" // IWYU pragma: export
+template<typename T>
+concept CStringRepr = requires(T a)
+{
+ { a.c_str() } -> std::convertible_to<const char*>;
+};
-namespace fud {
-
-void fud();
+template <CStringRepr T>
+Result<String, FudStatus> getEnv(const T& name)
+{
+ return getEnv(name.c_str());
+}
}