Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 96 lines (76 sloc) 4.451 kb
4d4563c Jan Objective C port of “diff-match-patch” as released in sub-folder “object...
authored
1 /*
2 * Diff Match and Patch
3 *
4 * Copyright 2010 geheimwerk.de.
5 * http://code.google.com/p/google-diff-match-patch/
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: fraser@google.com (Neil Fraser)
20 * ObjC port: jan@geheimwerk.de (Jan Weiß)
21 */
22
23 #ifndef _DIFFMATCHPATCHCFUTILITIES_H
24 #define _DIFFMATCHPATCHCFUTILITIES_H
25
26 CFStringRef diff_CFStringCreateFromUnichar(UniChar ch);
287b0e4 Jan Declaring diff_CFStringCreate…() utility functions CF_INLINE and moving ...
authored
27
28 CF_INLINE CFStringRef diff_CFStringCreateSubstring(CFStringRef text, CFIndex start_index, CFIndex length) {
29 CFRange substringRange = {
30 .length = length,
31 .location = start_index,
32 };
33
34 CFStringRef substring = CFStringCreateWithSubstring(kCFAllocatorDefault, text, substringRange);
35
36 return substring;
37 }
38
39 CF_INLINE CFStringRef diff_CFStringCreateRightSubstring(CFStringRef text, CFIndex text_length, CFIndex new_length) {
40 return diff_CFStringCreateSubstring(text, text_length - new_length, new_length);
41 }
42
43 CF_INLINE CFStringRef diff_CFStringCreateLeftSubstring(CFStringRef text, CFIndex new_length) {
44 return diff_CFStringCreateSubstring(text, 0, new_length);
45 }
46
47 CF_INLINE CFStringRef diff_CFStringCreateSubstringWithStartIndex(CFStringRef text, CFIndex start_index) {
48 return diff_CFStringCreateSubstring(text, start_index, (CFStringGetLength(text) - start_index));
49 }
50
51 CF_INLINE CFStringRef diff_CFStringCreateJavaSubstring(CFStringRef s, CFIndex begin, CFIndex end) {
52 return diff_CFStringCreateSubstring(s, begin, end - begin);
53 }
4d4563c Jan Objective C port of “diff-match-patch” as released in sub-folder “object...
authored
54
55 CFIndex diff_commonPrefix(CFStringRef text1, CFStringRef text2);
56 CFIndex diff_commonSuffix(CFStringRef text1, CFStringRef text2);
57 CFIndex diff_commonOverlap(CFStringRef text1, CFStringRef text2);
58 CFArrayRef diff_halfMatchCreate(CFStringRef text1, CFStringRef text2, const float diffTimeout);
59 CFArrayRef diff_halfMatchICreate(CFStringRef longtext, CFStringRef shorttext, CFIndex i);
60
61 CFStringRef diff_linesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef lineArray, CFMutableDictionaryRef lineHash);
2a6e947 Jan Adding high level support for munging sentences, paragraphs and line bre...
authored
62 CFStringRef diff_tokensToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash, CFOptionFlags tokenizerOptions);
2f0066b Jan Improved infrastructure for word mode support.
authored
63 CFStringRef diff_wordsToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
0e768ec Jan Adding low level support for munging sentences, paragraphs and line brea...
authored
64 CFStringRef diff_sentencesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
65 CFStringRef diff_paragraphsToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
81921bc Jan Fixing symbol names and options to correctly represent what “line break ...
authored
66 CFStringRef diff_lineBreakDelimiteredToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
b99ce5a Jan Implementing diff_rangesToCharsMungeCFStringCreate().
authored
67 CFStringRef diff_rangesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef substringArray, CFMutableDictionaryRef substringHash, CFRange *ranges, size_t ranges_count);
4d4563c Jan Objective C port of “diff-match-patch” as released in sub-folder “object...
authored
68
1c8f4c3 Jan Rewriting chars to tokens rehydration to improve performance.
authored
69 CFStringRef diff_charsToTokenCFStringCreate(CFStringRef charsString, CFArrayRef tokenArray);
70
4d4563c Jan Objective C port of “diff-match-patch” as released in sub-folder “object...
authored
71 CFIndex diff_cleanupSemanticScore(CFStringRef one, CFStringRef two);
72
73 CF_INLINE void diff_CFStringPrepareUniCharBuffer(CFStringRef string, const UniChar **string_chars, UniChar **string_buffer, CFRange string_range) {
74 *string_chars = CFStringGetCharactersPtr(string);
75 if (*string_chars == NULL) {
76 // Fallback in case CFStringGetCharactersPtr() didn’t work.
77 *string_buffer = malloc(string_range.length * sizeof(UniChar));
78 CFStringGetCharacters(string, string_range, *string_buffer);
79 *string_chars = *string_buffer;
80 }
81 }
82
35fd1e1 Jan Switching arrays of equalities from NSNumber/CFNumber objects to raw CFI...
authored
83 #define CFIndexArrayLastValueIndex (CFArrayGetCount(theArray)-1)
84
85 CF_INLINE CFIndex diff_CFArrayLastValueAsCFIndex(CFMutableArrayRef theArray) {
86 return (CFIndex)CFArrayGetValueAtIndex(theArray, CFIndexArrayLastValueIndex);
87 }
88
89 CF_INLINE void diff_CFArrayRemoveLastValue(CFMutableArrayRef theArray) {
90 CFArrayRemoveValueAtIndex(theArray, CFIndexArrayLastValueIndex);
91 }
92
93 #undef CFIndexArrayLastValueIndex
94
4d4563c Jan Objective C port of “diff-match-patch” as released in sub-folder “object...
authored
95 #endif //ifndef _DIFFMATCHPATCHCFUTILITIES_H
Something went wrong with that request. Please try again.