🛰️航天仿真算法库 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
51 ValueView getConfig(StringView key) const;
52
55 std::vector<std::string> getStringVector(StringView key) const;
56
57
60 std::vector<StringView> getStringViewVector(StringView key) const;
61
62
67 errc_t getConfig(StringView key, ValueView &value) const;
68
69public: // 修改配置
70
74 void setConfig(StringView key, ValueView value);
75
79 void setConfigRaw(StringView key, ValueView value);
80
84 void addConfig(StringView key, ValueView value);
85
89 void addConfigRaw(StringView key, ValueView value);
90
94 bool hasConfig(StringView key) const;
95
99 void printConfig(FILE* file=stdout) const;
100protected:
101 std::string decodeConfig(StringView value);
102protected:
103 using ConfigMap = std::unordered_map<std::string, GenericValue>;
104 ConfigMap configMap_;
105};
106
107
108
111AST_NAMESPACE_END
启动配置类
定义 StartupConfig.hpp:38
值视图类
定义 ValueView.hpp:40