45 map<string,T*> aCatalog;
48 typedef function<void (string& pKeyRef, T*& pValuePtrRef)>
ForEachWorker;
64 pReference.
forEach([&](
string& pKeyRef, T* pValuePtr){
65 put(pKeyRef,*pValuePtr);
81 T&
ref(
string& pKeyRef) {
83 T* vResultPtr =
nullptr;
85 if (aCatalog.count(pKeyRef)>0) {
86 vResultPtr = aCatalog[pKeyRef];
109 T&
ref(
const char* pKeyPtr) {
110 string vKey = string(pKeyPtr);
122 T* vResultPtr =
nullptr;
124 if (aCatalog.count(pKeyRef)>0) {
125 vResultPtr = aCatalog[pKeyRef];
137 T*
ptr(
const char* pKeyPtr) {
138 string vKey = string(pKeyPtr);
148 bool has(
string& pKeyRef) {
149 return (aCatalog.count(pKeyRef)>0);
158 bool has(
const char* pKeyPtr) {
159 string vKey(pKeyPtr);
172 void put(
string& pKeyRef, T& pValueRef) {
174 T* vValuePtr =
new T(pValueRef);
176 if (aCatalog.count(pKeyRef)>0) {
179 aCatalog.erase(pKeyRef);
181 aCatalog[pKeyRef] = vValuePtr;
194 void put(
const char* pKeyPtr, T& pValueRef) {
195 string vKey(pKeyPtr);
196 put (vKey,pValueRef);
208 void put(
string& pKeyRef, T* pValuePtr) {
210 if (aCatalog.count(pKeyRef)>0) {
211 aCatalog.erase(pKeyRef);
213 aCatalog[pKeyRef] = pValuePtr;
226 void put(
const char* pKeyPtr, T* pValuePtr) {
228 string vKey(pKeyPtr);
229 put (vKey,pValuePtr);
238 string vKey(pKeyPtr);
239 aCatalog.erase(vKey);
247 aCatalog.erase(pKeyRef);
256 forEach([](
string& xKeyRef, T*& xValuePtrRef) {
257 T* vValuePtrCopy = xValuePtrRef;
258 delete vValuePtrCopy;
259 xValuePtrRef =
nullptr;
283 for (pair<string,T*> vPair : aCatalog) {
285 pWorker(vPair.first, vPair.second);
287 catch(exception& vExc) {
288 setLastError(vExc.what());
302 return aCatalog.size();
325 #define SETSTRDICT(dict,name,value) \
326 string v##name = value; \
327 dict.put(#name,v##name)