Fabric: toString methods were moved into DebugStringConvertible with an implementation in .cpp file

Summary:
They need to be in DebugStringConvertible because it depends on they (and because `debugStringConvertibleUtils` depends on `DebugStringConvertible`).
We also moved they implementation to cpp file to avoid leaking Folly's features to consumer namespace.

Reviewed By: mdvacca

Differential Revision: D14715080

fbshipit-source-id: 7277e17b39a14a2d7ba7e5a9b44a70178feb1045
This commit is contained in:
Valentin Shergin
2019-04-04 12:38:21 -07:00
committed by Facebook Github Bot
parent 97e064b696
commit cabc9d1ab3
3 changed files with 39 additions and 18 deletions
@@ -7,6 +7,9 @@
#include "DebugStringConvertible.h"
#include <folly/Conv.h>
#include <folly/Format.h>
namespace facebook {
namespace react {
@@ -107,6 +110,28 @@ SharedDebugStringConvertibleList DebugStringConvertible::getDebugProps() const {
return SharedDebugStringConvertibleList();
}
/*
* `toString`-family implementation.
*/
std::string toString(std::string const &value) {
return value;
}
std::string toString(int const &value) {
return folly::to<std::string>(value);
}
std::string toString(bool const &value) {
return folly::to<std::string>(value);
}
std::string toString(float const &value) {
return folly::to<std::string>(value);
}
std::string toString(double const &value) {
return folly::to<std::string>(value);
}
std::string toString(void const *value) {
return folly::sformat("0x{0:016x}", reinterpret_cast<size_t>(value));
}
#endif
} // namespace react