EDN Admin
Well-known member
hi,all, i created the follow code:
<div style="color:black; background-color:white
<pre>MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr1;
MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr2;
MSXML2::IXMLDOMNodePtr DOMNodePtr1;
MSXML2::IXMLDOMNodePtr DOMNodePtr2;
_variant_t varSrc1;
_variant_t varSrc2;
_variant_t varContent1;
_variant_t varContent2;
set<Styles> vtrStyles1;
set<Styles> vtrStyles2;<br/><span style="color:green
DOMNamedNodeMapPtr1 = pNode1 ->attributes;
DOMNodePtr1 = DOMNamedNodeMapPtr1 ->getNamedItem(L<span style="color:#a31515 "SRC");
DOMNodePtr1 ->get_nodeValue(&varSrc1);
DOMNodePtr1 = DOMNamedNodeMapPtr1 ->getNamedItem(L<span style="color:#a31515 "Content");
DOMNodePtr1 ->get_nodeValue(&varContent1);
DOMNamedNodeMapPtr2 = pNode2 ->attributes;
DOMNodePtr2 = DOMNamedNodeMapPtr2 ->getNamedItem(L<span style="color:#a31515 "SRC");
DOMNodePtr2 ->get_nodeValue(&varSrc2);
DOMNodePtr2 = DOMNamedNodeMapPtr2 ->getNamedItem(L<span style="color:#a31515 "Content");
DOMNodePtr2 ->get_nodeValue(&varContent2);
vector<wstring> ProcTgtTagStrVec;
vector<wstring> ProcSrcTagStrVec;
MSHTML::IHTMLDocument2Ptr htmDoc1 = NULL;
MSHTML::IHTMLDocument2Ptr htmDoc2 = NULL;
SAFEARRAY *psaStrings1 = SafeArrayCreateVector(VT_VARIANT, 0, 1);
SAFEARRAY *psaStrings2 = SafeArrayCreateVector(VT_VARIANT, 0, 1);
CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (<span style="color:blue void**) &htmDoc1);
CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (<span style="color:blue void**) &htmDoc2);
VARIANT *param1 = NULL;
HRESULT hr = SafeArrayAccessData(psaStrings1, (LPVOID*)¶m1);
param1->vt = VT_BSTR;
param1->bstrVal = SysAllocString(varSrc1.bstrVal);
VARIANT *param2 = NULL;
hr = SafeArrayAccessData(psaStrings2, (LPVOID*)¶m2);
param2->vt = VT_BSTR;
param2->bstrVal = SysAllocString(varSrc2.bstrVal);
hr = SafeArrayUnaccessData(psaStrings1);
hr = htmDoc1->write(psaStrings1);
hr = SafeArrayUnaccessData(psaStrings2);
hr = htmDoc2->write(psaStrings2);
MSHTML::IHTMLElementPtr pElemBody1 = NULL;
MSHTML::IHTMLDOMNodePtr pHTMLBodyDOMNode1 =NULL;
hr = htmDoc1->get_body(&pElemBody1);
<span style="color:blue if(SUCCEEDED(hr))
{
hr = pElemBody1->QueryInterface(IID_IHTMLDOMNode,(<span style="color:blue void**)&pHTMLBodyDOMNode1);
<span style="color:blue if(SUCCEEDED(hr))
{
ProcessDomNodeSmartWrapper(pHTMLBodyDOMNode1, ProcTgtTagStrVec);
}
}
MSHTML::IHTMLElementPtr pElemBody2 = NULL;
MSHTML::IHTMLDOMNodePtr pHTMLBodyDOMNode2 =NULL;
hr = htmDoc2->get_body(&pElemBody2);
<span style="color:blue if(SUCCEEDED(hr))
{
hr = pElemBody2->QueryInterface(IID_IHTMLDOMNode,(<span style="color:blue void**)&pHTMLBodyDOMNode2);
<span style="color:blue if(SUCCEEDED(hr))
{
ProcessDomNodeSmartWrapper(pHTMLBodyDOMNode2, ProcSrcTagStrVec);
}
}
<span style="color:blue long lLength = 0;
MSHTML::IHTMLElementCollectionPtr pElemColl1 = NULL;
MSHTML::IHTMLElementPtr pChElem1 = NULL;
MSHTML::IHTMLStylePtr pStyle1 = NULL;
IDispatchPtr ppvdisp1 = NULL;
hr = htmDoc1->get_all(&pElemColl1);
hr = pElemColl1->get_length(&lLength);
<span style="color:blue for(<span style="color:blue long i = 0; i < lLength; i++)
{
_variant_t name(i);
_variant_t index(i);
ppvdisp1 = pElemColl1->item(name, index);
<span style="color:blue if(ppvdisp1 && SUCCEEDED(hr))
{
hr = ppvdisp1->QueryInterface(IID_IHTMLElement, (<span style="color:blue void **)&pChElem1);
<span style="color:blue if(pChElem1 && SUCCEEDED(hr))
{
BSTR bstrTagName = NULL;
_variant_t varFtColAtt;
_variant_t varFtFaceAtt;
pChElem1->get_tagName(&bstrTagName);
<span style="color:blue if(lstrcmpW(bstrTagName, L<span style="color:#a31515 "I") == 0)
{
Styles style;
style.styleVal = L<span style="color:#a31515 "italic";
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(L"italic")] = L"FontStyle";
}
varFtColAtt = pChElem1->getAttribute(_bstr_t(<span style="color:#a31515 "color"), 0);
<span style="color:blue if(varFtColAtt.vt == 8)
{
Styles style;
style.styleVal = wstring(varFtColAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(varFtColAtt.bstrVal)] = L"FontColor";
}
varFtFaceAtt = pChElem1->getAttribute(_bstr_t(<span style="color:#a31515 "face"), 0);
<span style="color:blue if(varFtFaceAtt.vt == 8 && SysStringLen(varFtFaceAtt.bstrVal) != 0)
{
Styles style;
style.styleVal = wstring(varFtFaceAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(varFtFaceAtt.bstrVal)] = L"FontFamily";
}
hr = pChElem1->get_style(&pStyle1);
<span style="color:blue if(pStyle1 && SUCCEEDED(hr))
{
BSTR bstrFtStyle = NULL;
BSTR bstrFtFam = NULL;
BSTR txtDecoration = NULL;
_variant_t varFtCol;
hr = pStyle1->get_fontStyle(&bstrFtStyle);
<span style="color:blue if(bstrFtStyle)
{
Styles style;
style.styleVal = wstring(bstrFtStyle);
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(bstrFtStyle)] = L"FontStyle";
SysFreeString(bstrFtStyle);
}
hr = pStyle1->get_fontFamily(&bstrFtFam);
<span style="color:blue if(bstrFtFam)
{
Styles style;
style.styleVal = wstring(bstrFtFam);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(bstrFtFam)] = L"FontFamily";
SysFreeString(bstrFtFam);
}
hr = pStyle1->get_textDecoration(&txtDecoration);
<span style="color:blue if(txtDecoration)
{
Styles style;
style.styleVal = wstring(txtDecoration);
style.styleName = L<span style="color:#a31515 "TextDecoration";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(txtDecoration)] = L"TextDecoration";
SysFreeString(txtDecoration);
}
hr = pStyle1->get_color(&varFtCol);
<span style="color:blue if(hr == S_OK && varFtCol.bstrVal)
{
Styles style;
style.styleVal = wstring(varFtCol.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles1.insert(style);
<span style="color:green // varFtCol.vt;
<span style="color:green // hmStyles1[wstring(varFtCol.bstrVal)] = L"FontColor";
}
}
<span style="color:blue if(bstrTagName)
SysFreeString(bstrTagName);
} <span style="color:green // if pStyle && SUCCEEDED(hr)
}<span style="color:green //if ppvdisp && SUCCEEDED(hr)
}<span style="color:green //for
MSHTML::IHTMLElementCollectionPtr pElemColl2 = NULL;
MSHTML::IHTMLElementPtr pChElem2 = NULL;
MSHTML::IHTMLStylePtr pStyle2 = NULL;
IDispatchPtr ppvdisp2 = NULL;
hr = htmDoc2->get_all(&pElemColl2);
hr = pElemColl2->get_length(&lLength);
<span style="color:blue for(<span style="color:blue long i = 0; i < lLength; i++)
{
_variant_t name(i);
_variant_t index(i);
ppvdisp2 = pElemColl2->item(name, index);
<span style="color:blue if(ppvdisp2 && SUCCEEDED(hr))
{
hr = ppvdisp2->QueryInterface(IID_IHTMLElement, (<span style="color:blue void **)&pChElem2);
<span style="color:blue if(pChElem2 && SUCCEEDED(hr))
{
BSTR bstrTagName = NULL;
_variant_t varFtColAtt;
_variant_t varFtFaceAtt;
pChElem2->get_tagName(&bstrTagName);
<span style="color:blue if(lstrcmpW(bstrTagName, L<span style="color:#a31515 "I") == 0)
{
Styles style;
style.styleVal = L<span style="color:#a31515 "italic";
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(L"italic")] = L"FontStyle";
}
varFtColAtt = pChElem2->getAttribute(_bstr_t(<span style="color:#a31515 "color"), 0);
<span style="color:blue if(varFtColAtt.vt == 8)
{
Styles style;
style.styleVal = wstring(varFtColAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(varFtColAtt.bstrVal)] = L"FontColor";
}
varFtFaceAtt = pChElem2->getAttribute(_bstr_t(<span style="color:#a31515 "face"), 0);
<span style="color:blue if(varFtFaceAtt.vt == 8 && SysStringLen(varFtFaceAtt.bstrVal) != 0)
{
Styles style;
style.styleVal = wstring(varFtFaceAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(varFtFaceAtt.bstrVal)] = L"FontFamily";
}
hr = pChElem2->get_style(&pStyle2);
<span style="color:blue if(pStyle2 && SUCCEEDED(hr))
{
BSTR bstrFtStyle = NULL;
BSTR bstrFtFam = NULL;
BSTR txtDecoration = NULL;
_variant_t varFtCol;
hr = pStyle2->get_fontStyle(&bstrFtStyle);
<span style="color:blue if(bstrFtStyle)
{
Styles style;
style.styleVal = wstring(bstrFtStyle);
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(bstrFtStyle)] = L"FontStyle";
SysFreeString(bstrFtStyle);
}
hr = pStyle2->get_fontFamily(&bstrFtFam);
<span style="color:blue if(bstrFtFam)
{
Styles style;
style.styleVal = wstring(bstrFtFam);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(bstrFtFam)] = L"FontFamily";
SysFreeString(bstrFtFam);
}
hr = pStyle2->get_textDecoration(&txtDecoration);
<span style="color:blue if(txtDecoration)
{
Styles style;
style.styleVal = wstring(txtDecoration);
style.styleName = L<span style="color:#a31515 "TextDecoration";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(txtDecoration)] = L"TextDecoration";
SysFreeString(txtDecoration);
}
hr = pStyle2->get_color(&varFtCol);
<span style="color:blue if(hr == S_OK && varFtCol.bstrVal)
{
Styles style;
style.styleVal = wstring(varFtCol.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles2.insert(style);
<span style="color:green // varFtCol.vt;
<span style="color:green // hmStyles2[wstring(varFtCol.bstrVal)] = L"FontColor";
}
}
<span style="color:blue if(bstrTagName)
SysFreeString(bstrTagName);
} <span style="color:green // if pStyle && SUCCEEDED(hr)
}<span style="color:green //if ppvdisp && SUCCEEDED(hr)
}<span style="color:green //for
SafeArrayDestroy(psaStrings1);
SafeArrayDestroy(psaStrings2);
std::set<Styles> vtrStyles3(vtrStyles1);
vtrStyles3.insert(vtrStyles2.begin(), vtrStyles2.end());
unCommon = vtrStyles1.size() + vtrStyles2.size() - vtrStyles3.size();
fSimPS = (<span style="color:blue float)unCommon / (<span style="color:blue float)vtrStyles3.size();
[/code]
<pre lang="x-cpp struct Styles{
wstring styleVal;
wstring styleName;
};[/code]
but having these compile errors:
<pre>1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &) : could not deduce template argument for const std::_Tree<_Traits> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(1885) : see declaration of std:perator <
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(124) : while compiling class template member function bool std::less<_Ty>:perator ()(const _Ty &,const _Ty &) const
1> with
1> [
1> _Ty=Styles
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeset(49) : see reference to class template instantiation std::less<_Ty> being compiled
1> with
1> [
1> _Ty=Styles
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(451) : see reference to class template instantiation std::_Tset_traits<_Kty,_Pr,_Alloc,_Mfl> being compiled
1> with
1> [
1> _Kty=Styles,
1> _Pr=std::less<Styles>,
1> _Alloc=std::allocator<Styles>,
1> _Mfl=false
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(520) : see reference to class template instantiation std::_Tree_nod<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(659) : see reference to class template instantiation std::_Tree_val<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeset(58) : see reference to class template instantiation std::_Tree<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> XMLDOMFromVCDlg.cpp(5378) : see reference to class template instantiation std::set<_Kty> being compiled
1> with
1> [
1> _Kty=Styles
1> ]
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &) : could not deduce template argument for const std::move_iterator<_RanIt> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeiterator(371) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *) : could not deduce template argument for const std::basic_string<_Elem,_Traits,_Alloc> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(243) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &) : could not deduce template argument for const _Elem * from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(233) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &) : could not deduce template argument for const std::basic_string<_Elem,_Traits,_Alloc> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(223) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Hash<_Traits> &,const std::_Hash<_Traits> &) : could not deduce template argument for const std::_Hash<_Traits> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexhash(933) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &) : could not deduce template argument for const std::list<_Ty,_Ax> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludelist(1588) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &) : could not deduce template argument for const std::vector<_Ty,_Ax> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludevector(1502) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &) : could not deduce template argument for const std::unique_ptr<_Ty,_Dx> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludememory(2582) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &) : could not deduce template argument for const std::reverse_iterator<_RanIt> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexutility(1356) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &) : could not deduce template argument for const std::_Revranit<_RanIt,_Base> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexutility(1179) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std:air<_Ty1,_Ty2> &,const std:air<_Ty1,_Ty2> &) : could not deduce template argument for const std:air<_Ty1,_Ty2> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeutility(318) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool operator <(_Interface *,const _com_ptr_t<_InterfacePtr> &) : could not deduce template argument for _Interface * from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludecomip.h(943) : see declaration of operator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool operator <(int,const _com_ptr_t<_IIID> &) : could not deduce template argument for const _com_ptr_t<_IIID> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludecomip.h(934) : see declaration of operator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2676: binary < : const Styles does not define this operator or a conversion to a type acceptable to the predefined operator
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/code]
whats going on?
cheers
daiyue
View the full article
<div style="color:black; background-color:white
<pre>MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr1;
MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr2;
MSXML2::IXMLDOMNodePtr DOMNodePtr1;
MSXML2::IXMLDOMNodePtr DOMNodePtr2;
_variant_t varSrc1;
_variant_t varSrc2;
_variant_t varContent1;
_variant_t varContent2;
set<Styles> vtrStyles1;
set<Styles> vtrStyles2;<br/><span style="color:green
DOMNamedNodeMapPtr1 = pNode1 ->attributes;
DOMNodePtr1 = DOMNamedNodeMapPtr1 ->getNamedItem(L<span style="color:#a31515 "SRC");
DOMNodePtr1 ->get_nodeValue(&varSrc1);
DOMNodePtr1 = DOMNamedNodeMapPtr1 ->getNamedItem(L<span style="color:#a31515 "Content");
DOMNodePtr1 ->get_nodeValue(&varContent1);
DOMNamedNodeMapPtr2 = pNode2 ->attributes;
DOMNodePtr2 = DOMNamedNodeMapPtr2 ->getNamedItem(L<span style="color:#a31515 "SRC");
DOMNodePtr2 ->get_nodeValue(&varSrc2);
DOMNodePtr2 = DOMNamedNodeMapPtr2 ->getNamedItem(L<span style="color:#a31515 "Content");
DOMNodePtr2 ->get_nodeValue(&varContent2);
vector<wstring> ProcTgtTagStrVec;
vector<wstring> ProcSrcTagStrVec;
MSHTML::IHTMLDocument2Ptr htmDoc1 = NULL;
MSHTML::IHTMLDocument2Ptr htmDoc2 = NULL;
SAFEARRAY *psaStrings1 = SafeArrayCreateVector(VT_VARIANT, 0, 1);
SAFEARRAY *psaStrings2 = SafeArrayCreateVector(VT_VARIANT, 0, 1);
CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (<span style="color:blue void**) &htmDoc1);
CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (<span style="color:blue void**) &htmDoc2);
VARIANT *param1 = NULL;
HRESULT hr = SafeArrayAccessData(psaStrings1, (LPVOID*)¶m1);
param1->vt = VT_BSTR;
param1->bstrVal = SysAllocString(varSrc1.bstrVal);
VARIANT *param2 = NULL;
hr = SafeArrayAccessData(psaStrings2, (LPVOID*)¶m2);
param2->vt = VT_BSTR;
param2->bstrVal = SysAllocString(varSrc2.bstrVal);
hr = SafeArrayUnaccessData(psaStrings1);
hr = htmDoc1->write(psaStrings1);
hr = SafeArrayUnaccessData(psaStrings2);
hr = htmDoc2->write(psaStrings2);
MSHTML::IHTMLElementPtr pElemBody1 = NULL;
MSHTML::IHTMLDOMNodePtr pHTMLBodyDOMNode1 =NULL;
hr = htmDoc1->get_body(&pElemBody1);
<span style="color:blue if(SUCCEEDED(hr))
{
hr = pElemBody1->QueryInterface(IID_IHTMLDOMNode,(<span style="color:blue void**)&pHTMLBodyDOMNode1);
<span style="color:blue if(SUCCEEDED(hr))
{
ProcessDomNodeSmartWrapper(pHTMLBodyDOMNode1, ProcTgtTagStrVec);
}
}
MSHTML::IHTMLElementPtr pElemBody2 = NULL;
MSHTML::IHTMLDOMNodePtr pHTMLBodyDOMNode2 =NULL;
hr = htmDoc2->get_body(&pElemBody2);
<span style="color:blue if(SUCCEEDED(hr))
{
hr = pElemBody2->QueryInterface(IID_IHTMLDOMNode,(<span style="color:blue void**)&pHTMLBodyDOMNode2);
<span style="color:blue if(SUCCEEDED(hr))
{
ProcessDomNodeSmartWrapper(pHTMLBodyDOMNode2, ProcSrcTagStrVec);
}
}
<span style="color:blue long lLength = 0;
MSHTML::IHTMLElementCollectionPtr pElemColl1 = NULL;
MSHTML::IHTMLElementPtr pChElem1 = NULL;
MSHTML::IHTMLStylePtr pStyle1 = NULL;
IDispatchPtr ppvdisp1 = NULL;
hr = htmDoc1->get_all(&pElemColl1);
hr = pElemColl1->get_length(&lLength);
<span style="color:blue for(<span style="color:blue long i = 0; i < lLength; i++)
{
_variant_t name(i);
_variant_t index(i);
ppvdisp1 = pElemColl1->item(name, index);
<span style="color:blue if(ppvdisp1 && SUCCEEDED(hr))
{
hr = ppvdisp1->QueryInterface(IID_IHTMLElement, (<span style="color:blue void **)&pChElem1);
<span style="color:blue if(pChElem1 && SUCCEEDED(hr))
{
BSTR bstrTagName = NULL;
_variant_t varFtColAtt;
_variant_t varFtFaceAtt;
pChElem1->get_tagName(&bstrTagName);
<span style="color:blue if(lstrcmpW(bstrTagName, L<span style="color:#a31515 "I") == 0)
{
Styles style;
style.styleVal = L<span style="color:#a31515 "italic";
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(L"italic")] = L"FontStyle";
}
varFtColAtt = pChElem1->getAttribute(_bstr_t(<span style="color:#a31515 "color"), 0);
<span style="color:blue if(varFtColAtt.vt == 8)
{
Styles style;
style.styleVal = wstring(varFtColAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(varFtColAtt.bstrVal)] = L"FontColor";
}
varFtFaceAtt = pChElem1->getAttribute(_bstr_t(<span style="color:#a31515 "face"), 0);
<span style="color:blue if(varFtFaceAtt.vt == 8 && SysStringLen(varFtFaceAtt.bstrVal) != 0)
{
Styles style;
style.styleVal = wstring(varFtFaceAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(varFtFaceAtt.bstrVal)] = L"FontFamily";
}
hr = pChElem1->get_style(&pStyle1);
<span style="color:blue if(pStyle1 && SUCCEEDED(hr))
{
BSTR bstrFtStyle = NULL;
BSTR bstrFtFam = NULL;
BSTR txtDecoration = NULL;
_variant_t varFtCol;
hr = pStyle1->get_fontStyle(&bstrFtStyle);
<span style="color:blue if(bstrFtStyle)
{
Styles style;
style.styleVal = wstring(bstrFtStyle);
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(bstrFtStyle)] = L"FontStyle";
SysFreeString(bstrFtStyle);
}
hr = pStyle1->get_fontFamily(&bstrFtFam);
<span style="color:blue if(bstrFtFam)
{
Styles style;
style.styleVal = wstring(bstrFtFam);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(bstrFtFam)] = L"FontFamily";
SysFreeString(bstrFtFam);
}
hr = pStyle1->get_textDecoration(&txtDecoration);
<span style="color:blue if(txtDecoration)
{
Styles style;
style.styleVal = wstring(txtDecoration);
style.styleName = L<span style="color:#a31515 "TextDecoration";
vtrStyles1.insert(style);
<span style="color:green // hmStyles1[wstring(txtDecoration)] = L"TextDecoration";
SysFreeString(txtDecoration);
}
hr = pStyle1->get_color(&varFtCol);
<span style="color:blue if(hr == S_OK && varFtCol.bstrVal)
{
Styles style;
style.styleVal = wstring(varFtCol.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles1.insert(style);
<span style="color:green // varFtCol.vt;
<span style="color:green // hmStyles1[wstring(varFtCol.bstrVal)] = L"FontColor";
}
}
<span style="color:blue if(bstrTagName)
SysFreeString(bstrTagName);
} <span style="color:green // if pStyle && SUCCEEDED(hr)
}<span style="color:green //if ppvdisp && SUCCEEDED(hr)
}<span style="color:green //for
MSHTML::IHTMLElementCollectionPtr pElemColl2 = NULL;
MSHTML::IHTMLElementPtr pChElem2 = NULL;
MSHTML::IHTMLStylePtr pStyle2 = NULL;
IDispatchPtr ppvdisp2 = NULL;
hr = htmDoc2->get_all(&pElemColl2);
hr = pElemColl2->get_length(&lLength);
<span style="color:blue for(<span style="color:blue long i = 0; i < lLength; i++)
{
_variant_t name(i);
_variant_t index(i);
ppvdisp2 = pElemColl2->item(name, index);
<span style="color:blue if(ppvdisp2 && SUCCEEDED(hr))
{
hr = ppvdisp2->QueryInterface(IID_IHTMLElement, (<span style="color:blue void **)&pChElem2);
<span style="color:blue if(pChElem2 && SUCCEEDED(hr))
{
BSTR bstrTagName = NULL;
_variant_t varFtColAtt;
_variant_t varFtFaceAtt;
pChElem2->get_tagName(&bstrTagName);
<span style="color:blue if(lstrcmpW(bstrTagName, L<span style="color:#a31515 "I") == 0)
{
Styles style;
style.styleVal = L<span style="color:#a31515 "italic";
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(L"italic")] = L"FontStyle";
}
varFtColAtt = pChElem2->getAttribute(_bstr_t(<span style="color:#a31515 "color"), 0);
<span style="color:blue if(varFtColAtt.vt == 8)
{
Styles style;
style.styleVal = wstring(varFtColAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(varFtColAtt.bstrVal)] = L"FontColor";
}
varFtFaceAtt = pChElem2->getAttribute(_bstr_t(<span style="color:#a31515 "face"), 0);
<span style="color:blue if(varFtFaceAtt.vt == 8 && SysStringLen(varFtFaceAtt.bstrVal) != 0)
{
Styles style;
style.styleVal = wstring(varFtFaceAtt.bstrVal);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(varFtFaceAtt.bstrVal)] = L"FontFamily";
}
hr = pChElem2->get_style(&pStyle2);
<span style="color:blue if(pStyle2 && SUCCEEDED(hr))
{
BSTR bstrFtStyle = NULL;
BSTR bstrFtFam = NULL;
BSTR txtDecoration = NULL;
_variant_t varFtCol;
hr = pStyle2->get_fontStyle(&bstrFtStyle);
<span style="color:blue if(bstrFtStyle)
{
Styles style;
style.styleVal = wstring(bstrFtStyle);
style.styleName = L<span style="color:#a31515 "FontStyle";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(bstrFtStyle)] = L"FontStyle";
SysFreeString(bstrFtStyle);
}
hr = pStyle2->get_fontFamily(&bstrFtFam);
<span style="color:blue if(bstrFtFam)
{
Styles style;
style.styleVal = wstring(bstrFtFam);
style.styleName = L<span style="color:#a31515 "FontFamily";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(bstrFtFam)] = L"FontFamily";
SysFreeString(bstrFtFam);
}
hr = pStyle2->get_textDecoration(&txtDecoration);
<span style="color:blue if(txtDecoration)
{
Styles style;
style.styleVal = wstring(txtDecoration);
style.styleName = L<span style="color:#a31515 "TextDecoration";
vtrStyles2.insert(style);
<span style="color:green // hmStyles2[wstring(txtDecoration)] = L"TextDecoration";
SysFreeString(txtDecoration);
}
hr = pStyle2->get_color(&varFtCol);
<span style="color:blue if(hr == S_OK && varFtCol.bstrVal)
{
Styles style;
style.styleVal = wstring(varFtCol.bstrVal);
style.styleName = L<span style="color:#a31515 "FontColor";
vtrStyles2.insert(style);
<span style="color:green // varFtCol.vt;
<span style="color:green // hmStyles2[wstring(varFtCol.bstrVal)] = L"FontColor";
}
}
<span style="color:blue if(bstrTagName)
SysFreeString(bstrTagName);
} <span style="color:green // if pStyle && SUCCEEDED(hr)
}<span style="color:green //if ppvdisp && SUCCEEDED(hr)
}<span style="color:green //for
SafeArrayDestroy(psaStrings1);
SafeArrayDestroy(psaStrings2);
std::set<Styles> vtrStyles3(vtrStyles1);
vtrStyles3.insert(vtrStyles2.begin(), vtrStyles2.end());
unCommon = vtrStyles1.size() + vtrStyles2.size() - vtrStyles3.size();
fSimPS = (<span style="color:blue float)unCommon / (<span style="color:blue float)vtrStyles3.size();
[/code]
<pre lang="x-cpp struct Styles{
wstring styleVal;
wstring styleName;
};[/code]
but having these compile errors:
<pre>1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &) : could not deduce template argument for const std::_Tree<_Traits> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(1885) : see declaration of std:perator <
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(124) : while compiling class template member function bool std::less<_Ty>:perator ()(const _Ty &,const _Ty &) const
1> with
1> [
1> _Ty=Styles
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeset(49) : see reference to class template instantiation std::less<_Ty> being compiled
1> with
1> [
1> _Ty=Styles
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(451) : see reference to class template instantiation std::_Tset_traits<_Kty,_Pr,_Alloc,_Mfl> being compiled
1> with
1> [
1> _Kty=Styles,
1> _Pr=std::less<Styles>,
1> _Alloc=std::allocator<Styles>,
1> _Mfl=false
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(520) : see reference to class template instantiation std::_Tree_nod<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludextree(659) : see reference to class template instantiation std::_Tree_val<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeset(58) : see reference to class template instantiation std::_Tree<_Traits> being compiled
1> with
1> [
1> _Traits=std::_Tset_traits<Styles,std::less<Styles>,std::allocator<Styles>,false>
1> ]
1> XMLDOMFromVCDlg.cpp(5378) : see reference to class template instantiation std::set<_Kty> being compiled
1> with
1> [
1> _Kty=Styles
1> ]
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &) : could not deduce template argument for const std::move_iterator<_RanIt> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeiterator(371) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *) : could not deduce template argument for const std::basic_string<_Elem,_Traits,_Alloc> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(243) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &) : could not deduce template argument for const _Elem * from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(233) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &) : could not deduce template argument for const std::basic_string<_Elem,_Traits,_Alloc> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludestring(223) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Hash<_Traits> &,const std::_Hash<_Traits> &) : could not deduce template argument for const std::_Hash<_Traits> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexhash(933) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &) : could not deduce template argument for const std::list<_Ty,_Ax> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludelist(1588) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &) : could not deduce template argument for const std::vector<_Ty,_Ax> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludevector(1502) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &) : could not deduce template argument for const std::unique_ptr<_Ty,_Dx> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludememory(2582) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &) : could not deduce template argument for const std::reverse_iterator<_RanIt> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexutility(1356) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &) : could not deduce template argument for const std::_Revranit<_RanIt,_Base> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludexutility(1179) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool std:perator <(const std:air<_Ty1,_Ty2> &,const std:air<_Ty1,_Ty2> &) : could not deduce template argument for const std:air<_Ty1,_Ty2> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludeutility(318) : see declaration of std:perator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool operator <(_Interface *,const _com_ptr_t<_InterfacePtr> &) : could not deduce template argument for _Interface * from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludecomip.h(943) : see declaration of operator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2784: bool operator <(int,const _com_ptr_t<_IIID> &) : could not deduce template argument for const _com_ptr_t<_IIID> & from const Styles
1> Crogram FilesMicrosoft Visual Studio 10.0VCincludecomip.h(934) : see declaration of operator <
1>Crogram FilesMicrosoft Visual Studio 10.0VCincludexfunctional(125): error C2676: binary < : const Styles does not define this operator or a conversion to a type acceptable to the predefined operator
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/code]
whats going on?
cheers
daiyue
View the full article