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

Side by Side Diff: base/string_piece.h

Issue 249363004: Revert of Style cleanup in preparation for auto-linting base/. (Closed)
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « base/stats_table_unittest.cc ('k') | base/sync_socket_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Copied from strings/stringpiece.h with modifications 4 // Copied from strings/stringpiece.h with modifications
5 // 5 //
6 // A string-like object that points to a sized piece of memory. 6 // A string-like object that points to a sized piece of memory.
7 // 7 //
8 // Functions or methods may use const StringPiece& parameters to accept either 8 // Functions or methods may use const StringPiece& parameters to accept either
9 // a "const char*" or a "string" value that will be implicitly converted to 9 // a "const char*" or a "string" value that will be implicitly converted to
10 // a StringPiece. The implicit conversion means that it is often appropriate 10 // a StringPiece. The implicit conversion means that it is often appropriate
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // data() may return a pointer to a buffer with embedded NULs, and the 49 // data() may return a pointer to a buffer with embedded NULs, and the
50 // returned buffer may or may not be null terminated. Therefore it is 50 // returned buffer may or may not be null terminated. Therefore it is
51 // typically a mistake to pass data() to a routine that expects a NUL 51 // typically a mistake to pass data() to a routine that expects a NUL
52 // terminated string. 52 // terminated string.
53 const char* data() const { return ptr_; } 53 const char* data() const { return ptr_; }
54 size_type size() const { return length_; } 54 size_type size() const { return length_; }
55 size_type length() const { return length_; } 55 size_type length() const { return length_; }
56 bool empty() const { return length_ == 0; } 56 bool empty() const { return length_ == 0; }
57 57
58 void clear() { 58 void clear() { ptr_ = NULL; length_ = 0; }
59 ptr_ = NULL; 59 void set(const char* data, size_type len) { ptr_ = data; length_ = len; }
60 length_ = 0;
61 }
62 void set(const char* data, size_type len) {
63 ptr_ = data;
64 length_ = len;
65 }
66 void set(const char* str) { 60 void set(const char* str) {
67 ptr_ = str; 61 ptr_ = str;
68 length_ = str ? strlen(str) : 0; 62 length_ = str ? strlen(str) : 0;
69 } 63 }
70 void set(const void* data, size_type len) { 64 void set(const void* data, size_type len) {
71 ptr_ = reinterpret_cast<const char*>(data); 65 ptr_ = reinterpret_cast<const char*>(data);
72 length_ = len; 66 length_ = len;
73 } 67 }
74 68
75 char operator[](size_type i) const { return ptr_[i]; } 69 char operator[](size_type i) const { return ptr_[i]; }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 inline bool operator>=(const StringPiece& x, const StringPiece& y) { 179 inline bool operator>=(const StringPiece& x, const StringPiece& y) {
186 return !(x < y); 180 return !(x < y);
187 } 181 }
188 182
189 // allow StringPiece to be logged (needed for unit testing). 183 // allow StringPiece to be logged (needed for unit testing).
190 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece); 184 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece);
191 185
192 } // namespace base 186 } // namespace base
193 187
194 #endif // BASE_STRING_PIECE_H_ 188 #endif // BASE_STRING_PIECE_H_
OLDNEW
« no previous file with comments | « base/stats_table_unittest.cc ('k') | base/sync_socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698