LCOV - code coverage report
Current view: top level - src/esys/repo/manifest - workspace_manifest.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 13 23 56.5 %
Date: 2026-11-07 22:18:26 Functions: 4 8 50.0 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/manifest/workspace_manifest.cpp
       3             :  * \brief Nested workspace metadata (ADR-0043)
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2026 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #include "esys/repo/esysrepo_prec.h"
      19             : #include "esys/repo/manifest/workspace.h"
      20             : 
      21             : #include <algorithm>
      22             : #include <cctype>
      23             : 
      24             : namespace esys::repo::manifest
      25             : {
      26             : namespace
      27             : {
      28             : 
      29           5 : std::string to_lower(std::string s)
      30             : {
      31          26 :     std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
      32           5 :     return s;
      33             : }
      34             : 
      35             : } // namespace
      36             : 
      37           4 : WorkspaceConfig::WorkspaceConfig(bool nested)
      38           4 :     : m_nested(nested)
      39             : {
      40           4 : }
      41             : 
      42           0 : void WorkspaceConfig::set_nested(bool nested)
      43             : {
      44           0 :     m_nested = nested;
      45           0 : }
      46             : 
      47           6 : bool WorkspaceConfig::get_nested() const
      48             : {
      49           6 :     return m_nested;
      50             : }
      51             : 
      52           0 : bool WorkspaceConfig::operator==(const WorkspaceConfig &other) const
      53             : {
      54           0 :     return m_nested == other.m_nested;
      55             : }
      56             : 
      57           0 : bool WorkspaceConfig::operator!=(const WorkspaceConfig &other) const
      58             : {
      59           0 :     return !(*this == other);
      60             : }
      61             : 
      62           5 : std::optional<bool> WorkspaceConfig::parse_nested(const std::string &text)
      63             : {
      64           5 :     const std::string v = to_lower(text);
      65           7 :     if (v == "true" || v == "yes" || v == "1") return true;
      66           1 :     if (v == "false" || v == "no" || v == "0") return false;
      67           0 :     return std::nullopt;
      68           5 : }
      69             : 
      70           0 : const char *WorkspaceConfig::to_string(bool nested)
      71             : {
      72           0 :     return nested ? "true" : "false";
      73             : }
      74             : 
      75             : } // namespace esys::repo::manifest

Generated by: LCOV version 1.14