class WriteAccessor final : public virtual FileAccessor {...};
WriteAccessor is used to write file data. It provides the WriteBinary and WriteText methods featuring a Result for controlled, unformatted writing, and the operator<< method for simple formatted writing. It also provides SyncToFile() to flush the buffer of the operating system to the physical storage.
Serves for buffered writing of binary and text files as well as their synchronization to physical storage.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: fd57dd10b948ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves for buffered writing of binary and text files as well as their synchronization to physical storage.
The ara::per::WriteAccessor class enables writing binary or textual file contents in the persistence module and provides methods for unformatted write access as well as a formatted stream operator [SWS_PER_00423]. Because write operations can initially be buffered in the operating system, calling SyncToFile() forces permanent flushing to physical storage [SWS_PER_00122]. All methods are exception-safe, but not thread-safe, which is why concurrent access must be protected by the application.
Context
ara::per::WriteAccessor is a final class of the persistence module (per) of the AUTOSAR Adaptive Platform and inherits virtually from FileAccessor. The class provides write operations for file contents. It offers methods for unformatted, controlled writing with error handling via ara::core::Result as well as an overloaded stream operator for formatted writing. The calling application, the operating system's internal file buffer, and the physical storage medium act as interaction partners.
Lifecycle
The default constructor of WriteAccessor is explicitly deleted and must not be used [SWS_PER_00596]. (Interpretation: Instances of WriteAccessor are likely created and provided via factory methods of higher-level persistence management entities such as file storage.) Question Q-af92be8494274611 (open)
Destruction takes place via the virtual destructor ~WriteAccessor()[SWS_PER_00597]. The class and its methods are specified as exception safe and declared as noexcept. Regarding concurrency, WriteAccessor is not thread-safe [SWS_PER_00597]; concurrent access to the same instance must be protected externally by the application.
Usage Path
The regular flow comprises writing data in unformatted or formatted mode, optionally adjusting the file size, and the concluding persistent storage:
Writing binary data: A byte range (ara::core::Span<const ara::core::Byte>) is written to the file via WriteBinary()[SWS_PER_00423].
Writing text data: Strings are passed via a ara::core::StringView using WriteText()[SWS_PER_00166]. In addition, operator<< is available as a convenience function for non-critical use cases, with occurring errors being silently ignored [SWS_PER_00125].
Enforcing persistence: The time of physical storage depends on the persistence implementation; SyncToFile() conclusively flushes the operating system buffer to the storage medium [SWS_PER_00122], [SWS_PER_00423], [SWS_PER_00166].
Adjusting file size: The file can be truncated using SetFileSize(), whereby trailing contents are removed; the file position remains unchanged or is set to the last valid position or 0 [SWS_PER_00428].
The methods WriteBinary(), WriteText(), SyncToFile(), and SetFileSize() return a ara::core::Result<void> that contains specific error codes upon failure:
PerErrc::kOutOfStorageSpace: Insufficient physical storage space [SWS_PER_00423], [SWS_PER_00166], [SWS_PER_00122]. During writing, the exceeding portion is discarded and the position is at the end of the file (no rollback semantics).
PerErrc::kEncryptionFailed: Encryption or decryption fails [SWS_PER_00423], [SWS_PER_00166], [SWS_PER_00122], [SWS_PER_00428]. While buffer and position are updated, the file cannot be persisted and reflects an older version on storage (rollback semantics).
Reduces the size of the file to ’size’, effectively removing the current content of the file beyond this size. The current file position is unchanged if it is lower than ’size’, or set to the last valid position in the file otherwise. If ’size’ is 0, the current file position will also be set to 0.
Writes the content of a Span of Byte to the file. The time when the content is persisted depends on the implementation of Persistency. SyncTo File can be used to force Persistency to persist the file content. In case of an error, the file content might be corrupted, and the current position might or might not have changed. The expected state of the file for each supported error can be expected to be as follows: • kPhysicalStorageFailure: The state of the file is unknown. It could have been entirely destroyed. • kEncryptionFailed: The content of the file and the current position will have been updated, but could not be persisted. The persisted file will reflect an older version of the file. • kOutOfStorageSpace: The content of the file will have been updated, but the part of the operation that exceeded the quota will have been discarded. The current position will be at the end of the file.
Writes the content of a StringView to the file. The time when the content is persisted depends on the implementation of Persistency. SyncTo File can be used to force Persistency to persist the file content. In case of an error, the file content might be corrupted, and the current position might or might not have changed. The expected state of the file for each supported error can be expected to be as follows: • kPhysicalStorageFailure: The state of the file is unknown. It could have been entirely destroyed. • kEncryptionFailed: The content of the file and the current position will have been updated, but could not be persisted. The persisted file will reflect an older version of the file. • kOutOfStorageSpace: The content of the file will have been updated, but the part of the operation that exceeded the quota will have been discarded. The current position will be at the end of the file.
Writes the content of a StringView to the file. This operator is just a comfort feature for non-safety critical Persistency users. If an error occurs during this operation, it is silently ignored.
Reduces the size of the file to ’size’, effectively removing the current content of the file beyond this size. The current file position is unchanged if it is lower than ’size’, or set to the last valid position in the file otherwise. If ’size’ is 0, the current file position will also be set to 0.
Flushes the current file content to the physical storage.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: c625990570f3ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function SyncToFile of class ara::per::WriteAccessor (defined in #include "ara/per/write_accessor.h") synchronously transfers the current file content to physical storage [SWS_PER_00122]. The call takes no arguments and returns a ara::core::Result<void> that is empty in the event of success or, in the event of an error, contains specific error codes of the Persistency module or vendor-specific errors [SWS_PER_00122].
During execution, different error cases can occur, some of which have rollback semantics [SWS_PER_00122]:
StorageFailure: Occurs if physical access to the storage medium fails (no rollback semantics) [SWS_PER_00122].
PerErrc::kOutOfStorageSpace: Is returned if the physical storage space is insufficient for the modified file (no rollback semantics) [SWS_PER_00122].
PerErrc::kQuotaExceeded: Is reported when the file exceeds the configured maximum size AllowedSize of the file storage (with rollback semantics) [SWS_PER_00122].
PerErrc::kEncryptionFailed: Encryption of the stored data fails (with rollback semantics) [SWS_PER_00122].
PerErrc::kAuthenticationFailed: Calculation of the MAC for the data fails (with rollback semantics) [SWS_PER_00122].
Regarding execution safety, the method is declared as noexcept and specified as exception safe[SWS_PER_00122]. However, since it is explicitly classified as not thread-safe, concurrent calls on the same WriteAccessor instance presumably have to be synchronized by the caller [SWS_PER_00122]. Question Q-e4b139f136cdcd31 (open)
This usage note was generated automatically based on the AUTOSAR R25-11 specification.
Writes the content of a Span of Byte to the file. The time when the content is persisted depends on the implementation of Persistency. SyncTo File can be used to force Persistency to persist the file content. In case of an error, the file content might be corrupted, and the current position might or might not have changed. The expected state of the file for each supported error can be expected to be as follows: • kPhysicalStorageFailure: The state of the file is unknown. It could have been entirely destroyed. • kEncryptionFailed: The content of the file and the current position will have been updated, but could not be persisted. The persisted file will reflect an older version of the file. • kOutOfStorageSpace: The content of the file will have been updated, but the part of the operation that exceeded the quota will have been discarded. The current position will be at the end of the file.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 65db1acb87c9Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The function WriteBinary of class ara::per::WriteAccessor writes the content of a byte sequence (ara::core::Span<const ara::core::Byte>) to a file [SWS_PER_00423]. The point in time of actual persistence on the storage medium depends on the implementation of Persistency; synchronous persisting can be forced via SyncToFile[SWS_PER_00423]. The function is declared as noexcept and is considered exception-safe [SWS_PER_00423].
With regard to concurrency, WriteBinary is specified as not thread-safe (not thread-safe) [SWS_PER_00423]. Parallel accesses to the same accessor must be synchronized at application level.
In the event of an error, an error code is returned in ara::core::Result<void>, whereby the file content may be corrupted and the current position may have changed [SWS_PER_00423]:
PerErrc::kPhysicalStorageFailure: State of the file is unknown and may be completely corrupted (no rollback semantics) [SWS_PER_00423].
PerErrc::kOutOfStorageSpace: Insufficient physical storage; data exceeding the quota is discarded and the file position is at the end [SWS_PER_00423].
PerErrc::kQuotaExceeded: The write operation would exceed the configured maximum size AllowedSize[SWS_PER_00423].
PerErrc::kEncryptionFailed: Encryption fails; file content and position are updated, but not persisted (persisted file retains previous version) [SWS_PER_00423].
PerErrc::kAuthenticationFailed or PerErrc::kValidationFailed: MAC calculation/verification fails or the validity of stored data is not guaranteed [SWS_PER_00423].
This usage note was generated automatically based on specification element [SWS_PER_00423].
Writes the content of a StringView to the file. The time when the content is persisted depends on the implementation of Persistency. SyncTo File can be used to force Persistency to persist the file content. In case of an error, the file content might be corrupted, and the current position might or might not have changed. The expected state of the file for each supported error can be expected to be as follows: • kPhysicalStorageFailure: The state of the file is unknown. It could have been entirely destroyed. • kEncryptionFailed: The content of the file and the current position will have been updated, but could not be persisted. The persisted file will reflect an older version of the file. • kOutOfStorageSpace: The content of the file will have been updated, but the part of the operation that exceeded the quota will have been discarded. The current position will be at the end of the file.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: f24ce7c436f3ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The synchronous method WriteText of interface ara::per::WriteAccessor writes the content of a ara::core::StringView into the opened file [SWS_PER_00166]. The function is specified as exception-safe (exception safe) and declares no throwing of C++ exceptions (noexcept) [SWS_PER_00166]. The exact point in time of physical storage depends on the Persistency implementation; immediate saving to the storage medium can be forced via SyncToFile[SWS_PER_00166].
Error handling
The return value is a ara::core::Result<void>, which in the event of an error reports error codes from PerErrc or vendor-specific errors [SWS_PER_00166]. If the operation fails, the file content may be corrupted and the write position may have changed [SWS_PER_00166]:
PerErrc::kPhysicalStorageFailure: Physical storage access failed; the file state is unknown or the file is corrupted [SWS_PER_00166].
PerErrc::kEncryptionFailed: Encryption fails; file content and position in memory are updated, but cannot be persisted, leaving an older persisted state [SWS_PER_00166].
PerErrc::kOutOfStorageSpace: Insufficient physical storage space; data beyond the quota is discarded and the position is at the end of the file [SWS_PER_00166].
PerErrc::kQuotaExceeded, PerErrc::kValidationFailed, and PerErrc::kAuthenticationFailed: Report quota violations (AllowedSize) as well as validation or authentication errors while maintaining rollback semantics [SWS_PER_00166].
Concurrency and Limitations
The operation is classified as not thread-safe (not thread-safe) [SWS_PER_00166]. In the case of parallel accesses to the same instance of WriteAccessor, callers presumably have to synchronize calls independently. Question Q-73a6dbdb7d3df643 (open)
This usage note is based on the AUTOSAR Adaptive Platform R25-11 specification.
Writes the content of a StringView to the file. This operator is just a comfort feature for non-safety critical Persistency users. If an error occurs during this operation, it is silently ignored.
gemini-3.8-flash-low· 2026-10-13 · German original