Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_http_client_mime.hpp
1/*
2##############################################################################
3# file: ms_http_client_mime.hpp #
4# 'msparser' toolkit #
5# Builds a MIME string from the boundary separator and the element values #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11 * @(#)$Source: parser/inc/ms_http_client_mime.hpp $
12 * @(#)$Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
13 * @(#)$Date: 2018-07-30 16:23:53 +0100 $
14##############################################################################
15 */
16
17#ifndef MS_HTTP_CLIENT_MIME_HPP
18#define MS_HTTP_CLIENT_MIME_HPP
19
20
21#include <string>
22#include <vector>
23
24namespace matrix_science
25{
31 // for internal use
32 class MS_MASCOTRESFILE_API ms_http_client_mime_item
33 {
34 public:
35 ms_http_client_mime_item();
36 ms_http_client_mime_item(const std::string & name, const std::string & value);
37 ms_http_client_mime_item(const std::string & name, const std::string & value, const std::string & filename, const std::string & contentType);
38
39 std::string name() const;
40 std::string value() const;
41 bool hasFilename() const;
42 std::string filename() const;
43 std::string contentType() const;
44
45 void setName(const std::string & name);
46 void setValue(const std::string & value);
47 void setValueWithFilename(const std::string & value, const std::string & filename, const std::string & contentType);
48
49 private:
50 std::string name_;
51 std::string value_;
52 bool hasFilename_;
53 std::string filename_;
54 std::string contentType_;
55 };
56
58
66 class MS_MASCOTRESFILE_API ms_http_client_mime
67 {
68 public:
69 enum ContentType {
70 CT_MIXED,
71 CT_FORMDATA
72 };
73
74 enum Continuation {
75 CONTENT_CONTINUES,
76 CONTENT_TERMINATES
77 };
78
80 static std::string formatHeader(
81 const std::string & boundary,
82 ContentType contentType);
83
85 virtual ~ms_http_client_mime();
86
88 void append(const std::string & name, const std::string & value);
89
91 void appendFile(const std::string & name, const std::string & filename, const std::string & contentType, const std::string & prefixData = "");
92
93
95 int getCount() const;
96 int count() const { return getCount(); } // Deprecated. Released with 2.5.2
97
98 // index 1..count inclusive (not zero based!)
100 std::string getName(int oneBasedIndex) const;
101 std::string name(int oneBasedIndex) const { return getName(oneBasedIndex); } // Deprecated. Released with 2.5.2
102
104 std::string getValue(int oneBasedIndex) const;
105 std::string value(int oneBasedIndex) const { return getValue(oneBasedIndex); } // Deprecated. Released with 2.5.2
106
108 bool hasFilename(int oneBasedIndex) const;
109
111 std::string getFilename(int oneBasedIndex) const;
112 std::string filename(int oneBasedIndex) const { return getFilename(oneBasedIndex); } // Deprecated. Released with 2.5.2
113
114 // index 1..count inclusive (not zero based!)
116 void setValue(int oneBasedIndex, const std::string & value);
117
119 void setValueWithFilename(int oneBasedIndex, const std::string & value, const std::string & filename, const std::string & contentType);
120
121 // index 1..count inclusive (not zero based!)
123 void erase(int oneBasedIndex);
124
126 std::string format(
127 const std::string & boundary,
128 matrix_science::ms_http_client_mime::Continuation continuation) const;
129
130 private:
131 std::vector<ms_http_client_mime_item> items_;
132 };
133 // end of http_client_group
135
136} // namespace matrix_science
137
138#endif // MS_HTTP_CLIENT_MIME_HPP
139
140/*------------------------------- End of File -------------------------------*/
The class eases the building of a MIME section.
Definition: ms_http_client_mime.hpp:67