ZeusBase-Library  2.0.4
VariableResolver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch)
3  *****************************************************************************
4  * Project : Zeus Base Library
5  * Module : VariableResolver
6  * Package : Zeus.ZeusBase.System
7  * Author : Benjamin Hadorn
8  * Date : 27.12.2011
9  * System : Zeus-Framework
10  *****************************************************************************
11  * Licence: *
12  * This library is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU Lesser General Public License as *
14  * published by the Free Software Foundation; either version *
15  * 2.1 of the License, or (at your option) any later version. *
16  * *
17  * This library is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU Lesser General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU Lesser General Public *
23  * License along with this library; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
25  *****************************************************************************/
26 
27 /*****************************************************************************
28  * Changes:
29  * 27.12.2011 bha: created zeus 2.0
30  *****************************************************************************/
31 
32 #ifndef VariableResolverH
33 #define VariableResolverH
34 
37 #include <zeusbase/System/Set.hpp>
39 
41 
42 /****************************************************************************/
48 /****************************************************************************/
50 {
51  public:
53 
54  //Methods of IVariableResolver
55  virtual void MQUALIFIER clearVariables();
56  virtual void MQUALIFIER addVariable(const IString& rName, const IString& rValue);
57  virtual void MQUALIFIER removeVariable(const IString& rName);
58  virtual Retval MQUALIFIER resolve(const IString& rData, IString& rOut, bool bRecursive);
59 
60  //Methods of IZUnknown
62 
63  void addVariables(const TStringMap<TString>& rVariables);
64  void addVariable(const TString& rName, const TString& rValue);
65 
66  void removeVariables(const TStringMap<TString>& rVariables);
67  void removeVariables(const TSet<TString>& rVariables);
68  void removeVariable(const TString& rName);
69 
70  Retval resolve(const TString& rData, IString& rOut, bool bRecursive);
71 
72  void resolveDependancies(const IString& rData, TSet<TString>& rDependancies, bool bRecusrive = false);
73  void resolveDependancies(const TString& rData, TSet<TString>& rDependancies, bool bRecusrive = false);
74 
75  protected:
76  virtual ~TVariableResolver();
77 
78  virtual Retval resolveVariable(const TString& rName, TString& rValue);
79  virtual Retval resolve_internal(const IString& rData, IString& rOut, bool bRecursive, TSet<TString>& rReplacedVars);
80 
81  private:
83  TStringMap<TString> m_mapVariables;
84 
85 };
86 
87 /****************************************************************************/
90 /****************************************************************************/
91 inline void MQUALIFIER TVariableResolver::addVariable(const IString& rName, const IString& rValue)
92 {
93  m_mapVariables.setItem(rName, rValue);
94 }
95 
96 /****************************************************************************/
99 /****************************************************************************/
100 inline void MQUALIFIER TVariableResolver::clearVariables()
101 {
102  m_mapVariables.clear();
103 }
104 
105 /****************************************************************************/
108 /****************************************************************************/
109 inline void MQUALIFIER TVariableResolver::removeVariable(const IString& rName)
110 {
111  m_mapVariables.deleteItem(rName);
112 }
113 
114 /****************************************************************************/
117 /****************************************************************************/
118 inline Retval MQUALIFIER TVariableResolver::resolve(const IString& rData, IString& rOut, bool bRecursive)
119 {
120  TSet<TString> setVars;
121  return resolve_internal(rData, rOut, bRecursive, setVars);
122 }
123 
124 /****************************************************************************/
127 /****************************************************************************/
128 inline void TVariableResolver::addVariable(const TString& rName, const TString& rValue)
129 {
130  m_mapVariables.setItem((const IString&)rName, (const IString&)rValue);
131 }
132 
133 /****************************************************************************/
136 /****************************************************************************/
137 inline void TVariableResolver::removeVariable(const TString& rName)
138 {
139  m_mapVariables.deleteItem((const IString&)rName);
140 }
141 
142 /****************************************************************************/
145 /****************************************************************************/
146 inline Retval TVariableResolver::resolve(const TString& rData, IString& rOut, bool bRecursive)
147 {
148  TSet<TString> setVars;
149  return resolve_internal(rData, rOut, bRecursive, setVars);
150 }
151 
152 /****************************************************************************/
155 /****************************************************************************/
156 inline void TVariableResolver::resolveDependancies(const TString& rData, TSet<TString>& rDependancies, bool bRecusrive /*= false*/)
157 {
158  resolveDependancies((const IString&)rData, rDependancies, bRecusrive);
159 }
160 
162 
163 #endif
Definition: ZObject.h:57
#define END_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:96
#define zeusbase_class
Definition: PlatformDefines.hpp:165
#define MQUALIFIER
Definition: LinuxPlatform.hpp:64
#define BEGIN_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:95
Definition: Set.hpp:57
Definition: String.h:113
Definition: VariableResolver.h:49
Definition: StringMap.hpp:68
Definition: IVariableResolver.hpp:47
#define MEMORY_MANAGER_DECL
Definition: IZUnknownImplHelper.hpp:44
Definition: IString.hpp:48


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Tue Sep 13 2016 22:30:52