2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../core/juce_StandardHeader.h"
30 #include "juce_StringPairArray.h"
33 //==============================================================================
34 StringPairArray::StringPairArray (const bool ignoreCase_
)
35 : ignoreCase (ignoreCase_
)
39 StringPairArray::StringPairArray (const StringPairArray
& other
)
41 values (other
.values
),
42 ignoreCase (other
.ignoreCase
)
46 StringPairArray::~StringPairArray()
50 StringPairArray
& StringPairArray::operator= (const StringPairArray
& other
)
53 values
= other
.values
;
57 bool StringPairArray::operator== (const StringPairArray
& other
) const
59 for (int i
= keys
.size(); --i
>= 0;)
60 if (other
[keys
[i
]] != values
[i
])
66 bool StringPairArray::operator!= (const StringPairArray
& other
) const
68 return ! operator== (other
);
71 const String
& StringPairArray::operator[] (const String
& key
) const
73 return values
[keys
.indexOf (key
, ignoreCase
)];
76 String
StringPairArray::getValue (const String
& key
, const String
& defaultReturnValue
) const
78 const int i
= keys
.indexOf (key
, ignoreCase
);
83 return defaultReturnValue
;
86 void StringPairArray::set (const String
& key
, const String
& value
)
88 const int i
= keys
.indexOf (key
, ignoreCase
);
92 values
.set (i
, value
);
101 void StringPairArray::addArray (const StringPairArray
& other
)
103 for (int i
= 0; i
< other
.size(); ++i
)
104 set (other
.keys
[i
], other
.values
[i
]);
107 void StringPairArray::clear()
113 void StringPairArray::remove (const String
& key
)
115 remove (keys
.indexOf (key
, ignoreCase
));
118 void StringPairArray::remove (const int index
)
121 values
.remove (index
);
124 void StringPairArray::setIgnoresCase (const bool shouldIgnoreCase
)
126 ignoreCase
= shouldIgnoreCase
;
129 String
StringPairArray::getDescription() const
133 for (int i
= 0; i
< keys
.size(); ++i
)
135 s
<< keys
[i
] << " = " << values
[i
];
143 void StringPairArray::minimiseStorageOverheads()
145 keys
.minimiseStorageOverheads();
146 values
.minimiseStorageOverheads();