BDE 4.39.x 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`.
89///
90/// See @ref balcl_constraint
91struct Constraint {
92
93 // TYPES
94 typedef bsl::function<bool(const char *,
95 bsl::ostream& )> CharConstraint;
96 typedef bsl::function<bool(const int *,
97 bsl::ostream& )> IntConstraint;
98 typedef bsl::function<bool(const bsls::Types::Int64 *,
99 bsl::ostream& )> Int64Constraint;
100 typedef bsl::function<bool(const double *,
101 bsl::ostream& )> DoubleConstraint;
102 typedef bsl::function<bool(const bsl::string *,
103 bsl::ostream& )> StringConstraint;
104 typedef bsl::function<bool(const bdlt::Datetime *,
105 bsl::ostream& )> DatetimeConstraint;
106 typedef bsl::function<bool(const bdlt::Date *,
107 bsl::ostream& )> DateConstraint;
108
109 /// These types are aliases for function objects (functors) used to
110 /// express user-defined constraints on option values. Such objects
111 /// should return `true` if the supplied value (first argument) are
112 /// deemed valid, and `false` otherwise. Descriptive error messages may
113 /// be written to the supplied stream (second argument).
114 typedef bsl::function<bool(const bdlt::Time *,
115 bsl::ostream& )> TimeConstraint;
116};
117
118} // close package namespace
119
120
121#endif
122
123// ----------------------------------------------------------------------------
124// Copyright 2020 Bloomberg Finance L.P.
125//
126// Licensed under the Apache License, Version 2.0 (the "License");
127// you may not use this file except in compliance with the License.
128// You may obtain a copy of the License at
129//
130// http://www.apache.org/licenses/LICENSE-2.0
131//
132// Unless required by applicable law or agreed to in writing, software
133// distributed under the License is distributed on an "AS IS" BASIS,
134// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135// See the License for the specific language governing permissions and
136// limitations under the License.
137// ----------------------------- END-OF-FILE ----------------------------------
138
139/** @} */
140/** @} */
141/** @} */
Definition bdlt_date.h:294
Definition bdlt_datetime.h:330
Definition bdlt_time.h:195
Definition bslstl_string.h:1252
Forward declaration.
Definition bslstl_function.h:946
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition balcl_commandline.h:1364
Definition balcl_constraint.h:91
bsl::function< bool(const bsl::string *, bsl::ostream &)> StringConstraint
Definition balcl_constraint.h:103
bsl::function< bool(const bdlt::Date *, bsl::ostream &)> DateConstraint
Definition balcl_constraint.h:107
bsl::function< bool(const double *, bsl::ostream &)> DoubleConstraint
Definition balcl_constraint.h:101
bsl::function< bool(const bsls::Types::Int64 *, bsl::ostream &)> Int64Constraint
Definition balcl_constraint.h:99
bsl::function< bool(const char *, bsl::ostream &)> CharConstraint
Definition balcl_constraint.h:95
bsl::function< bool(const bdlt::Datetime *, bsl::ostream &)> DatetimeConstraint
Definition balcl_constraint.h:105
bsl::function< bool(const int *, bsl::ostream &)> IntConstraint
Definition balcl_constraint.h:97
bsl::function< bool(const bdlt::Time *, bsl::ostream &)> TimeConstraint
Definition balcl_constraint.h:115
long long Int64
Definition bsls_types.h:134