• Skip to sidebar navigation
  • Skip to content
Linked Applications
  • Jira
  • Confluence
  • Bitbucket
  • Atlassian Bamboo
  • Почта

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Redkit
  1. Redkit

QtIFW

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Redkit
  2. QtIFW

Source

QtIFW/src/libs/7zip/unix/CPP/Common/MyCom.h
kh1kh1 committed be3b47d0d5015 Mar 2012
Raw file
Source viewDiff to previous
 
1
// MyCom.h
2
​
3
#ifndef __MYCOM_H
4
#define __MYCOM_H
5
​
6
#include "MyWindows.h"
7
​
8
#ifndef RINOK
9
#define RINOK(x) { HRESULT __result_ = (x); if (__result_ != S_OK) return __result_; }
10
#endif
11
​
12
template <class T>
13
class CMyComPtr
14
{
15
  T* _p;
16
public:
17
  // typedef T _PtrClass;
18
  CMyComPtr() { _p = NULL;}
19
  CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }
20
  CMyComPtr(const CMyComPtr<T>& lp)
21
  {
22
    if ((_p = lp._p) != NULL)
23
      _p->AddRef();
24
  }
25
  ~CMyComPtr() { if (_p) _p->Release(); }
26
  void Release() { if (_p) { _p->Release(); _p = NULL; } }
27
  operator T*() const {  return (T*)_p;  }
28
  // T& operator*() const {  return *_p; }
29
  T** operator&() { return &_p; }
30
  T* operator->() const { return _p; }
31
  T* operator=(T* p)
32
  {
33
    if (p != 0)
34
      p->AddRef();
35
    if (_p)
36
      _p->Release();
37
    _p = p;
38
    return p;
39
  }
40
  T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
41
  bool operator!() const { return (_p == NULL); }
42
  // bool operator==(T* pT) const {  return _p == pT; }
43
  // Compare two objects for equivalence
44
  void Attach(T* p2)
45
  {
46
    Release();
47
    _p = p2;
48
  }
49
  T* Detach()
50
  {
51
    T* pt = _p;
52
    _p = NULL;
53
    return pt;
54
  }
55
  #ifdef _WIN32
56
  HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
57
  {
58
    return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
59
  }
60
  #endif
61
  /*
62
  HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
63
  {
64
    CLSID clsid;
65
    HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
66
    ATLASSERT(_p == NULL);
67
    if (SUCCEEDED(hr))
68
      hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
69
    return hr;
70
  }
71
  */
72
  template <class Q>
73
  HRESULT QueryInterface(REFGUID iid, Q** pp) const
74
  {
75
    return _p->QueryInterface(iid, (void**)pp);
76
  }
77
};
78
​
79
//////////////////////////////////////////////////////////
80
​
81
inline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr)
82
{
83
  *bstr = ::SysAllocString(src);
84
  return (*bstr != 0) ? S_OK : E_OUTOFMEMORY;
85
}
86
​
87
class CMyComBSTR
88
{
89
public:
90
  BSTR m_str;
91
  CMyComBSTR(): m_str(NULL) {}
92
  CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.8.0
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.