Init
This commit is contained in:
commit
950e7b7e2d
350 files changed
+38599
No files matched your search
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#include "ConfigErrorCollector.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace bts {
|
||||
namespace config {
|
||||
namespace internal {
|
||||
|
||||
ConfigErrorCollector::ConfigErrorCollector(IConfigLog& log, const char* file):
|
||||
_log(log),
|
||||
_file(file),
|
||||
_errors()
|
||||
{
|
||||
}
|
||||
|
||||
inline std::string format(const std::string& file, int line, int column, const std::string& message)
|
||||
{
|
||||
std::stringstream buffer;
|
||||
buffer << file.c_str() << ":" << line+1 << ":" << column+1 << ": error: " << message;
|
||||
return buffer.str();
|
||||
}
|
||||
|
||||
void ConfigErrorCollector::AddError(int line, int column, const std::string& message)
|
||||
{
|
||||
_errors.push_back(format(_file, line, column, message));
|
||||
}
|
||||
|
||||
void ConfigErrorCollector::AddWarning(int line, int column, const std::string& message)
|
||||
{
|
||||
_log.warning(format(_file, line, column, message));
|
||||
}
|
||||
|
||||
// For debugging purposes
|
||||
void ConfigErrorCollector::AddError(
|
||||
const std::string& , // File name in which the error occurred.
|
||||
const std::string& , // Full name of the erroneous element.
|
||||
const proto::Message* , // Descriptor of the erroneous element.
|
||||
ErrorLocation , // One of the location constants, above.
|
||||
const std::string& // Human-readable error message.
|
||||
)
|
||||
{
|
||||
//_log.warning(format(filename, 0, 0, message));
|
||||
}
|
||||
|
||||
// For debugging purposes
|
||||
void ConfigErrorCollector::AddWarning(
|
||||
const std::string& , // File name in which the error occurred.
|
||||
const std::string& , // Full name of the erroneous element.
|
||||
const proto::Message* , // Descriptor of the erroneous element.
|
||||
ErrorLocation , // One of the location constants, above.
|
||||
const std::string& // Human-readable error message.
|
||||
)
|
||||
{
|
||||
//_log.warning(format(filename, 0, 0, message));
|
||||
}
|
||||
|
||||
std::string ConfigErrorCollector::ToString()
|
||||
{
|
||||
if (_errors.size() == 0) return "";
|
||||
|
||||
std::string error = _errors.front();
|
||||
for (size_t x = 1; x < _errors.size(); x++)
|
||||
{
|
||||
error += '\n';
|
||||
error += _errors[x];
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
}}}//namespace
|
||||
|
||||
Reference in new issue
Block a user