🛰️航天仿真算法库 SpaceAST 0.3.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
52 errc_t loadAndMerge(StringView filepath);
53
55 const std::string& filepath() const{return filepath_;}
56
58 StringView dirpath() const;
59
62 bool empty() const{return configMap_.empty();}
63
67 ValueView getConfig(StringView key) const;
68
71 std::vector<std::string> getStringVector(StringView key) const;
72
73
76 std::vector<StringView> getStringViewVector(StringView key) const;
77
78
83 errc_t getConfig(StringView key, ValueView &value) const;
84
85public: // 修改配置
86
90 void setConfig(StringView key, ValueView value);
91
95 void setConfigRaw(StringView key, ValueView value);
96
100 void addConfig(StringView key, ValueView value);
101
105 void addConfigRaw(StringView key, ValueView value);
106
110 bool hasConfig(StringView key) const;
111
115 void printConfig(FILE* file=stdout) const;
116protected:
121 errc_t loadImpl(StringView filepath, bool clear);
122
123 std::string decodeConfig(StringView value);
124protected:
125 using ConfigMap = std::unordered_map<std::string, GenericValue>;
126 ConfigMap configMap_{};
127 std::string filepath_{};
128};
129
130
131
134AST_NAMESPACE_END
启动配置类
定义 StartupConfig.hpp:38
bool empty() const
检查配置是否为空
定义 StartupConfig.hpp:62
const std::string & filepath() const
获取加载的配置文件路径
定义 StartupConfig.hpp:55
值视图类
定义 ValueView.hpp:41