BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslim::FuzzUtil Struct Reference

#include <bslim_fuzzutil.h>

Detailed Description

This utility struct provides a namespace for a suite of functions operating on objects of type FuzzDataViewand providing the consumption of fuzz data bytes into fundamental and standard library types.

See bslim_fuzzutil

Static Public Member Functions

static bool consumeBool (FuzzDataView *fuzzDataView)
 
template<class TYPE >
static bsl::enable_if< bsl::is_integral< TYPE >::value, TYPE >::type consumeNumber (FuzzDataView *fuzzDataView)
 
template<class TYPE >
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type consumeNumber (FuzzDataView *fuzzDataView)
 
template<class TYPE >
static bsl::enable_if< bsl::is_integral< TYPE >::value, TYPE >::type consumeNumberInRange (FuzzDataView *fuzzDataView, TYPE min, TYPE max)
 
template<class TYPE >
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type consumeNumberInRange (FuzzDataView *fuzzDataView, TYPE min, TYPE max)
 
static void consumeRandomLengthAsciiString (bsl::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 
static void consumeRandomLengthAsciiString (std::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 
static void consumeRandomLengthChars (bsl::vector< char > *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 
static void consumeRandomLengthChars (std::vector< char > *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 
static void consumeRandomLengthString (bsl::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 
static void consumeRandomLengthString (std::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
 

Member Function Documentation

◆ consumeBool()

bool bslim::FuzzUtil::consumeBool ( FuzzDataView fuzzDataView)
inlinestatic

Return a bool value based upon consuming a single byte from the specified fuzzDataView. If fuzzDataView->length() is 0, return false.

◆ consumeNumber() [1/2]

template<class TYPE >
bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type bslim::FuzzUtil::consumeNumber ( FuzzDataView fuzzDataView)
static

◆ consumeNumber() [2/2]

template<class TYPE >
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type bslim::FuzzUtil::consumeNumber ( FuzzDataView fuzzDataView)
static

Return a value of (template parameter) TYPE in the range [min .. max] – where min and max are the minimum and maximum values representable by the TYPE – based on at most the next sizeof(TYPE) + 1 bytes from the specified fuzzDataView, and update fuzzDataView to reflect the bytes consumed. If 0 == fuzzDataView->length(), return the minimum value of TYPE. This function does not participate in overload resolution unless either bsl::is_integral<TYPE>::value or bsl::is_floating_point<TYPE>::value is true.

Precondition
The behavior is undefined if bsl::is_same<TYPE, bool>::value or bsl::is_same<TYPE, long double> is true.

◆ consumeNumberInRange() [1/2]

template<class TYPE >
bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type bslim::FuzzUtil::consumeNumberInRange ( FuzzDataView fuzzDataView,
TYPE  min,
TYPE  max 
)
static

Return a value of (template parameter) TYPE in the specified range [min .. max] based on at most the next sizeof(TYPE) + 1 bytes from the specified fuzzDataView, and update fuzzDataView to reflect the bytes consumed. If 0 == fuzzDataView->length(), return the specified min. This function does not participate in overload resolution unless either bsl::is_integral<TYPE>::value or bsl::is_floating_point<TYPE>::value is true.

Precondition
The behavior is undefined if min > max, min or max is not finite, or either bsl::is_same<TYPE, bool>::value or bsl::is_same<TYPE, long double> is true.

◆ consumeNumberInRange() [2/2]

template<class TYPE >
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type bslim::FuzzUtil::consumeNumberInRange ( FuzzDataView fuzzDataView,
TYPE  min,
TYPE  max 
)
static

◆ consumeRandomLengthAsciiString() [1/2]

static void bslim::FuzzUtil::consumeRandomLengthAsciiString ( bsl::string output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

Load into the specified output a string consisting of printable ASCII characters of length from 0 to the specified maxLength. If the specified fuzzDataView has fewer bytes than maxLength, load at most fuzzDataView->length() bytes into output. If the buffer in fuzzDataView contains two successive backslash characters, then in output they will be converted to a single backslash (\\) character; if a single backslash character is encountered, the consumption of bytes is terminated.

Note
Note that because double backslashes are mapped to single backslashes, more than maxLength bytes may be consumed from the buffer to produce the output. Also note that the generated string is also a valid UTF-8 string.

◆ consumeRandomLengthAsciiString() [2/2]

static void bslim::FuzzUtil::consumeRandomLengthAsciiString ( std::string *  output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

◆ consumeRandomLengthChars() [1/2]

static void bslim::FuzzUtil::consumeRandomLengthChars ( bsl::vector< char > *  output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

Load into the specified output a sequence of characters of length from 0 to the specified maxLength. If the specified fuzzDataView has fewer bytes than maxLength, load at most fuzzDataView->length() bytes into output. If the buffer in fuzzDataView contains two successive backslash characters, then in output they will be converted to a single backslash (\\) character; if a single backslash character is encountered, the consumption of bytes is terminated.

Note
Note that because double backslashes are mapped to single backslashes, more than maxLength bytes may be consumed from the buffer to produce the output. Also note that the purpose of this function is to enable the creation of a non-zero-terminated string_view , which is not possible with the string counterpart.

◆ consumeRandomLengthChars() [2/2]

static void bslim::FuzzUtil::consumeRandomLengthChars ( std::vector< char > *  output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

◆ consumeRandomLengthString() [1/2]

static void bslim::FuzzUtil::consumeRandomLengthString ( bsl::string output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

Load into the specified output a string of length from 0 to the specified maxLength. If the specified fuzzDataView has fewer bytes than maxLength, load at most fuzzDataView->length() bytes into output. If the buffer in fuzzDataView contains two successive backslash characters, then in output they will be converted to a single backslash (\\) character; if a single backslash character is encountered, the consumption of bytes is terminated.

Note
Note that because double backslashes are mapped to single backslashes, more than maxLength bytes may be consumed from the buffer to produce the output.

◆ consumeRandomLengthString() [2/2]

static void bslim::FuzzUtil::consumeRandomLengthString ( std::string *  output,
FuzzDataView fuzzDataView,
bsl::size_t  maxLength 
)
static

The documentation for this struct was generated from the following file: