]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - os_win32/wmiquery.h
4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2011-18 Christian Franke
8 * SPDX-License-Identifier: GPL-2.0-or-later
14 #define WMIQUERY_H_CVSID "$Id: wmiquery.h 4760 2018-08-19 18:45:53Z chrfranke $"
21 #define __attribute_format_printf(x, y) /**/
22 #elif defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO
23 // Check format of __mingw_*printf() instead of MSVCRT.DLL:*printf()
24 #define __attribute_format_printf(x, y) __attribute__((format (gnu_printf, x, y)))
26 #define __attribute_format_printf(x, y) __attribute__((format (printf, x, y)))
29 /////////////////////////////////////////////////////////////////////////////
32 /// Wrapper class for COM BSTR
36 /// Construct from string.
37 explicit com_bstr(const char * str
);
39 /// Destructor frees BSTR.
41 { SysFreeString(m_bstr
); }
43 /// Implicit conversion to BSTR.
47 /// Convert BSTR back to std::string.
48 static bool to_str(const BSTR
& bstr
, std::string
& str
);
53 com_bstr(const com_bstr
&);
54 void operator=(const com_bstr
&);
58 /////////////////////////////////////////////////////////////////////////////
61 /// Wrapper class for COM Interface pointer
66 /// Construct empty object
70 /// Destructor releases the interface.
74 /// Release interface and clear the pointer.
78 m_ptr
->Release(); m_ptr
= 0;
82 /// Return the pointer.
86 /// Pointer dereferencing.
90 /// Return address of pointer for replacement.
92 { reset(); return &m_ptr
; }
94 /// For (ptr != 0) check.
98 /// For (ptr == 0) check.
99 bool operator!() const
105 com_intf_ptr(const com_intf_ptr
&);
106 void operator=(const com_intf_ptr
&);
110 /////////////////////////////////////////////////////////////////////////////
113 class wbem_enumerator
;
115 /// Wrapper class for IWbemClassObject
119 /// Get string representation.
120 std::string
get_str(const char * name
) /*const*/;
123 /// Contents is set by wbem_enumerator.
124 friend class wbem_enumerator
;
125 com_intf_ptr
<IWbemClassObject
> m_intf
;
129 /////////////////////////////////////////////////////////////////////////////
134 /// Wrapper class for IEnumWbemClassObject
135 class wbem_enumerator
138 /// Get next object, return false if none or error.
139 bool next(wbem_object
& obj
);
142 /// Contents is set by wbem_services.
143 friend class wbem_services
;
144 com_intf_ptr
<IEnumWbemClassObject
> m_intf
;
148 /////////////////////////////////////////////////////////////////////////////
151 /// Wrapper class for IWbemServices
155 /// Connect to service, return false on error.
158 /// Execute query, get result list.
159 /// Return false on error.
160 bool vquery(wbem_enumerator
& result
, const char * qstr
, va_list args
) /*const*/
161 __attribute_format_printf(3, 0);
163 /// Execute query, get single result object.
164 /// Return false on error or result size != 1.
165 bool vquery1(wbem_object
& obj
, const char * qstr
, va_list args
) /*const*/
166 __attribute_format_printf(3, 0);
168 /// Version of vquery() with printf() formatting.
169 bool query(wbem_enumerator
& result
, const char * qstr
, ...) /*const*/
170 __attribute_format_printf(3, 4);
172 /// Version of vquery1() with printf() formatting.
173 bool query1(wbem_object
& obj
, const char * qstr
, ...) /*const*/
174 __attribute_format_printf(3, 4);
177 com_intf_ptr
<IWbemServices
> m_intf
;