-
Notifications
You must be signed in to change notification settings - Fork 63
/
ustdxept.cc
57 lines (47 loc) · 1.39 KB
/
ustdxept.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This file is part of the uSTL library, an STL implementation.
//
// Copyright (c) 2005 by Mike Sharov <[email protected]>
// This file is free software, distributed under the MIT License.
#include "ustdxept.h"
#include "mistream.h"
#include "mostream.h"
#include "strmsize.h"
#include "uiosfunc.h"
#include "uspecial.h"
namespace ustl {
//----------------------------------------------------------------------
/// \p arg contains a description of the error.
error_message::error_message (const char* arg) noexcept
: m_Arg ()
{
try { m_Arg = arg; } catch (...) {}
set_format (xfmt_ErrorMessage);
}
/// Virtual destructor
error_message::~error_message (void) noexcept
{
}
/// Returns a descriptive error message. fmt="%s: %s"
void error_message::info (string& msgbuf, const char* fmt) const noexcept
{
if (!fmt) fmt = "%s: %s";
try { msgbuf.format (fmt, name(), m_Arg.cdata()); } catch (...) {}
}
/// Reads the object from stream \p is.
void error_message::read (istream& is)
{
exception::read (is);
is >> m_Arg >> ios::align();
}
/// Writes the object to stream \p os.
void error_message::write (ostream& os) const
{
exception::write (os);
os << m_Arg << ios::align();
}
/// Returns the size of the written object.
size_t error_message::stream_size (void) const noexcept
{
return (exception::stream_size() + Align (stream_size_of (m_Arg)));
}
} // namespace ustl