1//===-- CFCMutableSet.cpp ---------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "CFCMutableSet.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16
17//----------------------------------------------------------------------
18// CFCString constructor
19//----------------------------------------------------------------------
20CFCMutableSet::CFCMutableSet(CFMutableSetRef s) :
21    CFCReleaser<CFMutableSetRef> (s)
22{
23}
24
25//----------------------------------------------------------------------
26// CFCMutableSet copy constructor
27//----------------------------------------------------------------------
28CFCMutableSet::CFCMutableSet(const CFCMutableSet& rhs) :
29    CFCReleaser<CFMutableSetRef> (rhs)
30{
31}
32
33//----------------------------------------------------------------------
34// CFCMutableSet copy constructor
35//----------------------------------------------------------------------
36const CFCMutableSet&
37CFCMutableSet::operator=(const CFCMutableSet& rhs)
38{
39    if (this != &rhs)
40        *this = rhs;
41    return *this;
42}
43
44//----------------------------------------------------------------------
45// Destructor
46//----------------------------------------------------------------------
47CFCMutableSet::~CFCMutableSet()
48{
49}
50
51
52CFIndex
53CFCMutableSet::GetCount() const
54{
55    CFMutableSetRef set = get();
56    if (set)
57        return ::CFSetGetCount (set);
58    return 0;
59}
60
61CFIndex
62CFCMutableSet::GetCountOfValue(const void *value) const
63{
64    CFMutableSetRef set = get();
65    if (set)
66        return ::CFSetGetCountOfValue (set, value);
67    return 0;
68}
69
70const void *
71CFCMutableSet::GetValue(const void *value) const
72{
73    CFMutableSetRef set = get();
74    if (set)
75        return ::CFSetGetValue(set, value);
76    return NULL;
77}
78
79
80const void *
81CFCMutableSet::AddValue(const void *value, bool can_create)
82{
83    CFMutableSetRef set = get();
84    if (set == NULL)
85    {
86        if (can_create == false)
87            return NULL;
88        set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
89        reset ( set );
90    }
91    if (set != NULL)
92    {
93        ::CFSetAddValue(set, value);
94        return value;
95    }
96    return NULL;
97}
98
99void
100CFCMutableSet::RemoveValue(const void *value)
101{
102    CFMutableSetRef set = get();
103    if (set)
104        ::CFSetRemoveValue(set, value);
105}
106
107void
108CFCMutableSet::RemoveAllValues()
109{
110    CFMutableSetRef set = get();
111    if (set)
112        ::CFSetRemoveAllValues(set);
113}
114
115