pacemaker 3.0.3
COM automation for people with deadlines and a hatred of GUIs
 
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1#ifndef PACEMAKER_INCA_DETAIL_UTILS_HPP_
2#define PACEMAKER_INCA_DETAIL_UTILS_HPP_
3
4#include <stdexcept>
5#include <typeinfo>
6
7#include <comdef.h>
8
10
12{
39 template<class T>
41 {
42 if (src == nullptr)
43 throw std::invalid_argument("Attempt on calling QueryInterface on nullptr");
44
45 T *out{nullptr};
46 HRESULT hr = src->QueryInterface(__uuidof(T::type), reinterpret_cast<void **>(&out));
47
48 if (FAILED(hr))
49 throw std::runtime_error(
50 std::string("QueryInterface failed for ") + typeid(T).name());
51
53 }
54} // namespace pacemaker::inca::detail
55
56#endif // PACEMAKER_INCA_DETAIL_UTILS_HPP_
auto query_interface(pacemaker::inca::detail::unique_com_ptr<::IDispatch > src) -> pacemaker::inca::detail::unique_com_ptr< T >
Narrows a generic IDispatch pointer to a typed DispatchWrapper.
Definition utils.hpp:40
std::unique_ptr< T, ComObjDeleter< T > > unique_com_ptr
RAII owning pointer for COM objects.