1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
18 //----------------------------------------------------------------------
20 /// \p arg contains a description of the error.
21 error_message::error_message (const char* arg
) throw()
24 try { m_Arg
= arg
; } catch (...) {}
25 set_format (xfmt_ErrorMessage
);
28 /// Virtual destructor
29 error_message::~error_message (void) throw()
33 /// Returns a descriptive error message. fmt="%s: %s"
34 void error_message::info (string
& msgbuf
, const char* fmt
) const throw()
36 if (!fmt
) fmt
= "%s: %s";
37 try { msgbuf
.format (fmt
, what(), m_Arg
.cdata()); } catch (...) {}
40 /// Reads the object from stream \p is.
41 void error_message::read (istream
& is
)
44 is
>> m_Arg
>> ios::align();
47 /// Writes the object to stream \p os.
48 void error_message::write (ostream
& os
) const
50 exception::write (os
);
51 os
<< m_Arg
<< ios::align();
54 /// Returns the size of the written object.
55 size_t error_message::stream_size (void) const
57 return (exception::stream_size() + Align (stream_size_of (m_Arg
)));
60 //----------------------------------------------------------------------