Orcus
Public Member Functions | List of all members
orcus::file_content Class Reference

#include <stream.hpp>

Public Member Functions

 file_content (const file_content &)=delete
 
file_contentoperator= (const file_content &)=delete
 
 file_content (file_content &&other)
 
 file_content (const char *filepath)
 
const char * data () const
 
size_t size () const
 
bool empty () const
 
void swap (file_content &other)
 
void load (const char *filepath)
 
void convert_to_utf8 ()
 
pstring str () const
 

Detailed Description

Represents the content of a file. The file content may be either in-memory, or memory-mapped; it is initially memory-mapped, but it may become in-memory when converted to a different encoding.

Member Function Documentation

◆ convert_to_utf8()

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.

◆ load()

void orcus::file_content::load ( const char *  filepath)

Load from a new file. This will invalidate the pointer returned from the file_content#data() method prior to the call.

Parameters
filepathpath of the file to load from.