Software APIs
Public Member Functions
bootstrap_fuzzer::StreamParser Class Reference

Consumes values on demand from a non-owning span. More...

#include <sw/device/silicon_creator/lib/bootstrap_fuzzer_util.h>

Public Member Functions

 StreamParser (absl::Span< const uint8_t > data, bool verbose)
 For speed, the constructor does not make a copy of data. More...
 
 StreamParser (StreamParser &&)=default
 
 StreamParser (StreamParser &)=delete
 
spi_device_cmd_t ParseCmdOr (spi_device_cmd_t default_value)
 Attempts to parse a spi_device_cmd_t. More...
 
template<typename IntType >
IntType ParseIntOr (const char *log_label, IntType default_value)
 Attempts to parse an IntType from the stream. More...
 

Detailed Description

Consumes values on demand from a non-owning span.

Definition at line 24 of file bootstrap_fuzzer_util.h.

Constructor & Destructor Documentation

◆ StreamParser()

bootstrap_fuzzer::StreamParser::StreamParser ( absl::Span< const uint8_t >  data,
bool  verbose 
)
inline

For speed, the constructor does not make a copy of data.

Ensure that data points to memory that outlives this.

Parameters
dataNon-owning view into fuzzer-generated data.
verboseWhether verbose logging is enabled.

Definition at line 33 of file bootstrap_fuzzer_util.h.

Member Function Documentation

◆ ParseCmdOr()

spi_device_cmd_t bootstrap_fuzzer::StreamParser::ParseCmdOr ( spi_device_cmd_t  default_value)
inline

Attempts to parse a spi_device_cmd_t.

If there are not enough bytes, it returns default_value. When verbose_ is true, it describes the returned value in a human-readable string written to stdout

Definition at line 45 of file bootstrap_fuzzer_util.h.

◆ ParseIntOr()

template<typename IntType >
IntType bootstrap_fuzzer::StreamParser::ParseIntOr ( const char *  log_label,
IntType  default_value 
)
inline

Attempts to parse an IntType from the stream.

If there are not enough bytes, it returns default_value. When verbose_ is true, it uses log_label to write a human-readable message to stdout.

Definition at line 62 of file bootstrap_fuzzer_util.h.