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

Side by Side Diff: third_party/WebKit/Source/core/inspector/ProtocolString.h

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ProtocolString_h
6 #define ProtocolString_h
7
8 #include "platform/Decimal.h"
9 #include "wtf/Allocator.h"
10 #include "wtf/text/StringBuilder.h"
11 #include "wtf/text/StringHash.h"
12 #include "wtf/text/WTFString.h"
13
14 namespace blink {
15 namespace protocol {
16
17 using String = WTF::String;
18 using StringBuilder = WTF::StringBuilder;
19
20 class CORE_EXPORT StringUtil {
21 STATIC_ONLY(StringUtil);
22 public:
23 static String substring(const String& s, unsigned pos, unsigned len = UINT_M AX) { return s.substring(pos, len); }
24 static String fromInteger(int number) { return String::number(number); }
25 static String fromDouble(double number) { return Decimal::fromDouble(number) .toString(); }
26 static const size_t kNotFound = WTF::kNotFound;
27 static void toCharacters(const String& s, const UChar** characters, size_t* length)
28 {
29 if (s.isEmpty()) {
30 *characters = nullptr;
31 *length = 0;
32 return;
33 }
34 if (s.is8Bit()) {
35 String s16 = s;
36 s16.ensure16Bit();
37 *characters = s16.characters16();
38 *length = s16.length();
39 } else {
40 *characters = s.characters16();
41 *length = s.length();
42 }
43 }
44 static void builderReserve(StringBuilder& builder, unsigned capacity) { buil der.reserveCapacity(capacity); }
45 };
46
47 } // namespace protocol
48 } // namespace blink
49
50 namespace std {
51 template<> struct hash<WTF::String> {
52 std::size_t operator()(const WTF::String& string) const
53 {
54 return StringHash::hash(string);
55 }
56 };
57 } // namespace std
58
59 #endif // !defined(ProtocolString_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698