MoCSI API Reference
Loading...
Searching...
No Matches
IniParser.h
Go to the documentation of this file.
1#ifndef INI_PARSER_H
2#define INI_PARSER_H
3
4#include <any>
5#include <exception>
6#include <iostream>
7#include <map>
8#include <string>
9#include <unordered_map>
10#include <utility>
11#include <vector>
12
20{
21 private:
22 std::unordered_map<std::string, std::any> m_ini_file_content;
23
24 void parseFile(const std::string& filename);
25 static bool validChar(char character);
26
27 public:
28 IniParser(const std::string& filename);
29
30 const std::unordered_map<std::string, std::any>& getIniContents()
31 {
32 return m_ini_file_content;
33 }
34};
35
45{
46 private:
47 std::map<std::string, std::unordered_map<std::string, std::any>> m_ini_file_content;
48 std::string m_current_module;
49
50 void parseSnapshotFile(const std::string& filename);
51 static bool validChar(char character);
52 bool checkNewModule(const std::string& current_module_name);
53
54 public:
55 IniParserSnapshot(const std::string& filename);
56
57 std::vector<std::string> getModuleNames() const;
58
59 const std::unordered_map<std::string, std::any>& getModuleContents(const std::string& key)
60 {
61 return m_ini_file_content.at(key);
62 }
63};
64
70class BadInput : public std::exception
71{
72 private:
73 std::string m_error_string;
74
75 public:
76 BadInput(std::string message) : m_error_string{std::move(message)} {}
77
78 [[nodiscard]] const char* what() const noexcept override { return m_error_string.c_str(); }
79
80 ~BadInput() override = default;
81};
82
83#endif
This error class inherits from std::exception and marks faulty parameter or CL inputs....
Definition IniParser.h:71
BadInput(std::string message)
Definition IniParser.h:76
~BadInput() override=default
const char * what() const noexcept override
Definition IniParser.h:78
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
This class parses ini files from a snapshot file. Currently supported are only the following data typ...
Definition IniParser.h:45
const std::unordered_map< std::string, std::any > & getModuleContents(const std::string &key)
Definition IniParser.h:59
std::vector< std::string > getModuleNames() const
Getter function for the module names.
Definition IniParser.cpp:213
This class parses ini files. Currently supported are only the following data types: string/char,...
Definition IniParser.h:20
const std::unordered_map< std::string, std::any > & getIniContents()
Definition IniParser.h:30