-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathCfgTuple.h
125 lines (107 loc) · 3.85 KB
/
CfgTuple.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//==============================================================================
//
// CfgTuple.h
//
// Copyright (C) 2013-2025 Greg Utas
//
// This file is part of the Robust Services Core (RSC).
//
// RSC is free software: you can redistribute it and/or modify it under the
// terms of the Lesser GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// RSC is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the Lesser GNU General Public License
// along with RSC. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef CFGTUPLE_H_INCLUDED
#define CFGTUPLE_H_INCLUDED
#include "Protected.h"
#include <cstddef>
#include <string>
#include "NbTypes.h"
#include "Q1Link.h"
#include "SysTypes.h"
//------------------------------------------------------------------------------
namespace NodeBase
{
// A key-value pair for a configuration parameter. Applications do not
// use this class directly. Instances of it are created when
// o CfgParmRegistry::LoadTuples reads key-value pairs from the element
// configuration file during system initialization;
// o CfgParmRegistry::BindParm adds a parameter to the registry and no
// tuple for that parameter existed in the element configuration file.
// In this case, a tuple is created for the parameter, and its value
// is set to the parameter's default.
//
class CfgTuple : public Protected
{
public:
// Deleted to prohibit copying.
//
CfgTuple(const CfgTuple& that) = delete;
// Deleted to prohibit copy assignment.
//
CfgTuple& operator=(const CfgTuple& that) = delete;
// The character that prefixes comments in the file that contains
// element configuration parameters. This character, and any that
// follow it on the same line, are ignored.
//
static const char CommentChar;
// Sets key_ and input_ from the arguments.
//
CfgTuple(c_string key, c_string input);
// Removes the tuple from CfgParmRegistry. Not subclassed.
//
~CfgTuple();
// Returns the tuple's key.
//
c_string Key() const { return key_.c_str(); }
// Returns the string used to set the parameter's value.
//
c_string Input() const { return input_.c_str(); }
// Saves the string that would set the parameter to its current value.
// Such a string must be available so that it can be written to a file
// that can later be read to restore the parameter's current value.
//
void SetInput(c_string input) { input_ = input; }
// Returns a string containing the characters that are valid in the
// name of a configuration parameter.
//
static const std::string& ValidKeyChars();
// Returns a string containing the characters that are valid in an
// input string that sets the value of a configuration parameter.
//
static const std::string& ValidValueChars();
// Returns a string containing the characters that are valid blanks
// in the file that sets configuration parameters.
//
static const std::string& ValidBlankChars();
// Returns the offset to link_.
//
static ptrdiff_t LinkDiff();
// Overridden to display member variables.
//
void Display(std::ostream& stream,
const std::string& prefix, const Flags& options) const override;
// Overridden for patching.
//
void Patch(sel_t selector, void* arguments) override;
private:
// The name of the parameter associated with the tuple.
//
const ProtectedStr key_;
// The string used to set the parameter's value.
//
ProtectedStr input_;
// The next tuple in CfgParmRegistry.
//
Q1Link link_;
};
}
#endif