StringUriByteWriteResource.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_RESOURCE__STRING_URI_WRITE_RESOURCE
18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__STRING_URI_WRITE_RESOURCE
19 
21 
22 #include <sstream>
23 #include <memory>
24 
25 namespace Balau::Resource {
26 
27 class StringUri;
28 class Uri;
29 
37  public: explicit StringUriByteWriteResource(StringUri & stringUri_);
38 
40  : stringUri(std::move(rhs.stringUri))
41  , stream(std::move(rhs.stream)) {}
42 
43  public: ~StringUriByteWriteResource() override {
44  close();
45  }
46 
47  public: std::ostream & writeStream() override {
48  return stream;
49  }
50 
51  public: const Uri & uri() const override;
52 
53  public: void close() override {}
54 
56 
57  private: std::unique_ptr<StringUri> stringUri;
58  private: std::ostringstream stream;
59 };
60 
61 } // namespace Balau::Resource
62 
63 #endif // COM_BORA_SOFTWARE__BALAU_RESOURCE__STRING_URI_WRITE_RESOURCE
const Uri & uri() const override
Get the URI associated with this resource.
void close() override
Close the stream(s) in the resource.
Definition: StringUriByteWriteResource.hpp:53
A write-only resource which is written as bytes.
An abstract universal resource identifier.
Definition: Uri.hpp:131
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
A write-only resource which is written from bytes.
Definition: ByteWriteResource.hpp:29
An immediate string pseudo-URI.
Definition: StringUri.hpp:49
A write only String URI that is written as bytes.
Definition: StringUriByteWriteResource.hpp:33
std::ostream & writeStream() override
Get the output stream of the byte write resource.
Definition: StringUriByteWriteResource.hpp:47
StringUriByteWriteResource(StringUri &stringUri_)
Create a new string Uri byte write resource from the supplied String URI.