AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EnvGuards.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 #ifndef INCLUDED_CPPU_ENVGUARDS_HXX
4 #define INCLUDED_CPPU_ENVGUARDS_HXX
5 
6 #include "uno/environment.hxx"
7 
8 
9 namespace cppu
10 {
18  class EnvGuard
19  {
20  css::uno::Environment m_env;
21 
22  public:
23  explicit EnvGuard(css::uno::Environment const & env)
24  {
25  if (env.is())
26  {
27  m_env = css::uno::Environment::getCurrent();
28  env.enter();
29  }
30  }
31 
33  {
34  m_env.enter();
35  }
36 
41  bool SAL_CALL is() const
42  {
43  return m_env.is();
44  }
45 
49  void clear()
50  {
51  if (m_env.is())
52  {
53  m_env.enter();
54  m_env.clear();
55  }
56  }
57  };
58 
67  {
68  css::uno::Environment m_env;
69 
70  public:
71  explicit AntiEnvGuard()
72  : m_env(css::uno::Environment::getCurrent())
73  {
75  }
76 
78  {
79  m_env.enter();
80  }
81  };
82 }
83 
84 #endif
85 
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
EnvGuard(css::uno::Environment const &env)
Definition: EnvGuards.hxx:23
void clear()
Leaves the associated environment and clears the reference.
Definition: EnvGuards.hxx:49
bool is() const
Checks if the associated environment is non empty.
Definition: EnvGuards.hxx:41
Environment Guard The provided Environment becomes entered in the constructor and left in the destruc...
Definition: EnvGuards.hxx:18
Environment Anti-Guard Any entered Environment becomes left in the constructor and re-entered in the ...
Definition: EnvGuards.hxx:66
CPPU_DLLPUBLIC void uno_Environment_enter(uno_Environment *pEnv) SAL_THROW_EXTERN_C()
Enter an environment explicitly.
~AntiEnvGuard()
Definition: EnvGuards.hxx:77
~EnvGuard()
Definition: EnvGuards.hxx:32
AntiEnvGuard()
Definition: EnvGuards.hxx:71