]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - os_win32/wmiquery.h
4 * Home page of code is: http://smartmontools.sourceforge.net
6 * Copyright (C) 2011 Christian Franke <smartmontools-support@lists.sourceforge.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * You should have received a copy of the GNU General Public License
14 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
21 #define WMIQUERY_H_CVSID "$Id: wmiquery.h 3243 2011-01-19 20:03:47Z chrfranke $"
26 #include "wbemcli_small.h"
31 #if !defined(__GNUC__) && !defined(__attribute__)
32 #define __attribute__(x) /**/
35 /////////////////////////////////////////////////////////////////////////////
38 /// Wrapper class for COM BSTR
42 /// Construct from string.
43 com_bstr(const char * str
);
45 /// Destructor frees BSTR.
47 { SysFreeString(m_bstr
); }
49 /// Implicit conversion to BSTR.
53 /// Convert BSTR back to std::string.
54 static bool to_str(const BSTR
& bstr
, std::string
& str
);
59 com_bstr(const com_bstr
&);
60 void operator=(const com_bstr
&);
64 /////////////////////////////////////////////////////////////////////////////
67 /// Wrapper class for COM Interface pointer
72 /// Construct empty object
76 /// Destructor releases the interface.
80 /// Release interface and clear the pointer.
84 m_ptr
->Release(); m_ptr
= 0;
88 /// Return the pointer.
92 /// Pointer dereferencing.
96 /// Return address of pointer for replacement.
98 { reset(); return &m_ptr
; }
100 /// For (ptr != 0) check.
101 operator bool() const
104 /// For (ptr == 0) check.
105 bool operator!() const
111 com_intf_ptr(const com_intf_ptr
&);
112 void operator=(const com_intf_ptr
&);
116 /////////////////////////////////////////////////////////////////////////////
119 class wbem_enumerator
;
121 /// Wrapper class for IWbemClassObject
125 /// Get string representation.
126 std::string
get_str(const char * name
) /*const*/;
129 /// Contents is set by wbem_enumerator.
130 friend class wbem_enumerator
;
131 com_intf_ptr
<IWbemClassObject
> m_intf
;
135 /////////////////////////////////////////////////////////////////////////////
140 /// Wrapper class for IEnumWbemClassObject
141 class wbem_enumerator
144 /// Get next object, return false if none or error.
145 bool next(wbem_object
& obj
);
148 /// Contents is set by wbem_services.
149 friend class wbem_services
;
150 com_intf_ptr
<IEnumWbemClassObject
> m_intf
;
154 /////////////////////////////////////////////////////////////////////////////
157 /// Wrapper class for IWbemServices
161 /// Connect to service, return false on error.
164 /// Execute query, get result list.
165 /// Return false on error.
166 bool vquery(wbem_enumerator
& result
, const char * qstr
, va_list args
) /*const*/;
168 /// Execute query, get single result object.
169 /// Return false on error or result size != 1.
170 bool vquery1(wbem_object
& obj
, const char * qstr
, va_list args
) /*const*/;
172 /// Version of vquery() with printf() formatting.
173 bool query(wbem_enumerator
& result
, const char * qstr
, ...) /*const*/
174 __attribute__ ((format (printf
, 3, 4)));
176 /// Version of vquery1() with printf() formatting.
177 bool query1(wbem_object
& obj
, const char * qstr
, ...) /*const*/
178 __attribute__ ((format (printf
, 3, 4)));
181 com_intf_ptr
<IWbemServices
> m_intf
;