2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|
|
|
|
#include "acl_cpp/mime/mime_head.hpp"
|
|
|
|
|
|
|
|
|
|
class mime_builder
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
mime_builder();
|
|
|
|
|
~mime_builder();
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {acl::mime_head&}
|
|
|
|
|
*/
|
|
|
|
|
acl::mime_head& primary_header(void)
|
|
|
|
|
{
|
|
|
|
|
return (header_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param src {const char*) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len {size_t} src <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {mime_builder&}
|
|
|
|
|
*/
|
|
|
|
|
mime_builder& set_body_text(const char* src, size_t len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ϊ HTML <EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param src {const char*) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len {size_t} src <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {mime_builder&}
|
|
|
|
|
*/
|
|
|
|
|
mime_builder& set_body_html(const char* src, size_t len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param filepath {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {mime_builder&}
|
|
|
|
|
*/
|
|
|
|
|
mime_builder& add_file(const char* filepath);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param to {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool save_as(const char* to);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param fp {acl::ofstream&} Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool save_as(acl::ofstream& fp);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
acl::mime_head header_;
|
|
|
|
|
char* body_text_;
|
|
|
|
|
char* body_html_;
|
|
|
|
|
std::vector<char*> attachs_;
|
|
|
|
|
acl::string delimeter_;
|
|
|
|
|
|
|
|
|
|
bool add_body(acl::ofstream& fp);
|
|
|
|
|
bool add_boundary(acl::ofstream& fp, bool end = false);
|
|
|
|
|
bool add_attach(acl::ofstream& fp, const char* filepath);
|
|
|
|
|
};
|