BDE 4.14.0 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`
79 /// string. Note that this code uses the (ASCII) '\' character, rather
80 /// than Unicode code points for escapes.
81 template <class OUT_STR>
82 static void createQuotedEscapedCString_Impl(
83 OUT_STR *result,
84 const bsl::string_view& input);
85
86 public:
87 // CLASS METHODS
88
90 const bsl::string_view& input);
91 /// Load into the specified `result` string the `"` delimited and
92 /// escaped C/C++ string literal equivalent representing the same value
93 /// as that of the specified `input` string. When the C string literal
94 /// equivalent is translated by a compiler having C-compatible string
95 /// literals, it will result in a string identical to the `input`
96 /// string. Note that this code uses the (ASCII) '\' character, rather
97 /// than Unicode code points for escapes.
98 static void createQuotedEscapedCString(std::string *result,
99 const bsl::string_view& input);
100
101#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
102 /// Load into the specified `result` string the `"` delimited and
103 /// escaped C/C++ string literal equivalent representing the same value
104 /// as that of the specified `input` string. When the C string literal
105 /// equivalent is translated by a compiler having C-compatible string
106 /// literals, it will result in a string identical to the `input`
107 /// string. Note that this code uses the (ASCII) `\` character, rather
108 /// than Unicode code points for escapes.
109 static void createQuotedEscapedCString(std::pmr::string *result,
110 const bsl::string_view& input);
111#endif
112};
113
114} // close package namespace
115
116
117#endif
118
119// ----------------------------------------------------------------------------
120// Copyright 2020 Bloomberg Finance L.P.
121//
122// Licensed under the Apache License, Version 2.0 (the "License");
123// you may not use this file except in compliance with the License.
124// You may obtain a copy of the License at
125//
126// http://www.apache.org/licenses/LICENSE-2.0
127//
128// Unless required by applicable law or agreed to in writing, software
129// distributed under the License is distributed on an "AS IS" BASIS,
130// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131// See the License for the specific language governing permissions and
132// limitations under the License.
133// ----------------------------- END-OF-FILE ----------------------------------
134
135/** @} */
136/** @} */
137/** @} */
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
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)