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

Side by Side Diff: base/string_piece.h

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | « base/string_number_conversions.h ('k') | base/string_split.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
11 // to include this .h file in other files rather than forward-declaring 11 // to include this .h file in other files rather than forward-declaring
12 // StringPiece as would be appropriate for most other Google classes. 12 // StringPiece as would be appropriate for most other Google classes.
13 // 13 //
14 // Systematic usage of StringPiece is encouraged as it will reduce unnecessary 14 // Systematic usage of StringPiece is encouraged as it will reduce unnecessary
15 // conversions from "const char*" to "string" and back again. 15 // conversions from "const char*" to "string" and back again.
16 // 16 //
17 17
18 #ifndef BASE_STRING_PIECE_H_ 18 #ifndef BASE_STRING_PIECE_H_
19 #define BASE_STRING_PIECE_H_ 19 #define BASE_STRING_PIECE_H_
20 #pragma once 20 #pragma once
21 21
22 #include <string> 22 #include <string>
23 23
24 #include "base/base_api.h" 24 #include "base/base_export.h"
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 26
27 namespace base { 27 namespace base {
28 28
29 class BASE_API StringPiece { 29 class BASE_EXPORT StringPiece {
30 public: 30 public:
31 // standard STL container boilerplate 31 // standard STL container boilerplate
32 typedef size_t size_type; 32 typedef size_t size_type;
33 typedef char value_type; 33 typedef char value_type;
34 typedef const char* pointer; 34 typedef const char* pointer;
35 typedef const char& reference; 35 typedef const char& reference;
36 typedef const char& const_reference; 36 typedef const char& const_reference;
37 typedef ptrdiff_t difference_type; 37 typedef ptrdiff_t difference_type;
38 typedef const char* const_iterator; 38 typedef const char* const_iterator;
39 typedef const char* iterator; 39 typedef const char* iterator;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 static int wordmemcmp(const char* p, const char* p2, size_type N) { 158 static int wordmemcmp(const char* p, const char* p2, size_type N) {
159 return memcmp(p, p2, N); 159 return memcmp(p, p2, N);
160 } 160 }
161 161
162 private: 162 private:
163 const char* ptr_; 163 const char* ptr_;
164 size_type length_; 164 size_type length_;
165 }; 165 };
166 166
167 BASE_API bool operator==(const StringPiece& x, const StringPiece& y); 167 BASE_EXPORT bool operator==(const StringPiece& x, const StringPiece& y);
168 168
169 inline bool operator!=(const StringPiece& x, const StringPiece& y) { 169 inline bool operator!=(const StringPiece& x, const StringPiece& y) {
170 return !(x == y); 170 return !(x == y);
171 } 171 }
172 172
173 inline bool operator<(const StringPiece& x, const StringPiece& y) { 173 inline bool operator<(const StringPiece& x, const StringPiece& y) {
174 const int r = StringPiece::wordmemcmp( 174 const int r = StringPiece::wordmemcmp(
175 x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size())); 175 x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size()));
176 return ((r < 0) || ((r == 0) && (x.size() < y.size()))); 176 return ((r < 0) || ((r == 0) && (x.size() < y.size())));
177 } 177 }
178 178
179 inline bool operator>(const StringPiece& x, const StringPiece& y) { 179 inline bool operator>(const StringPiece& x, const StringPiece& y) {
180 return y < x; 180 return y < x;
181 } 181 }
182 182
183 inline bool operator<=(const StringPiece& x, const StringPiece& y) { 183 inline bool operator<=(const StringPiece& x, const StringPiece& y) {
184 return !(x > y); 184 return !(x > y);
185 } 185 }
186 186
187 inline bool operator>=(const StringPiece& x, const StringPiece& y) { 187 inline bool operator>=(const StringPiece& x, const StringPiece& y) {
188 return !(x < y); 188 return !(x < y);
189 } 189 }
190 190
191 } // namespace base 191 } // namespace base
192 192
193 #endif // BASE_STRING_PIECE_H_ 193 #endif // BASE_STRING_PIECE_H_
OLDNEW
« no previous file with comments | « base/string_number_conversions.h ('k') | base/string_split.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698