| 26 | namespace { |
| 27 | |
| 28 | HRESULT SkipToElementEnd(const CComPtr<IXmlReader>& pReader) |
| 29 | { |
| 30 | XmlNodeType type = XmlNodeType_None; |
| 31 | |
| 32 | // Elements such as '<foo/>' does not need to be skipped as next call will do |
| 33 | if (pReader->IsEmptyElement()) |
| 34 | { |
| 35 | return S_OK; |
| 36 | } |
| 37 | |
| 38 | UINT depth; |
| 39 | HRESULT hr = pReader->GetDepth(&depth); |
| 40 | if (FAILED(hr)) |
| 41 | { |
| 42 | Log::Error(L"Failed get root element depth [{}]", SystemError(hr)); |
| 43 | return hr; |
| 44 | } |
| 45 | |
| 46 | UINT currentDepth; |
| 47 | do |
| 48 | { |
| 49 | hr = pReader->Read(&type); |
| 50 | if (FAILED(hr)) |
| 51 | { |
| 52 | Log::Error(L"Failed to read element [{}]", SystemError(hr)); |
| 53 | return hr; |
| 54 | } |
| 55 | |
| 56 | hr = pReader->GetDepth(¤tDepth); |
| 57 | if (FAILED(hr)) |
| 58 | { |
| 59 | Log::Error(L"Failed get element depth [{}]", SystemError(hr)); |
| 60 | return hr; |
| 61 | } |
| 62 | |
| 63 | } while ((type != XmlNodeType_EndElement && type != XmlNodeType_None) && currentDepth >= depth); |
| 64 | |
| 65 | return S_OK; |
| 66 | } |
| 67 | |
| 68 | } // namespace |
| 69 |
no test coverage detected