blob: 09233bab5e836c7242900dce68412d2a5cbfee98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/**
* Scintilla source code edit control
* @file DictionaryForCF.h - Wrapper for CFMutableDictionary
*
* Copyright 2024 Neil Hodgson.
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
*/
#ifndef DICTIONARYFORCF_H
#define DICTIONARYFORCF_H
class DictionaryForCF {
CFMutableDictionaryRef dict;
public:
DictionaryForCF() noexcept :
dict(::CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks)) {
}
~DictionaryForCF() {
::CFRelease(dict);
}
CFMutableDictionaryRef get() const noexcept {
return dict;
}
void SetValue(const void *key, const void *value) noexcept {
::CFDictionarySetValue(dict, key, value);
}
void SetItem(const void *key, CFNumberType theType, const void *valuePtr) noexcept {
CFNumberRef number = ::CFNumberCreate(kCFAllocatorDefault, theType, valuePtr);
::CFDictionarySetValue(dict, key, number);
::CFRelease(number);
}
};
#endif
|