OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <stdarg.h> | 10 #include <stdarg.h> |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 std::string JoinString(const std::vector<std::string>& parts, | 610 std::string JoinString(const std::vector<std::string>& parts, |
611 const std::string& separator) { | 611 const std::string& separator) { |
612 return JoinStringT(parts, separator); | 612 return JoinStringT(parts, separator); |
613 } | 613 } |
614 | 614 |
615 string16 JoinString(const std::vector<string16>& parts, | 615 string16 JoinString(const std::vector<string16>& parts, |
616 const string16& separator) { | 616 const string16& separator) { |
617 return JoinStringT(parts, separator); | 617 return JoinStringT(parts, separator); |
618 } | 618 } |
619 | 619 |
620 static std::string JoinStringKeyValuePair( | |
erikwright (departed)
2014/07/10 14:26:24
These methods are only used from a single file AFA
Marc Treib
2014/07/10 15:40:39
I moved these functions into safe_search_util.cc.
| |
621 const StringPairs::value_type& key_value, | |
622 char delimiter) { | |
623 return key_value.first + delimiter + key_value.second; | |
624 } | |
625 | |
626 std::string JoinStringKeyValuePairs(const StringPairs& pairs, | |
627 char key_value_delimiter, | |
628 char key_value_pair_delimiter) { | |
629 if (pairs.empty()) | |
630 return std::string(); | |
631 | |
632 StringPairs::const_iterator it = pairs.begin(); | |
633 std::string result = JoinStringKeyValuePair(*it, key_value_delimiter); | |
634 ++it; | |
635 | |
636 for (; it != pairs.end(); ++it) { | |
637 result += key_value_pair_delimiter; | |
638 result += JoinStringKeyValuePair(*it, key_value_delimiter); | |
639 } | |
640 | |
641 return result; | |
642 } | |
643 | |
620 template<class FormatStringType, class OutStringType> | 644 template<class FormatStringType, class OutStringType> |
621 OutStringType DoReplaceStringPlaceholders(const FormatStringType& format_string, | 645 OutStringType DoReplaceStringPlaceholders(const FormatStringType& format_string, |
622 const std::vector<OutStringType>& subst, std::vector<size_t>* offsets) { | 646 const std::vector<OutStringType>& subst, std::vector<size_t>* offsets) { |
623 size_t substitutions = subst.size(); | 647 size_t substitutions = subst.size(); |
624 | 648 |
625 size_t sub_length = 0; | 649 size_t sub_length = 0; |
626 for (typename std::vector<OutStringType>::const_iterator iter = subst.begin(); | 650 for (typename std::vector<OutStringType>::const_iterator iter = subst.begin(); |
627 iter != subst.end(); ++iter) { | 651 iter != subst.end(); ++iter) { |
628 sub_length += iter->length(); | 652 sub_length += iter->length(); |
629 } | 653 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 } | 907 } |
884 | 908 |
885 } // namespace | 909 } // namespace |
886 | 910 |
887 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { | 911 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { |
888 return lcpyT<char>(dst, src, dst_size); | 912 return lcpyT<char>(dst, src, dst_size); |
889 } | 913 } |
890 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 914 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
891 return lcpyT<wchar_t>(dst, src, dst_size); | 915 return lcpyT<wchar_t>(dst, src, dst_size); |
892 } | 916 } |
OLD | NEW |