Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cWinAtom.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cWinAtom_H
7 #define _INC_cWinAtom_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 
14 #ifdef _WIN32
16 
17 namespace GrayLib
18 {
19  class GRAYLIB_LINK cWinAtomBase
20  {
24  public:
25  ATOM m_a;
26 
27  public:
28  cWinAtomBase(ATOM a = INVALID_ATOM) noexcept
29  : m_a(a)
30  {
31  }
32  const GChar_t* get_IntAtom() const noexcept
33  {
36  return (const GChar_t *) MAKEINTATOM(m_a);
37  }
38  bool isValidAtom() const noexcept
39  {
40  return m_a != INVALID_ATOM;
41  }
42  };
43 
44  class GRAYLIB_LINK cWinAtomH : public cWinAtomBase
45  {
51 
52  public:
53  cWinAtomH(ATOM a = INVALID_ATOM) noexcept
54  : cWinAtomBase(a)
55  {
56  }
57 #ifndef UNDER_CE
58  cWinAtomH(const GChar_t* pszStr) noexcept
59  : cWinAtomBase(_GTN(::AddAtom)(pszStr))
60  {
61  }
62  StrLen_t GetName(GChar_t* pszName, StrLen_t iLenMax) const noexcept
63  {
64  return _GTN(::GetAtomName)(m_a, pszName, iLenMax);
65  }
66  static ATOM GRAYCALL Find(const GChar_t* pszStr) noexcept
67  {
69  return _GTN(::FindAtom)(pszStr);
70  }
71  void Delete() noexcept
72  {
74  ::DeleteAtom(m_a);
75  m_a = INVALID_ATOM;
76  }
77 #endif
78  };
79 
80  class GRAYLIB_LINK cWinAtomGlobalH : public cWinAtomBase
81  {
86 
87  public:
88  cWinAtomGlobalH(ATOM a = INVALID_ATOM) noexcept
89  : cWinAtomBase(a)
90  {
91  }
92 #ifndef UNDER_CE
93  cWinAtomGlobalH(const GChar_t* pszStr) noexcept
94  : cWinAtomBase(_GTN(::GlobalAddAtom)(pszStr))
95  {
96  }
97  StrLen_t GetName(GChar_t* pszName, StrLen_t iLenMax) const noexcept
98  {
99  return _GTN(::GlobalGetAtomName)(m_a, pszName, iLenMax);
100  }
101  static ATOM GRAYCALL Find(const GChar_t* pszStr) noexcept
102  {
104  return _GTN(::GlobalFindAtom)(pszStr);
105  }
106  void Delete() noexcept
107  {
109  ::GlobalDeleteAtom(m_a);
110  m_a = INVALID_ATOM;
111  }
112 #endif
113  };
114 
115 #ifndef UNDER_CE
116  class GRAYLIB_LINK cWinAtom : public cWinAtomH
117  {
120 
121  public:
122  ~cWinAtom() noexcept
123  {
124  ::DeleteAtom(m_a);
125  }
126  };
127 
128  class GRAYLIB_LINK cWinAtomGlobal : public cWinAtomGlobalH
129  {
132 
133  public:
134  ~cWinAtomGlobal() noexcept
135  {
136  ::GlobalDeleteAtom(m_a);
137  }
138  };
139 #endif
140 };
141 #endif // _WIN32
142 #endif // _INC_cWinAtom_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GTN(c)
_WIN32 name has a A or W for UTF8 or UNICODE (like _FNF)
Definition: StrConst.h:28
Definition: cMesh.h:22
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26