LCOV - code coverage report
Current view: top level - src - utils.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 9 77.8 %
Date: 2025-11-03 23:36:02 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #ifndef SOCIAL_NETWORK_MICROSERVICES_UTILS_H
       2             : #define SOCIAL_NETWORK_MICROSERVICES_UTILS_H
       3             : 
       4             : #include <string>
       5             : #include <fstream>
       6             : #include <iostream>
       7             : #include <nlohmann/json.hpp>
       8             : 
       9             : #include "logger.h"
      10             : 
      11             : namespace social_network{
      12             : using json = nlohmann::json;
      13             : 
      14           1 : int load_config_file(const std::string &file_name, json *config_json) {
      15           2 :   std::ifstream json_file;
      16           1 :   json_file.open(file_name);
      17           1 :   if (json_file.is_open()) {
      18           1 :     json_file >> *config_json;
      19           1 :     json_file.close();
      20           1 :     return 0;
      21             :   }
      22             :   else {
      23           0 :     LOG(error) << "Cannot open service-config.json";
      24           0 :     return -1;
      25             :   }
      26             : };
      27             : 
      28             : } //namespace social_network
      29             : 
      30             : #endif //SOCIAL_NETWORK_MICROSERVICES_UTILS_H

Generated by: LCOV version 1.12