BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balcl_constraint.h
Go to the documentation of this file.
1/// @file balcl_constraint.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// balcl_constraint.h -*-C++-*-
8#ifndef INCLUDED_BALCL_CONSTRAINT
9#define INCLUDED_BALCL_CONSTRAINT
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup balcl_constraint balcl_constraint
15/// @brief Define constraint function signatures for supported value types.
16/// @addtogroup bal
17/// @{
18/// @addtogroup balcl
19/// @{
20/// @addtogroup balcl_constraint
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#balcl_constraint-purpose"> Purpose</a>
25/// * <a href="#balcl_constraint-classes"> Classes </a>
26/// * <a href="#balcl_constraint-description"> Description </a>
27/// * <a href="#balcl_constraint-usage"> Usage </a>
28///
29/// # Purpose {#balcl_constraint-purpose}
30/// Define constraint function signatures for supported value types.
31///
32/// # Classes {#balcl_constraint-classes}
33///
34/// - balcl::Constraint: constraint function signatures for supported types
35///
36/// # Description {#balcl_constraint-description}
37/// This component defines a single `struct`, `balcl::Constraint`,
38/// that provides a namespace for function signatures used to impose
39/// user-defined constraints on values entered with command-line options (if so
40/// defined). Signatures are defined for each of the supported
41/// command-line-option values of scalar type.
42///
43/// For further details see @ref balcl_commandline-type-and-constraint-field and
44/// @ref balcl_commandline-example-type-and-constraint-field .
45///
46/// ## Usage {#balcl_constraint-usage}
47///
48///
49/// The intended use of this component is illustrated in
50/// @ref balcl_commandline-usage .
51/// @}
52/** @} */
53/** @} */
54
55/** @addtogroup bal
56 * @{
57 */
58/** @addtogroup balcl
59 * @{
60 */
61/** @addtogroup balcl_constraint
62 * @{
63 */
64
65#include <balscm_version.h>
66
67#include <bsls_types.h> // 'bsls::Types::Int64'
68
69#include <bsl_functional.h> // 'bsl::function'
70#include <bsl_iosfwd.h>
71#include <bsl_string.h>
72
73#include <bdlt_date.h>
74#include <bdlt_datetime.h>
75#include <bdlt_time.h>
76
77
78
79
80namespace balcl {
81 // =================
82 // struct Constraint
83 // =================
84
85/// This `struct` provides a namespace that defines the types used to impose
86/// user-defined constraints on values associated with command-line options.
87/// One type is defined for each scalar type defined in `balcl::OptionType`
88/// except for `bool`.
89struct Constraint {
90
91 // TYPES
92 typedef bsl::function<bool(const char *,
93 bsl::ostream& )> CharConstraint;
94 typedef bsl::function<bool(const int *,
95 bsl::ostream& )> IntConstraint;
96 typedef bsl::function<bool(const bsls::Types::Int64 *,
97 bsl::ostream& )> Int64Constraint;
98 typedef bsl::function<bool(const double *,
99 bsl::ostream& )> DoubleConstraint;
100 typedef bsl::function<bool(const bsl::string *,
101 bsl::ostream& )> StringConstraint;
102 typedef bsl::function<bool(const bdlt::Datetime *,
103 bsl::ostream& )> DatetimeConstraint;
104 typedef bsl::function<bool(const bdlt::Date *,
105 bsl::ostream& )> DateConstraint;
106
107 /// These types are aliases for function objects (functors) used to
108 /// express user-defined constraints on option values. Such objects
109 /// should return `true` if the supplied value (first argument) are
110 /// deemed valid, and `false` otherwise. Descriptive error messages may
111 /// be written to the supplied stream (second argument).
112 typedef bsl::function<bool(const bdlt::Time *,
113 bsl::ostream& )> TimeConstraint;
114};
115
116} // close package namespace
117
118
119#endif
120
121// ----------------------------------------------------------------------------
122// Copyright 2020 Bloomberg Finance L.P.
123//
124// Licensed under the Apache License, Version 2.0 (the "License");
125// you may not use this file except in compliance with the License.
126// You may obtain a copy of the License at
127//
128// http://www.apache.org/licenses/LICENSE-2.0
129//
130// Unless required by applicable law or agreed to in writing, software
131// distributed under the License is distributed on an "AS IS" BASIS,
132// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133// See the License for the specific language governing permissions and
134// limitations under the License.
135// ----------------------------- END-OF-FILE ----------------------------------
136
137/** @} */
138/** @} */
139/** @} */
Definition bdlt_date.h:294
Definition bdlt_datetime.h:331
Definition bdlt_time.h:196
Definition bslstl_string.h:1281
Forward declaration.
Definition bslstl_function.h:934
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balcl_commandline.h:1364
Definition balcl_constraint.h:89
bsl::function< bool(const bsl::string *, bsl::ostream &)> StringConstraint
Definition balcl_constraint.h:101
bsl::function< bool(const bdlt::Date *, bsl::ostream &)> DateConstraint
Definition balcl_constraint.h:105
bsl::function< bool(const double *, bsl::ostream &)> DoubleConstraint
Definition balcl_constraint.h:99
bsl::function< bool(const bsls::Types::Int64 *, bsl::ostream &)> Int64Constraint
Definition balcl_constraint.h:97
bsl::function< bool(const char *, bsl::ostream &)> CharConstraint
Definition balcl_constraint.h:93
bsl::function< bool(const bdlt::Datetime *, bsl::ostream &)> DatetimeConstraint
Definition balcl_constraint.h:103
bsl::function< bool(const int *, bsl::ostream &)> IntConstraint
Definition balcl_constraint.h:95
bsl::function< bool(const bdlt::Time *, bsl::ostream &)> TimeConstraint
Definition balcl_constraint.h:113
long long Int64
Definition bsls_types.h:132