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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2019 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UTF32Char};
use crate::data::CFDataRef;
use crate::string::{CFStringRef, UniChar};
use std::os::raw::c_void;

pub type CFCharacterSetPredefinedSet = CFIndex;

// Members of CFCharacterSetPredefinedSet enum
pub static kCFCharacterSetControl: CFCharacterSetPredefinedSet = 1;
pub static kCFCharacterSetWhitespace: CFCharacterSetPredefinedSet = 2;
pub static kCFCharacterSetWhitespaceAndNewline: CFCharacterSetPredefinedSet = 3;
pub static kCFCharacterSetDecimalDigit: CFCharacterSetPredefinedSet = 4;
pub static kCFCharacterSetLetter: CFCharacterSetPredefinedSet = 5;
pub static kCFCharacterSetLowercaseLetter: CFCharacterSetPredefinedSet = 6;
pub static kCFCharacterSetUppercaseLetter: CFCharacterSetPredefinedSet = 7;
pub static kCFCharacterSetNonBase: CFCharacterSetPredefinedSet = 8;
pub static kCFCharacterSetDecomposable: CFCharacterSetPredefinedSet = 9;
pub static kCFCharacterSetAlphaNumeric: CFCharacterSetPredefinedSet = 10;
pub static kCFCharacterSetPunctuation: CFCharacterSetPredefinedSet = 11;
pub static kCFCharacterSetIllegal: CFCharacterSetPredefinedSet = 12;
pub static kCFCharacterSetCapitalizedLetter: CFCharacterSetPredefinedSet = 13;
pub static kCFCharacterSetSymbol: CFCharacterSetPredefinedSet = 14;
pub static kCFCharacterSetNewline: CFCharacterSetPredefinedSet = 15;

#[repr(C)]
pub struct __CFCharacterSet(c_void);

pub type CFCharacterSetRef = *const __CFCharacterSet;
pub type CFMutableCharacterSetRef = *mut __CFCharacterSet;

extern "C" {
    /*
     * CFCharacterSet.h
     */

    /* CFCharacterSet */
    /* Creating Character Sets */
    pub fn CFCharacterSetCreateCopy(
        alloc: CFAllocatorRef,
        theSet: CFCharacterSetRef,
    ) -> CFCharacterSetRef;
    pub fn CFCharacterSetCreateInvertedSet(
        alloc: CFAllocatorRef,
        theSet: CFCharacterSetRef,
    ) -> CFCharacterSetRef;
    pub fn CFCharacterSetCreateWithCharactersInRange(
        alloc: CFAllocatorRef,
        theRange: CFRange,
    ) -> CFCharacterSetRef;
    pub fn CFCharacterSetCreateWithCharactersInString(
        alloc: CFAllocatorRef,
        theString: CFStringRef,
    ) -> CFCharacterSetRef;
    pub fn CFCharacterSetCreateWithBitmapRepresentation(
        alloc: CFAllocatorRef,
        theData: CFDataRef,
    ) -> CFCharacterSetRef;

    /* Getting Predefined Character Sets */
    pub fn CFCharacterSetGetPredefined(
        theSetIdentifier: CFCharacterSetPredefinedSet,
    ) -> CFCharacterSetRef;

    /* Querying Character Sets */
    pub fn CFCharacterSetCreateBitmapRepresentation(
        alloc: CFAllocatorRef,
        theSet: CFCharacterSetRef,
    ) -> CFDataRef;
    pub fn CFCharacterSetHasMemberInPlane(theSet: CFCharacterSetRef, thePlane: CFIndex) -> Boolean;
    pub fn CFCharacterSetIsCharacterMember(theSet: CFCharacterSetRef, theChar: UniChar) -> Boolean;
    pub fn CFCharacterSetIsLongCharacterMember(
        theSet: CFCharacterSetRef,
        theChar: UTF32Char,
    ) -> Boolean;
    pub fn CFCharacterSetIsSupersetOfSet(
        theSet: CFCharacterSetRef,
        theOtherset: CFCharacterSetRef,
    ) -> Boolean;

    /* Getting the Character Set Type Identifier */
    pub fn CFCharacterSetGetTypeID() -> CFTypeID;

    /* CFMutableCharacterSet */
    /* Creating a Mutable Character Set */
    pub fn CFCharacterSetCreateMutable(alloc: CFAllocatorRef) -> CFMutableCharacterSetRef;
    pub fn CFCharacterSetCreateMutableCopy(
        alloc: CFAllocatorRef,
        theSet: CFCharacterSetRef,
    ) -> CFMutableCharacterSetRef;

    /* Adding Characters */
    pub fn CFCharacterSetAddCharactersInRange(theSet: CFMutableCharacterSetRef, theRange: CFRange);
    pub fn CFCharacterSetAddCharactersInString(
        theSet: CFMutableCharacterSetRef,
        theString: CFStringRef,
    );

    /* Removing Characters */
    pub fn CFCharacterSetRemoveCharactersInRange(
        theSet: CFMutableCharacterSetRef,
        theRange: CFRange,
    );
    pub fn CFCharacterSetRemoveCharactersInString(
        theSet: CFMutableCharacterSetRef,
        theString: CFStringRef,
    );

    /* Logical Operations */
    pub fn CFCharacterSetIntersect(
        theSet: CFMutableCharacterSetRef,
        theOtherSet: CFCharacterSetRef,
    );
    pub fn CFCharacterSetInvert(theSet: CFMutableCharacterSetRef);
    pub fn CFCharacterSetUnion(theSet: CFMutableCharacterSetRef, theOtherSet: CFCharacterSetRef);
}