Flow 1.0.2
Flow project: Full implementation reference.
string_ostream.cpp
Go to the documentation of this file.
1/* Flow
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19
21
22namespace flow::util
23{
24
25String_ostream::String_ostream(std::string* target_str) :
26 m_target(target_str ? target_str : (&m_own_target_str)), // m_own_target_str blank/ignored if target_str not null.
27 m_target_inserter(*m_target),
28 m_target_appender_ostream(m_target_inserter)
29{
30 // Nothing else.
31}
32
33std::ostream& String_ostream::os()
34{
36}
37
38const std::ostream& String_ostream::os() const
39{
41}
42
43const std::string& String_ostream::str() const
44{
45 return *m_target;
46}
47
49{
50 m_target->clear();
51}
52
53} // namespace flow::util
void str_clear()
Performs std::string::clear() on the object returned by str().
String_ostream(std::string *target_str=0)
Wraps either the given std::string or a newly created empty string if a null pointer is passed.
std::ostream & os()
Access to stream that will write to owned string.
const std::string & str() const
Read-only access to the string being wrapped.
String_appender_ostream m_target_appender_ostream
Appender ostream into m_target by way of m_target_inserter. Write/flush here to write to m_target.
std::string * m_target
Pointer to the target string. Emptied at construction and in str_clear() only.
Flow module containing miscellaneous general-use facilities that don't fit into any other Flow module...
Definition: basic_blob.hpp:29