simdjson 4.4.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
simdjson::padded_memory_map Class Reference

A class representing a memory-mapped file with padding. More...

#include <padded_string.h>

Public Member Functions

simdjson_inline padded_memory_map (const char *filename) noexcept
 Create a new padded memory map for the given file.
 
simdjson_inline ~padded_memory_map () noexcept
 Destroy the padded memory map and release any resources.
 
simdjson_inline simdjson::padded_string_view view () const noexcept simdjson_lifetime_bound
 Get a view of the memory-mapped file.
 
simdjson_inline bool is_valid () const noexcept
 Check if the memory map is valid.
 

Detailed Description

A class representing a memory-mapped file with padding.

It is only available on non-Windows platforms, as Windows has different APIs for memory mapping.

Definition at line 286 of file padded_string.h.

Constructor & Destructor Documentation

◆ padded_memory_map()

simdjson_inline simdjson::padded_memory_map::padded_memory_map ( const char *  filename)
noexcept

Create a new padded memory map for the given file.

After creating the memory map, you can call view() to get a padded_string_view of the file content. The memory map will be automatically released when the padded_memory_map instance is destroyed. Note that the file content is not copied, so this is efficient for large files. However, the file must remain unchanged while the memory map is in use. In case of error (e.g., file not found, permission denied, etc.), the memory map will be invalid and view() will return an empty view. You can check if the memory map is valid by calling is_valid() before using view().

Parameters
filenamethe path to the file to memory-map.

Definition at line 379 of file padded_string-inl.h.

◆ ~padded_memory_map()

simdjson_inline simdjson::padded_memory_map::~padded_memory_map ( )
noexcept

Destroy the padded memory map and release any resources.

Definition at line 409 of file padded_string-inl.h.

Member Function Documentation

◆ is_valid()

simdjson_inline bool simdjson::padded_memory_map::is_valid ( ) const
noexcept

Check if the memory map is valid.

Returns
true if the memory map is valid, false otherwise.

Definition at line 423 of file padded_string-inl.h.

◆ view()

simdjson_inline simdjson::padded_string_view simdjson::padded_memory_map::view ( ) const
noexcept

Get a view of the memory-mapped file.

It always succeeds, but the view may be empty if the memory map is invalid (e.g., due to file not found, permission denied, etc.). You can check if the memory map is valid by calling is_valid() before using the view.

Lifetime of the view is tied to the memory map, so the view should not be used after the padded_memory_map instance is destroyed.

Returns
a padded_string_view representing the memory-mapped file, or an empty view if the memory map is invalid.

Definition at line 416 of file padded_string-inl.h.


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