🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
StartupConfig.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include <unordered_map>
25#include "AstUtil/ValueView.hpp"
26#include "AstUtil/GenericValue.hpp"
27#include <cstdio>
28
29AST_NAMESPACE_BEGIN
30
37class AST_UTIL_API StartupConfig
38{
39public:
40 StartupConfig() = default;
41 ~StartupConfig() = default;
42
46 errc_t load(StringView filepath);
47
49 const std::string& filepath() const{return filepath_;}
50
52 StringView dirpath() const;
53
56 bool empty() const{return configMap_.empty();}
57
61 ValueView getConfig(StringView key) const;
62
65 std::vector<std::string> getStringVector(StringView key) const;
66
67
70 std::vector<StringView> getStringViewVector(StringView key) const;
71
72
77 errc_t getConfig(StringView key, ValueView &value) const;
78
79public: // 修改配置
80
84 void setConfig(StringView key, ValueView value);
85
89 void setConfigRaw(StringView key, ValueView value);
90
94 void addConfig(StringView key, ValueView value);
95
99 void addConfigRaw(StringView key, ValueView value);
100
104 bool hasConfig(StringView key) const;
105
109 void printConfig(FILE* file=stdout) const;
110protected:
111 std::string decodeConfig(StringView value);
112protected:
113 using ConfigMap = std::unordered_map<std::string, GenericValue>;
114 ConfigMap configMap_;
115 std::string filepath_;
116};
117
118
119
122AST_NAMESPACE_END
启动配置类
定义 StartupConfig.hpp:38
bool empty() const
检查配置是否为空
定义 StartupConfig.hpp:56
const std::string & filepath() const
获取加载的配置文件路径
定义 StartupConfig.hpp:49
值视图类
定义 ValueView.hpp:41