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

Side by Side Diff: Source/wtf/text/WTFString.h

Issue 21262003: Remove String::adopt(Vector<UChar>) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool isAllSpecialCharacters(const CharacterType*, size_t); 85 bool isAllSpecialCharacters(const CharacterType*, size_t);
86 86
87 class WTF_EXPORT String { 87 class WTF_EXPORT String {
88 public: 88 public:
89 // Construct a null string, distinguishable from an empty string. 89 // Construct a null string, distinguishable from an empty string.
90 String() { } 90 String() { }
91 91
92 // Construct a string with UTF-16 data. 92 // Construct a string with UTF-16 data.
93 String(const UChar* characters, unsigned length); 93 String(const UChar* characters, unsigned length);
94 94
95 // Construct a string by copying the contents of a vector. To avoid 95 // Construct a string by copying the contents of a vector.
96 // copying, consider using String::adopt instead.
97 // This method will never create a null string. Vectors with size() == 0 96 // This method will never create a null string. Vectors with size() == 0
98 // will return the empty string. 97 // will return the empty string.
99 // NOTE: This is different from String(vector.data(), vector.size()) 98 // NOTE: This is different from String(vector.data(), vector.size())
100 // which will sometimes return a null string when vector.data() is null 99 // which will sometimes return a null string when vector.data() is null
101 // which can only occur for vectors without inline capacity. 100 // which can only occur for vectors without inline capacity.
102 // See: https://bugs.webkit.org/show_bug.cgi?id=109792 101 // See: https://bugs.webkit.org/show_bug.cgi?id=109792
103 template<size_t inlineCapacity> 102 template<size_t inlineCapacity>
104 explicit String(const Vector<UChar, inlineCapacity>&); 103 explicit String(const Vector<UChar, inlineCapacity>&);
105 104
106 // Construct a string with UTF-16 data, from a null-terminated source. 105 // Construct a string with UTF-16 data, from a null-terminated source.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void swap(String& o) { m_impl.swap(o.m_impl); } 142 void swap(String& o) { m_impl.swap(o.m_impl); }
144 143
145 template<typename CharType> 144 template<typename CharType>
146 static String adopt(StringBuffer<CharType>& buffer) 145 static String adopt(StringBuffer<CharType>& buffer)
147 { 146 {
148 if (!buffer.length()) 147 if (!buffer.length())
149 return StringImpl::empty(); 148 return StringImpl::empty();
150 return String(buffer.release()); 149 return String(buffer.release());
151 } 150 }
152 151
153 template<typename CharType, size_t inlineCapacity>
154 static String adopt(Vector<CharType, inlineCapacity>& vector) { return Strin gImpl::adopt(vector); }
155
156 bool isNull() const { return !m_impl; } 152 bool isNull() const { return !m_impl; }
157 bool isEmpty() const { return !m_impl || !m_impl->length(); } 153 bool isEmpty() const { return !m_impl || !m_impl->length(); }
158 154
159 StringImpl* impl() const { return m_impl.get(); } 155 StringImpl* impl() const { return m_impl.get(); }
160 PassRefPtr<StringImpl> releaseImpl() { return m_impl.release(); } 156 PassRefPtr<StringImpl> releaseImpl() { return m_impl.release(); }
161 157
162 unsigned length() const 158 unsigned length() const
163 { 159 {
164 if (!m_impl) 160 if (!m_impl)
165 return 0; 161 return 0;
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 using WTF::equal; 726 using WTF::equal;
731 using WTF::equalIgnoringCase; 727 using WTF::equalIgnoringCase;
732 using WTF::find; 728 using WTF::find;
733 using WTF::isAllSpecialCharacters; 729 using WTF::isAllSpecialCharacters;
734 using WTF::isSpaceOrNewline; 730 using WTF::isSpaceOrNewline;
735 using WTF::reverseFind; 731 using WTF::reverseFind;
736 using WTF::ASCIILiteral; 732 using WTF::ASCIILiteral;
737 733
738 #include "wtf/text/AtomicString.h" 734 #include "wtf/text/AtomicString.h"
739 #endif 735 #endif
OLDNEW
« no previous file with comments | « Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698