Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / third_party / angle / util / com_utils.h
1 //
2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // com_utils.h: Utility functions for working with COM objects
8
9 #ifndef UTIL_COM_UTILS_H
10 #define UTIL_COM_UTILS_H
11
12 template <typename outType>
13 inline outType *DynamicCastComObject(IUnknown *object)
14 {
15     outType *outObject = nullptr;
16     HRESULT result = object->QueryInterface(__uuidof(outType), reinterpret_cast<void**>(&outObject));
17     if (SUCCEEDED(result))
18     {
19         return outObject;
20     }
21     else
22     {
23         SafeRelease(outObject);
24         return nullptr;
25     }
26 }
27
28 #endif // UTIL_COM_UTILS_H