MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

Block.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_CONFIG_BLOCK_HXX
21 #define MPD_CONFIG_BLOCK_HXX
22
23 #include "check.h"
24 #include "Param.hxx"
25 #include "Compiler.h"
26
27 #include <string>
28 #include <vector>
29
30 class AllocatedPath;
31
32 struct BlockParam {
33 std::string name;
34 std::string value;
35 int line;
36
41 mutable bool used;
42
43 gcc_nonnull_all
44 BlockParam(const char *_name, const char *_value, int _line=-1)
45 :name(_name), value(_value), line(_line), used(false) {}
46
47 gcc_pure
48 int GetIntValue() const;
49
50 gcc_pure
51 unsigned GetUnsignedValue() const;
52
53 gcc_pure
54 bool GetBoolValue() const;
55 };
56
57 struct ConfigBlock {
62 ConfigBlock *next;
63
64 int line;
65
66 std::vector<BlockParam> block_params;
67
72 bool used;
73
74 explicit ConfigBlock(int _line=-1)
75 :next(nullptr), line(_line), used(false) {}
76
77 ConfigBlock(const ConfigBlock &) = delete;
78
79 ~ConfigBlock();
80
81 ConfigBlock &operator=(const ConfigBlock &) = delete;
82
88 bool IsNull() const {
89 return line < 0;
90 }
91
92 gcc_pure
93 bool IsEmpty() const {
94 return block_params.empty();
95 }
96
97 gcc_nonnull_all
98 void AddBlockParam(const char *_name, const char *_value,
99 int _line=-1) {
100 block_params.emplace_back(_name, _value, _line);
101 }
102
103 gcc_nonnull_all gcc_pure
104 const BlockParam *GetBlockParam(const char *_name) const;
105
106 gcc_pure
107 const char *GetBlockValue(const char *name,
108 const char *default_value=nullptr) const;
109
116 AllocatedPath GetPath(const char *name,
117 const char *default_value=nullptr) const;
118
119 gcc_pure
120 int GetBlockValue(const char *name, int default_value) const;
121
122 gcc_pure
123 unsigned GetBlockValue(const char *name, unsigned default_value) const;
124
125 gcc_pure
126 bool GetBlockValue(const char *name, bool default_value) const;
127 };
128
129 #endif
BlockParam::name
std::string name
Definition: Block.hxx:33
check.h
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
ConfigBlock::GetBlockParam
gcc_nonnull_all gcc_pure const BlockParam * GetBlockParam(const char *_name) const
Param.hxx
AllocatedPath
A path name in the native file system character set.
Definition: AllocatedPath.hxx:38
BlockParam::BlockParam
gcc_nonnull_all BlockParam(const char *_name, const char *_value, int _line=-1)
Definition: Block.hxx:44
BlockParam::GetBoolValue
gcc_pure bool GetBoolValue() const
ConfigBlock::next
ConfigBlock * next
The next ConfigBlock with the same name.
Definition: Block.hxx:62
ConfigBlock::GetPath
AllocatedPath GetPath(const char *name, const char *default_value=nullptr) const
Same as config_get_path(), but looks up the setting in the specified block.
ConfigBlock::AddBlockParam
gcc_nonnull_all void AddBlockParam(const char *_name, const char *_value, int _line=-1)
Definition: Block.hxx:98
ConfigBlock::used
bool used
This flag is false when nobody has queried the value of this option yet.
Definition: Block.hxx:72
BlockParam::value
std::string value
Definition: Block.hxx:34
ConfigBlock
Definition: Block.hxx:57
Compiler.h
ConfigBlock::line
int line
Definition: Block.hxx:64
BlockParam::GetIntValue
gcc_pure int GetIntValue() const
ConfigBlock::operator=
ConfigBlock & operator=(const ConfigBlock &)=delete
ConfigBlock::IsNull
bool IsNull() const
Determine if this is a "null" instance, i.e.
Definition: Block.hxx:88
ConfigBlock::ConfigBlock
ConfigBlock(int _line=-1)
Definition: Block.hxx:74
ConfigBlock::GetBlockValue
gcc_pure const char * GetBlockValue(const char *name, const char *default_value=nullptr) const
ConfigBlock::~ConfigBlock
~ConfigBlock()
ConfigBlock::IsEmpty
gcc_pure bool IsEmpty() const
Definition: Block.hxx:93
BlockParam::used
bool used
This flag is false when nobody has queried the value of this option yet.
Definition: Block.hxx:41
BlockParam::GetUnsignedValue
gcc_pure unsigned GetUnsignedValue() const
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
BlockParam::line
int line
Definition: Block.hxx:35
BlockParam
Definition: Block.hxx:32
ConfigBlock::block_params
std::vector< BlockParam > block_params
Definition: Block.hxx:66
name
const Partition const char * name
Definition: Count.hxx:34