copy constructor added to StringMap; code refactoring
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 14 Sep 2009 10:27:40 +0000 (10:27 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 14 Sep 2009 10:27:40 +0000 (10:27 +0000)
20 files changed:
include/nms_util.h
src/client/windows/nxcon/ObjectPropsCustomAttrs.cpp
src/client/windows/nxcon/RuleSituationDlg.cpp
src/libnetxms/strmap.cpp
src/libnxcl/epp.cpp
src/libnxcl/objects.cpp
src/libnxcl/situation.cpp
src/libnxlp/parser.cpp
src/libnxmb/filter.cpp
src/server/core/epp.cpp
src/server/core/events.cpp
src/server/core/netobj.cpp
src/server/core/situation.cpp
src/server/core/userdb_objects.cpp
src/server/include/nms_events.h
src/server/include/nms_objects.h
src/server/include/nms_users.h
src/webui/nxhttpd/httprequest.cpp
src/webui/nxhttpd/httpresponse.cpp
src/webui/nxhttpd/nxhttpd.h

index f45e4f1..65fbaa0 100644 (file)
@@ -287,28 +287,28 @@ public:
 class LIBNETXMS_EXPORTABLE StringMap
 {
 protected:
-       DWORD m_dwSize;
-       TCHAR **m_ppszKeys;
-       TCHAR **m_ppszValues;
+       DWORD m_size;
+       TCHAR **m_keys;
+       TCHAR **m_values;
 
-       DWORD Find(const TCHAR *pszKey);
+       DWORD find(const TCHAR *key);
 
 public:
        StringMap();
-       StringMap(StringMap *src);
+       StringMap(const StringMap &src);
        ~StringMap();
 
-       StringMap& operator =(StringMap &src);
+       StringMap& operator =(const StringMap &src);
 
-       void Set(const TCHAR *pszKey, const TCHAR *pszValue);
-       void SetPreallocated(TCHAR *pszKey, TCHAR *pszValue);
-       TCHAR *Get(const TCHAR *pszKey);
-       void Delete(const TCHAR *pszKey);
-       void Clear(void);
+       void set(const TCHAR *key, const TCHAR *value);
+       void setPreallocated(TCHAR *key, TCHAR *value);
+       const TCHAR *get(const TCHAR *key);
+       void remove(const TCHAR *key);
+       void clear();
 
-       DWORD Size(void) { return m_dwSize; }
-       TCHAR *GetKeyByIndex(DWORD idx) { return (idx < m_dwSize) ? CHECK_NULL_EX(m_ppszKeys[idx]) : NULL; }
-       TCHAR *GetValueByIndex(DWORD idx) { return (idx < m_dwSize) ? CHECK_NULL_EX(m_ppszValues[idx]) : NULL; }
+       DWORD getSize() { return m_size; }
+       const TCHAR *getKeyByIndex(DWORD idx) { return (idx < m_size) ? CHECK_NULL_EX(m_keys[idx]) : NULL; }
+       const TCHAR *getValueByIndex(DWORD idx) { return (idx < m_size) ? CHECK_NULL_EX(m_values[idx]) : NULL; }
 };
 
 
index b87a7bc..d26f365 100644 (file)
@@ -73,11 +73,11 @@ BOOL CObjectPropsCustomAttrs::OnInitDialog()
        m_wndListCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
 
        // Fill list control with data
-       for(i = 0; i < m_pObject->pCustomAttrs->Size(); i++)
+       for(i = 0; i < m_pObject->pCustomAttrs->getSize(); i++)
        {
-               item = m_wndListCtrl.InsertItem(i, m_pObject->pCustomAttrs->GetKeyByIndex(i));
+               item = m_wndListCtrl.InsertItem(i, m_pObject->pCustomAttrs->getKeyByIndex(i));
                if (item != -1)
-                       m_wndListCtrl.SetItemText(item, 1, m_pObject->pCustomAttrs->GetValueByIndex(i));
+                       m_wndListCtrl.SetItemText(item, 1, m_pObject->pCustomAttrs->getValueByIndex(i));
        }
        
        EnableDlgItem(this, IDC_BUTTON_EDIT, m_wndListCtrl.GetSelectedCount() == 1);
@@ -100,7 +100,7 @@ void CObjectPropsCustomAttrs::OnOK()
                m_pUpdate->pCustomAttrs = &m_strMap;
                for(i = 0; i < m_wndListCtrl.GetItemCount(); i++)
                {
-                       m_strMap.Set(m_wndListCtrl.GetItemText(i, 0), m_wndListCtrl.GetItemText(i, 1));
+                       m_strMap.set(m_wndListCtrl.GetItemText(i, 0), m_wndListCtrl.GetItemText(i, 1));
                }
        }
        CPropertyPage::OnOK();
index f142622..61ff15c 100644 (file)
@@ -72,10 +72,10 @@ BOOL CRuleSituationDlg::OnInitDialog()
        SetDlgItemText(IDC_EDIT_INSTANCE, m_strInstance);
 
        // Attributes
-       for(i = 0; i < m_attrList.Size(); i++)
+       for(i = 0; i < m_attrList.getSize(); i++)
        {
-               item = m_wndListCtrl.InsertItem(i, m_attrList.GetKeyByIndex(i));
-               m_wndListCtrl.SetItemText(item, 1, m_attrList.GetValueByIndex(i));
+               item = m_wndListCtrl.InsertItem(i, m_attrList.getKeyByIndex(i));
+               m_wndListCtrl.SetItemText(item, 1, m_attrList.getValueByIndex(i));
        }
 
        SendDlgItemMessage(IDC_CHECK_ENABLE, BM_SETCHECK, (m_dwSituation != 0) ? BST_CHECKED : BST_UNCHECKED, 0);
@@ -112,20 +112,20 @@ void CRuleSituationDlg::OnOK()
        if (SendDlgItemMessage(IDC_CHECK_ENABLE, BM_GETCHECK, 0, 0) == BST_CHECKED)
        {
                GetDlgItemText(IDC_EDIT_INSTANCE, m_strInstance);
-               m_attrList.Clear();
+               m_attrList.clear();
                count = m_wndListCtrl.GetItemCount();
                for(i = 0; i < count; i++)
                {
                        m_wndListCtrl.GetItemText(i, 0, attr, MAX_DB_STRING);
                        m_wndListCtrl.GetItemText(i, 1, value, MAX_DB_STRING);
-                       m_attrList.Set(attr, value);
+                       m_attrList.set(attr, value);
                }
        }
        else
        {
                m_dwSituation = 0;
                m_strInstance = _T("");
-               m_attrList.Clear();
+               m_attrList.clear();
        }
        CDialog::OnOK();
 }
index 4f182c1..117e42c 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Foundation Library
-** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
+** Copyright (C) 2003-2009 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 
 StringMap::StringMap()
 {
-       m_dwSize = 0;
-       m_ppszKeys = NULL;
-       m_ppszValues = NULL;
+       m_size = 0;
+       m_keys = NULL;
+       m_values = NULL;
 }
 
-StringMap::StringMap(StringMap *src)
+
+//
+// Copy constructor
+//
+
+StringMap::StringMap(const StringMap &src)
 {
        DWORD i;
 
-       m_dwSize = src->m_dwSize;
-       m_ppszKeys = (TCHAR **)malloc(sizeof(TCHAR *) * m_dwSize);
-       m_ppszValues = (TCHAR **)malloc(sizeof(TCHAR *) * m_dwSize);
-       for(i = 0; i < m_dwSize; i++)
+       m_size = src.m_size;
+       m_keys = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);
+       m_values = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);
+       for(i = 0; i < m_size; i++)
        {
-               m_ppszKeys[i] = _tcsdup(src->m_ppszKeys[i]);
-               m_ppszValues[i] = _tcsdup(src->m_ppszValues[i]);
+               m_keys[i] = _tcsdup(src.m_keys[i]);
+               m_values[i] = _tcsdup(src.m_values[i]);
        }
 }
 
@@ -56,7 +61,7 @@ StringMap::StringMap(StringMap *src)
 
 StringMap::~StringMap()
 {
-       Clear();
+       clear();
 }
 
 
@@ -64,18 +69,18 @@ StringMap::~StringMap()
 // Assignment
 //
 
-StringMap& StringMap::operator =(StringMap &src)
+StringMap& StringMap::operator =(const StringMap &src)
 {
        DWORD i;
 
-       Clear();
-       m_dwSize = src.m_dwSize;
-       m_ppszKeys = (TCHAR **)malloc(sizeof(TCHAR *) * m_dwSize);
-       m_ppszValues = (TCHAR **)malloc(sizeof(TCHAR *) * m_dwSize);
-       for(i = 0; i < m_dwSize; i++)
+       clear();
+       m_size = src.m_size;
+       m_keys = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);
+       m_values = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);
+       for(i = 0; i < m_size; i++)
        {
-               m_ppszKeys[i] = _tcsdup(src.m_ppszKeys[i]);
-               m_ppszValues[i] = _tcsdup(src.m_ppszValues[i]);
+               m_keys[i] = _tcsdup(src.m_keys[i]);
+               m_values[i] = _tcsdup(src.m_values[i]);
        }
        return *this;
 }
@@ -85,18 +90,18 @@ StringMap& StringMap::operator =(StringMap &src)
 // Clear map
 //
 
-void StringMap::Clear(void)
+void StringMap::clear()
 {
        DWORD i;
 
-       for(i = 0; i < m_dwSize; i++)
+       for(i = 0; i < m_size; i++)
        {
-               safe_free(m_ppszKeys[i]);
-               safe_free(m_ppszValues[i]);
+               safe_free(m_keys[i]);
+               safe_free(m_values[i]);
        }
-       m_dwSize = 0;
-       safe_free_and_null(m_ppszKeys);
-       safe_free_and_null(m_ppszValues);
+       m_size = 0;
+       safe_free_and_null(m_keys);
+       safe_free_and_null(m_values);
 }
 
 
@@ -104,13 +109,13 @@ void StringMap::Clear(void)
 // Find value by key
 //
 
-DWORD StringMap::Find(const TCHAR *pszKey)
+DWORD StringMap::find(const TCHAR *key)
 {
        DWORD i;
 
-       for(i = 0; i < m_dwSize; i++)
+       for(i = 0; i < m_size; i++)
        {
-               if (!_tcsicmp(pszKey, m_ppszKeys[i]))
+               if (!_tcsicmp(key, m_keys[i]))
                        return i;
        }
        return INVALID_INDEX;
@@ -121,24 +126,24 @@ DWORD StringMap::Find(const TCHAR *pszKey)
 // Set value - arguments are preallocated dynamic strings
 //
 
-void StringMap::SetPreallocated(TCHAR *pszKey, TCHAR *pszValue)
+void StringMap::setPreallocated(TCHAR *key, TCHAR *value)
 {
-       DWORD dwIndex;
+       DWORD index;
 
-       dwIndex = Find(pszKey);
-       if (dwIndex != INVALID_INDEX)
+       index = find(key);
+       if (index != INVALID_INDEX)
        {
-               free(pszKey);   // Not needed
-               safe_free(m_ppszValues[dwIndex]);
-               m_ppszValues[dwIndex] = pszValue;
+               free(key);      // Not needed
+               safe_free(m_values[index]);
+               m_values[index] = value;
        }
        else
        {
-               m_ppszKeys = (TCHAR **)realloc(m_ppszKeys, (m_dwSize + 1) * sizeof(TCHAR *));
-               m_ppszValues = (TCHAR **)realloc(m_ppszValues, (m_dwSize + 1) * sizeof(TCHAR *));
-               m_ppszKeys[m_dwSize] = pszKey;
-               m_ppszValues[m_dwSize] = pszValue;
-               m_dwSize++;
+               m_keys = (TCHAR **)realloc(m_keys, (m_size + 1) * sizeof(TCHAR *));
+               m_values = (TCHAR **)realloc(m_values, (m_size + 1) * sizeof(TCHAR *));
+               m_keys[m_size] = key;
+               m_values[m_size] = value;
+               m_size++;
        }
 }
 
@@ -147,23 +152,23 @@ void StringMap::SetPreallocated(TCHAR *pszKey, TCHAR *pszValue)
 // Set value
 //
 
-void StringMap::Set(const TCHAR *pszKey, const TCHAR *pszValue)
+void StringMap::set(const TCHAR *key, const TCHAR *value)
 {
-       DWORD dwIndex;
+       DWORD index;
 
-       dwIndex = Find(pszKey);
-       if (dwIndex != INVALID_INDEX)
+       index = find(key);
+       if (index != INVALID_INDEX)
        {
-               safe_free(m_ppszValues[dwIndex]);
-               m_ppszValues[dwIndex] = _tcsdup(pszValue);
+               safe_free(m_values[index]);
+               m_values[index] = _tcsdup(value);
        }
        else
        {
-               m_ppszKeys = (TCHAR **)realloc(m_ppszKeys, (m_dwSize + 1) * sizeof(TCHAR *));
-               m_ppszValues = (TCHAR **)realloc(m_ppszValues, (m_dwSize + 1) * sizeof(TCHAR *));
-               m_ppszKeys[m_dwSize] = _tcsdup(pszKey);
-               m_ppszValues[m_dwSize] = _tcsdup(pszValue);
-               m_dwSize++;
+               m_keys = (TCHAR **)realloc(m_keys, (m_size + 1) * sizeof(TCHAR *));
+               m_values = (TCHAR **)realloc(m_values, (m_size + 1) * sizeof(TCHAR *));
+               m_keys[m_size] = _tcsdup(key);
+               m_values[m_size] = _tcsdup(value);
+               m_size++;
        }
 }
 
@@ -172,12 +177,12 @@ void StringMap::Set(const TCHAR *pszKey, const TCHAR *pszValue)
 // Get value by key
 //
 
-TCHAR *StringMap::Get(const TCHAR *pszKey)
+const TCHAR *StringMap::get(const TCHAR *key)
 {
-       DWORD dwIndex;
+       DWORD index;
 
-       dwIndex = Find(pszKey);
-       return (dwIndex != INVALID_INDEX) ? m_ppszValues[dwIndex] : NULL;
+       index = find(key);
+       return (index != INVALID_INDEX) ? m_values[index] : NULL;
 }
 
 
@@ -185,18 +190,17 @@ TCHAR *StringMap::Get(const TCHAR *pszKey)
 // Delete value
 //
 
-void StringMap::Delete(const TCHAR *pszKey)
+void StringMap::remove(const TCHAR *key)
 {
-       DWORD dwIndex;
+       DWORD index;
 
-       dwIndex = Find(pszKey);
-       if (dwIndex != INVALID_INDEX)
+       index = find(key);
+       if (index != INVALID_INDEX)
        {
-               safe_free(m_ppszKeys[dwIndex]);
-               safe_free(m_ppszValues[dwIndex]);
-               m_dwSize--;
-               memmove(&m_ppszKeys[dwIndex], &m_ppszKeys[dwIndex + 1], sizeof(TCHAR *) * (m_dwSize - dwIndex));
-               memmove(&m_ppszValues[dwIndex], &m_ppszValues[dwIndex + 1], sizeof(TCHAR *) * (m_dwSize - dwIndex));
+               safe_free(m_keys[index]);
+               safe_free(m_values[index]);
+               m_size--;
+               memmove(&m_keys[index], &m_keys[index + 1], sizeof(TCHAR *) * (m_size - index));
+               memmove(&m_values[index], &m_values[index + 1], sizeof(TCHAR *) * (m_size - index));
        }
 }
-
index 2eff20d..e76703c 100644 (file)
@@ -182,7 +182,7 @@ DWORD LIBNXCL_EXPORTABLE NXCOpenEventPolicy(NXC_SESSION hSession, NXC_EPP **ppEv
                                        {
                                                attr = pResponse->GetVariableStr(id++);
                                                value = pResponse->GetVariableStr(id++);
-                                               (*ppEventPolicy)->pRuleList[i].pSituationAttrList->SetPreallocated(attr, value);
+                                               (*ppEventPolicy)->pRuleList[i].pSituationAttrList->setPreallocated(attr, value);
                                        }
                delete pResponse;
             }
@@ -284,12 +284,12 @@ DWORD LIBNXCL_EXPORTABLE NXCSaveEventPolicy(NXC_SESSION hSession, NXC_EPP *pEven
                        msg.SetVariable(VID_ALARM_TIMEOUT_EVENT, pEventPolicy->pRuleList[i].dwAlarmTimeoutEvent);
                        msg.SetVariable(VID_SITUATION_ID, pEventPolicy->pRuleList[i].dwSituationId);
                        msg.SetVariable(VID_SITUATION_INSTANCE, pEventPolicy->pRuleList[i].szSituationInstance);
-                       count = (pEventPolicy->pRuleList[i].pSituationAttrList != NULL) ? pEventPolicy->pRuleList[i].pSituationAttrList->Size() : 0;
+                       count = (pEventPolicy->pRuleList[i].pSituationAttrList != NULL) ? pEventPolicy->pRuleList[i].pSituationAttrList->getSize() : 0;
                        msg.SetVariable(VID_SITUATION_NUM_ATTRS, count);
                        for(j = 0, id = VID_SITUATION_ATTR_LIST_BASE; j < count; j++)
                        {
-                               msg.SetVariable(id++, pEventPolicy->pRuleList[i].pSituationAttrList->GetKeyByIndex(j));
-                               msg.SetVariable(id++, pEventPolicy->pRuleList[i].pSituationAttrList->GetValueByIndex(j));
+                               msg.SetVariable(id++, pEventPolicy->pRuleList[i].pSituationAttrList->getKeyByIndex(j));
+                               msg.SetVariable(id++, pEventPolicy->pRuleList[i].pSituationAttrList->getValueByIndex(j));
                        }
 
          ((NXCL_Session *)hSession)->SendMsg(&msg);
index f3dde73..b8e2b39 100644 (file)
@@ -240,7 +240,7 @@ static NXC_OBJECT *NewObjectFromMsg(CSCPMessage *pMsg)
        dwCount = pMsg->GetVariableLong(VID_NUM_CUSTOM_ATTRIBUTES);
        for(i = 0, dwId1 = VID_CUSTOM_ATTRIBUTES_BASE; i < dwCount; i++, dwId1 += 2)
        {
-               pObject->pCustomAttrs->SetPreallocated(pMsg->GetVariableStr(dwId1), pMsg->GetVariableStr(dwId1 + 1));
+               pObject->pCustomAttrs->setPreallocated(pMsg->GetVariableStr(dwId1), pMsg->GetVariableStr(dwId1 + 1));
        }
 
    // Parents
@@ -909,11 +909,11 @@ DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_SESSION hSession, NXC_OBJECT_UPDATE
    }
    if (pUpdate->qwFlags & OBJ_UPDATE_CUSTOM_ATTRS)
    {
-      msg.SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, pUpdate->pCustomAttrs->Size());
-      for(i = 0, dwId1 = VID_CUSTOM_ATTRIBUTES_BASE; i < pUpdate->pCustomAttrs->Size(); i++)
+      msg.SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, pUpdate->pCustomAttrs->getSize());
+      for(i = 0, dwId1 = VID_CUSTOM_ATTRIBUTES_BASE; i < pUpdate->pCustomAttrs->getSize(); i++)
       {
-         msg.SetVariable(dwId1++, pUpdate->pCustomAttrs->GetKeyByIndex(i));
-         msg.SetVariable(dwId1++, pUpdate->pCustomAttrs->GetValueByIndex(i));
+         msg.SetVariable(dwId1++, pUpdate->pCustomAttrs->getKeyByIndex(i));
+         msg.SetVariable(dwId1++, pUpdate->pCustomAttrs->getValueByIndex(i));
       }
    }
    if (pUpdate->qwFlags & OBJ_UPDATE_AUTO_APPLY)
@@ -1413,17 +1413,17 @@ DWORD LIBNXCL_EXPORTABLE NXCSaveObjectCache(NXC_SESSION hSession, const TCHAR *p
                                fwrite(pList[i].pObject->pdwTrustedNodes, pList[i].pObject->dwNumTrustedNodes, sizeof(DWORD), hFile);
 
                        // Custom attributes
-                       dwSize = pList[i].pObject->pCustomAttrs->Size();
+                       dwSize = pList[i].pObject->pCustomAttrs->getSize();
          fwrite(&dwSize, 1, sizeof(DWORD), hFile);
-                       for(j = 0; j < pList[i].pObject->pCustomAttrs->Size(); j++)
+                       for(j = 0; j < pList[i].pObject->pCustomAttrs->getSize(); j++)
                        {
-            dwSize = (DWORD)_tcslen(pList[i].pObject->pCustomAttrs->GetKeyByIndex(j)) * sizeof(TCHAR);
+            dwSize = (DWORD)_tcslen(pList[i].pObject->pCustomAttrs->getKeyByIndex(j)) * sizeof(TCHAR);
             fwrite(&dwSize, 1, sizeof(DWORD), hFile);
-            fwrite(pList[i].pObject->pCustomAttrs->GetKeyByIndex(j), 1, dwSize, hFile);
+            fwrite(pList[i].pObject->pCustomAttrs->getKeyByIndex(j), 1, dwSize, hFile);
 
-            dwSize = (DWORD)_tcslen(pList[i].pObject->pCustomAttrs->GetValueByIndex(j)) * sizeof(TCHAR);
+            dwSize = (DWORD)_tcslen(pList[i].pObject->pCustomAttrs->getValueByIndex(j)) * sizeof(TCHAR);
             fwrite(&dwSize, 1, sizeof(DWORD), hFile);
-            fwrite(pList[i].pObject->pCustomAttrs->GetValueByIndex(j), 1, dwSize, hFile);
+            fwrite(pList[i].pObject->pCustomAttrs->getValueByIndex(j), 1, dwSize, hFile);
                        }
 
          switch(pList[i].pObject->iClass)
@@ -1565,7 +1565,7 @@ void NXCL_Session::LoadObjectsFromCache(const TCHAR *pszFile)
                      fread(value, 1, dwSize, hFile);
                      value[dwSize / sizeof(TCHAR)] = 0;
 
-                                                       object.pCustomAttrs->SetPreallocated(key, value);
+                                                       object.pCustomAttrs->setPreallocated(key, value);
                                                }
 
                   switch(object.iClass)
index 34a24d5..e332524 100644 (file)
@@ -48,7 +48,7 @@ static void SituationFromMessage(CSCPMessage *msg, NXC_SITUATION *situation)
                {
                        attr = msg->GetVariableStr(id++);
                        value = msg->GetVariableStr(id++);
-                       situation->m_instanceList[i].m_attrList->SetPreallocated(attr, value);
+                       situation->m_instanceList[i].m_attrList->setPreallocated(attr, value);
                }
        }
 }
@@ -243,7 +243,7 @@ static void CopySituation(NXC_SITUATION *dst, NXC_SITUATION *src)
        for(i = 0; i < src->m_instanceCount; i++)
        {
                dst->m_instanceList[i].m_name = _tcsdup(CHECK_NULL_EX(src->m_instanceList[i].m_name));
-               dst->m_instanceList[i].m_attrList = new StringMap(src->m_instanceList[i].m_attrList);
+               dst->m_instanceList[i].m_attrList = new StringMap(*(src->m_instanceList[i].m_attrList));
        }
 }
 
index 364fdec..4ad70eb 100644 (file)
@@ -175,7 +175,7 @@ const TCHAR *LogParser::checkContext(LogParserRule *rule)
                return s_states[CONTEXT_SET_MANUAL];
        }
                
-       state = m_contexts.Get(rule->getContext());
+       state = m_contexts.get(rule->getContext());
        if (state == NULL)
        {
                trace(5, _T("  context '%s' inactive, rule should be skipped"), rule->getContext());
@@ -229,14 +229,14 @@ bool LogParser::matchLogRecord(bool hasAttributes, const char *source, DWORD eve
                                // Update context
                                if (m_rules[i]->getContextToChange() != NULL)
                                {
-                                       m_contexts.Set(m_rules[i]->getContextToChange(), s_states[m_rules[i]->getContextAction()]);
+                                       m_contexts.set(m_rules[i]->getContextToChange(), s_states[m_rules[i]->getContextAction()]);
                                        trace(2, _T("rule %d \"%s\": context %s set to %s"), i + 1, m_rules[i]->getDescription(), m_rules[i]->getContextToChange(), s_states[m_rules[i]->getContextAction()]);
                                }
                                
                                // Set context of this rule to inactive if rule context mode is "automatic reset"
                                if (!_tcscmp(state, s_states[CONTEXT_SET_AUTOMATIC]))
                                {
-                                       m_contexts.Set(m_rules[i]->getContext(), s_states[CONTEXT_CLEAR]);
+                                       m_contexts.set(m_rules[i]->getContext(), s_states[CONTEXT_CLEAR]);
                                        trace(2, _T("rule %d \"%s\": context %s cleared because it was set to automatic reset mode"),
                                                        i + 1, m_rules[i]->getDescription(), m_rules[i]->getContext());
                                }
@@ -292,7 +292,7 @@ void LogParser::setFileName(const TCHAR *name)
 
 void LogParser::addMacro(const TCHAR *name, const TCHAR *value)
 {
-       m_macros.Set(name, value);
+       m_macros.set(name, value);
 }
 
 
@@ -304,7 +304,7 @@ const TCHAR *LogParser::getMacro(const TCHAR *name)
 {
        const TCHAR *value;
 
-       value = m_macros.Get(name);
+       value = m_macros.get(name);
        return CHECK_NULL_EX(value);
 }
 
index 9238582..55729c9 100644 (file)
@@ -62,15 +62,15 @@ NXMBTypeFilter::~NXMBTypeFilter()
 
 bool NXMBTypeFilter::isAllowed(NXMBMessage &msg)
 { 
-       return m_types.Get(msg.getType()) != NULL;
+       return m_types.get(msg.getType()) != NULL;
 }
 
 void NXMBTypeFilter::addMessageType(const TCHAR *type)
 { 
-       m_types.Set(type, _T("*"));
+       m_types.set(type, _T("*"));
 }
 
 void NXMBTypeFilter::removeMessageType(const TCHAR *type)
 { 
-       m_types.Delete(type);
+       m_types.remove(type);
 }
index b8cf725..63cae0e 100644 (file)
@@ -133,7 +133,7 @@ EPRule::EPRule(CSCPMessage *pMsg)
    {
        name = pMsg->GetVariableStr(id++);
        value = pMsg->GetVariableStr(id++);
-       m_situationAttrList.SetPreallocated(name, value);
+       m_situationAttrList.setPreallocated(name, value);
    }
 
    m_pszScript = pMsg->GetVariableStr(VID_SCRIPT);
@@ -377,10 +377,10 @@ BOOL EPRule::ProcessEvent(Event *pEvent)
                                if (pSituation != NULL)
                                {
                                        pszText = pEvent->expandText(m_szSituationInstance);
-                                       for(i = 0; i < m_situationAttrList.Size(); i++)
+                                       for(i = 0; i < m_situationAttrList.getSize(); i++)
                                        {
-                                               pszAttr = pEvent->expandText(m_situationAttrList.GetKeyByIndex(i));
-                                               pszValue = pEvent->expandText(m_situationAttrList.GetValueByIndex(i));
+                                               pszAttr = pEvent->expandText(m_situationAttrList.getKeyByIndex(i));
+                                               pszValue = pEvent->expandText(m_situationAttrList.getValueByIndex(i));
                                                pSituation->UpdateSituation(pszText, pszAttr, pszValue);
                                                free(pszAttr);
                                                free(pszValue);
@@ -497,7 +497,7 @@ BOOL EPRule::LoadFromDB(void)
          DecodeSQLString(name);
          DBGetField(hResult, i, 1, value, MAX_DB_STRING);
          DecodeSQLString(value);
-         m_situationAttrList.Set(name, value);
+         m_situationAttrList.set(name, value);
       }
       DBFreeResult(hResult);
    }
@@ -569,10 +569,10 @@ void EPRule::SaveToDB(void)
    }
 
        // Situation attributes
-       for(i = 0; i < m_situationAttrList.Size(); i++)
+       for(i = 0; i < m_situationAttrList.getSize(); i++)
        {
-               pszEscName = EncodeSQLString(m_situationAttrList.GetKeyByIndex(i));
-               pszEscValue = EncodeSQLString(m_situationAttrList.GetValueByIndex(i));
+               pszEscName = EncodeSQLString(m_situationAttrList.getKeyByIndex(i));
+               pszEscValue = EncodeSQLString(m_situationAttrList.getValueByIndex(i));
       _stprintf(pszQuery, _T("INSERT INTO policy_situation_attr_list (rule_id,situation_id,attr_name,attr_value) VALUES (%d,%d,'%s','%s')"),
                 m_dwId, m_dwSituationId, pszEscName, pszEscValue);
                free(pszEscName);
@@ -609,11 +609,11 @@ void EPRule::CreateMessage(CSCPMessage *pMsg)
    pMsg->SetVariable(VID_SCRIPT, CHECK_NULL_EX(m_pszScript));
        pMsg->SetVariable(VID_SITUATION_ID, m_dwSituationId);
        pMsg->SetVariable(VID_SITUATION_INSTANCE, m_szSituationInstance);
-       pMsg->SetVariable(VID_SITUATION_NUM_ATTRS, m_situationAttrList.Size());
-       for(i = 0, id = VID_SITUATION_ATTR_LIST_BASE; i < m_situationAttrList.Size(); i++)
+       pMsg->SetVariable(VID_SITUATION_NUM_ATTRS, m_situationAttrList.getSize());
+       for(i = 0, id = VID_SITUATION_ATTR_LIST_BASE; i < m_situationAttrList.getSize(); i++)
        {
-               pMsg->SetVariable(id++, m_situationAttrList.GetKeyByIndex(i));
-               pMsg->SetVariable(id++, m_situationAttrList.GetValueByIndex(i));
+               pMsg->SetVariable(id++, m_situationAttrList.getKeyByIndex(i));
+               pMsg->SetVariable(id++, m_situationAttrList.getValueByIndex(i));
        }
 }
 
index d2058c5..dcc0274 100644 (file)
@@ -157,7 +157,7 @@ Event::~Event()
 // Create message text from template
 //
 
-void Event::expandMessageText(void)
+void Event::expandMessageText()
 {
    if (m_pszMessageTemplate != NULL)
    {
@@ -177,13 +177,13 @@ void Event::expandMessageText(void)
 // Substitute % macros in given text with actual values
 //
 
-TCHAR *Event::expandText(TCHAR *pszTemplate, TCHAR *pszAlarmMsg)
+TCHAR *Event::expandText(const TCHAR *pszTemplate, const TCHAR *pszAlarmMsg)
 {
-   char *pCurr;
+   const TCHAR *pCurr;
    DWORD dwPos, dwSize, dwParam;
    NetObj *pObject;
    struct tm *lt;
-   char *pText, szBuffer[4], scriptName[256];
+   TCHAR *pText, szBuffer[4], scriptName[256];
        int i;
 
    pObject = FindObjectById(m_dwSource);
@@ -192,7 +192,7 @@ TCHAR *Event::expandText(TCHAR *pszTemplate, TCHAR *pszAlarmMsg)
       pObject = g_pEntireNet;
    }
    dwSize = (DWORD)_tcslen(pszTemplate) + 1;
-   pText = (char *)malloc(dwSize);
+   pText = (TCHAR *)malloc(dwSize * sizeof(TCHAR));
    for(pCurr = pszTemplate, dwPos = 0; *pCurr != 0; pCurr++)
    {
       switch(*pCurr)
index 1f0fa49..14a71c1 100644 (file)
@@ -205,7 +205,7 @@ BOOL NetObj::LoadCommonProperties(void)
                                        if (value != NULL)
                                        {
                                                DecodeSQLString(value);
-                                               m_customAttributes.SetPreallocated(name, value);
+                                               m_customAttributes.setPreallocated(name, value);
                                        }
                                }
                        }
@@ -295,10 +295,10 @@ BOOL NetObj::SaveCommonProperties(DB_HANDLE hdb)
                {
                        TCHAR *escName, *escValue;
                
-                       for(i = 0; i < (int)m_customAttributes.Size(); i++)
+                       for(i = 0; i < (int)m_customAttributes.getSize(); i++)
                        {
-                               escName = EncodeSQLString(m_customAttributes.GetKeyByIndex(i));
-                               escValue = EncodeSQLString(m_customAttributes.GetValueByIndex(i));
+                               escName = EncodeSQLString(m_customAttributes.getKeyByIndex(i));
+                               escValue = EncodeSQLString(m_customAttributes.getValueByIndex(i));
                                _sntprintf(szQuery, 32768, _T("INSERT INTO object_custom_attributes (object_id,attr_name,attr_value) VALUES (%d,'%s','%s')"),
                                           m_dwId, escName, escValue);
                                free(escName);
@@ -782,11 +782,11 @@ void NetObj::CreateMessage(CSCPMessage *pMsg)
        if (m_dwNumTrustedNodes > 0)
                pMsg->SetVariableToInt32Array(VID_TRUSTED_NODES, m_dwNumTrustedNodes, m_pdwTrustedNodes);
 
-       pMsg->SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, m_customAttributes.Size());
-       for(i = 0, dwId = VID_CUSTOM_ATTRIBUTES_BASE; i < m_customAttributes.Size(); i++)
+       pMsg->SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, m_customAttributes.getSize());
+       for(i = 0, dwId = VID_CUSTOM_ATTRIBUTES_BASE; i < m_customAttributes.getSize(); i++)
        {
-               pMsg->SetVariable(dwId++, m_customAttributes.GetKeyByIndex(i));
-               pMsg->SetVariable(dwId++, m_customAttributes.GetValueByIndex(i));
+               pMsg->SetVariable(dwId++, m_customAttributes.getKeyByIndex(i));
+               pMsg->SetVariable(dwId++, m_customAttributes.getValueByIndex(i));
        }
 
    m_pAccessList->CreateMessage(pMsg);
@@ -887,13 +887,13 @@ DWORD NetObj::ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked)
       TCHAR *name, *value;
 
       dwNumElements = pRequest->GetVariableLong(VID_NUM_CUSTOM_ATTRIBUTES);
-      m_customAttributes.Clear();
+      m_customAttributes.clear();
       for(i = 0, dwId = VID_CUSTOM_ATTRIBUTES_BASE; i < dwNumElements; i++)
       {
        name = pRequest->GetVariableStr(dwId++);
        value = pRequest->GetVariableStr(dwId++);
        if ((name != NULL) && (value != NULL))
-               m_customAttributes.SetPreallocated(name, value);
+               m_customAttributes.setPreallocated(name, value);
       }
    }
 
index 1d4f2a1..37db824 100644 (file)
@@ -84,7 +84,7 @@ SituationInstance::~SituationInstance()
 
 void SituationInstance::UpdateAttribute(const TCHAR *attribute, const TCHAR *value)
 {
-       m_attributes.Set(attribute, value);
+       m_attributes.set(attribute, value);
 }
 
 
@@ -94,7 +94,7 @@ void SituationInstance::UpdateAttribute(const TCHAR *attribute, const TCHAR *val
 
 const TCHAR *SituationInstance::GetAttribute(const TCHAR *attribute)
 {
-       return m_attributes.Get(attribute);
+       return m_attributes.get(attribute);
 }
 
 
@@ -107,11 +107,11 @@ DWORD SituationInstance::CreateMessage(CSCPMessage *msg, DWORD baseId)
        DWORD i, id = baseId;
        
        msg->SetVariable(id++, m_name);
-       msg->SetVariable(id++, m_attributes.Size());
-       for(i = 0; i < m_attributes.Size(); i++)
+       msg->SetVariable(id++, m_attributes.getSize());
+       for(i = 0; i < m_attributes.getSize(); i++)
        {
-               msg->SetVariable(id++, m_attributes.GetKeyByIndex(i));
-               msg->SetVariable(id++, m_attributes.GetValueByIndex(i));
+               msg->SetVariable(id++, m_attributes.getKeyByIndex(i));
+               msg->SetVariable(id++, m_attributes.getValueByIndex(i));
        }
        return id;
 }
index 38050df..6a90960 100644 (file)
@@ -113,11 +113,11 @@ void UserDatabaseObject::fillMessage(CSCPMessage *msg)
    msg->SetVariable(VID_USER_SYS_RIGHTS, m_systemRights);
    msg->SetVariable(VID_USER_DESCRIPTION, m_description);
    msg->SetVariable(VID_GUID, m_guid, UUID_LENGTH);
-       msg->SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, m_attributes.Size());
-       for(i = 0, varId = VID_CUSTOM_ATTRIBUTES_BASE; i < m_attributes.Size(); i++)
+       msg->SetVariable(VID_NUM_CUSTOM_ATTRIBUTES, m_attributes.getSize());
+       for(i = 0, varId = VID_CUSTOM_ATTRIBUTES_BASE; i < m_attributes.getSize(); i++)
        {
-               msg->SetVariable(varId++, m_attributes.GetKeyByIndex(i));
-               msg->SetVariable(varId++, m_attributes.GetValueByIndex(i));
+               msg->SetVariable(varId++, m_attributes.getKeyByIndex(i));
+               msg->SetVariable(varId++, m_attributes.getValueByIndex(i));
        }
 }
 
@@ -146,12 +146,12 @@ void UserDatabaseObject::modifyFromMessage(CSCPMessage *msg)
                TCHAR *name, *value;
 
                count = msg->GetVariableLong(VID_NUM_CUSTOM_ATTRIBUTES);
-               m_attributes.Clear();
+               m_attributes.clear();
                for(i = 0, varId = VID_CUSTOM_ATTRIBUTES_BASE; i < count; i++)
                {
                        name = msg->GetVariableStr(varId++);
                        value = msg->GetVariableStr(varId++);
-                       m_attributes.SetPreallocated((name != NULL) ? name : _tcsdup(_T("")), (value != NULL) ? value : _tcsdup(_T("")));
+                       m_attributes.setPreallocated((name != NULL) ? name : _tcsdup(_T("")), (value != NULL) ? value : _tcsdup(_T("")));
                }
        }
 
@@ -203,7 +203,7 @@ bool UserDatabaseObject::loadCustomAttributes(DB_HANDLE hdb)
                        else
                                attrValue = _tcsdup(_T(""));
 
-                       m_attributes.SetPreallocated(attrName, attrValue);
+                       m_attributes.setPreallocated(attrName, attrValue);
                }
                DBFreeResult(hResult);
                success = true;
@@ -225,10 +225,10 @@ bool UserDatabaseObject::saveCustomAttributes(DB_HANDLE hdb)
        _sntprintf(query, 256, _T("DELETE FROM userdb_custom_attributes WHERE object_id=%d"), m_id);
        if (DBQuery(hdb, query))
        {
-               for(i = 0; i < m_attributes.Size(); i++)
+               for(i = 0; i < m_attributes.getSize(); i++)
                {
-                       escName = EncodeSQLString(m_attributes.GetKeyByIndex(i));
-                       escValue = EncodeSQLString(m_attributes.GetValueByIndex(i));
+                       escName = EncodeSQLString(m_attributes.getKeyByIndex(i));
+                       escValue = EncodeSQLString(m_attributes.getValueByIndex(i));
                        _sntprintf(query, 8192, _T("INSERT INTO userdb_custom_attributes (object_id,attr_name,attr_value) VALUES (%d,'%s','%s')"),
                                   m_id, escName, escValue);
                        free(escName);
@@ -236,7 +236,7 @@ bool UserDatabaseObject::saveCustomAttributes(DB_HANDLE hdb)
                        if (!DBQuery(hdb, query))
                                break;
                }
-               success = (i == m_attributes.Size());
+               success = (i == m_attributes.getSize());
        }
        return success;
 }
index 5924eb0..46b2751 100644 (file)
@@ -91,7 +91,7 @@ public:
    void prepareMessage(CSCPMessage *pMsg);
 
    void expandMessageText();
-   TCHAR *expandText(TCHAR *szTemplate, TCHAR *pszAlarmMsg = NULL);
+   TCHAR *expandText(const TCHAR *szTemplate, const TCHAR *pszAlarmMsg = NULL);
 
    DWORD getParametersCount() { return m_dwNumParameters; }
    char *getParameter(DWORD index) { return (index < m_dwNumParameters) ? m_ppszParameters[index] : NULL; }
index bc79c3b..51c18ca 100644 (file)
@@ -306,10 +306,10 @@ public:
 
    void AddChildNodesToList(DWORD *pdwNumNodes, Node ***pppNodeList, DWORD dwUserId);
    
-   const TCHAR *GetCustomAttribute(const TCHAR *name) { return m_customAttributes.Get(name); }
-   void SetCustomAttribute(const TCHAR *name, const TCHAR *value) { m_customAttributes.Set(name, value); Modify(); }
-   void SetCustomAttributePV(const TCHAR *name, TCHAR *value) { m_customAttributes.SetPreallocated(_tcsdup(name), value); Modify(); }
-   void DeleteCustomAttribute(const TCHAR *name) { m_customAttributes.Delete(name); Modify(); }
+   const TCHAR *GetCustomAttribute(const TCHAR *name) { return m_customAttributes.get(name); }
+   void SetCustomAttribute(const TCHAR *name, const TCHAR *value) { m_customAttributes.set(name, value); Modify(); }
+   void SetCustomAttributePV(const TCHAR *name, TCHAR *value) { m_customAttributes.setPreallocated(_tcsdup(name), value); Modify(); }
+   void DeleteCustomAttribute(const TCHAR *name) { m_customAttributes.remove(name); Modify(); }
 
    // Debug methods
    const char *ParentList(char *szBuffer);
index c961c8d..36e6a21 100644 (file)
@@ -83,9 +83,9 @@ public:
 
        void setDeleted() { m_flags |= UF_DELETED; }
 
-       const TCHAR *getAttribute(const TCHAR *name) { return m_attributes.Get(name); }
+       const TCHAR *getAttribute(const TCHAR *name) { return m_attributes.get(name); }
        DWORD getAttributeAsULong(const TCHAR *name);
-       void setAttribute(const TCHAR *name, const TCHAR *value) { m_attributes.Set(name, value); m_flags |= UF_MODIFIED; }
+       void setAttribute(const TCHAR *name, const TCHAR *value) { m_attributes.set(name, value); m_flags |= UF_MODIFIED; }
 };
 
 
index 186b53c..06e9ce1 100644 (file)
@@ -316,7 +316,7 @@ BOOL HttpRequest::ParseParameter(TCHAR *pszParam)
                        *pSep = 0;
                        pSep++;
                        DecodeQueryParam(pSep);
-                       m_query.Set(pszParam, pSep);
+                       m_query.set(pszParam, pSep);
                        bRet = TRUE;
                }
                free(pszParam);
@@ -331,7 +331,7 @@ BOOL HttpRequest::ParseParameter(TCHAR *pszParam)
 
 void HttpRequest::SetQueryParam(const TCHAR *pszName, const TCHAR *pszValue)
 {
-       m_query.Set(pszName, pszValue);
+       m_query.set(pszName, pszValue);
 }
 
 
@@ -342,9 +342,9 @@ void HttpRequest::SetQueryParam(const TCHAR *pszName, const TCHAR *pszValue)
 BOOL HttpRequest::GetQueryParam(const TCHAR *pszName, String &value)
 {
        BOOL ret = FALSE;
-       TCHAR *pszValue;
+       const TCHAR *pszValue;
 
-       pszValue = m_query.Get(pszName);
+       pszValue = m_query.get(pszName);
        if (pszValue != NULL)
        {
                value = pszValue;
index c1bad61..8f8fff1 100644 (file)
@@ -173,11 +173,11 @@ char *HttpResponse::BuildStream(int &size)
        tmp += (TCHAR *)m_codeString;
        tmp += _T("\r\n");
 
-       for(i = 0; i < m_headers.Size(); i++)
+       for(i = 0; i < m_headers.getSize(); i++)
        {
-               tmp += m_headers.GetKeyByIndex(i);
+               tmp += m_headers.getKeyByIndex(i);
                tmp += _T(": ");
-               tmp += m_headers.GetValueByIndex(i);
+               tmp += m_headers.getValueByIndex(i);
                tmp += _T("\r\n");
        }
        tmp += _T("\r\n");
index 3ddef81..67271a2 100644 (file)
@@ -183,8 +183,8 @@ public:
        HttpResponse();
        ~HttpResponse();
 
-       void SetHeader(const TCHAR *pszHdr, const TCHAR *pszValue) { m_headers.Set(pszHdr, pszValue); }
-       void SetType(const TCHAR *pszType) { m_headers.Set(_T("Content-type"), pszType); }
+       void SetHeader(const TCHAR *pszHdr, const TCHAR *pszValue) { m_headers.set(pszHdr, pszValue); }
+       void SetType(const TCHAR *pszType) { m_headers.set(_T("Content-type"), pszType); }
        void SetBody(const TCHAR *data, int size = -1, BOOL bAppend = FALSE);
        void AppendBody(const TCHAR *data, int size = -1) { SetBody(data, size, TRUE); }
        void SetJSONBody(JSONObjectBuilder &json);