1//
2// ConfigurationView.h
3//
4// Library: Util
5// Package: Configuration
6// Module: ConfigurationView
7//
8// Definition of the ConfigurationView class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Util_ConfigurationView_INCLUDED
18#define Util_ConfigurationView_INCLUDED
19
20
21#include "Poco/Util/Util.h"
22#include "Poco/Util/AbstractConfiguration.h"
23
24
25namespace Poco {
26namespace Util {
27
28
29class Util_API ConfigurationView: public AbstractConfiguration
30 /// This configuration implements a "view" into a sub-hierarchy
31 /// of another configuration.
32 ///
33 /// For example, given a configuration with the following properties:
34 /// config.value1
35 /// config.value2
36 /// config.sub.value1
37 /// config.sub.value2
38 /// and a ConfigurationView with the prefix "config", then
39 /// the above properties will be available via the view as
40 /// value1
41 /// value2
42 /// sub.value1
43 /// sub.value2
44 ///
45 /// A ConfigurationView is most useful in combination with a
46 /// LayeredConfiguration.
47 ///
48 /// If a property is not found in the view, it is searched in
49 /// the original configuration. Given the above example configuration,
50 /// the property named "config.value1" will still be found in the view.
51 ///
52 /// The main reason for this is that placeholder expansion (${property})
53 /// still works as expected given a ConfigurationView.
54{
55public:
56 ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig);
57 /// Creates the ConfigurationView. The ConfigurationView does not take
58 /// ownership of the passed configuration.
59
60protected:
61 bool getRaw(const std::string& key, std::string& value) const;
62 void setRaw(const std::string& key, const std::string& value);
63 void enumerate(const std::string& key, Keys& range) const;
64 void removeRaw(const std::string& key);
65
66 std::string translateKey(const std::string& key) const;
67
68 ~ConfigurationView();
69
70private:
71 ConfigurationView(const ConfigurationView&);
72 ConfigurationView& operator = (const ConfigurationView&);
73
74 std::string _prefix;
75 AbstractConfiguration* _pConfig;
76};
77
78
79} } // namespace Poco::Util
80
81
82#endif // Util_ConfigurationView_INCLUDED
83