Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
ConfigUtil.h
浏览该文件的文档.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
23
#pragma once
24
25
#include "
sese/io/InputStream.h
"
26
#include "
sese/io/OutputStream.h
"
27
28
#include <map>
29
30
#ifdef _WIN32
31
#pragma warning(disable : 4251)
32
#endif
33
34
namespace
sese
{
35
39
class
ConfigObject
{
40
public
:
41
using
Ptr
= std::shared_ptr<ConfigObject>;
42
44
struct
Section
{
45
using
Ptr
= std::shared_ptr<Section>;
46
47
std::string
name
;
48
std::map<std::string, std::string>
parameter
{};
49
50
explicit
Section
(std::string
name
);
57
[[nodiscard]] std::string
getValueByKey
(
const
std::string &key,
const
std::string &default_value)
const
;
58
void
setKeyValue
(
const
std::string &key,
const
std::string &value);
59
};
60
61
public
:
62
ConfigObject
();
63
[[nodiscard]]
Section::Ptr
getDefaultSection
() const noexcept {
return
this->
defaultSection
; }
// GCOVR_EXCL_LINE
69
[[nodiscard]]
Section::Ptr
getSectionByName
(
const
std::string §ion_name)
const
;
70
void
setSection
(
const
Section::Ptr
§ion);
71
[[nodiscard]]
const
std::map<std::string, Section::Ptr> &
getAllSection
()
const
;
72
73
private
:
74
Section::Ptr
defaultSection
;
75
std::map<std::string, Section::Ptr>
sections
;
76
};
77
81
class
SESE_DEPRECATED
ConfigUtil
{
82
public
:
83
using
InputStream
=
io::InputStream
;
84
using
OutputStream
=
io::OutputStream
;
85
91
static
ConfigObject::Ptr
readFrom
(
InputStream
*input);
98
static
bool
write2
(
const
ConfigObject::Ptr
&config_file,
OutputStream
*output);
99
100
private
:
101
static
std::string
readLine
(
InputStream
*input);
102
};
103
}
// namespace sese
sese
config
ConfigUtil.h
生成于 2024年 十一月 4日 星期一 09:57:59 , 为 Sese Framework使用
1.11.0