Orcus
|
#include <stream.hpp>
Public Member Functions | |
file_content (const file_content &)=delete | |
file_content & | operator= (const file_content &)=delete |
file_content (file_content &&other) | |
file_content (std::string_view filepath) | |
const char * | data () const |
size_t | size () const |
bool | empty () const |
void | swap (file_content &other) |
void | load (std::string_view filepath) |
void | convert_to_utf8 () |
std::string_view | str () const |
Represents the content of a file.
The file content is memory-mapped initially, but may later become in-memory if the non-utf-8 content gets converted to utf-8.
void orcus::file_content::convert_to_utf8 | ( | ) |
Convert a non-utf-8 stream to a utf-8 one if the source stream contains a byte order mark. If not, it does nothing. When the conversion happens, the converted content will be stored in-memory.
const char* orcus::file_content::data | ( | ) | const |
Obtain the memory address to the first character in the content buffer.
bool orcus::file_content::empty | ( | ) | const |
Query whether or not the content is empty.
void orcus::file_content::load | ( | std::string_view | filepath | ) |
Load from a new file. This will invalidate the pointer returned from the data() method prior to the call.
filepath | path of the file to load from. |
size_t orcus::file_content::size | ( | ) | const |
Return the size of the content i.e. the number of characters in the content buffer.
void orcus::file_content::swap | ( | file_content & | other | ) |
Swap content with another instance.
other | another instance to swap content with. |