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: 2026-12-03 01:19:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* Copyright (C) 2026 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             : #include <utility>
      22             : 
      23             : #ifdef _MSC_VER
      24             :  // Avoid complaints about unreachable code; the optimiser is realising
      25             :  // that some code is incapable of throwing, then warning about the catch
      26             :  // block that will never be executed.
      27             :  #pragma warning(disable: 4702)
      28             :  #include <map>
      29             :  #pragma warning(default: 4702)
      30             : #else
      31             :  #include <map>
      32             : #endif
      33             : 
      34             : // AtNode is an immutable tree node, with a string and and multimap of children.
      35          13 : class AtNode
      36             : {
      37             :     friend class AtSmartPtr<AtNode>;
      38             :     friend class AtSmartPtr<const AtNode>;
      39             : 
      40             : public:
      41             :     typedef AtSmartPtr<const AtNode> Ptr;
      42             : 
      43          34 :     AtNode() : m_Refcount(0) {}
      44          26 :     explicit AtNode(const AtNode* n) { *this = *n; m_Refcount = 0; }
      45           7 :     explicit AtNode(const char* text) : m_Refcount(0), m_Value(text) {}
      46             : 
      47             :     // Create a new AtNode (since AtNodes are immutable, so it's not possible
      48             :     // to just change this one), with the relevant alterations to its content.
      49             :     const AtNode::Ptr setValue(const char* value) const;
      50             :     const AtNode::Ptr addChild(const char* key, const AtNode::Ptr &data) const;
      51             :     const AtNode::Ptr setChild(const char* key, const AtNode::Ptr &data) const;
      52             :     const AtNode::Ptr unsetChild(const char* key) const;
      53             :     const AtNode::Ptr addOverlay(const AtNode::Ptr &data) const;
      54             :     const AtIter getChild(const char* key) const;
      55             : 
      56             :     // Check recursively for any 'value' data
      57             :     bool hasContent() const;
      58             : 
      59             : //private:  // (but not actually private, since I'm still too lazy to waste
      60             :             // time with dozens of friends)
      61             : 
      62             :     std::string m_Value;
      63             : 
      64             :     typedef std::multimap<std::string, AtNode::Ptr> child_maptype;
      65             :     typedef std::pair<std::string, AtNode::Ptr> child_pairtype;
      66             : 
      67             :     child_maptype m_Children;
      68             : 
      69             : private:
      70             :     mutable unsigned int m_Refcount;
      71             : };
      72             : 
      73             : // Implementation of AtIter
      74             : class AtIterImpl
      75             : {
      76             :     friend class AtSmartPtr<AtIterImpl>;
      77             : 
      78             : public:
      79             :     AtIterImpl() : m_Refcount(0) {}
      80             : 
      81           0 :     AtIterImpl(AtNode::child_maptype::const_iterator it, AtNode::child_maptype::const_iterator up)
      82           0 :         : m_Refcount(0), iter(it), iter_upperbound(up) {}
      83             : 
      84             :     AtNode::child_maptype::const_iterator iter, iter_upperbound;
      85             : 
      86             : private:
      87             :     mutable unsigned int m_Refcount;
      88             : };

Generated by: LCOV version 1.16