Matrix Science header

ms_http_client_mime.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_http_client_mime.hpp                                                  #
00004 # 'msparser' toolkit                                                         #
00005 # Builds a MIME string from the boundary separator and the element values    #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2013 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011  * @(#)$Source: parser/inc/ms_http_client_mime.hpp $
00012  * @(#)$Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_2_8_1-0-gea32989045 $
00013  * @(#)$Date: 2018-07-30 16:23:53 +0100 $
00014 ##############################################################################
00015  */
00016 
00017 #ifndef MS_HTTP_CLIENT_MIME_HPP
00018 #define MS_HTTP_CLIENT_MIME_HPP
00019 
00020 
00021 #include <string>
00022 #include <vector>
00023 
00024 namespace matrix_science
00025 {
00031     // for internal use
00032     class MS_MASCOTRESFILE_API ms_http_client_mime_item
00033     {
00034         public:
00035             ms_http_client_mime_item();
00036             ms_http_client_mime_item(const std::string & name, const std::string & value);
00037             ms_http_client_mime_item(const std::string & name, const std::string & value, const std::string & filename, const std::string & contentType);
00038 
00039             std::string name() const;
00040             std::string value() const;
00041             bool hasFilename() const;
00042             std::string filename() const;
00043             std::string contentType() const;
00044 
00045             void setName(const std::string & name);
00046             void setValue(const std::string & value);
00047             void setValueWithFilename(const std::string & value, const std::string & filename, const std::string & contentType);
00048 
00049         private:
00050             std::string name_;
00051             std::string value_;
00052             bool        hasFilename_;
00053             std::string filename_;
00054             std::string contentType_;
00055     };
00056 
00058 
00066     class MS_MASCOTRESFILE_API ms_http_client_mime
00067     {
00068         public:
00069             enum ContentType {
00070                 CT_MIXED,
00071                 CT_FORMDATA
00072             };
00073 
00074             enum Continuation {
00075                 CONTENT_CONTINUES,
00076                 CONTENT_TERMINATES
00077             };
00078 
00080             static std::string formatHeader(
00081                     const std::string & boundary,
00082                     ContentType contentType);
00083 
00085             virtual ~ms_http_client_mime();
00086 
00088             void append(const std::string & name, const std::string & value);
00089 
00091             void appendFile(const std::string & name, const std::string & filename, const std::string & contentType, const std::string & prefixData = "");
00092 
00093 
00095             int getCount() const;
00096             int count() const { return getCount(); }   // Deprecated. Released with 2.5.2
00097 
00098             // index 1..count inclusive (not zero based!)
00100             std::string getName(int oneBasedIndex) const;
00101             std::string name(int oneBasedIndex) const { return getName(oneBasedIndex); }  // Deprecated. Released with 2.5.2
00102 
00104             std::string getValue(int oneBasedIndex) const;
00105             std::string value(int oneBasedIndex) const { return getValue(oneBasedIndex); } // Deprecated. Released with 2.5.2
00106 
00108             bool hasFilename(int oneBasedIndex) const;
00109 
00111             std::string getFilename(int oneBasedIndex) const;
00112             std::string filename(int oneBasedIndex) const { return getFilename(oneBasedIndex); } // Deprecated. Released with 2.5.2
00113 
00114             // index 1..count inclusive (not zero based!)
00116             void setValue(int oneBasedIndex, const std::string & value);
00117 
00119             void setValueWithFilename(int oneBasedIndex, const std::string & value, const std::string & filename, const std::string & contentType);
00120 
00121             // index 1..count inclusive (not zero based!)
00123             void erase(int oneBasedIndex);
00124 
00126             std::string format(
00127                     const std::string & boundary,
00128                     matrix_science::ms_http_client_mime::Continuation continuation) const;
00129 
00130         private:
00131             std::vector<ms_http_client_mime_item> items_;
00132     };
00133  // end of http_client_group
00135 
00136 } // namespace matrix_science
00137 
00138 #endif // MS_HTTP_CLIENT_MIME_HPP
00139 
00140 /*------------------------------- End of File -------------------------------*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29