#ifndef FOLLY_BASE_STRING_H_
#define FOLLY_BASE_STRING_H_
+#include <exception>
#include <string>
#include <boost/type_traits.hpp>
return folly::to<fbstring>(demangle(typeid(e)), ": ", e.what());
}
+inline fbstring exceptionStr(std::exception_ptr ep) {
+ try {
+ std::rethrow_exception(ep);
+ } catch (const std::exception& e) {
+ return exceptionStr(e);
+ } catch (...) {
+ return "<unknown exception>";
+ }
+}
+
/*
* Split a string into a list of tokens by delimiter.
*
OutputIterator out,
bool ignoreEmpty = false);
+/*
+ * Join list of tokens.
+ *
+ * Stores a string representation of tokens in the same order with
+ * deliminer between each element.
+ */
+
+template <class Delim, class Iterator, class String>
+void join(const Delim& delimiter,
+ Iterator begin,
+ Iterator end,
+ String& output);
+
+template <class Delim, class Container, class String>
+void join(const Delim& delimiter,
+ const Container& container,
+ String& output) {
+ join(delimiter, container.begin(), container.end(), output);
+}
+
+template <class Delim, class Container>
+std::string join(const Delim& delimiter,
+ const Container& container) {
+ std::string output;
+ join(delimiter, container.begin(), container.end(), output);
+ return output;
+}
+
} // namespace folly
// Hash functions for string and fbstring usable with e.g. hash_map