35 Data(
const void* pStart,
size_t length)
36 :
start(static_cast<const T*>(pStart))
37 ,
end (static_cast<const T*>(pStart) + length/sizeof(T)) {
39 "SYSTEM",
"MappedFile::Data: start pointer is not aligned to T.")
41 "SYSTEM",
"MappedFile::Data: byte length is not a multiple of sizeof(T).")
43 "SYSTEM",
"MappedFile::Data: end pointer is not aligned to T.")
60 template <
typename TCheck = alib::CHK>
62 if constexpr ( TCheck::value ) {
75 template <
typename TCheck = alib::CHK>
89 template <
typename TIntegral>
90 requires std::integral<TIntegral>
104 #if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0
105 void* mapAddr =
nullptr;
130 std::size_t knownSize = (std::numeric_limits<std::size_t>::max)(),
131 bool disableMMap=
false,
132 bool willNeed =
true );
135 void Close() noexcept;
139 #if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0
140 return mapAddr !=
nullptr;
151 static_assert(
alignof(T) <=
alignof(std::max_align_t),
152 "MappedFile fallback buffer cannot guarantee this over-alignment." );
153 #if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0
#define ALIB_ASSERT_ERROR(cond, domain,...)
const T operator*() const noexcept
Data(const void *pStart, size_t length)
Data< U > Clone() const noexcept
const T * end
Pointer to the end of the data.
Data()
Defaulted default-constructor.
integer Remaining() const noexcept
bool IsEOF() const noexcept
const T * start
Current pointer position.
const T Current() const noexcept
MappedFile & operator=(MappedFile &&)=delete
MappedFile()=default
Default constructor. Creates an empty view.
MappedFile(MappedFile &&)=delete
Deleted move constructor.
~MappedFile()
Destructor. Calls #".Close".
void Close() noexcept
Release resources (unmap / free buffer).
std::size_t Size() const noexcept
MappedFile(const MappedFile &)=delete
Deleted copy constructor.
bool IsEmpty() const noexcept
bool IsMMap() const noexcept
std::size_t size
Size of the loaded data.
MappedFile & operator=(const MappedFile &)=delete
Deleted copy assignment operator.
std::vector< std::max_align_t > noMMapBuf
Internal buffer used for fallback read mode.
std::errc Open(const CPathString &path, std::size_t knownSize=(std::numeric_limits< std::size_t >::max)(), bool disableMMap=false, bool willNeed=true)
Data< T > GetData() const noexcept
lang::integer integer
Type alias in namespace #"%alib".
strings::TCString< PathCharType > CPathString
The string-type used with this ALib Module.
system::MappedFile MappedFile
Type alias in namespace #"%alib".