summaryrefslogtreecommitdiff
path: root/source/fud_assert.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-27 09:04:05 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-27 09:04:05 -0500
commitb8345246dcc2121bcb6d1515a9341789de20199f (patch)
tree4a25857512a90ff38e8a40166c54694b74920216 /source/fud_assert.cpp
parentf84b8259f6e980fed647d8e1ec0634f89ee59c06 (diff)
First crack at file objects.
Diffstat (limited to 'source/fud_assert.cpp')
-rw-r--r--source/fud_assert.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/source/fud_assert.cpp b/source/fud_assert.cpp
index 0c4d7cf..a7c9d76 100644
--- a/source/fud_assert.cpp
+++ b/source/fud_assert.cpp
@@ -1,11 +1,27 @@
+/*
+ * libfud
+ * Copyright 2024 Dominick Allen
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "fud_assert.hpp"
#include "fud_format.hpp"
-#include "fud_string.hpp"
+#include "fud_string.hpp" // DrainResult
+#include "fud_string_view.hpp"
-#include <climits>
#include <cstdio>
-#include <exception>
namespace fud {
@@ -24,6 +40,7 @@ DrainResult BufferSink::drain(StringView source)
result.status = FudStatus::Success;
return result;
}
+ /* TODO: give users control over this functionality */
result.bytesWritten = fwrite(reinterpret_cast<const char*>(source.m_data), 1, source.m_length, stderr);
if (result.bytesWritten != source.m_length) {
result.status = FudStatus::Full;
@@ -43,7 +60,14 @@ void assertFailMessage(const char* assertion, const std::source_location sourceL
if (functionName == nullptr) {
functionName = "Unknown Function";
}
- format(sink, FormatCharMode::Unchecked, "{}:{}:{}: {}\n", fileName, functionName, sourceLocation.line(), assertion);
+ static_cast<void>(format(
+ sink,
+ FormatCharMode::Unchecked,
+ "{}:{}:{}: {}\n",
+ fileName,
+ functionName,
+ sourceLocation.line(),
+ assertion));
}
} // namespace impl