]> granicus.if.org Git - icinga2/commitdiff
Make buildable with VS 2017
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 15 Mar 2019 10:53:56 +0000 (11:53 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 18 Mar 2019 14:07:57 +0000 (15:07 +0100)
lib/base/json.cpp

index 0f2a8de91a667ac8f130052cb6b83f94246a89e8..c1a47c788dfede193104e5c932ae4d1346acffa3 100644 (file)
@@ -37,19 +37,8 @@ public:
        Value GetResult();
 
 private:
-       struct Node
-       {
-               union
-               {
-                       Dictionary *Object;
-                       Array *Aray;
-               };
-
-               bool IsObject;
-       };
-
        Value m_Root;
-       std::stack<Node> m_CurrentSubtree;
+       std::stack<std::pair<Dictionary*, Array*>> m_CurrentSubtree;
        String m_CurrentKey;
 
        void FillCurrentTarget(Value value);
@@ -280,7 +269,7 @@ bool JsonSax::start_object(std::size_t)
 
        FillCurrentTarget(object);
 
-       m_CurrentSubtree.push(Node{{.Object = object}, true});
+       m_CurrentSubtree.push({object, nullptr});
 
        return true;
 }
@@ -309,7 +298,7 @@ bool JsonSax::start_array(std::size_t)
 
        FillCurrentTarget(array);
 
-       m_CurrentSubtree.push(Node{{.Aray = array}, false});
+       m_CurrentSubtree.push({nullptr, array});
 
        return true;
 }
@@ -342,10 +331,10 @@ void JsonSax::FillCurrentTarget(Value value)
        } else {
                auto& node (m_CurrentSubtree.top());
 
-               if (node.IsObject) {
-                       node.Object->Set(m_CurrentKey, value);
+               if (node.first) {
+                       node.first->Set(m_CurrentKey, value);
                } else {
-                       node.Aray->Add(value);
+                       node.second->Add(value);
                }
        }
 }