class ReadAccessor : public virtual FileAccessor {...};
ReadAccessor is used to read file data. It provides binary and text mode methods for checking or getting the current byte/character (PeekByte/PeekChar, GetByte/GetChar) methods for reading a section of a binary/text file (Read Binary/ReadText), a method to read a line of text (ReadLine).
Enables block-by-block, line-by-line, or character-based reading of persisted file and binary data.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 811820211677ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Enables block-by-block, line-by-line, or character-based reading of persisted file and binary data.
The class ara::per::ReadAccessor provides synchronous methods for sequential and line-based reading of files in binary and text modes [SWS_PER_00421], [SWS_PER_00119]. In addition to consuming reads, it allows pointer-neutral previewing of subsequent bytes or characters. Because instances are not thread-safe, concurrent accesses must be coordinated externally, while a rollback guarantee protects the read pointer position in the event of an error [SWS_PER_00419].
Context and Scope
The class ara::per::ReadAccessor provides an interface for synchronous reading of file contents within persistence management (module per) and derives virtually from FileAccessor. It abstracts read access to persisted data storage and provides both binary and textual access methods. Applications can inspect and retrieve individual bytes or characters as well as read contiguous blocks or complete lines via specialized functions.
Life cycle and concurrency
The default constructor of ReadAccessor is deleted [SWS_PER_00461]; instantiation therefore typically occurs mediated via higher-level opening and access mechanisms of the persistence module. The interface and bound access resources are released via the virtual destructor ~ReadAccessor()[SWS_PER_00417]. Instances of ReadAccessor possess an internal read pointer that manages the current position in the file. All methods of the class are explicitly specified as not thread-safe (not thread-safe) [SWS_PER_00419], which is why concurrent read operations on the same instance must be synchronized externally by callers.
Usage Paths for Binary and Text Data
For binary file operations, the class offers functions for previewable or sequential reading. With PeekByte(), the byte at the current read position can be inspected without modifying the read pointer [SWS_PER_00418]. In contrast, GetByte() reads exactly one byte and advances the position [SWS_PER_00419]. Larger data blocks can be read into a ara::core::Vector<ara::core::Byte> via ReadBinary(n), adjusting the position accordingly; if the end of the file is reached prematurely, the vector contains fewer bytes than requested [SWS_PER_00422]. Using ReadBinary(), all remaining bytes up to the end of the file can be obtained in a single step [SWS_PER_00421].
Sequence diagram: Typical flow of a sequential read access with advance inspection and section-by-section data processing. Sources: [SWS_PER_00418], [SWS_PER_00422], [SWS_PER_00421].
In text mode, PeekChar() provides a character-based preview [SWS_PER_00167], while GetChar() consumes the next character [SWS_PER_00168]. Line-by-line reading is performed via ReadLine(), which reads up to a delimiter (default: '\n', ASCII 0x0a); the delimiter is not included in the resulting string [SWS_PER_00119]. Sections of n characters or the entire remaining content can be read via the overloads of ReadText()[SWS_PER_00165], [SWS_PER_00420]. If the read pointer is located in the middle of a multi-byte character, the resulting character strings may exhibit incomplete Unicode code points [SWS_PER_00119], [SWS_PER_00165].
Error Scenarios and Error Handling
All read operations of ReadAccessor return their values encapsulated in a ara::core::Result and are specified as exception-safe (exception safe) [SWS_PER_00419]. If an error occurs during an access, strict rollback semantics apply: the current position of the read pointer always remains unchanged in case of an error [SWS_PER_00421], [SWS_PER_00422]. Typical documented error conditions include:
PerErrc::kPhysicalStorageFailure in the event of errors of the physical storage medium [SWS_PER_00419], [SWS_PER_00420],
Reads all remaining bytes into a Vector of Byte, starting from the current position. The current position is set to the end of the file. In case of an error, the current position is not changed.
Reads a complete line of characters into a String, advancing the current position accordingly. The end of the line is demarcated by the delimiter, or by "\\n" (ASCII 0x0a) if that parameter is omitted. The delimiter itself is not included in the returned String. Only Unicode code points with one character (code unit) can be used as delimiters. The returned string may start with an incomplete Unicode code point in case the current read position is in the middle of a code point. If the end of the file is reached, the remaining characters are returned and the current position is set to the end of the file. In case of an error, the current position is not changed.
Reads a number of characters into a String, starting from the current position. The returned string may start and/or end with incomplete Unicode code points in case the current read position and/or the last read character (code unit) is in the middle of a code point. The current position is advanced accordingly. If the end of the file is reached, the number of returned characters can be less than the requested number, and the current position is set to the end of the file. In case of an error, the current position is not changed.
Returns the byte at the current position of the file. The current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: eb387be6a3cfProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The synchronous member function PeekByte of class ara::per::ReadAccessor reads a single byte at the current position of the file without changing the file position [SWS_PER_00418]. The function requires inclusion of header ara/per/read_accessor.h, takes no parameters, and returns the read value in a ara::core::Result<ara::core::Byte>[SWS_PER_00418].
If an error occurs during access, the return object contains either a vendor-specific error code or one of the defined errors from PerErrc[SWS_PER_00418]:
PerErrc::kEof: The current position is at the end of the file or the file is empty.
PerErrc::kPhysicalStorageFailure: Access to physical storage has failed.
PerErrc::kValidationFailed: The validity of the stored data cannot be guaranteed.
PerErrc::kEncryptionFailed: Decryption of the stored data failed.
PerErrc::kAuthenticationFailed: Verification of the MAC (message authentication code) failed.
Regarding execution safety, the method is declared as noexcept and exception safe[SWS_PER_00418]. However, since the specification classifies PeekByte as not thread-safe, parallel calls on the same instance of ara::per::ReadAccessor likely require application-side synchronization [SWS_PER_00418]. Question Q-14b3334052f6c810 (open)
This usage note was generated by an AI based on the AUTOSAR specification R25-11.
Returns the character at the current position of the file. The current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: b4d92aee30b2Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The method PeekChar of class ara::per::ReadAccessor (header #include "ara/per/read_accessor.h") reads the character at the current position of a file without changing the read pointer [SWS_PER_00167].
use
The function has the signature ara::core::Result<char> PeekChar() const noexcept;. It operates synchronously, is declared as const, and guarantees exception safety (exception safe) [SWS_PER_00167]. The return value is a ara::core::Result<char>, which contains the read character in the event of success [SWS_PER_00167].
Error handling
If an error occurs, the ara::core::Result provides vendor-specific errors or one of the following error codes from PerErrc[SWS_PER_00167]:
PerErrc::kEof: The current read position has reached the end of the file or the file is empty [SWS_PER_00167].
PerErrc::kPhysicalStorageFailure: Access to the physical storage medium failed [SWS_PER_00167].
PerErrc::kValidationFailed: The validity of the stored data cannot be ensured [SWS_PER_00167].
PerErrc::kEncryptionFailed: Decryption of the stored data has failed [SWS_PER_00167].
PerErrc::kAuthenticationFailed: Verification of the message authentication code (MAC) of the data failed [SWS_PER_00167].
Concurrency and Limitations
The operation is not thread-safe (not thread-safe) [SWS_PER_00167]. Therefore, parallel accesses to the same ReadAccessor instance must be synchronized by the caller.
This usage note is based on the specification AUTOSAR Adaptive Release R25-11.
Reads all remaining bytes into a Vector of Byte, starting from the current position. The current position is set to the end of the file. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 325f0e841208ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The parameterless method ReadBinary of class ara::per::ReadAccessor synchronously reads all bytes remaining from the current file position up to the end of the file into a ara::core::Vector<ara::core::Byte>[SWS_PER_00421]. After a successful read operation, the current file position is set to the end of the file [SWS_PER_00421]. The return value is encapsulated as ara::core::Result and declared as noexcept; interpretation: since no asynchronous return type is present, the method is likely to block the caller. Question Q-8e6054123cea57ac (open)
If an error occurs during reading, the original file position is preserved unchanged [SWS_PER_00421]. In this case, the returned ara::core::Result contains either vendor-specific errors or one of the specific error codes from PerErrc[SWS_PER_00421]:
PerErrc::kValidationFailed: The validity of the stored data cannot be ensured [SWS_PER_00421].
PerErrc::kEncryptionFailed: Decryption of the data fails [SWS_PER_00421].
PerErrc::kAuthenticationFailed: Verification of the MAC fails [SWS_PER_00421].
PerErrc::kEof: The file is empty or the read position is already at the end of the file [SWS_PER_00421].
The function is defined as exception-safe (exception safe), but explicitly as not thread-safe (not thread-safe) [SWS_PER_00421]. Concurrent calls on the same ReadAccessor must therefore be coordinated by the caller. If not all remaining file content is to be read at once, but only a subset of bytes, the overloaded variant ReadBinary(std::uint64_t n) is to be used instead [SWS_PER_00422].
This text was created by an AI. All statements are based on the requirements of the AUTOSAR specification.
Reads a number of bytes into a Vector of Byte, starting from the current position. The current position is advanced accordingly. If the end of the file is reached, the number of returned bytes can be less than the requested number, and the current position is set to the end of the file. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 4e14906b2550Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Starting from the current file position, the function ReadBinary of class ara::per::ReadAccessor synchronously reads up to n bytes into a ara::core::Vector<ara::core::Byte>[SWS_PER_00422]. Upon a successful read operation, the current file position is advanced by the number of bytes read; if the end of the file is reached in the process, the returned vector may contain fewer than n bytes, and the file position remains at the end of the file [SWS_PER_00422].
If an error occurs during the read operation, the file position is not changed [SWS_PER_00422]. Error handling is performed via the returned ara::core::Result, which may contain specific error codes from PerErrc or vendor-specific errors [SWS_PER_00422]:
PerErrc::kPhysicalStorageFailure: Access to physical storage fails [SWS_PER_00422].
PerErrc::kValidationFailed: Validation of the stored data cannot be ensured [SWS_PER_00422].
PerErrc::kEncryptionFailed: Decryption of the stored data fails [SWS_PER_00422].
PerErrc::kEof: The current position is already at the end of the file or the file is empty [SWS_PER_00422].
PerErrc::kAuthenticationFailed: Verification of the MAC (Message Authentication Code) of the data fails [SWS_PER_00422].
Regarding concurrency, the method is specified as not thread-safe, which is why parallel accesses to the same accessor must be synchronized on the application side; however, it is declared as exception safe and annotated with noexcept[SWS_PER_00422]. In contrast to the parameterless overload [SWS_PER_00421], which always reads all remaining bytes up to the end of the file, this variant permits the piecewise reading of defined block sizes.
This text was generated by an AI and serves as a curation aid.
Reads a complete line of characters into a String, advancing the current position accordingly. The end of the line is demarcated by the delimiter, or by "\\n" (ASCII 0x0a) if that parameter is omitted. The delimiter itself is not included in the returned String. Only Unicode code points with one character (code unit) can be used as delimiters. The returned string may start with an incomplete Unicode code point in case the current read position is in the middle of a code point. If the end of the file is reached, the remaining characters are returned and the current position is set to the end of the file. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 30f46bde066bProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The synchronous method ReadLine of class ara::per::ReadAccessor reads a complete line up to a specified delimiter into a ara::core::String and advances the read position accordingly [SWS_PER_00119]. By default, \n (ASCII 0x0a) acts as delimiter; only Unicode code points consisting of a single code unit are permitted as delimiter[SWS_PER_00119]. The delimiter itself is not included in the resulting string. If the read operation reaches the end of the file, all characters remaining up to that point are returned and the position is set to the end of the file [SWS_PER_00119].
Error handling
The function returns a ara::core::Result<ara::core::String>[SWS_PER_00119]. If an error occurs, the current position is not modified [SWS_PER_00119]. The specified errors include:
PerErrc::kEof: The current read position is at the end of the file or the file is empty [SWS_PER_00119].
StorageFailure: Access to physical storage fails [SWS_PER_00119].
PerErrc::kValidationFailed: The validity of the stored data cannot be ensured [SWS_PER_00119].
PerErrc::kEncryptionFailed: Decryption of the data fails [SWS_PER_00119].
PerErrc::kAuthenticationFailed: Verification of the Message Authentication Code (MAC) fails [SWS_PER_00119].
Concurrency and Constraints
The method is declared as noexcept and is exception-safe ("exception safe"), but explicitly not thread-safe ("not thread-safe") [SWS_PER_00119]. Interpretation: Concurrent calls on the same ReadAccessor instance will likely require external synchronization. Question Q-307b6e250938c76b (open) If the current read position is located in the middle of a multi-part Unicode code point, the returned string may begin with an incomplete code point [SWS_PER_00119].
This text was created by an AI and is based on the AUTOSAR specification.
Reads a number of characters into a String, starting from the current position. The returned string may start and/or end with incomplete Unicode code points in case the current read position and/or the last read character (code unit) is in the middle of a code point. The current position is advanced accordingly. If the end of the file is reached, the number of returned characters can be less than the requested number, and the current position is set to the end of the file. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 042205956a20Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The synchronous member function ReadText of class ara::per::ReadAccessor reads up to n characters from the current file position into a ara::core::String[SWS_PER_00165]. Inclusion takes place via header #include "ara/per/read_accessor.h"[SWS_PER_00165].
Usage and Semantics
The method is called with parameter std::uint64_t n and returns a ara::core::Result<ara::core::String>[SWS_PER_00165]. Upon a successful read operation, the current read position is advanced according to the number of characters read [SWS_PER_00165]. If the read operation reaches the end of the file, the number of returned characters can be smaller than the requested n; the file position is thereby set to the end of the file [SWS_PER_00165]. If the current read position or the last character (code unit) read lies in the middle of a Unicode code point, the returned string may begin or end with incomplete code points [SWS_PER_00165].
Error Handling and Boundary Conditions
In the event of an error, the file position remains unchanged [SWS_PER_00165]. The returned ara::core::Result can contain vendor-specific errors or the following error codes [SWS_PER_00165]:
PerErrc::kPhysicalStorageFailure: Physical storage access has failed [SWS_PER_00165].
PerErrc::kValidationFailed: The validity of the stored data cannot be ensured [SWS_PER_00165].
PerErrc::kEncryptionFailed: Decryption of the stored data has failed [SWS_PER_00165].
PerErrc::kEof: The current position is already at the end of the file or the file is empty [SWS_PER_00165].
PerErrc::kAuthenticationFailed: The MAC verification of the data has failed [SWS_PER_00165].
Regarding concurrency, the function is declared as exception-safe, but explicitly as not thread-safe [SWS_PER_00165]. Parallel calls on the same instance must consequently be synchronized.
Interaction
In addition to the overload with length limitation, a parameterless variant ReadText() exists [SWS_PER_00420], which reads all remaining characters up to the end of the file starting from the current position.
This text was created and curated by an AI. All statements are based on the specification of AUTOSAR release R25-11.
Reads all remaining characters into a String, starting from the current position. The returned string may start with an incomplete Unicode code point in case the current read position is in the middle of a code point. The current position is set to the end of the file. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d5efea9a0341Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The synchronous method ReadText of class ara::per::ReadAccessor reads all characters remaining from the current file position into a ara::core::String[SWS_PER_00420]. The function expects no parameters and sets the current position to the end of the file after successful reading [SWS_PER_00420]. If the read position is in the middle of a Unicode code point, the returned string may begin with an incomplete code point [SWS_PER_00420].
The return value is a ara::core::Result<ara::core::String>[SWS_PER_00420]. If an error occurs, the file position remains unchanged (rollback semantics) and the result contains either a vendor-specific error or an error code from PerErrc[SWS_PER_00420]:
PerErrc::kEof: The current position is already at the end of the file or the file is empty [SWS_PER_00420].
PerErrc::kPhysicalStorageFailure: Access to the physical storage fails [SWS_PER_00420].
PerErrc::kValidationFailed: The validity of the stored data cannot be ensured [SWS_PER_00420].
PerErrc::kEncryptionFailed: Decryption of the stored data fails [SWS_PER_00420].
PerErrc::kAuthenticationFailed: Verification of the Message Authentication Code (MAC) fails [SWS_PER_00420].
Regarding concurrency, ReadText is specified as exception-safe and declared with noexcept, but explicitly classified as not thread-safe [SWS_PER_00420].
In interaction with the related overload ReadText(std::uint64_t n), which reads at most n characters and advances the position accordingly [SWS_PER_00165], the parameterless variant serves to completely read in the entire remaining content up to the end of the file [SWS_PER_00420].
This usage note was created automatically based on the AUTOSAR specification R25-11.
gemini-3.8-flash-low· 2026-10-13 · German original