浏览代码

HPCC-11922 Changes from code review

- Substitute all static method class for namespace scoping
- Refactor odd member field nomenclature

Signed-off-by: rpastrana <rodrigo.pastrana@lexisnexis.com>
rpastrana 10 年之前
父节点
当前提交
937cec4ec2
共有 2 个文件被更改,包括 43 次插入45 次删除
  1. 19 21
      esp/services/common/jsonhelpers.hpp
  2. 24 24
      esp/services/common/wsexcept.cpp

+ 19 - 21
esp/services/common/jsonhelpers.hpp

@@ -31,9 +31,23 @@
 #define REQSF_ESCAPEFORMATTERS 0x0008
 #define REQSF_EXCLUSIVE (REQSF_SAMPLE_DATA | REQSF_TRIM)
 
-class HttpParamHelpers
+namespace HttpParamHelpers
 {
-public:
+    static const char * nextParameterTag(StringBuffer &tag, const char *path)
+    {
+        while (*path=='.')
+            path++;
+        const char *finger = strchr(path, '.');
+        if (finger)
+        {
+            tag.clear().append(finger - path, path);
+            finger++;
+        }
+        else
+            tag.set(path);
+        return finger;
+    }
+
     static void ensureParameter(IPropertyTree *pt, StringBuffer &tag, const char *path, const char *value, const char *fullpath)
     {
         if (!tag.length())
@@ -79,7 +93,7 @@ public:
         }
 
         StringBuffer nextTag;
-        path = nextParameterTag(nextTag, path);
+        path = HttpParamHelpers::nextParameterTag(nextTag, path);
         ensureParameter(pt, nextTag, path, value, fullpath);
     }
 
@@ -87,7 +101,7 @@ public:
     {
         const char *fullpath = path;
         StringBuffer tag;
-        path = nextParameterTag(tag, path);
+        path = HttpParamHelpers::nextParameterTag(tag, path);
         ensureParameter(pt, tag, path, value, fullpath);
     }
 
@@ -103,26 +117,10 @@ public:
         }
         return pt.getClear();
     }
-
-    static const char *nextParameterTag(StringBuffer &tag, const char *path)
-        {
-            while (*path=='.')
-                path++;
-            const char *finger = strchr(path, '.');
-            if (finger)
-            {
-                tag.clear().append(finger - path, path);
-                finger++;
-            }
-            else
-                tag.set(path);
-            return finger;
-        }
 };
 
-class JsonHelpers
+namespace JsonHelpers
 {
-public:
     static StringBuffer &appendJSONExceptionItem(StringBuffer &s, int code, const char *msg, const char *objname="Exceptions", const char *arrayName = "Exception")
     {
         if (objname && *objname)

+ 24 - 24
esp/services/common/wsexcept.cpp

@@ -1,8 +1,7 @@
 #include "platform.h"
 #include "wsexcept.hpp"
 
-class CWsException : public CInterface,
-implements IWsException
+class CWsException : public CInterface, implements IWsException
 {
 public:
     IMPLEMENT_IINTERFACE
@@ -10,18 +9,19 @@ public:
     CWsException (const char* source, WsErrorType errorType )
     {
         if (source)
-            source_.append(source);
-        errorType_ = errorType;
+            m_source.append(source);
+        m_errorType = errorType;
     }
+
     CWsException( IMultiException& me, WsErrorType errorType )
     {
         append(me);
-        errorType_ = errorType;
+        m_errorType = errorType;
 
         const char* source = me.source();
 
         if (source)
-            source_.append(source);
+            m_source.append(source);
     }
     CWsException( IException& e, const char* source, WsErrorType errorType )
     {
@@ -30,38 +30,38 @@ public:
             append(*me);
         } else
             append(e);
-        errorType_ = errorType;
+        m_errorType = errorType;
 
         if (source)
-            source_.append(source);
+            m_source.append(source);
     }
 
     //convenience methods for handling this as an array
     virtual aindex_t ordinality() const
     {
         synchronized block(m_mutex);
-        return array_.ordinality();
+        return m_array.ordinality();
     }
     virtual IException& item(aindex_t pos) const
     {
         synchronized block(m_mutex);
-        return array_.item(pos);
+        return m_array.item(pos);
     }
     virtual const char* source() const
     {
         synchronized block(m_mutex);
-        return source_.str();
+        return m_source.str();
     }
 
     //for complete control...caller is responsible for thread safety!
-    virtual IArrayOf<IException>& getArray()     { return array_;              }
+    virtual IArrayOf<IException>& getArray()     { return m_array;              }
 
     // add another exception. Pass ownership to this obj:
     // i.e., caller needs to make sure that e has one consumable ref count
     virtual void append(IException& e)
     {
         synchronized block(m_mutex);
-        array_.append(e);
+        m_array.append(e);
     }
     virtual void append(IMultiException& me)
     {
@@ -77,10 +77,10 @@ public:
                 StringBuffer msg;
                 msg.appendf("[%s] ",source);
                 e.errorMessage(msg);
-                array_.append(*MakeStringExceptionDirect(e.errorAudience(), e.errorCode(), msg));
+                m_array.append(*MakeStringExceptionDirect(e.errorAudience(), e.errorCode(), msg));
             }
             else
-                array_.append(*LINK(&e));
+                m_array.append(*LINK(&e));
         }
     }
 
@@ -95,12 +95,12 @@ public:
         if (!simplified)
         {
             if (indent) buffer.append("\n\t");
-            buffer.appendf("<Source>%s</Source>", source_.str());
+            buffer.appendf("<Source>%s</Source>", m_source.str());
         }
 
-        ForEachItemIn(i, array_)
+        ForEachItemIn(i, m_array)
         {
-            IException& exception = array_.item(i);
+            IException& exception = m_array.item(i);
 
             if (indent) buffer.append("\n\t");
             buffer.append("<Exception>");
@@ -115,7 +115,7 @@ public:
             {
                 if (indent) buffer.append("\n\t\t");
                 StringBuffer msg;
-                buffer.appendf("<Source>%s</Source>", source_.str());
+                buffer.appendf("<Source>%s</Source>", m_source.str());
             }
 
             if (indent) buffer.append("\n\t\t");
@@ -142,7 +142,7 @@ public:
     virtual StringBuffer& errorMessage(StringBuffer &msg) const
     {
         synchronized block(m_mutex);
-        ForEachItemIn(i, array_)
+        ForEachItemIn(i, m_array)
         {
             IException& e = item(i);
 
@@ -159,14 +159,14 @@ public:
     virtual WsErrorType errorType() const
     {
         synchronized block(m_mutex);
-        return errorType_;
+        return m_errorType;
     }
 private:
     CWsException( const CWsException& );
-    IArrayOf<IException> array_;
-    StringBuffer         source_;
+    IArrayOf<IException> m_array;
+    StringBuffer         m_source;
     mutable Mutex        m_mutex;
-    WsErrorType          errorType_;
+    WsErrorType          m_errorType;
 };
 
 IWsException esdl_decl *makeWsException(IMultiException& me, WsErrorType errorType)