mmCEsim 0.3.0
mmWave Channel Estimation Simulation
read.h
Go to the documentation of this file.
1
12#ifndef _READ_H_
13#define _READ_H_
14
15#include "error_code.h"
16#include "meta.h"
17#include "yaml.h"
18#include <iostream>
19#include <string>
20#include <tuple>
21#include <vector>
22
23struct YAML_Error {
24 int line = -1;
25 int col = -1;
26 std::string msg;
28
29 YAML_Error(const std::string& msg, int line = -1, int col = -1);
30
31 YAML_Error(const std::string& msg, Err ec, int line = -1, int col = -1);
32
33 YAML_Error(Err ec, int line = -1, int col = -1);
34};
35
36using YAML_Errors = std::vector<YAML_Error>;
37
39 public:
40 ReadConfig(const std::string& file);
41
42 std::tuple<YAML::Node, YAML_Errors> read() const;
43
44 static std::tuple<YAML::Node, YAML_Errors> read(const std::string& file);
45
46 private:
47 std::string _file;
48};
49
50static inline bool hasError(const YAML_Errors& e) {
51 for (auto&& item : e) {
52 if (isError(item.ec)) return true;
53 }
54 return false;
55}
56
57#endif
Definition: read.h:38
std::tuple< YAML::Node, YAML_Errors > read() const
Definition: read.cpp:25
ReadConfig(const std::string &file)
Definition: read.cpp:22
std::string _file
Definition: read.h:47
Error Codes (Including Warnings)
Err
Error Code.
Definition: error_code.h:29
static bool isError(const Err &e) noexcept
Check if the error code corresponds to an error.
Definition: error_code.h:106
mmCEsim meta data
std::vector< YAML_Error > YAML_Errors
Definition: read.h:36
static bool hasError(const YAML_Errors &e)
Definition: read.h:50
Definition: read.h:23
int line
Definition: read.h:24
int col
Definition: read.h:25
Err ec
Definition: read.h:27
YAML_Error(const std::string &msg, int line=-1, int col=-1)
Definition: read.cpp:14
std::string msg
Definition: read.h:26
Wrapper for yaml-cpp for static linking.