Cthulhu  0.2.10
Cthulhu compiler collection
sources.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "editor/utils/io.hpp"
4 
5 #include "io/io.h"
6 
7 #include <string>
8 #include <vector>
9 #include <filesystem>
10 
11 typedef struct io_t io_t;
12 typedef struct arena_t arena_t;
13 typedef struct language_t language_t;
14 typedef struct lifetime_t lifetime_t;
15 
16 namespace ed
17 {
18  namespace fs = std::filesystem;
19 
20  class SourceView
21  {
22  std::string directory;
23  std::string basename;
24 
25  ctu::Io io;
26  ctu::OsError error;
27  std::string_view source;
28 
29  std::vector<size_t> line_offsets;
30 
31  void build_line_offsets();
32 
33  public:
34  SourceView(const fs::path& ospath);
35 
36  const char *get_basename() const { return basename.c_str(); }
37  const char *get_path() const { return directory.c_str(); }
38  size_t get_size() const { return source.size(); }
39  io_t *get_io() const { return io.get(); }
40 
41  void draw_content();
42  };
43 }
Definition: io.hpp:30
io_t * get() const
Definition: io.hpp:47
io_t * get_io() const
Definition: sources.hpp:39
const char * get_basename() const
Definition: sources.hpp:36
const char * get_path() const
Definition: sources.hpp:37
size_t get_size() const
Definition: sources.hpp:38
void draw_content()
Definition: sources.cpp:41
SourceView(const fs::path &ospath)
Definition: sources.cpp:8
Definition: compile.hpp:13
struct lifetime_t lifetime_t
Definition: sources.hpp:14
an allocator object
Definition: arena.h:86
io object implementation
Definition: impl.h:122
a language driver support capabilities
Definition: broker.h:143