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

Side by Side Diff: mojo/public/cpp/bindings/string.h

Issue 399313007: Mojo: Convert assert()s under mojo/public/cpp/bindings/... to MOJO_DCHECK()s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
7 7
8 #include <assert.h>
9
10 #include <string> 8 #include <string>
11 9
12 #include "mojo/public/cpp/bindings/lib/array_internal.h" 10 #include "mojo/public/cpp/bindings/lib/array_internal.h"
13 #include "mojo/public/cpp/bindings/type_converter.h" 11 #include "mojo/public/cpp/bindings/type_converter.h"
14 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/environment/logging.h"
15 13
16 namespace mojo { 14 namespace mojo {
17 15
18 class String { 16 class String {
19 public: 17 public:
20 typedef internal::String_Data Data_; 18 typedef internal::String_Data Data_;
21 19
22 String() : is_null_(true) {} 20 String() : is_null_(true) {}
23 String(const std::string& str) : value_(str), is_null_(false) {} 21 String(const std::string& str) : value_(str), is_null_(false) {}
24 String(const char* chars) : is_null_(!chars) { 22 String(const char* chars) : is_null_(!chars) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 116 }
119 static std::string ConvertTo(const String& input) { 117 static std::string ConvertTo(const String& input) {
120 return input; 118 return input;
121 } 119 }
122 }; 120 };
123 121
124 template <size_t N> 122 template <size_t N>
125 class TypeConverter<String, char[N]> { 123 class TypeConverter<String, char[N]> {
126 public: 124 public:
127 static String ConvertFrom(const char input[N]) { 125 static String ConvertFrom(const char input[N]) {
128 assert(input); 126 MOJO_DCHECK(input);
129 return String(input, N-1); 127 return String(input, N-1);
130 } 128 }
131 }; 129 };
132 130
133 // Appease MSVC. 131 // Appease MSVC.
134 template <size_t N> 132 template <size_t N>
135 class TypeConverter<String, const char[N]> { 133 class TypeConverter<String, const char[N]> {
136 public: 134 public:
137 static String ConvertFrom(const char input[N]) { 135 static String ConvertFrom(const char input[N]) {
138 assert(input); 136 MOJO_DCHECK(input);
139 return String(input, N-1); 137 return String(input, N-1);
140 } 138 }
141 }; 139 };
142 140
143 template <> 141 template <>
144 class TypeConverter<String, const char*> { 142 class TypeConverter<String, const char*> {
145 public: 143 public:
146 // |input| may be null, in which case a null String will be returned. 144 // |input| may be null, in which case a null String will be returned.
147 static String ConvertFrom(const char* input) { 145 static String ConvertFrom(const char* input) {
148 return String(input); 146 return String(input);
149 } 147 }
150 }; 148 };
151 149
152 } // namespace mojo 150 } // namespace mojo
153 151
154 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 152 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698