LCOV - code coverage report
Current view: top level - source/tools/atlas/AtlasObject - AtlasObjectImpl.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 4 6 66.7 %
Date: 2023-01-19 00:18:29 Functions: 5 6 83.3 %

          Line data    Source code
       1             : /* Copyright (C) 2021 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "AtlasObject.h"
      19             : 
      20             : #include <string>
      21             : 
      22             : #ifdef _MSC_VER
      23             :  // Avoid complaints about unreachable code; the optimiser is realising
      24             :  // that some code is incapable of throwing, then warning about the catch
      25             :  // block that will never be executed.
      26             :  #pragma warning(disable: 4702)
      27             :  #include <map>
      28             :  #pragma warning(default: 4702)
      29             : #else
      30             :  #include <map>
      31             : #endif
      32             : 
      33             : // AtNode is an immutable tree node, with a string and and multimap of children.
      34          67 : class AtNode
      35             : {
      36             :     friend class AtSmartPtr<AtNode>;
      37             :     friend class AtSmartPtr<const AtNode>;
      38             : 
      39             : public:
      40             :     typedef AtSmartPtr<const AtNode> Ptr;
      41             : 
      42          34 :     AtNode() : m_Refcount(0) {}
      43          13 :     explicit AtNode(const AtNode* n) { *this = *n; m_Refcount = 0; }
      44           7 :     explicit AtNode(const char* text) : m_Refcount(0), m_Value(text) {}
      45             : 
      46             :     // Create a new AtNode (since AtNodes are immutable, so it's not possible
      47             :     // to just change this one), with the relevant alterations to its content.
      48             :     const AtNode::Ptr setValue(const char* value) const;
      49             :     const AtNode::Ptr addChild(const char* key, const AtNode::Ptr &data) const;
      50             :     const AtNode::Ptr setChild(const char* key, const AtNode::Ptr &data) const;
      51             :     const AtNode::Ptr unsetChild(const char* key) const;
      52             :     const AtNode::Ptr addOverlay(const AtNode::Ptr &data) const;
      53             :     const AtIter getChild(const char* key) const;
      54             : 
      55             :     // Check recursively for any 'value' data
      56             :     bool hasContent() const;
      57             : 
      58             : //private:  // (but not actually private, since I'm still too lazy to waste
      59             :             // time with dozens of friends)
      60             : 
      61             :     std::string m_Value;
      62             : 
      63             :     typedef std::multimap<std::string, AtNode::Ptr> child_maptype;
      64             :     typedef std::pair<std::string, AtNode::Ptr> child_pairtype;
      65             : 
      66             :     child_maptype m_Children;
      67             : 
      68             : private:
      69             :     mutable unsigned int m_Refcount;
      70             : };
      71             : 
      72             : // Implementation of AtIter
      73             : class AtIterImpl
      74             : {
      75             :     friend class AtSmartPtr<AtIterImpl>;
      76             : 
      77             : public:
      78             :     AtIterImpl() : m_Refcount(0) {}
      79             : 
      80           0 :     AtIterImpl(AtNode::child_maptype::const_iterator it, AtNode::child_maptype::const_iterator up)
      81           0 :         : m_Refcount(0), iter(it), iter_upperbound(up) {}
      82             : 
      83             :     AtNode::child_maptype::const_iterator iter, iter_upperbound;
      84             : 
      85             : private:
      86             :     mutable unsigned int m_Refcount;
      87             : };

Generated by: LCOV version 1.13