| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_CHROME_COMMON_STRING_UTIL_H_ | 5 #ifndef IOS_CHROME_COMMON_STRING_UTIL_H_ |
| 6 #define IOS_CHROME_COMMON_STRING_UTIL_H_ | 6 #define IOS_CHROME_COMMON_STRING_UTIL_H_ |
| 7 | 7 |
| 8 #import <CoreGraphics/CoreGraphics.h> | 8 #import <CoreGraphics/CoreGraphics.h> |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 // Parses a string with an embedded link inside, delineated by BEGIN_LINK and | 12 // Parses a string with an embedded link inside, delineated by BEGIN_LINK and |
| 13 // END_LINK. Returns the string without the link delimiters. If |out_link_range| | 13 // END_LINK. Returns the string without the link delimiters. If |out_link_range| |
| 14 // is not null, then it is filled out with the range of the link in the returned | 14 // is not null, then it is filled out with the range of the link in the returned |
| 15 // string. | 15 // string. |
| 16 // If no link is found, then it returns |text| and sets |out_link_range| to | 16 // If no link is found, then it returns |text| and sets |out_link_range| to |
| 17 // {NSNotFound, 0}. | 17 // {NSNotFound, 0}. |
| 18 NSString* ParseStringWithLink(NSString* text, NSRange* out_link_range); | 18 NSString* ParseStringWithLink(NSString* text, NSRange* out_link_range); |
| 19 | 19 |
| 20 // Utility method that returns an NSCharacterSet containing Unicode graphics | 20 // Utility method that returns an NSCharacterSet containing Unicode graphics |
| 21 // and drawing characters (but not including the Braille Patterns characters). | 21 // and drawing characters (but not including the Braille Patterns characters). |
| 22 NSCharacterSet* GraphicCharactersSet(); | 22 NSCharacterSet* GraphicCharactersSet(); |
| 23 | 23 |
| 24 // Cleans an NSString by collapsing whitespace and removing leading and trailing | 24 // Cleans an NSString by collapsing whitespace and removing leading and trailing |
| 25 // spaces. If |removeGraphicChars| is true, unicode graphic characters will also | 25 // spaces. If |removeGraphicChars| is true, unicode graphic characters will also |
| 26 // be removed from the string. | 26 // be removed from the string. |
| 27 NSString* CleanNSStringForDisplay(NSString* dirty, BOOL removeGraphicChars); | 27 NSString* CleanNSStringForDisplay(NSString* dirty, BOOL removeGraphicChars); |
| 28 | 28 |
| 29 // Cleans a std::string identically to CleanNSStringForDisplay() | 29 // Cleans a std::string identically to CleanNSStringForDisplay() |
| 30 std::string CleanStringForDisplay(std::string dirty, BOOL removeGraphicChars); | 30 std::string CleanStringForDisplay(const std::string& dirty, |
| 31 BOOL removeGraphicChars); |
| 31 | 32 |
| 32 // Find the longest leading substring of |string| that, when rendered with | 33 // Find the longest leading substring of |string| that, when rendered with |
| 33 // |attributes|, will fit on a single line inside |targetWidth|. If |trailing| | 34 // |attributes|, will fit on a single line inside |targetWidth|. If |trailing| |
| 34 // is YES, then find the trailing (instead of leading) substring. | 35 // is YES, then find the trailing (instead of leading) substring. |
| 35 NSString* SubstringOfWidth(NSString* string, | 36 NSString* SubstringOfWidth(NSString* string, |
| 36 NSDictionary* attributes, | 37 NSDictionary* attributes, |
| 37 CGFloat targetWidth, | 38 CGFloat targetWidth, |
| 38 BOOL trailing); | 39 BOOL trailing); |
| 39 | 40 |
| 40 #endif // IOS_CHROME_COMMON_STRING_UTIL_H_ | 41 #endif // IOS_CHROME_COMMON_STRING_UTIL_H_ |
| OLD | NEW |