BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlb_literalutil.h
Go to the documentation of this file.
1/// @file bdlb_literalutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlb_literalutil.h -*-C++-*-
8#ifndef INCLUDED_BDLB_LITERALUTIL
9#define INCLUDED_BDLB_LITERALUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlb_literalutil bdlb_literalutil
15/// @brief Provide utility routines for programming language literals.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlb
19/// @{
20/// @addtogroup bdlb_literalutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlb_literalutil-purpose"> Purpose</a>
25/// * <a href="#bdlb_literalutil-classes"> Classes </a>
26/// * <a href="#bdlb_literalutil-description"> Description </a>
27///
28/// # Purpose {#bdlb_literalutil-purpose}
29/// Provide utility routines for programming language literals.
30///
31/// # Classes {#bdlb_literalutil-classes}
32///
33/// - bdlb::LiteralUtil: utilities namespace for programming language literals
34///
35/// @see hslc_lexer, hslc_parser
36///
37/// # Description {#bdlb_literalutil-description}
38/// This component provides a namespace, `bdlb::LiteralUtil`, for a
39/// set of utility routines that operate on (programming language) literals.
40/// @}
41/** @} */
42/** @} */
43
44/** @addtogroup bdl
45 * @{
46 */
47/** @addtogroup bdlb
48 * @{
49 */
50/** @addtogroup bdlb_literalutil
51 * @{
52 */
53
54#include <bdlscm_version.h>
55
57
58#include <bsl_string.h>
59#include <bsl_string_view.h>
60
61#include <string> // 'std::string', 'std::pmr::string'
62
63
64namespace bdlb {
65
66 // ==================
67 // struct LiteralUtil
68 // ==================
69
71 private:
72 // PRIVATE CLASS METHODS
73
74 /// Load into the specified `result` string the `"` delimited and
75 /// escaped C/C++ string literal equivalent representing the same value
76 /// as that of the specified `input` string. When the C string literal
77 /// equivalent is translated by a compiler having C-compatible string
78 /// literals, it will result in a string identical to the `input` string.
79 ///
80 /// \note Note that this code uses the (ASCII) '\' character, rather
81 /// than Unicode code points for escapes.
82 template <class OUT_STR>
83 static void createQuotedEscapedCString_Impl(
84 OUT_STR *result,
85 const bsl::string_view& input);
86
87 public:
88 // CLASS METHODS
89
90 /// Load into the specified `result` string the `"` delimited and
91 /// escaped C/C++ string literal equivalent representing the same value
92 /// as that of the specified `input` string. When the C string literal
93 /// equivalent is translated by a compiler having C-compatible string
94 /// literals, it will result in a string identical to the `input` string.
95 ///
96 /// \note Note that this code uses the (ASCII) '\' character, rather
97 /// than Unicode code points for escapes.
99 const bsl::string_view& input);
100 static void createQuotedEscapedCString(std::string *result,
101 const bsl::string_view& input);
102
103#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
104 /// Load into the specified `result` string the `"` delimited and
105 /// escaped C/C++ string literal equivalent representing the same value
106 /// as that of the specified `input` string. When the C string literal
107 /// equivalent is translated by a compiler having C-compatible string
108 /// literals, it will result in a string identical to the `input` string.
109 ///
110 /// \note Note that this code uses the (ASCII) '\' character, rather
111 /// than Unicode code points for escapes.
112 static void createQuotedEscapedCString(std::pmr::string *result,
113 const bsl::string_view& input);
114#endif
115};
116
117} // close package namespace
118
119
120#endif
121
122// ----------------------------------------------------------------------------
123// Copyright 2020 Bloomberg Finance L.P.
124//
125// Licensed under the Apache License, Version 2.0 (the "License");
126// you may not use this file except in compliance with the License.
127// You may obtain a copy of the License at
128//
129// http://www.apache.org/licenses/LICENSE-2.0
130//
131// Unless required by applicable law or agreed to in writing, software
132// distributed under the License is distributed on an "AS IS" BASIS,
133// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134// See the License for the specific language governing permissions and
135// limitations under the License.
136// ----------------------------- END-OF-FILE ----------------------------------
137
138/** @} */
139/** @} */
140/** @} */
Definition bslstl_stringview.h:471
Definition bslstl_string.h:1252
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlb_algorithmworkaroundutil.h:74
Definition bdlb_literalutil.h:70
static void createQuotedEscapedCString(bsl::string *result, const bsl::string_view &input)
static void createQuotedEscapedCString(std::string *result, const bsl::string_view &input)