Reduce Beast public interface and eliminate unused code:

Beast includes a lot of code for encapsulating cross-platform differences
which are not used or needed by rippled. Additionally, a lot of that code
implements functionality that is available from the standard library.

This moves away from custom implementations of features that the standard
library provides and reduces the number of platform-specific interfaces
andfeatures that Beast makes available.

Highlights include:
* Use std:: instead of beast implementations when possible
* Reduce the use of beast::String in public interfaces
* Remove Windows-specific COM and Registry code
* Reduce the public interface of beast::File
* Reduce the public interface of beast::SystemStats
* Remove unused sysctl/getsysinfo functions
* Remove beast::Logger
This commit is contained in:
Nik Bougalis
2014-10-13 14:20:54 -07:00
committed by Vinnie Falco
parent fefdb32d08
commit 186ca9c235
82 changed files with 361 additions and 7762 deletions

View File

@@ -26,45 +26,50 @@ namespace beast {
// FatalError::Reporter
//
void FatalError::Reporter::onFatalError (
char const* message, char const* stackBacktrace, char const* filePath, int lineNumber)
char const* message,
char const* backtrace,
char const* filePath,
int lineNumber)
{
String formattedMessage = formatMessage (
message, stackBacktrace, filePath, lineNumber);
reportMessage (formattedMessage);
reportMessage (formatMessage (message, backtrace, filePath, lineNumber));
}
void FatalError::Reporter::reportMessage (String& formattedMessage)
void FatalError::Reporter::reportMessage (std::string const& message)
{
std::cerr << formattedMessage.toRawUTF8 ();
std::cerr << message << std::endl;
}
String FatalError::Reporter::formatMessage (
char const* message, char const* stackBacktrace, char const* filePath, int lineNumber)
std::string FatalError::Reporter::formatMessage (
char const* message,
char const* backtrace,
char const* filePath,
int lineNumber)
{
String formattedMessage;
formattedMessage.preallocateBytes (16 * 1024);
std::string output;
output.reserve (16 * 1024);
formattedMessage << message;
output.append (message);
if (filePath != nullptr && filePath [0] != 0)
{
formattedMessage << ", in " << formatFilePath (filePath)
<< " line " << String (lineNumber);
output.append (", in ");
output.append (formatFilePath (filePath));
output.append (" line ");
output.append (std::to_string (lineNumber));
}
formattedMessage << newLine;
output.append ("\n");
if (stackBacktrace != nullptr && stackBacktrace [0] != 0)
if (backtrace != nullptr && backtrace[0] != 0)
{
formattedMessage << "Stack:" << newLine;
formattedMessage << stackBacktrace;
output.append ("Stack:\n");
output.append (backtrace);
}
return formattedMessage;
return output;
}
String FatalError::Reporter::formatFilePath (char const* filePath)
std::string FatalError::Reporter::formatFilePath (char const* filePath)
{
return filePath;
}
@@ -94,19 +99,13 @@ FatalError::FatalError (char const* message, char const* fileName, int lineNumbe
std::lock_guard <LockType> lock (s_mutex);
String const backtraceString = SystemStats::getStackBacktrace ();
auto const backtrace = SystemStats::getStackBacktrace ();
char const* const szStackBacktrace = backtraceString.toRawUTF8 ();
String const fileNameString = fileName;
char const* const szFileName = fileNameString.toRawUTF8 ();
Reporter* const reporter (s_reporter);
Reporter* const reporter = s_reporter;
if (reporter != nullptr)
{
reporter->onFatalError (message, szStackBacktrace, szFileName, lineNumber);
reporter->onFatalError (message, backtrace.c_str (), fileName, lineNumber);
}
Process::terminate ();