Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: ios/chrome/common/string_util.h

Issue 1073863005: Upstream string_util function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test deps Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/common/README.txt ('k') | ios/chrome/common/string_util.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/common/string_util.h
diff --git a/ios/chrome/common/string_util.h b/ios/chrome/common/string_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..9176a3a89cecd13cf2c277382a1f46b88b505738
--- /dev/null
+++ b/ios/chrome/common/string_util.h
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_COMMON_STRING_UTIL_H_
+#define IOS_CHROME_COMMON_STRING_UTIL_H_
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+#include <string>
+
+// Parses a string with an embedded link inside, delineated by BEGIN_LINK and
+// END_LINK. Returns the string without the link delimiters. If |out_link_range|
+// is not null, then it is filled out with the range of the link in the returned
+// string.
+// If no link is found, then it returns |text| and sets |out_link_range| to
+// {NSNotFound, 0}.
+NSString* ParseStringWithLink(NSString* text, NSRange* out_link_range);
+
+// Utility method that returns an NSCharacterSet containing Unicode graphics
+// and drawing characters (but not including the Braille Patterns characters).
+NSCharacterSet* GraphicCharactersSet();
+
+// Cleans an NSString by collapsing whitespace and (if |trim| is true)
+// removing leading and trailing spaces. If |removeGraphicChars| is true,
+// unicode graphic characters will also be removed from the string.
+NSString* CleanNSStringForDisplay(NSString* dirty,
+ BOOL removeGraphicChars,
+ BOOL trim);
+
+// Cleans a std::string identically to CleanNSStringForDisplay()
+std::string CleanStringForDisplay(std::string dirty,
+ BOOL removeGraphicChars,
+ BOOL trim);
+
+// Find the longest leading substring of |string| that, when rendered with
+// |attributes|, will fit on a single line inside |targetWidth|. If |trailing|
+// is YES, then find the trailing (instead of leading) substring.
+NSString* SubstringOfWidth(NSString* string,
+ NSDictionary* attributes,
+ CGFloat targetWidth,
+ BOOL trailing);
+
+#endif // IOS_CHROME_COMMON_STRING_UTIL_H_
« no previous file with comments | « ios/chrome/common/README.txt ('k') | ios/chrome/common/string_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698