1 | // |
---|---|
2 | // StringPartSource.cpp |
3 | // |
4 | // Library: Net |
5 | // Package: Messages |
6 | // Module: StringPartSource |
7 | // |
8 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/Net/StringPartSource.h" |
16 | |
17 | |
18 | namespace Poco { |
19 | namespace Net { |
20 | |
21 | |
22 | StringPartSource::StringPartSource(const std::string& str): |
23 | PartSource("text/plain"), |
24 | _istr(str) |
25 | { |
26 | } |
27 | |
28 | |
29 | StringPartSource::StringPartSource(const std::string& str, const std::string& mediaType): |
30 | PartSource(mediaType), |
31 | _istr(str) |
32 | { |
33 | } |
34 | |
35 | |
36 | StringPartSource::StringPartSource(const std::string& str, const std::string& mediaType, const std::string& filename): |
37 | PartSource(mediaType), |
38 | _istr(str), |
39 | _filename(filename) |
40 | { |
41 | } |
42 | |
43 | |
44 | StringPartSource::~StringPartSource() |
45 | { |
46 | } |
47 | |
48 | |
49 | std::istream& StringPartSource::stream() |
50 | { |
51 | return _istr; |
52 | } |
53 | |
54 | |
55 | const std::string& StringPartSource::filename() const |
56 | { |
57 | return _filename; |
58 | } |
59 | |
60 | |
61 | std::streamsize StringPartSource::getContentLength() const |
62 | { |
63 | return _istr.str().length(); |
64 | } |
65 | |
66 | |
67 | } } // namespace Poco::Net |
68 |