X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FString.h;h=6889476bd87069aff07f95072cc3ab1150f761b1;hp=5d631340fd18ff3569183d583a51f0e5cbd5813a;hb=13cc05eaec5c19feaedc0b7fec17a6272f4b3f83;hpb=89cc32931877aa684e1a1f06776f564a49d39eab diff --git a/folly/String.h b/folly/String.h index 5d631340..6889476b 100644 --- a/folly/String.h +++ b/folly/String.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,21 +17,15 @@ #pragma once #define FOLLY_STRING_H_ +#include #include -#include #include -#include -#include - -#ifdef FOLLY_HAVE_DEPRECATED_ASSOC -#ifdef _GLIBCXX_SYMVER -#include -#include -#endif -#endif - -#include #include +#include +#include + +#include +#include #include #include @@ -217,12 +211,15 @@ std::string& stringVAppendf(std::string* out, const char* format, va_list ap); * C++, use cEscape instead. This function is for display purposes * only. */ -template -void backslashify(const String1& input, String2& output, bool hex_style=false); +template +void backslashify( + folly::StringPiece input, + OutputString& output, + bool hex_style = false); -template -String backslashify(const String& input, bool hex_style=false) { - String output; +template +OutputString backslashify(StringPiece input, bool hex_style = false) { + OutputString output; backslashify(input, output, hex_style); return output; } @@ -255,7 +252,7 @@ String humanify(const String& input) { * If append_output is true, append data to the output rather than * replace it. */ -template +template bool hexlify(const InputString& input, OutputString& output, bool append=false); @@ -278,7 +275,7 @@ OutputString hexlify(StringPiece input) { * Same functionality as Python's binascii.unhexlify. Returns true * on successful conversion. */ -template +template bool unhexlify(const InputString& input, OutputString& output); template @@ -415,20 +412,23 @@ fbstring errnoStr(int err); * or not (generating empty tokens). */ -template +template void split(const Delim& delimiter, const String& input, std::vector& out, const bool ignoreEmpty = false); -template +template void split(const Delim& delimiter, const String& input, folly::fbvector& out, const bool ignoreEmpty = false); -template +template < + class OutputValueType, + class Delim, + class String, + class OutputIterator> void splitTo(const Delim& delimiter, const String& input, OutputIterator out, @@ -564,11 +564,12 @@ std::string join(const Delim& delimiter, return output; } -template ::iterator_category, - std::random_access_iterator_tag>::value>::type* = nullptr> +template < + class Delim, + class Iterator, + typename std::enable_if::iterator_category, + std::random_access_iterator_tag>::value>::type* = nullptr> std::string join(const Delim& delimiter, Iterator begin, Iterator end) { std::string output; join(delimiter, begin, end, output); @@ -620,7 +621,7 @@ std::string stripLeftMargin(std::string s); * Leaves all other characters unchanged, including those with the 0x80 * bit set. * @param str String to convert - * @param len Length of str, in bytes + * @param length Length of str, in bytes */ void toLowerAscii(char* str, size_t length); @@ -628,8 +629,14 @@ inline void toLowerAscii(MutableStringPiece str) { toLowerAscii(str.begin(), str.size()); } -template >> +inline void toLowerAscii(std::string& str) { + // str[0] is legal also if the string is empty. + toLowerAscii(&str[0], str.size()); +} + +template < + class Iterator = const char*, + class Base = folly::Range>> class UTF8Range : public Base { public: /* implicit */ UTF8Range(const folly::Range baseRange) @@ -645,12 +652,4 @@ using UTF8StringPiece = UTF8Range; } // namespace folly -// Hook into boost's type traits -namespace boost { -template -struct has_nothrow_constructor > : true_type { - enum { value = true }; -}; -} // namespace boost - #include