LCOV - code coverage report
Current view: top level - src/esys/repo - revisionpin.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 29 46 63.0 %
Date: 2026-08-12 14:26:50 Functions: 12 14 85.7 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/revisionpin.cpp
       3             :  * \brief
       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/revisionpin.h"
      20             : 
      21             : namespace esys::repo
      22             : {
      23             : 
      24           3 : RevisionPin::RevisionPin() = default;
      25             : 
      26           3 : RevisionPin::~RevisionPin() = default;
      27             : 
      28           3 : void RevisionPin::set_selector(PinSelector selector)
      29             : {
      30           3 :     m_selector = selector;
      31           3 : }
      32             : 
      33           2 : PinSelector RevisionPin::get_selector() const
      34             : {
      35           2 :     return m_selector;
      36             : }
      37             : 
      38           3 : void RevisionPin::set_value(const std::string &value)
      39             : {
      40           3 :     m_value = value;
      41           3 : }
      42             : 
      43           2 : const std::string &RevisionPin::get_value() const
      44             : {
      45           2 :     return m_value;
      46             : }
      47             : 
      48           3 : void RevisionPin::set_rev(const std::string &rev)
      49             : {
      50           3 :     m_rev = rev;
      51           3 : }
      52             : 
      53           6 : const std::string &RevisionPin::get_rev() const
      54             : {
      55           6 :     return m_rev;
      56             : }
      57             : 
      58           3 : void RevisionPin::set_path(const std::string &path)
      59             : {
      60           3 :     m_path = path;
      61           3 : }
      62             : 
      63          10 : const std::string &RevisionPin::get_path() const
      64             : {
      65          10 :     return m_path;
      66             : }
      67             : 
      68           0 : void RevisionPin::clear()
      69             : {
      70           0 :     m_selector = PinSelector::NOT_SET;
      71           0 :     m_value.clear();
      72           0 :     m_rev.clear();
      73           0 :     m_path.clear();
      74           0 : }
      75             : 
      76           1 : std::string to_string(PinSelector selector)
      77             : {
      78           1 :     switch (selector)
      79             :     {
      80           1 :         case PinSelector::NAME: return "name";
      81           0 :         case PinSelector::PROJECT: return "project";
      82           0 :         case PinSelector::URL: return "url";
      83           0 :         default: return "";
      84             :     }
      85             : }
      86             : 
      87           1 : bool pin_selector_from_string(const std::string &text, PinSelector &selector)
      88             : {
      89           1 :     if (text == "name")
      90             :     {
      91           1 :         selector = PinSelector::NAME;
      92           1 :         return true;
      93             :     }
      94           0 :     if (text == "project")
      95             :     {
      96           0 :         selector = PinSelector::PROJECT;
      97           0 :         return true;
      98             :     }
      99           0 :     if (text == "url")
     100             :     {
     101           0 :         selector = PinSelector::URL;
     102           0 :         return true;
     103             :     }
     104           0 :     selector = PinSelector::NOT_SET;
     105           0 :     return false;
     106             : }
     107             : 
     108             : } // namespace esys::repo

Generated by: LCOV version 1.14