| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 std::string* rest); | 169 std::string* rest); |
| 170 | 170 |
| 171 // Safe sprintf to std::string | 171 // Safe sprintf to std::string |
| 172 //void sprintf(std::string& value, size_t maxlen, const char * format, ...) | 172 //void sprintf(std::string& value, size_t maxlen, const char * format, ...) |
| 173 // PRINTF_FORMAT(3); | 173 // PRINTF_FORMAT(3); |
| 174 | 174 |
| 175 // Convert arbitrary values to/from a string. | 175 // Convert arbitrary values to/from a string. |
| 176 | 176 |
| 177 template <class T> | 177 template <class T> |
| 178 static bool ToString(const T &t, std::string* s) { | 178 static bool ToString(const T &t, std::string* s) { |
| 179 DCHECK(s); | 179 RTC_DCHECK(s); |
| 180 std::ostringstream oss; | 180 std::ostringstream oss; |
| 181 oss << std::boolalpha << t; | 181 oss << std::boolalpha << t; |
| 182 *s = oss.str(); | 182 *s = oss.str(); |
| 183 return !oss.fail(); | 183 return !oss.fail(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 template <class T> | 186 template <class T> |
| 187 static bool FromString(const std::string& s, T* t) { | 187 static bool FromString(const std::string& s, T* t) { |
| 188 DCHECK(t); | 188 RTC_DCHECK(t); |
| 189 std::istringstream iss(s); | 189 std::istringstream iss(s); |
| 190 iss >> std::boolalpha >> *t; | 190 iss >> std::boolalpha >> *t; |
| 191 return !iss.fail(); | 191 return !iss.fail(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Inline versions of the string conversion routines. | 194 // Inline versions of the string conversion routines. |
| 195 | 195 |
| 196 template<typename T> | 196 template<typename T> |
| 197 static inline std::string ToString(const T& val) { | 197 static inline std::string ToString(const T& val) { |
| 198 std::string str; ToString(val, &str); return str; | 198 std::string str; ToString(val, &str); return str; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 210 | 210 |
| 211 // simple function to strip out characters which shouldn't be | 211 // simple function to strip out characters which shouldn't be |
| 212 // used in filenames | 212 // used in filenames |
| 213 char make_char_safe_for_filename(char c); | 213 char make_char_safe_for_filename(char c); |
| 214 | 214 |
| 215 ////////////////////////////////////////////////////////////////////// | 215 ////////////////////////////////////////////////////////////////////// |
| 216 | 216 |
| 217 } // namespace rtc | 217 } // namespace rtc |
| 218 | 218 |
| 219 #endif // WEBRTC_BASE_STRINGENCODE_H__ | 219 #endif // WEBRTC_BASE_STRINGENCODE_H__ |
| OLD | NEW |