Click here to Skip to main content
15,896,111 members
Articles / Desktop Programming / ATL

En/Decode MIME-Content with MimeSniffer

Rate me:
Please Sign up or sign in to vote.
4.88/5 (26 votes)
2 Dec 20022 min read 377.2K   7K   74  
RFC-compliant Mime-En/Decoder
#ifndef __class__CYYSType
#define __class__CYYSType

class CYYSType
{
public:
	typedef map<string,CComVariant>	param_map;
	typedef pair<string,CComVariant>	param;

	CYYSType();
	CYYSType(const CYYSType& e);
	CYYSType(const long n);
	CYYSType(const char* s);
	CYYSType(const string& s);
	// CYYSType(const char c);
	CYYSType(const param& p);
	CYYSType(const VARIANT p);

	~CYYSType();

public:
	string				m_sVal;
	long				m_nVal;
	char				m_cVal;
	param				m_pVal;
	param_map			m_mVal;
	IStreamPtr			m_streamVal;

	long				m_nDay;			
	long				m_nMonth;			
	long				m_nYear;			
	long				m_nHour;			
	long				m_nMinute;			
	long				m_nSecond;			
	string				m_strZone;
	vector<CYYSType>	m_Container;

protected:
	long	m_nCurrentType;

public:
	enum {	  type_Invalid = -1, type_String, type_Long, type_Char
			, type_Param, type_ParamMap, type_Time, type_Date, type_Container
			, type_Bulk
		 };

public:
	void	Init();
	bool	IsValid();
#ifdef _DEBUG
	void	Dump() const;
#endif

	CYYSType& operator=(const CYYSType& e);
	CYYSType& operator=(const long n);
	CYYSType& operator=(const char* s);
	CYYSType& operator=(const string& s);
	// CYYSType& operator=(const char c);
	CYYSType& operator=(const param& p);
	CYYSType& operator=(const VARIANT p);

	void Contains(const CYYSType& e);

	void SetTime(long nHour, long nMinute, long nSecond = 0, const char* strZone = NULL);
	void SetTime(const CYYSType& e, const char* strZone = NULL);
	void SetDate(long nDay, long nMonth, long nYear, long nHour = 0, long nMinute = 0, long nSecond = 0, const char* strZone = NULL);
	void SetDate(const CYYSType& dt, const CYYSType& tm);

	CYYSType& operator+=(const CYYSType& e);
	CYYSType& operator+=(const long n);
	CYYSType& operator+=(const char* s);
	CYYSType& operator+=(const string& s);
	CYYSType& operator+=(char c);

	CYYSType operator+(const CYYSType& e);
	CYYSType operator+(const long n);
	CYYSType operator+(const string& s);
	CYYSType operator+(const char* s);
	CYYSType operator+(char c);

	CComVariant& operator[](string strIndex);

	operator const char*() const;
	operator long() const;
	operator CComVariant() const;

	void InitType(long nNewType);
	long GetType() const
	{
		return m_nCurrentType;
	}
	DWORD	length();

public:
	void FormatAsMailbox(string& str) const;

	bool GetAsMailAddresses(VARIANT& vt);
	void PutAsMailAddresses(const VARIANT& vt);

	bool GetAsMailAddress(VARIANT& vt);
	void PutAsMailAddress(const VARIANT& vt);

	bool GetAsDate(VARIANT& vt);
	void PutAsDate(const VARIANT& vt);

	bool GetAsPlainText(VARIANT& vt);
	void PutAsPlainText(const VARIANT& vt);

	bool GetAsUnQuotedText(VARIANT& vt);
	void PutAsQuotedInlineText(const VARIANT& vt);
};

typedef class __CYYSType
{
public:
	CYYSType m_Val;

public:
	__CYYSType()
	{
	}
	__CYYSType(const __CYYSType& e)
	{
		*this = e;
	}
	~__CYYSType()
	{
	}

	__CYYSType& operator=(const __CYYSType& e)
	{
		m_Val = e.m_Val;
		return *this;
	}
	__CYYSType& operator+=(const __CYYSType& e)
	{
		m_Val += e.m_Val;
		return *this;
	}

} __YYSTYPE;


#define YYSTYPE __YYSTYPE


#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions