MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ErrorMsgStream

Class ErrorMsgStream

source/util/parse_number.cpp:34–54  ·  view source on GitHub ↗

A helper class that temporarily stores error messages and dump the messages to a string which given as as pointer when it is destructed. If the given pointer is a nullptr, this class does not store error message.

Source from the content-addressed store, hash-verified

32// to a string which given as as pointer when it is destructed. If the given
33// pointer is a nullptr, this class does not store error message.
34class ErrorMsgStream {
35 public:
36 explicit ErrorMsgStream(std::string* error_msg_sink)
37 : error_msg_sink_(error_msg_sink) {
38 if (error_msg_sink_) stream_ = MakeUnique<std::ostringstream>();
39 }
40 ~ErrorMsgStream() {
41 if (error_msg_sink_ && stream_) *error_msg_sink_ = stream_->str();
42 }
43 template <typename T>
44 ErrorMsgStream& operator<<(T val) {
45 if (stream_) *stream_ << val;
46 return *this;
47 }
48
49 private:
50 std::unique_ptr<std::ostringstream> stream_;
51 // The destination string to which this class dump the error message when
52 // destructor is called.
53 std::string* error_msg_sink_;
54};
55} // namespace
56
57EncodeNumberStatus ParseAndEncodeIntegerNumber(

Callers 3

ParseAndEncodeNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected