acl/app/net_tools/mail/mime_builder.hpp

68 lines
1.4 KiB
C++
Raw Normal View History

#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();
/**
* <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_);
}
/**
* <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);
/**
* <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);
/**
* <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);
/**
* <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);
/**
* <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);
};