Cleanup setting of 'sysroot' in common.gypi
[chromium-blink-merge.git] / third_party / mozilla / NSString+Utils.h
blobf556cc6e9c57ca089609266aed75679e2fd64a07
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is Chimera code.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2002
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Simon Fraser <sfraser@netscape.com>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #import <Foundation/Foundation.h>
40 typedef enum
42 kTruncateAtStart,
43 kTruncateAtMiddle,
44 kTruncateAtEnd
45 } ETruncationType;
48 // a category to extend NSString
49 @interface NSString (ChimeraStringUtils)
51 + (id)ellipsisString;
52 + (NSString*)stringWithUUID;
54 - (BOOL)isEqualToStringIgnoringCase:(NSString*)inString;
55 - (BOOL)hasCaseInsensitivePrefix:(NSString*)inString;
57 // Some URIs can contain spaces and still work, even though they aren't strictly valid
58 // per RFC2396. This method allows us to account for those URIs.
59 - (BOOL)isLooselyValidatedURI;
61 // Utility method to identify URIs that can be run in the context of the current page.
62 // These URIs could be used as attack vectors via AppleScript, for example.
63 - (BOOL)isPotentiallyDangerousURI;
65 // Utility method to ensure validity of URI strings. NSURL is used to validate
66 // most of them, but the NSURL test may fail for |javascript:| and |data:| URIs
67 // because they often contain invalid (per RFC2396) characters such as spaces.
68 - (BOOL)isValidURI;
70 - (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
71 - (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;
72 - (NSString *)stringByTruncatingTo:(unsigned int)maxCharacters at:(ETruncationType)truncationType;
73 - (NSString *)stringByTruncatingToWidth:(float)inWidth at:(ETruncationType)truncationType withAttributes:(NSDictionary *)attributes;
74 - (NSString *)stringByTrimmingWhitespace;
75 - (NSString *)stringByRemovingAmpEscapes;
76 - (NSString *)stringByAddingAmpEscapes;
78 @end
80 @interface NSMutableString (ChimeraMutableStringUtils)
82 - (void)truncateTo:(unsigned)maxCharacters at:(ETruncationType)truncationType;
83 - (void)truncateToWidth:(float)maxWidth at:(ETruncationType)truncationType withAttributes:(NSDictionary *)attributes;
85 @end
87 @interface NSString (ChimeraFilePathStringUtils)
89 - (NSString*)volumeNamePathComponent;
90 - (NSString*)displayNameOfLastPathComponent;
92 @end
94 @interface NSString (CaminoURLStringUtils)
96 // Returns true if the string represents a "blank" URL ("" or "about:blank")
97 - (BOOL)isBlankURL;
98 // Returns a URI that looks good in a location field
99 - (NSString *)unescapedURI;
101 @end