Skip to content

Commit 8b2e775

Browse files
committed
Fix bug with FileObject::get_line
1 parent 6975852 commit 8b2e775

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

libraries/FsAPI/include/fs/FileObject.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ class FileObject : public api::ExecutionContext, public FileInfoFlags {
186186
StringType result;
187187
const auto file_location = location();
188188
read(var::View(result.data(), result.capacity()));
189-
size_t offset = 0;
190-
for (auto c : var::StringView(result)) {
189+
size_t offset{};
190+
for (auto c : result.string_view()) {
191191
if (c == term) {
192192
const auto new_length = offset + 1;
193193
seek(file_location + new_length);

libraries/VarAPI/include/var/MagicEnum.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ template <class Type> class MagicEnum {
2323
return magic_enum::enum_cast<Type>(name);
2424
}
2525

26-
static auto from_string_view(var::StringView name) {
26+
static auto from_string(var::StringView name) {
2727
return magic_enum::enum_cast<Type>(name.to_std_string_view());
2828
}
2929

30+
static Type from_string_with_invalid(var::StringView name, Type invalid) {
31+
const auto result = from_string(name);
32+
return result.has_value() ? result.value() : invalid;
33+
}
34+
3035
static size_t count() { return magic_enum::enum_count<Type>(); }
3136

3237
static constexpr auto list() { return magic_enum::enum_values<Type>(); }

0 commit comments

Comments
 (0)