![]() |
simdjson 4.4.0
Ridiculously Fast JSON
|
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. | |
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.
|
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().
| filename | the path to the file to memory-map. |
Definition at line 379 of file padded_string-inl.h.
|
noexcept |
Destroy the padded memory map and release any resources.
Definition at line 409 of file padded_string-inl.h.
|
noexcept |
Check if the memory map is valid.
Definition at line 423 of file padded_string-inl.h.
|
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.
Definition at line 416 of file padded_string-inl.h.