Home | History | Annotate | Download | only in base

Lines Matching refs:str

168 template<typename STR>
169 bool RemoveCharsT(const STR& input,
170 const typename STR::value_type remove_chars[],
171 STR* output) {
178 while (found != STR::npos) {
180 output->replace(found, 1, STR());
207 template<typename STR>
208 TrimPositions TrimStringT(const STR& input,
209 const typename STR::value_type trim_chars[],
211 STR* output) {
213 const typename STR::size_type last_char = input.length() - 1;
214 const typename STR::size_type first_good_char = (positions & TRIM_LEADING) ?
216 const typename STR::size_type last_good_char = (positions & TRIM_TRAILING) ?
223 (first_good_char == STR::npos) || (last_good_char == STR::npos)) {
323 template<typename STR>
324 STR CollapseWhitespaceT(const STR& text,
326 STR result;
335 for (typename STR::const_iterator i(text.begin()); i != text.end(); ++i) {
382 bool ContainsOnlyWhitespaceASCII(const std::string& str) {
383 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) {
390 bool ContainsOnlyWhitespace(const string16& str) {
391 for (string16::const_iterator i(str.begin()); i != str.end(); ++i) {
398 template<typename STR>
399 static bool ContainsOnlyCharsT(const STR& input, const STR& characters) {
400 for (typename STR::const_iterator iter = input.begin();
402 if (characters.find(*iter) == STR::npos)
448 template<class STR>
449 static bool DoIsStringASCII(const STR& str) {
450 for (size_t i = 0; i < str.length(); i++) {
451 typename ToUnsigned<typename STR::value_type>::Unsigned c = str[i];
458 bool IsStringASCII(const std::wstring& str) {
459 return DoIsStringASCII(str);
463 bool IsStringASCII(const string16& str) {
464 return DoIsStringASCII(str);
468 bool IsStringASCII(const base::StringPiece& str) {
469 return DoIsStringASCII(str);
472 bool IsStringUTF8(const std::string& str) {
473 const char *src = str.data();
474 int32 src_len = static_cast<int32>(str.length());
562 bool StartsWithASCII(const std::string& str,
566 return str.compare(0, search.length(), search) == 0;
568 return base::strncasecmp(str.c_str(), search.c_str(), search.length()) == 0;
571 template <typename STR>
572 bool StartsWithT(const STR& str, const STR& search, bool case_sensitive) {
574 return str.compare(0, search.length(), search) == 0;
576 if (search.size() > str.size())
578 return std::equal(search.begin(), search.end(), str.begin(),
579 base::CaseInsensitiveCompare<typename STR::value_type>());
583 bool StartsWith(const std::wstring& str, const std::wstring& search,
585 return StartsWithT(str, search, case_sensitive);
589 bool StartsWith(const string16& str, const string16& search,
591 return StartsWithT(str, search, case_sensitive);
595 template <typename STR>
596 bool EndsWithT(const STR& str, const STR& search, bool case_sensitive) {
597 typename STR::size_type str_length = str.length();
598 typename STR::size_type search_length = search.length();
602 return str.compare(str_length - search_length, search_length, search) == 0;
605 str.begin() + (str_length - search_length),
606 base::CaseInsensitiveCompare<typename STR::value_type>());
610 bool EndsWith(const std::string& str, const std::string& search,
612 return EndsWithT(str, search, case_sensitive);
615 bool EndsWith(const std::wstring& str, const std::wstring& search,
617 return EndsWithT(str, search, case_sensitive);
621 bool EndsWith(const string16& str, const string16& search,
623 return EndsWithT(str, search, case_sensitive);
709 void DoReplaceSubstringsAfterOffset(StringType* str,
714 if ((start_offset == StringType::npos) || (start_offset >= str->length()))
718 for (typename StringType::size_type offs(str->find(find_this, start_offset));
719 offs != StringType::npos; offs = str->find(find_this, offs)) {
720 str->replace(offs, find_this.length(), replace_with);
728 void ReplaceFirstSubstringAfterOffset(string16* str,
732 DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with,
736 void ReplaceFirstSubstringAfterOffset(std::string* str,
740 DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with,
744 void ReplaceSubstringsAfterOffset(string16* str,
748 DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with,
752 void ReplaceSubstringsAfterOffset(std::string* str,
756 DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with,
761 template<typename STR>
762 static size_t TokenizeT(const STR& str,
763 const STR& delimiters,
764 std::vector<STR>* tokens) {
767 typename STR::size_type start = str.find_first_not_of(delimiters);
768 while (start != STR::npos) {
769 typename STR::size_type end = str.find_first_of(delimiters, start + 1);
770 if (end == STR::npos) {
771 tokens->push_back(str.substr(start));
774 tokens->push_back(str.substr(start, end - start));
775 start = str.find_first_not_of(delimiters, end + 1);
782 size_t Tokenize(const std::wstring& str,
785 return TokenizeT(str, delimiters, tokens);
789 size_t Tokenize(const string16& str,
792 return TokenizeT(str, delimiters, tokens);
796 size_t Tokenize(const std::string& str,
799 return TokenizeT(str, delimiters, tokens);
802 size_t Tokenize(const base::StringPiece& str,
805 return TokenizeT(str, delimiters, tokens);
808 template<typename STR>
809 static STR JoinStringT(const std::vector<STR>& parts,
810 typename STR::value_type sep) {
812 return STR();
814 STR result(parts[0]);
815 typename std::vector<STR>::const_iterator iter = parts.begin();
1074 // ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c