Iter
Description
Memory iterators are there to allow reading regions of memory by remembering current read position and the size limit. With proper checking we can guarantee that we can never overflow or underflow when reading a memory region.
This also means that Iter objects are created for use with only one reading operation, and only one object in their lifetime.
The designed API does not allow modifications to the data Iter is iterating over.
Fields
| Name | Description |
|---|---|
data |
Pointer to memory we’re iterating over |
length |
Number of objects in memory. |
pos |
Current iterating position. |
alignment |
Alignment requirements (if-any), must be at-least 1 |
dir |
Iteration direction, -1 or 1 |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Iter.Deadend.c:3:
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Types.h>
int main(void) {
WriteFmt("[INFO] Starting Iter.Deadend tests\n\n");
TestFunction tests[] = {
deadend_must_read_eof, };
int total = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(NULL, 0, tests, total, "Iter.Deadend");
}- In
Iter.c:3:
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Types.h>- In
Iter.c:226:
int main(void) {
WriteFmt("[INFO] Starting Iter tests\n\n");
TestFunction tests[] = {
test_iter_remaining_forward,- In
Iter.c:245:
};
int total = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total, NULL, 0, "Iter");
}- In
Utility.h:12:
#include <Misra/Types.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Std/Utility/Pair.h>
#include <Misra/Std/Utility/StrIter.h>- In
Iter.h:11:
// clang-format off
#include "Iter/Type.h"
#include "Iter/Init.h"
#include "Iter/Access.h"- In
Iter.h:12:
// clang-format off
#include "Iter/Type.h"
#include "Iter/Init.h"
#include "Iter/Access.h"
#include "Iter/Move.h"- In
Iter.h:13:
#include "Iter/Type.h"
#include "Iter/Init.h"
#include "Iter/Access.h"
#include "Iter/Move.h"
#include "Iter/Private.h"- In
Iter.h:14:
#include "Iter/Init.h"
#include "Iter/Access.h"
#include "Iter/Move.h"
#include "Iter/Private.h"
// clang-format on
- In
Iter.h:15:
#include "Iter/Access.h"
#include "Iter/Move.h"
#include "Iter/Private.h"
// clang-format on
- In
StrIter.h:16:
#include <Misra/Std/Container/Vec/Type.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Types.h>- In
StrIter.h:19:
#include <Misra/Types.h>
typedef Iter(char) StrIter;
typedef Vec(StrIter) StrIters;- In
Buf.h:15:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Buf.h:23:
/// Iterator over an immutable byte buffer. Layout matches `Iter(const u8)`
/// so the generic Iter macros work on it.
typedef Iter(const u8) BufIter;
// ---------------------------------------------------------------------------
- In
Access.h:7:
#define MISRA_STD_CONTAINER_VEC_ACCESS_H
#include <Misra/Std/Utility/Iter.h>
#include "Type.h"- In
Type.h:11:
#include <Misra/Std/Container/Vec/Type.h>
#include <Misra/Std/Utility/Iter/Type.h>
#include <Misra/Types.h>
Last updated on