OpenShot Audio Library | OpenShotAudio  0.3.3
juce_NamedValueSet.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 //==============================================================================
34 class JUCE_API NamedValueSet
35 {
36 public:
37  //==============================================================================
39  struct JUCE_API NamedValue
40  {
41  NamedValue() noexcept;
42  ~NamedValue() noexcept;
43 
44  NamedValue (const Identifier& name, const var& value);
45  NamedValue (const Identifier& name, var&& value) noexcept;
46  NamedValue (Identifier&& name, var&& value) noexcept;
47 
48  NamedValue (const NamedValue&);
49  NamedValue (NamedValue&&) noexcept;
50  NamedValue& operator= (NamedValue&&) noexcept;
51 
52  bool operator== (const NamedValue&) const noexcept;
53  bool operator!= (const NamedValue&) const noexcept;
54 
55  Identifier name;
56  var value;
57  };
58 
59  //==============================================================================
61  NamedValueSet() noexcept;
62 
64  NamedValueSet (NamedValueSet&&) noexcept;
65  NamedValueSet& operator= (const NamedValueSet&);
66  NamedValueSet& operator= (NamedValueSet&&) noexcept;
67 
69  NamedValueSet (std::initializer_list<NamedValue>);
70 
72  ~NamedValueSet() noexcept;
73 
77  bool operator== (const NamedValueSet&) const noexcept;
78  bool operator!= (const NamedValueSet&) const noexcept;
79 
80  const NamedValueSet::NamedValue* begin() const noexcept { return values.begin(); }
81  const NamedValueSet::NamedValue* end() const noexcept { return values.end(); }
82 
83  //==============================================================================
85  int size() const noexcept;
86 
88  bool isEmpty() const noexcept;
89 
93  const var& operator[] (const Identifier& name) const noexcept;
94 
98  var getWithDefault (const Identifier& name, const var& defaultReturnValue) const;
99 
104  bool set (const Identifier& name, const var& newValue);
105 
110  bool set (const Identifier& name, var&& newValue);
111 
113  bool contains (const Identifier& name) const noexcept;
114 
119  bool remove (const Identifier& name);
120 
124  Identifier getName (int index) const noexcept;
125 
134  var* getVarPointer (const Identifier& name) noexcept;
135 
144  const var* getVarPointer (const Identifier& name) const noexcept;
145 
149  const var& getValueAt (int index) const noexcept;
150 
156  var* getVarPointerAt (int index) noexcept;
157 
163  const var* getVarPointerAt (int index) const noexcept;
164 
166  int indexOf (const Identifier& name) const noexcept;
167 
169  void clear();
170 
171  //==============================================================================
173  void setFromXmlAttributes (const XmlElement& xml);
174 
178  void copyToXmlAttributes (XmlElement& xml) const;
179 
180 private:
181  //==============================================================================
182  Array<NamedValue> values;
183 };
184 
185 } // namespace juce