コード例 #1
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetStrings(IXMLDOMElement* e, std::vector<std::wstring>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;
		std::wstring str;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"value"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		str = (LPCWSTR)(_bstr_t)var;
		v.push_back(str);
	}
}
コード例 #2
0
VARIANT XMLDoc::getVariant(const XMLNodePtr &node, const TCHAR *tagName, int instans) {
  VARIANT result;
  result.vt = NULL;

  if(node!=NULL) {
    int i=0;
    for(XMLNodePtr p = node->firstChild; p != NULL; p = p->nextSibling) {
      if(p->nodeType==NODE_ELEMENT &&
          _tcsicmp(((XMLElementPtr)p)->tagName,tagName) == 0 &&
          i++ == instans) {
        IXMLDOMNodeListPtr childList = p->childNodes;
        LONG length;
        childList->get_length(&length);
        for(int j = 0; j < length; j++) {
          IXMLDOMNodePtr item;
          childList->get_item(j, &item);
          DOMNodeType itemType;
          item->get_nodeType(&itemType);
          if(itemType == NODE_TEXT) {
            item->get_nodeValue(&result);
            return result;
          }
        }
        return result;
      }
    }
  }
  return result;
}
コード例 #3
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetULongs(IXMLDOMElement* e,std::vector<unsigned long>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;
		unsigned long val;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"val"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		val = (unsigned long)var;
		v.push_back(val);
	}
}
コード例 #4
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetGUIDs(IXMLDOMElement* e, std::vector<GUID>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;
		GUID guid;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"name"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		string_to_guid((LPCWSTR)(_bstr_t)var,&guid);
		v.push_back(guid);
	}
}
コード例 #5
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetGUIDLists(IXMLDOMElement* e,std::map<unsigned long,std::vector<GUID> >& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"id"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		GetGUIDs(item,v[(unsigned long)var]);

	}
}
コード例 #6
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetDeviceList(IXMLDOMElement* e, DEVICELIST& d)
{
	HRESULT hr;
	IXMLDOMNodeListPtr list;
	long listlength;

	hr = e->get_childNodes(&list);
	if(hr!=S_OK) throw _com_error(hr);

	hr = list->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);
	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMNodePtr itemnode;
		IXMLDOMElementPtr itemlement;

		hr = list->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		itemlement = itemnode;

		DEVICE device;
		GetDevice(itemlement,device);
		d.push_back(device);

	}
}
コード例 #7
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetBDATemplateConnections(IXMLDOMElement* e,std::vector<BDA_TEMPLATE_CONNECTION>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;
		BDA_TEMPLATE_CONNECTION con;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"FromNodeType"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		con.FromNodeType = (unsigned long)var;
		var.Clear();
		hr = item->getAttribute(_bstr_t(L"FromNodePinType"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		con.FromNodePinType = (unsigned long)var;
		var.Clear();
		hr = item->getAttribute(_bstr_t(L"ToNodeType"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		con.ToNodeType = (unsigned long)var;
		var.Clear();
		hr = item->getAttribute(_bstr_t(L"ToNodePinType"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		con.ToNodePinType = (unsigned long)var;
		var.Clear();
		v.push_back(con);
	}
}
コード例 #8
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetBDANodeDescriptors(IXMLDOMElement* e,std::vector<BDANODE_DESCRIPTOR>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item;
		IXMLDOMNodePtr itemnode;
		_variant_t var;

		BDANODE_DESCRIPTOR con;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"ulBdaNodeType"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		con.ulBdaNodeType = (unsigned long)var;
		var.Clear();
		hr = item->getAttribute(_bstr_t(L"guidFunction"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		string_to_guid((LPCWSTR)(_bstr_t)var,&con.guidFunction);
		var.Clear();
		hr = item->getAttribute(_bstr_t(L"guidName"),&var);
		if(hr!=S_OK) throw _com_error(hr);
		string_to_guid((LPCWSTR)(_bstr_t)var,&con.guidName);
		var.Clear();
	}
}
コード例 #9
0
ファイル: main.cpp プロジェクト: tomorrow56/VS2010
bool GetXmlValue(	const IXMLDOMDocumentPtr&	pXMLDOMDocument,
					const CComBSTR&				bstrTagName,
					const CComBSTR&				bstrAttributeName,
					std::vector<CComBSTR>&		rvbstrValue )
{
	// アウトプットの初期化
	rvbstrValue.clear();

	// インプットのチェック
	if( 0 == bstrTagName.Length() )
	{
		return false;
	}

	HRESULT hResult;

	// タグ名のノードリストの取得
	IXMLDOMNodeListPtr pXMLDOMNodeList = NULL;
	hResult = pXMLDOMDocument->getElementsByTagName( bstrTagName, &pXMLDOMNodeList );
	if( FAILED(hResult) || NULL == pXMLDOMNodeList )
	{
		assert( !"タグ名のノードリストの取得に失敗" );
		return false;
	}
	// ノードリストのノードの数の取得
	long lCountNode = 0;
	hResult = pXMLDOMNodeList->get_length( &lCountNode );
	if( FAILED(hResult) )
	{
		assert( !"ノードリストのノードの数の取得に失敗" );
		return false;
	}
	// ノードリストのノード一つずつ処理
	for( int i = 0; i < lCountNode; ++i )
	{
		// ノードリストのうちの一つのノードの取得
		IXMLDOMNodePtr pXMLDOMNode = NULL;
		hResult = pXMLDOMNodeList->get_item( i, &pXMLDOMNode );
		if( FAILED(hResult) )
		{
			assert( !"ノードリストのうちの一つのノードの取得に失敗" );
			return false; 
		}

		// ノードタイプの取得
		DOMNodeType eNodeType;
		hResult = pXMLDOMNode->get_nodeType( &eNodeType );
		if( FAILED(hResult) )
		{
			assert( !"ノードタイプの取得に失敗" );
			return false; 
		}
		if( NODE_ELEMENT != eNodeType )
		{
			assert( !"ノードタイプがエレメントでないのはおかしい" );
			return false;
		}
		// エレメント型への変換
		IXMLDOMElementPtr pXMLDOMElement = NULL;
		hResult = pXMLDOMNode->QueryInterface( IID_IXMLDOMElement, (void**)&pXMLDOMElement );	// スマートポインタ型を利用しているので、pXMLDOMElement = pXMLDOMNode; でも良い。
		if( FAILED(hResult) || NULL == pXMLDOMElement )
		{
			assert( !"エレメント型への変換に失敗" );
			return false;
		}

		// 属性値の取得か、データ値の取得か
		if( bstrAttributeName.Length() )
		{	// 属性値の取得
			IXMLDOMAttribute* pAttributeNode = NULL;
			CComVariant varValue;
			hResult = pXMLDOMElement->getAttribute( bstrAttributeName, &varValue ); 
			if( SUCCEEDED(hResult) && VT_BSTR == varValue.vt )
			{
				rvbstrValue.push_back( varValue.bstrVal );
			}
		}
		else
		{	// データ値の取得
			CComBSTR bstrText;
			hResult = pXMLDOMElement->get_text( &bstrText );
			if( SUCCEEDED(hResult) )
			{
				rvbstrValue.push_back( bstrText );
			}
		}
	}

	return true;
}
コード例 #10
0
/**Read the XML config file. Currently contains keyboard choices.*/
void read_config_file()
{
	TrainerConfig *result = new TrainerConfig();

	CoInitialize(NULL);

	//read XML
	MSXML2::IXMLDOMDocumentPtr spXMLDoc;
	spXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
	if (!spXMLDoc->load("ent-config.xml"))
	{
		write_text_to_log_file("No config found, using defaults");
		config = result; //the default config
	}

	IXMLDOMNodeListPtr nodes = spXMLDoc->selectNodes(L"//ent-config/keys/key");

	long length;
	nodes->get_length(&length);
	for (int i = 0; i < length; i++)
	{
		IXMLDOMNode *node;
		nodes->get_item(i, &node);
		IXMLDOMNamedNodeMap *attribs;
		node->get_attributes(&attribs);

		long length_attribs;
		attribs->get_length(&length_attribs);

		char *attrib_key_func = NULL;
		char *attrib_key_value = NULL;

		for (long j = 0; j < length_attribs; j++)
		{
			IXMLDOMNode *attribNode;
			attribs->get_item(j, &attribNode);
			attribNode->get_nodeName(&bstr);
			if (wcscmp(bstr, L"function") == 0)
			{
				VARIANT var;
				VariantInit(&var);
				attribNode->get_nodeValue(&var);
				attrib_key_func = _com_util::ConvertBSTRToString(V_BSTR(&var));
			}
			else if (wcscmp(bstr, L"value") == 0)
			{
				VARIANT var;
				VariantInit(&var);
				attribNode->get_nodeValue(&var);
				attrib_key_value = _com_util::ConvertBSTRToString(V_BSTR(&var));
			}
			SysFreeString(bstr);
			attribNode->Release();
		}
		
		if (attrib_key_func != NULL && attrib_key_value != NULL)
		{
			result->get_key_config()->set_key(attrib_key_func, attrib_key_value);
		}
		
		delete attrib_key_func;
		delete attrib_key_value;

		attribs->Release();
		node->Release();
	}

	//nodes->Release(); //don't do this, it crashes on exit
	spXMLDoc.Release();
	CoUninitialize();
	
	config = result;
}
コード例 #11
0
/******************************************************************************
Function Name  :  nLoadHeader
Input(s)       :  MSXML2::IXMLDOMNodePtr& pHeaderDOMNode
Output         :  INT
Functionality  :  Retrieves the Header info
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
Codetag        :
******************************************************************************/
INT CTestSetupEntity::nLoadHeader(MSXML2::IXMLDOMNodePtr& pHeaderDOMNode)
{
    // CComPtr<IXMLDOMNode> pHeaderDOMNode;
    MSXML2::IXMLDOMNodeListPtr pXMLDOMInfoList;
    MSXML2::IXMLDOMNodePtr pInfoNode;
    MSXML2::IXMLDOMNodePtr pInfoCategoryNode;
    MSXML2::IXMLDOMNodePtr pInfoValueNode;
    _bstr_t bstrNodeName = "info";
    CComVariant NodeValue;
    pXMLDOMInfoList = pHeaderDOMNode->selectNodes(bstrNodeName);

    LONG lCount = 0;
    pXMLDOMInfoList->get_length(&lCount);
    SInfo ouTempSInfo;
    for(int i = 0; i<lCount; i++)
    {
        pInfoNode = pXMLDOMInfoList->Getitem(i);

        //bstrNodeName = def_STR_CATEGORY_NODE;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_CATEGORY_NODE)));
        pInfoCategoryNode = pInfoNode->selectSingleNode(bstrNodeName);
        pInfoCategoryNode->get_nodeTypedValue(&NodeValue);

        ouTempSInfo.m_omCategory = strCopyBSTRToCString(NodeValue);

        pInfoCategoryNode.Release();

        //bstrNodeName = def_STR_VALUE_NODE;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VALUE_NODE)));
        pInfoCategoryNode = pInfoNode->selectSingleNode(bstrNodeName);
        pInfoCategoryNode->get_nodeTypedValue(&NodeValue);
        ouTempSInfo.m_omValue = strCopyBSTRToCString(NodeValue);
        pInfoCategoryNode.Release();

        pInfoNode.Release();


        if(ouTempSInfo.m_omCategory == def_STR_MODULENAME)
        {
            m_ouTestSetupHeader.m_sModuleName.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sModuleName.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_ENGINEERNAME)
        {
            m_ouTestSetupHeader.m_sEngineerInfo1.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sEngineerInfo1.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_ENGINERROLE)
        {
            m_ouTestSetupHeader.m_sEngineerInfo2.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sEngineerInfo2.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_VERSION)
        {
            m_ouTestSetupHeader.m_sVersion.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sVersion.m_omValue = ouTempSInfo.m_omValue;
        }
    }
    //Taking Database
    long lCount2 = 0;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_LISTOFDB)));
    IXMLDOMNodeListPtr pIDOMSignalList = pHeaderDOMNode->selectNodes(bstrNodeName);
    pIDOMSignalList->get_length(&lCount2);

    for(INT j = 0; j < lCount2; j++)
    {
        IXMLDOMNode* pIDOMSChildSignal;
        pIDOMSignalList->get_item(j, &pIDOMSChildSignal);
        pIDOMSChildSignal->get_nodeTypedValue(&NodeValue);
        m_ouTestSetupHeader.m_omDatabasePaths.Add(strCopyBSTRToCString(NodeValue));
        //Set The Database Paths
        SetDatabaseFile(strCopyBSTRToCString(NodeValue), j+1);
    }
   // pInfoNode.Release();

    //bstrNodeName = def_STR_REPORT_FORMAT;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_FORMAT)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
    CString omStrExt;
    omStrExt = strCopyBSTRToCString(NodeValue);
    pInfoNode.Release();


    if(omStrExt == "HTM")
    {
        m_ouTestSetupHeader.m_sReportFile.m_eType = HTM;
    }
    else
    {
        m_ouTestSetupHeader.m_sReportFile.m_eType = TXT;
    }

    //bstrNodeName = def_STR_REPORT_PATH;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_PATH)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
    m_ouTestSetupHeader.m_sReportFile.m_omPath = strCopyBSTRToCString(NodeValue);
    pInfoNode.Release();




    //bstrNodeName = def_STR_REPORT_TIMEMODE;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_TIMEMODE)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
    CString strTemp;
    strTemp = strCopyBSTRToCString(NodeValue);
    if(strTemp == "ABS")
    {
        m_ouTestSetupHeader.m_sReportFile.m_eTimeMode = ABS;
    }
    else                    //Default
    {
        m_ouTestSetupHeader.m_sReportFile.m_eTimeMode = REL;
    }
    pInfoNode.Release();


    //bstrNodeName = def_STR_BUS_TYPE;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_BUS_TYPE)));
    pInfoNode= pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
    strTemp = strCopyBSTRToCString(NodeValue);

    if(strTemp == "CAN")
    {
        m_ouTestSetupHeader.m_eBus = CAN;
    }

    pInfoNode.Release();

    return 0;
}
コード例 #12
0
/******************************************************************************
Function Name  :  GetData
Input(s)       :  MSXML2::IXMLDOMNodePtr& pIDomNode
Output         :  HRESULT
Functionality  :  Fill the datastructure from xml node pIDomNode
Member of      :  CVerify_MessageEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam, GT-Derka
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerify_MessageEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
    IXMLDOMNode* pIDOMChildNode;
    LONG lCount;
    CComBSTR bstrNodeName;
    CComVariant NodeValue;
    CString omstrTemp;
    CSignalCondition ouSignalCondition;
    IXMLDOMNamedNodeMapPtr pIDOMAttributes;
    pIDOMAttributes = pIDomNode->Getattributes();// get_attributes((IXMLDOMNamedNodeMap**)&pIDOMAttributes);

    //Retrieving Message ID
    bstrNodeName = def_STR_TCATTRIB_ID;
    pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
    omstrTemp = strCopyBSTRToCString(NodeValue);
    m_ouData.m_dwMessageID = atoi((LPCSTR)omstrTemp);
    m_ouData.m_omMessageName = omstrTemp;
    if(m_ouDataBaseManager.bIsValidMessageID(m_ouData.m_dwMessageID)== FALSE)
    {
        //TODO::INVALID MSG POSSIBLE ONLY WHEN THE FILE IS EDITED WITH NOTEPAD.
        return -1;
    }
    pIDOMChildNode->Release();

    //Retrieving Message UNIT
    bstrNodeName = _(def_STR_TCATTRIB_UNIT);
    pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
    omstrTemp = strCopyBSTRToCString(NodeValue);
    if(omstrTemp == "RAW")
    {
        m_ouData.m_eSignalUnitType = RAW;
    }
    else                                    // else if(omstrTemp == "ENG")
    {
        m_ouData.m_eSignalUnitType = ENG;
    }
    pIDOMChildNode->Release();

    //Retrieving Message Channel
    bstrNodeName = def_STR_TCATTRIB_CHANNEL;
    pIDOMAttributes->getNamedItem(bstrNodeName, &pIDOMChildNode);
    m_ouData.m_byChannelNumber = 0;                 // set default-value for the case, the number is incorrect or the whole argument is missing
    if (NULL != pIDOMChildNode)                     // avoid crash in case XML-file -without channel-information- is loaded
    {
        pIDOMChildNode->get_nodeTypedValue(&NodeValue);
        omstrTemp = strCopyBSTRToCString(NodeValue);
        m_ouData.m_byChannelNumber = atoi((LPCSTR)omstrTemp);
        pIDOMChildNode->Release();
    }
    if(m_ouData.m_byChannelNumber == 0)             // if casting fails (failure in xml)
    {
        m_ouData.m_byChannelNumber = 1; // set default channel */
        m_lDefaultChannelUsed = 1;
    }

    //Retrieving Signals and their Data

    IFrame* sMsg;
    IXMLDOMNodeListPtr pIDOMSignalList;
    IXMLDOMNode* pIDOMSChildSignal;

    bstrNodeName = _(def_STR_SIGNAL_NODE);
    pIDOMSignalList = pIDomNode->selectNodes((_bstr_t)bstrNodeName);
    pIDOMSignalList->get_length(&lCount);


    INT nRetVal;
    nRetVal = m_ouDataBaseManager.nGetMessageName(m_ouData.m_dwMessageID, m_ouData.m_omMessageName);
    if(nRetVal != S_OK)
    {
        return nRetVal;
    }

    nRetVal =  m_ouDataBaseManager.nGetMessageInfo(m_ouData.m_omMessageName, &sMsg);
    if ( sMsg == nullptr )
    {
        return nRetVal;
    }

    UINT unSignalCount = sMsg->GetSignalCount();
    //W4 Removal - Local variable not required
    //UINT unTSSignalCount = lCount;
    std::map<ISignal*, SignalInstanse> signalList;
    sMsg->GetSignalList( signalList);
    std::string signalName;
for (auto signal : signalList )
        //for(UINT i = 0; i < unSignalCount; i++)
    {
        CSignalCondition ouSignalData, ouTSSignalData;
        signal.first->GetName( signalName );
        ouSignalData.m_omSigName = signalName.c_str();
        ouSignalData.m_omCondition = "";
        for(int i = 0; i < lCount; i++)
        {
            pIDOMSignalList->get_item(i, &pIDOMSChildSignal);
            vRetrieveConditionSignalValue(pIDOMSChildSignal, ouTSSignalData);
            if(ouSignalData.m_omSigName == ouTSSignalData.m_omSigName)
            {
                ouSignalData.m_omCondition = ouTSSignalData.m_omCondition;
                break;
            }
        }
        m_ouData.m_odSignalConditionList.AddTail(ouSignalData);
    }
    return S_OK;
}
コード例 #13
0
ファイル: xmldoc.cpp プロジェクト: jensvaaben/mfcbdainf
static void GetPininfos(IXMLDOMElement* e,std::vector<PININFO>& v)
{
	HRESULT hr;
	IXMLDOMNodeListPtr children;
	long listlength;

	hr = e->get_childNodes(&children);
	if(hr!=S_OK) throw _com_error(hr);
	hr = children->get_length(&listlength);
	if(hr!=S_OK) throw _com_error(hr);

	for(size_t n=0;n<listlength;n++)
	{
		IXMLDOMElementPtr item, item2;
		IXMLDOMNodePtr itemnode, itemnode2;
		_variant_t var;
		PININFO pininfo;

		hr = children->get_item(n,&itemnode);
		if(hr!=S_OK) throw _com_error(hr);
		item = itemnode;

		hr = item->getAttribute(_bstr_t(L"ksproperty_pin_category"),&var);
		if(hr==S_OK)
		{
			string_to_guid((LPCWSTR)(_bstr_t)var,&pininfo.category);
			pininfo.category_valid = true;
			var.Clear();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_cinstances"),&itemnode2);
		if(hr==S_OK)
		{
			item2 = itemnode2;
			hr = item2->getAttribute(_bstr_t(L"PossibleCount"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.cinstances.PossibleCount = (unsigned long)var;
			var.Clear();
			hr = item2->getAttribute(_bstr_t(L"CurrentCount"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.cinstances.CurrentCount = (unsigned long)var;
			var.Clear();
			pininfo.cinstances_valid = true;
			itemnode2.Release();
			item2.Release();
		}

		hr = item->getAttribute(_bstr_t(L"ksproperty_pin_communication"),&var);
		if(hr==S_OK)
		{
			pininfo.communication = (KSPIN_COMMUNICATION)(unsigned long)var;
			pininfo.communication_valid = true;
			var.Clear();
		}

		hr = item->getAttribute(_bstr_t(L"ksproperty_pin_dataflow"),&var);
		if(hr==S_OK)
		{
			pininfo.dataflow = (KSPIN_DATAFLOW)(unsigned long)var;
			pininfo.dataflow_valid = true;
			var.Clear();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_dataintersection"),&itemnode2);
		if(hr == S_OK)
		{
			item2 = itemnode2;
			GetKSDATARANGE(item2,pininfo.dataintersection);
			pininfo.dataintersection_valid = true;
			itemnode2.Release();
			item2.Release();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_dataranges"),&itemnode2);
		if(hr==S_OK)
		{
			IXMLDOMNodeListPtr children2;
			long listlength2;
			item2 = itemnode2;

			hr = item2->get_childNodes(&children2);
			if(hr!=S_OK) throw _com_error(hr);
			hr = children2->get_length(&listlength2);
			if(hr!=S_OK) throw _com_error(hr);

			for(size_t m=0;m<listlength2;m++)
			{
				IXMLDOMElementPtr item3;
				IXMLDOMNodePtr itemnode3;
				KSDATARANGE ksdatarange;

				hr = children2->get_item(m, &itemnode3);
				if(hr!=S_OK) throw _com_error(hr);
				item3 = itemnode3;

				GetKSDATARANGE(item3,ksdatarange);
				pininfo.dataranges.push_back(ksdatarange);
			}

			item2.Release();
			itemnode2.Release();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_globalcinstances"),&itemnode2);
		if(hr==S_OK)
		{
			item2 = itemnode2;
			hr = item2->getAttribute(_bstr_t(L"PossibleCount"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.globalcinstances.PossibleCount = (unsigned long)var;
			var.Clear();
			hr = item2->getAttribute(_bstr_t(L"CurrentCount"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.globalcinstances.CurrentCount = (unsigned long)var;
			var.Clear();
			pininfo.globalcinstances_valid = true;
			itemnode2.Release();
			item2.Release();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_interfaces"),&itemnode2);
		if(hr==S_OK)
		{
			IXMLDOMNodeListPtr children2;
			long listlength2;
			item2 = itemnode2;

			hr = item2->get_childNodes(&children2);
			if(hr!=S_OK) throw _com_error(hr);
			hr = children2->get_length(&listlength2);
			if(hr!=S_OK) throw _com_error(hr);

			for(size_t m=0;m<listlength2;m++)
			{
				IXMLDOMElementPtr item3;
				IXMLDOMNodePtr itemnode3;
				KSIDENTIFIER ksidentifier;

				hr = children2->get_item(m, &itemnode3);
				if(hr!=S_OK) throw _com_error(hr);
				item3 = itemnode3;

				GetKSIDENTIFIER(item3,ksidentifier);
				pininfo.interfaces.push_back(ksidentifier);
			}

			itemnode2.Release();
			item2.Release();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_mediums"),&itemnode2);
		if(hr==S_OK)
		{
			IXMLDOMNodeListPtr children2;
			long listlength2;
			item2 = itemnode2;

			hr = item2->get_childNodes(&children2);
			if(hr!=S_OK) throw _com_error(hr);
			hr = children2->get_length(&listlength2);
			if(hr!=S_OK) throw _com_error(hr);

			for(size_t m=0;m<listlength2;m++)
			{
				IXMLDOMElementPtr item3;
				IXMLDOMNodePtr itemnode3;
				KSIDENTIFIER ksidentifier;

				hr = children2->get_item(m, &itemnode3);
				if(hr!=S_OK) throw _com_error(hr);
				item3 = itemnode3;

				GetKSIDENTIFIER(item3,ksidentifier);
				pininfo.mediums.push_back(ksidentifier);
			}

			itemnode2.Release();
			item2.Release();
		}

		hr = item->getAttribute(_bstr_t(L"ksproperty_pin_name"),&var);
		if(hr==S_OK)
		{
			pininfo.name = (LPCWSTR)(_bstr_t)var;
			var.Clear();
		}

		hr = item->getAttribute(_bstr_t(L"ksproperty_pin_necessaryinstances"),&var);
		if(hr==S_OK)
		{
			pininfo.necessaryinstances = (unsigned long)var;
			pininfo.necessaryinstances_valid = true;
			var.Clear();
		}

		hr = item->selectSingleNode(_bstr_t(L"ksproperty_pin_physicalconnection"),&itemnode2);
		if(hr==S_OK)
		{
			item2 = itemnode2;
			hr = item2->getAttribute(_bstr_t(L"Size"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.physicalconnection.Size = (unsigned long)var;
			var.Clear();
			hr = item2->getAttribute(_bstr_t(L"Pin"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.physicalconnection.Pin = (unsigned long)var;
			var.Clear();
			hr = item2->getAttribute(_bstr_t(L"SymbolicLinkName"),&var);
			if(hr!=S_OK) throw _com_error(hr);
			pininfo.symboliclinkname = (LPCWSTR)(_bstr_t)var;
			var.Clear();
			pininfo.physicalconnection_valid = true;
			itemnode2.Release();
			item2.Release();
		}

		v.push_back(pininfo);
	}
}