1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #include "propertyset.h"
26
27 MI_BEGIN_NAMESPACE
28
29 PropertySet::PropertySet(MI_PropertySet* propertySet) : _rep(propertySet)
30 {
31 }
32
33 MI_Uint32 PropertySet::GetSize() const
34 {
35 MI_Uint32 n;
36
37 if (MI_PropertySet_GetElementCount(_rep, &n) != MI_RESULT_OK)
38 return 0;
39
40 return n;
41 }
42
43 mike 1.1 bool PropertySet::Contains(const String& name) const
44 {
45 MI_Boolean b;
46
47 if (MI_PropertySet_ContainsElement(_rep, name.Str(), &b) != MI_RESULT_OK)
48 return false;
49
50 return b ? true : false;
51 }
52
53 bool PropertySet::Add(const String& name)
54 {
55 if (MI_PropertySet_AddElement(_rep, name.Str()) != MI_RESULT_OK)
56 return false;
57
58 return true;
59 }
60
61 void PropertySet::Clear()
62 {
63 MI_PropertySet_Clear(_rep);
64 mike 1.1 }
65
66 bool PropertySet::Get(MI_Uint32 index, String& name) const
67 {
68 const MI_Char* tmp;
69
70 if (MI_PropertySet_GetElement(_rep, index, &tmp) != MI_RESULT_OK)
71 return false;
72
73 name = tmp;
74 return true;
75 }
76
77 MI_END_NAMESPACE
|