Click here to Skip to main content
15,881,413 members
Articles / Programming Languages / Visual Basic

EfTidy: The Tidy Library Wrapper

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
6 Sep 2013GPL310 min read 184.5K   5K   88  
A free component for HTML parsing and cleaning
// tidyOption.h : Declaration of the CtidyOption

#ifndef __TIDYOPTION_H_
#define __TIDYOPTION_H_
#include TIDYH
#include BUFFIOH 


#include "resource.h"       // main symbols
#include <vector>
#include <string>


typedef enum 
{
 EMPTYTAGS,INLINETAGS,PRETAGS,BLOCKTAGS
}TagsType;
/////////////////////////////////////////////////////////////////////////////
// CtidyOption
class ATL_NO_VTABLE CtidyOption : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CtidyOption, &CLSID_tidyOption>,
	public ISupportErrorInfo,
	public IDispatchImpl<ItidyOption, &IID_ItidyOption, &LIBID_EFTIDYLib>
{
			
public:
	TidyDoc *m_tdoc;
	std::vector<std::string> m_vecEmptyTags;
	std::vector<std::string> m_vecInlineTags;
	std::vector<std::string> m_vecPreTags;
	std::vector<std::string> m_vecBlockTags;

	CtidyOption()
	{
		m_tdoc=NULL;
	}

DECLARE_REGISTRY_RESOURCEID(IDR_TIDYOPTION)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CtidyOption)
	COM_INTERFACE_ENTRY(ItidyOption)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// ItidyOption
public:
	void ReturnTagsString(TagsType tags_Type,CString &TagString);
	void ParseTags(TagsType Tags_Type, const char *tag);
	void AddNewTags(TagsType  Tags_Type,const char* tag);
	STDMETHOD(get_DoctypeMode)(/*[out, retval]*/ DoctypeModes *pVal);
	STDMETHOD(put_DoctypeMode)(/*[in]*/ DoctypeModes newVal);
	STDMETHOD(get_HideComments)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_HideComments)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_BodyOnly)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_BodyOnly)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_FixUrl)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_FixUrl)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_MarkUp)(/*[out, retval]*/VARIANT_BOOL *pVal);
	STDMETHOD(put_MarkUp)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_GnuEmacs)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_GnuEmacs)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_ErrorFile)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_ErrorFile)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_KeepTime)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_KeepTime)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_Quiet)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_Quiet)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_ShowWarnings)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_ShowWarnings)(/*[in]*/ VARIANT_BOOL newVal);
    STDMETHOD(get_LiteralAttribs)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_LiteralAttribs)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_BreakBeforeBR)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_BreakBeforeBR)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_IndentAttributes)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_IndentAttributes)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_TabSize)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_TabSize)(/*[in]*/ long newVal);
	STDMETHOD(get_WrapLen)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_WrapLen)(/*[in]*/ long newVal);
	STDMETHOD(get_IndentSpace)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_IndentSpace)(/*[in]*/ long newVal);
	STDMETHOD(get_Indent)(/*[out, retval]*/ IndentScheme *pVal);
	STDMETHOD(put_Indent)(/*[in]*/ IndentScheme newVal);
	STDMETHOD(get_QuoteAmpersand)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_QuoteAmpersand)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_QuoteNBSP)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_QuoteNBSP)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_QuoteMarks)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_QuoteMarks)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_NumericsEntities)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_NumericsEntities)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_OutCharEncoding)(/*[out, retval]*/ CharEncodingType *pVal);
	STDMETHOD(put_OutCharEncoding)(/*[in]*/ CharEncodingType newVal);
	STDMETHOD(get_InCharEncoding)(/*[out, retval]*/ CharEncodingType *pVal);
	STDMETHOD(put_InCharEncoding)(/*[in]*/ CharEncodingType newVal);
	STDMETHOD(get_CharEncoding)(/*[out, retval]*/ CharEncodingType *pVal);
	STDMETHOD(put_CharEncoding)(/*[in]*/ CharEncodingType newVal);
	STDMETHOD(get_DropPropAttr)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_DropPropAttr)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_Bare)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_Bare)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_NewPreTags)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_NewPreTags)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_NewBlockLevelTags)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_NewBlockLevelTags)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_NewInlineTags)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_NewInlineTags)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_NewEmptyTags)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_NewEmptyTags)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_AssumeXmlProcins)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_AssumeXmlProcins)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_AddXmlSpace)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_AddXmlSpace)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_ADDXmlDecl)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_ADDXmlDecl)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_FixBackslash)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_FixBackslash)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_FixBadComment)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_FixBadComment)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_Word2000)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_Word2000)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_DropEmptyParas)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_DropEmptyParas)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_DropFontTags)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_DropFontTags)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_Clean)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_Clean)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_EncloseBlockText)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_EncloseBlockText)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_EncloseText)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_EncloseText)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_HideEndTag)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_HideEndTag)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_TidyMark)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_TidyMark)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(ResetToDefaultValue)();
	STDMETHOD(LoadConfigFile)(/*[in]*/BSTR ConfigFile);
	STDMETHOD(get_WrapPhp)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapPhp)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_WrapJste)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapJste)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_WrapAsp)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapAsp)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_WrapSection)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapSection)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_WrapAttVals)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapAttVals)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_WrapScriptlets)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_WrapScriptlets)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_LogicalEmphasis)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_LogicalEmphasis)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_OutputAttrInUpperCase)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_OutputAttrInUpperCase)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_OutputTagInUpperCase)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_OutputTagInUpperCase)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_InputAsXML)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_InputAsXML)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_DefaultAltText)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_DefaultAltText)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_Doctype)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(put_Doctype)(/*[in]*/ BSTR newVal);
	STDMETHOD(get_OutputType)(/*[out, retval]*/ OutputType *pVal);
	STDMETHOD(put_OutputType)(/*[in]*/ OutputType newVal);
};

#endif //__TIDYOPTION_H_

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, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
India India
He used to have biography here Smile | :) , but now he will hire someone (for free offcourse Big Grin | :-D ), Who writes his biography on his behalf Smile | :)

He is Great Fan of Mr. Johan Rosengren (his idol),Lim Bio Liong, Nishant S and DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!

He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively

Last but not the least, For good 8 years he was Visual CPP MSMVP!

Comments and Discussions