OpenShot Audio Library | OpenShotAudio  0.3.1
juce_PropertySet.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  The code included in this file is provided under the terms of the ISC license
11  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12  To use, copy, modify, and/or distribute this software for any purpose with or
13  without fee is hereby granted provided that the above copyright notice and
14  this permission notice appear in all copies.
15 
16  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18  DISCLAIMED.
19 
20  ==============================================================================
21 */
22 
23 namespace juce
24 {
25 
26 //==============================================================================
38 class JUCE_API PropertySet
39 {
40 public:
41  //==============================================================================
46  PropertySet (bool ignoreCaseOfKeyNames = false);
47 
49  PropertySet (const PropertySet& other);
50 
52  PropertySet& operator= (const PropertySet& other);
53 
55  virtual ~PropertySet();
56 
57  //==============================================================================
67  String getValue (StringRef keyName, const String& defaultReturnValue = String()) const noexcept;
68 
78  int getIntValue (StringRef keyName, int defaultReturnValue = 0) const noexcept;
79 
89  double getDoubleValue (StringRef keyName, double defaultReturnValue = 0.0) const noexcept;
90 
103  bool getBoolValue (StringRef keyName, bool defaultReturnValue = false) const noexcept;
104 
116  std::unique_ptr<XmlElement> getXmlValue (StringRef keyName) const;
117 
118  //==============================================================================
124  void setValue (const String& keyName, const var& value);
125 
133  void setValue (const String& keyName, const XmlElement* xml);
134 
138  void addAllPropertiesFrom (const PropertySet& source);
139 
140  //==============================================================================
144  void removeValue (StringRef keyName);
145 
147  bool containsKey (StringRef keyName) const noexcept;
148 
150  void clear();
151 
152  //==============================================================================
154  StringPairArray& getAllProperties() noexcept { return properties; }
155 
157  const CriticalSection& getLock() const noexcept { return lock; }
158 
159  //==============================================================================
164  std::unique_ptr<XmlElement> createXml (const String& nodeName) const;
165 
170  void restoreFromXml (const XmlElement& xml);
171 
172  //==============================================================================
185  void setFallbackPropertySet (PropertySet* fallbackProperties) noexcept;
186 
190  PropertySet* getFallbackPropertySet() const noexcept { return fallbackProperties; }
191 
192 protected:
194  virtual void propertyChanged();
195 
196 private:
197  StringPairArray properties;
198  PropertySet* fallbackProperties;
199  CriticalSection lock;
200  bool ignoreCaseOfKeys;
201 
202  JUCE_LEAK_DETECTOR (PropertySet)
203 };
204 
205 } // namespace juce
StringPairArray & getAllProperties() noexcept
PropertySet * getFallbackPropertySet() const noexcept
const CriticalSection & getLock() const noexcept