BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslx_testinstreamexception.h
Go to the documentation of this file.
1/// @file bslx_testinstreamexception.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslx_testinstreamexception.h -*-C++-*-
8#ifndef INCLUDED_BSLX_TESTINSTREAMEXCEPTION
9#define INCLUDED_BSLX_TESTINSTREAMEXCEPTION
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslx_testinstreamexception bslx_testinstreamexception
15/// @brief Provide an exception class for unexternalization operations.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslx
19/// @{
20/// @addtogroup bslx_testinstreamexception
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslx_testinstreamexception-purpose"> Purpose</a>
25/// * <a href="#bslx_testinstreamexception-classes"> Classes </a>
26/// * <a href="#bslx_testinstreamexception-description"> Description </a>
27/// * <a href="#bslx_testinstreamexception-usage"> Usage </a>
28/// * <a href="#bslx_testinstreamexception-example-1-throw-and-catch"> Example 1: Throw and Catch </a>
29///
30/// # Purpose {#bslx_testinstreamexception-purpose}
31/// Provide an exception class for unexternalization operations.
32///
33/// # Classes {#bslx_testinstreamexception-classes}
34///
35/// - bslx::TestInStreamException: exception containing unexternalization info
36///
37/// @see bslx_testinstream
38///
39/// # Description {#bslx_testinstreamexception-description}
40/// This component defines a simple exception object for testing
41/// exceptions during unexternalization operations. The exception object
42/// `bslx::TestInStreamException` contains information about an
43/// unexternalization request, which can be queried by the "catcher" of the
44/// exception.
45///
46/// ## Usage {#bslx_testinstreamexception-usage}
47///
48///
49/// This section illustrates intended use of this component.
50///
51/// ### Example 1: Throw and Catch {#bslx_testinstreamexception-example-1-throw-and-catch}
52///
53///
54/// In the following example, the `bslx::TestInStreamException` object is
55/// thrown, caught, and examined. First, set up a `try` block and throw the
56/// exception with the indication that the exception occurred during
57/// unexternalization of an `unsigned int`:
58/// @code
59/// try {
60/// throw TestInStreamException(bslx::TypeCode::e_UINT32);
61/// @endcode
62/// Then, catch the exception and verify the indicated cause of the exception:
63/// @code
64/// } catch (const bslx::TestInStreamException& e) {
65/// assert(bslx::TypeCode::e_UINT32 == e.dataType());
66/// }
67/// @endcode
68/// @}
69/** @} */
70/** @} */
71
72/** @addtogroup bsl
73 * @{
74 */
75/** @addtogroup bslx
76 * @{
77 */
78/** @addtogroup bslx_testinstreamexception
79 * @{
80 */
81
82#include <bslscm_version.h>
83
84#include <bslx_typecode.h>
85
86
87namespace bslx {
88
89 // ===========================
90 // class TestInStreamException
91 // ===========================
92
93/// This class defines an exception object for unexternalization operations.
94/// Instances of this class contain information about an unexternalization
95/// request.
96///
97/// See @ref bslx_testinstreamexception
99
100 // DATA
101 TypeCode::Enum d_dataType; // type of the input data requested
102
103 public:
104 // CREATORS
105
106 /// Create an exception object initialized with the specified `type`.
108
110 // Destroy this object. Note that this method's definition is compiler
111 // generated.
112
113 // ACCESSORS
114
115 /// Return the type code that was supplied at construction of this
116 /// exception object.
117 TypeCode::Enum dataType() const;
118};
119
120// ============================================================================
121// INLINE DEFINITIONS
122// ============================================================================
123
124 // ---------------------------
125 // class TestInStreamException
126 // ---------------------------
127
128// CREATORS
129inline
134
135// ACCESSORS
136inline
138{
139 return d_dataType;
140}
141
142} // close package namespace
143
144
145#endif
146
147// ----------------------------------------------------------------------------
148// Copyright 2014 Bloomberg Finance L.P.
149//
150// Licensed under the Apache License, Version 2.0 (the "License");
151// you may not use this file except in compliance with the License.
152// You may obtain a copy of the License at
153//
154// http://www.apache.org/licenses/LICENSE-2.0
155//
156// Unless required by applicable law or agreed to in writing, software
157// distributed under the License is distributed on an "AS IS" BASIS,
158// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159// See the License for the specific language governing permissions and
160// limitations under the License.
161// ----------------------------- END-OF-FILE ----------------------------------
162
163/** @} */
164/** @} */
165/** @} */
Definition bslx_testinstreamexception.h:98
TestInStreamException(TypeCode::Enum type)
Create an exception object initialized with the specified type.
Definition bslx_testinstreamexception.h:130
TypeCode::Enum dataType() const
Definition bslx_testinstreamexception.h:137
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslx_byteinstream.h:377
Enum
Definition bslx_typecode.h:156