Skip to content

Commit

Permalink
concepts: start work on file output
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jan 2, 2025
1 parent 36ea859 commit c97cc1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/avnd/concepts/file_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ concept raw_file_port = requires(T t) {
};

AVND_DEFINE_TAG(file_watch)
AVND_DEFINE_TAG(file_load)
AVND_DEFINE_TAG(file_create)
}
22 changes: 22 additions & 0 deletions include/halp/file_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cstddef>
#include <string_view>
#include <vector>

HALP_MODULE_EXPORT
namespace halp
{
Expand Down Expand Up @@ -39,6 +40,15 @@ struct mmap_file_view
};
};

struct output_file_view
{
std::string_view filename;
enum
{
file_create
};
};

template <halp::static_string lit, typename FileType = text_file_view>
struct file_port
{
Expand All @@ -51,4 +61,16 @@ struct file_port

FileType file;
};

template <halp::static_string lit>
struct file_write_port
{
using file_type = output_file_view;
static clang_buggy_consteval auto name() { return std::string_view{lit.value}; }

HALP_INLINE_FLATTEN operator output_file_view&() noexcept { return file; }
HALP_INLINE_FLATTEN operator const output_file_view&() const noexcept { return file; }

output_file_view file;
};
}

0 comments on commit c97cc1d

Please sign in to comment.