Cogs.Core
Public Types | Public Member Functions | Public Attributes | List of all members
Cogs::FileContents Struct Referenceabstract

Abstract base class storing data read from a file. More...

#include <FileContents.h>

Inheritance diagram for Cogs::FileContents:
Cogs::MMapBackedFileContents Cogs::MemoryBufferBackedFileContents Cogs::Platform::ResourceBufferBackedFileContents

Public Types

using Ptr = std::unique_ptr< FileContents >
 
using Callback = std::function< void(Ptr &&)>
 

Public Member Functions

 FileContents (const uint8_t *ptr, size_t size, FileContentsHints hints)
 
 FileContents (const FileContents &)=delete
 
FileContentsoperator= (const FileContents &)=delete
 
Memory::MemoryBuffer takeCopy ()
 
constexpr const void * data () const
 Access to buffer data. Cast to actual type using static_cast<const MyType*>(..)
 
virtual Memory::MemoryBuffer take ()=0
 Take ownership of underlying memorybuffer if exists.
 
virtual StringView origin ()=0
 

Public Attributes

const uint8_t * ptr
 Start of buffer storing file data. Use.
 
size_t size
 Number of data bytes.
 
size_t mimeTypeHash = 0
 
FileContentsHints hints = FileContentsHints::None
 

Detailed Description

Abstract base class storing data read from a file.

Definition at line 20 of file FileContents.h.

Member Typedef Documentation

◆ Callback

using Cogs::FileContents::Callback = std::function<void(Ptr&&)>

Definition at line 24 of file FileContents.h.

◆ Ptr

using Cogs::FileContents::Ptr = std::unique_ptr<FileContents>

Definition at line 23 of file FileContents.h.

Constructor & Destructor Documentation

◆ FileContents()

Cogs::FileContents::FileContents ( const uint8_t *  ptr,
size_t  size,
FileContentsHints  hints 
)
inline

Definition at line 35 of file FileContents.h.

Member Function Documentation

◆ data()

constexpr const void * Cogs::FileContents::data ( ) const
inlineconstexpr

Access to buffer data. Cast to actual type using static_cast<const MyType*>(..)

Definition at line 45 of file FileContents.h.

◆ take()

virtual Memory::MemoryBuffer Cogs::FileContents::take ( )
pure virtual

Take ownership of underlying memorybuffer if exists.

Implemented in Cogs::Platform::ResourceBufferBackedFileContents, Cogs::MemoryBufferBackedFileContents, and Cogs::MMapBackedFileContents.

◆ takeCopy()

Cogs::Memory::MemoryBuffer Cogs::FileContents::takeCopy ( )

Definition at line 3 of file FileContents.cpp.

Member Data Documentation

◆ hints

FileContentsHints Cogs::FileContents::hints = FileContentsHints::None

Definition at line 31 of file FileContents.h.

◆ mimeTypeHash

size_t Cogs::FileContents::mimeTypeHash = 0

Definition at line 30 of file FileContents.h.

◆ ptr

const uint8_t* Cogs::FileContents::ptr

Start of buffer storing file data. Use.

See also
data() to ease casting to actual data type.

Definition at line 27 of file FileContents.h.

◆ size

size_t Cogs::FileContents::size

Number of data bytes.

Definition at line 29 of file FileContents.h.


The documentation for this struct was generated from the following files: