BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlat_fuzzutiloptions.h
Go to the documentation of this file.
1/// @file bdlat_fuzzutiloptions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlat_fuzzutiloptions.h -*-C++-*-
8#ifndef INCLUDED_BDLAT_FUZZUTILOPTIONS
9#define INCLUDED_BDLAT_FUZZUTILOPTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlat_fuzzutiloptions bdlat_fuzzutiloptions
15/// @brief Provide options for `bdlat::FuzzUtil`.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlat
19/// @{
20/// @addtogroup bdlat_fuzzutiloptions
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlat_fuzzutiloptions-purpose"> Purpose</a>
25/// * <a href="#bdlat_fuzzutiloptions-classes"> Classes </a>
26/// * <a href="#bdlat_fuzzutiloptions-description"> Description </a>
27///
28/// # Purpose {#bdlat_fuzzutiloptions-purpose}
29/// Provide options for `bdlat::FuzzUtil`.
30///
31/// # Classes {#bdlat_fuzzutiloptions-classes}
32///
33/// - bdlat::FuzzUtilOptions: options for `bdlat::FuzzUtil`
34///
35/// @see bdlat_fuzzutil
36///
37/// # Description {#bdlat_fuzzutiloptions-description}
38/// This component provides a set of customization options for
39/// `bdlat::FuzzUtil`, e.g. limits on the lengths of generated strings and
40/// arrays.
41/// @}
42/** @} */
43/** @} */
44
45/** @addtogroup bdl
46 * @{
47 */
48/** @addtogroup bdlat
49 * @{
50 */
51/** @addtogroup bdlat_fuzzutiloptions
52 * @{
53 */
54
55#include <bslscm_version.h>
56
57
58namespace bdlat {
59
60 // =====================
61 // class FuzzUtilOptions
62 // =====================
63
64/// Options for `bdlat::FuzzUtil`.
65///
66/// See @ref bdlat_fuzzutiloptions
68 // DATA
69 unsigned d_maxArrayLength;
70 unsigned d_maxStringLength;
71 bool d_printableAsciiCharsOnly;
72
73 public:
74 // TYPES
75
76 /// Default values
77 static const unsigned k_MAX_ARRAY_LENGTH_DEFAULT = 8;
78 static const unsigned k_MAX_STRING_LENGTH_DEFAULT = 32;
79 static const bool k_PRINTABLE_ASCII_CHARS_ONLY_DEFAULT = true;
80
81 // CREATORS
82
83 /// Set all the attributes to to the corresponding default values.
85
86 // MANIPULATORS
87
88 /// Set the maximum array length to the specified `value`. Return a
89 /// reference to `*this`.
90 FuzzUtilOptions& setMaxArrayLength(unsigned value);
91
92 /// Set the maximum string length to the specified `value`. Return a
93 /// reference to `*this`.
94 FuzzUtilOptions& setMaxStringLength(unsigned value);
95
96 /// Set whether to generate only printable ASCII characters for strings.
98
99 // ACCESSORS
100
101 /// Return the maximum array length.
102 unsigned maxArrayLength() const;
103
104 /// Return the maximum string length.
105 unsigned maxStringLength() const;
106
107 /// Return whether to generate only printable ASCII characters for strings.
108 bool printableAsciiCharsOnly() const;
109};
110
111// FREE OPERATORS
112
113/// Return `true` if the specified `lhs` and `rhs` objects have the same value,
114/// and `false` otherwise. Two `FuzzUtilOptions` objects have the same value
115/// if all of the corresponding values of their `maxArrayLength`,
116/// `maxStringLength`, and `printableAsciiCharsOnly` attributes are the same.
117bool operator==(const FuzzUtilOptions& lhs, const FuzzUtilOptions& rhs);
118
119/// Return `true` if the specified `lhs` and `rhs` objects do not have the same
120/// value, and `false` otherwise. Two `FuzzUtilOptions` objects do not have
121/// the same value if any of the corresponding values of their
122/// `maxArrayLength`, `maxStringLength`, and `printableAsciiCharsOnly`
123/// attributes are not the same.
124bool operator!=(const FuzzUtilOptions& lhs, const FuzzUtilOptions& rhs);
125
126// ============================================================================
127// INLINE DEFINITIONS
128// ============================================================================
129
130 // ---------------------
131 // class FuzzUtilOptions
132 // ---------------------
133
134// MANIPULATORS
135inline
137{
138 d_maxArrayLength = value;
139 return *this;
140}
141
142inline
144{
145 d_maxStringLength = value;
146 return *this;
147}
148
149inline
151{
152 d_printableAsciiCharsOnly = value;
153 return *this;
154}
155
156// ACCESSORS
157inline
159{
160 return d_maxArrayLength;
161}
162
163inline
165{
166 return d_maxStringLength;
167}
168
169inline
171{
172 return d_printableAsciiCharsOnly;
173}
174
175} // close package namespace
176
177// FREE OPERATORS
178inline
179bool bdlat::operator==(const FuzzUtilOptions& lhs, const FuzzUtilOptions& rhs)
180{
181 return lhs.maxArrayLength() == rhs.maxArrayLength()
182 && lhs.maxStringLength() == rhs.maxStringLength()
183 && lhs.printableAsciiCharsOnly() == rhs.printableAsciiCharsOnly();
184}
185
186inline
187bool bdlat::operator!=(const FuzzUtilOptions& lhs, const FuzzUtilOptions& rhs)
188{
189 return !(lhs == rhs);
190}
191
192
193
194#endif
195
196// ----------------------------------------------------------------------------
197// Copyright 2025 Bloomberg Finance L.P.
198//
199// Licensed under the Apache License, Version 2.0 (the "License");
200// you may not use this file except in compliance with the License.
201// You may obtain a copy of the License at
202//
203// http://www.apache.org/licenses/LICENSE-2.0
204//
205// Unless required by applicable law or agreed to in writing, software
206// distributed under the License is distributed on an "AS IS" BASIS,
207// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208// See the License for the specific language governing permissions and
209// limitations under the License.
210// ----------------------------- END-OF-FILE ----------------------------------
211
212/** @} */
213/** @} */
214/** @} */
Definition bdlat_fuzzutiloptions.h:67
static const bool k_PRINTABLE_ASCII_CHARS_ONLY_DEFAULT
Definition bdlat_fuzzutiloptions.h:79
FuzzUtilOptions()
Set all the attributes to to the corresponding default values.
bool printableAsciiCharsOnly() const
Return whether to generate only printable ASCII characters for strings.
Definition bdlat_fuzzutiloptions.h:170
FuzzUtilOptions & setPrintableAsciiCharsOnly(bool value)
Set whether to generate only printable ASCII characters for strings.
Definition bdlat_fuzzutiloptions.h:150
static const unsigned k_MAX_STRING_LENGTH_DEFAULT
Definition bdlat_fuzzutiloptions.h:78
unsigned maxStringLength() const
Return the maximum string length.
Definition bdlat_fuzzutiloptions.h:164
FuzzUtilOptions & setMaxArrayLength(unsigned value)
Definition bdlat_fuzzutiloptions.h:136
static const unsigned k_MAX_ARRAY_LENGTH_DEFAULT
Default values.
Definition bdlat_fuzzutiloptions.h:77
FuzzUtilOptions & setMaxStringLength(unsigned value)
Definition bdlat_fuzzutiloptions.h:143
unsigned maxArrayLength() const
Return the maximum array length.
Definition bdlat_fuzzutiloptions.h:158
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlat_arrayutil.h:198
bool operator!=(const FuzzUtilOptions &lhs, const FuzzUtilOptions &rhs)
bool operator==(const FuzzUtilOptions &lhs, const FuzzUtilOptions &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917