aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/basetypes/MCRange.h
blob: 9ec4f56809f6d1f179be788bd50058280849821e (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef MAILCORE_MCRANGE_H

#define MAILCORE_MCRANGE_H

#ifdef __cplusplus

#include <inttypes.h>

#include <MailCore/MCUtils.h>

#ifndef UINT64_MAX
# define UINT64_MAX 18446744073709551615ULL
#endif

namespace mailcore {
    
    class IndexSet;
    class String;
    
    // infinite length : UINT64_MAX
    // empty range : location = UINT64_MAX
    struct Range {
        uint64_t location;
        uint64_t length;
    };
    
    MAILCORE_EXPORT
    extern Range RangeEmpty;
    
    MAILCORE_EXPORT
    Range RangeMake(uint64_t location, uint64_t length);

    MAILCORE_EXPORT
    IndexSet * RangeRemoveRange(Range range1, Range range2);

    MAILCORE_EXPORT
    IndexSet * RangeUnion(Range range1, Range range2);

    MAILCORE_EXPORT
    Range RangeIntersection(Range range1, Range range2);

    MAILCORE_EXPORT
    bool RangeHasIntersection(Range range1, Range range2);

    MAILCORE_EXPORT
    uint64_t RangeLeftBound(Range range);

    MAILCORE_EXPORT
    uint64_t RangeRightBound(Range range);

    MAILCORE_EXPORT
    String * RangeToString(Range range);
    
    MAILCORE_EXPORT
    Range RangeFromString(String * rangeString);
}

#endif

#endif