LCOV - code coverage report
Current view: top level - src/config - yamlparser.cpp (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 5 28 17.9 %
Date: 2024-12-21 08:56:24 Functions: 1 4 25.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  This program 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 3 of the License, or
       7             :  *  (at your option) any later version.
       8             :  *
       9             :  *  This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "yamlparser.h"
      19             : #include "fileutils.h"
      20             : 
      21             : namespace jami {
      22             : namespace yaml_utils {
      23             : 
      24             : void
      25           0 : parsePath(const YAML::Node& node, const char* key, std::string& path, const std::filesystem::path& base)
      26             : {
      27           0 :     std::string val;
      28           0 :     parseValue(node, key, val);
      29           0 :     path = fileutils::getFullPath(base, val).string();
      30           0 : }
      31             : 
      32             : void
      33           0 : parsePathOptional(const YAML::Node& node, const char* key, std::string& path, const std::filesystem::path& base)
      34             : {
      35           0 :     std::string val;
      36           0 :     if (parseValueOptional(node, key, val))
      37           0 :         path = fileutils::getFullPath(base, val).string();
      38           0 : }
      39             : 
      40             : std::vector<std::map<std::string, std::string>>
      41           0 : parseVectorMap(const YAML::Node& node, const std::initializer_list<std::string>& keys)
      42             : {
      43           0 :     std::vector<std::map<std::string, std::string>> result;
      44           0 :     result.reserve(node.size());
      45           0 :     for (const auto& n : node) {
      46           0 :         std::map<std::string, std::string> t;
      47           0 :         for (const auto& k : keys) {
      48           0 :             t[k] = n[k].as<std::string>("");
      49             :         }
      50           0 :         result.emplace_back(std::move(t));
      51           0 :     }
      52           0 :     return result;
      53           0 : }
      54             : 
      55             : std::set<std::string>
      56          60 : parseVector(const YAML::Node& node)
      57             : {
      58          60 :     std::set<std::string> result;
      59          60 :     for (const auto& n : node) {
      60           0 :         result.emplace(n.as<std::string>(""));
      61          60 :     }
      62          60 :     return result;
      63           0 : }
      64             : } // namespace yaml_utils
      65             : } // namespace jami

Generated by: LCOV version 1.14