diff options
Diffstat (limited to 'cpp/src/Slice/Util.cpp')
-rw-r--r-- | cpp/src/Slice/Util.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index cf2e77ed32f..6a691df8fb3 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -172,3 +172,82 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) return result; } +static ostream* errorStream = &cerr; + +void +Slice::setErrorStream(ostream& stream) +{ + errorStream = &stream; +} + +ostream& +Slice::getErrorStream() +{ + return *errorStream; +} + +void +Slice::emitError(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitError(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitRaw(const char* message) +{ + *errorStream << message << flush; +} |