OLD | NEW |
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 // | 4 // |
5 // This file defines utility functions for working with strings. | 5 // This file defines utility functions for working with strings. |
6 | 6 |
7 #ifndef BASE_STRING_UTIL_H_ | 7 #ifndef BASE_STRING_UTIL_H_ |
8 #define BASE_STRING_UTIL_H_ | 8 #define BASE_STRING_UTIL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 std::vector<std::string>* r); | 487 std::vector<std::string>* r); |
488 | 488 |
489 // The same as SplitString, but don't trim white space. | 489 // The same as SplitString, but don't trim white space. |
490 void SplitStringDontTrim(const std::wstring& str, | 490 void SplitStringDontTrim(const std::wstring& str, |
491 wchar_t s, | 491 wchar_t s, |
492 std::vector<std::wstring>* r); | 492 std::vector<std::wstring>* r); |
493 void SplitStringDontTrim(const std::string& str, | 493 void SplitStringDontTrim(const std::string& str, |
494 char s, | 494 char s, |
495 std::vector<std::string>* r); | 495 std::vector<std::string>* r); |
496 | 496 |
| 497 // Does the opposite of SplitString(). |
| 498 std::wstring JoinString(const std::vector<std::wstring>& parts, wchar_t s); |
| 499 std::string JoinString(const std::vector<std::string>& parts, char s); |
| 500 |
497 // WARNING: this uses whitespace as defined by the HTML5 spec. If you need | 501 // WARNING: this uses whitespace as defined by the HTML5 spec. If you need |
498 // a function similar to this but want to trim all types of whitespace, then | 502 // a function similar to this but want to trim all types of whitespace, then |
499 // factor this out into a function that takes a string containing the characters | 503 // factor this out into a function that takes a string containing the characters |
500 // that are treated as whitespace. | 504 // that are treated as whitespace. |
501 // | 505 // |
502 // Splits the string along whitespace (where whitespace is the five space | 506 // Splits the string along whitespace (where whitespace is the five space |
503 // characters defined by HTML 5). Each contiguous block of non-whitespace | 507 // characters defined by HTML 5). Each contiguous block of non-whitespace |
504 // characters is added to result. | 508 // characters is added to result. |
505 void SplitStringAlongWhitespace(const std::wstring& str, | 509 void SplitStringAlongWhitespace(const std::wstring& str, |
506 std::vector<std::wstring>* result); | 510 std::vector<std::wstring>* result); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 // Returns a hex string representation of a binary buffer. | 553 // Returns a hex string representation of a binary buffer. |
550 // The returned hex string will be in upper case. | 554 // The returned hex string will be in upper case. |
551 // This function does not check if |size| is within reasonable limits since | 555 // This function does not check if |size| is within reasonable limits since |
552 // it's written with trusted data in mind. | 556 // it's written with trusted data in mind. |
553 // If you suspect that the data you want to format might be large, | 557 // If you suspect that the data you want to format might be large, |
554 // the absolute max size for |size| should be is | 558 // the absolute max size for |size| should be is |
555 // std::numeric_limits<size_t>::max() / 2 | 559 // std::numeric_limits<size_t>::max() / 2 |
556 std::string HexEncode(const void* bytes, size_t size); | 560 std::string HexEncode(const void* bytes, size_t size); |
557 | 561 |
558 #endif // BASE_STRING_UTIL_H_ | 562 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |