LibreOffice Module comphelper (master) 1
errcode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <rtl/ustrbuf.hxx>
22
24{
25 OUStringBuffer buf(128);
26 buf.append(toHexString() + "(");
27 if (IsWarning())
28 buf.append("Warning");
29 else
30 buf.append("Error");
31 if (IsDynamic())
32 buf.append(" Dynamic");
33 else
34 {
35 std::u16string_view pArea;
36 switch (GetArea())
37 {
38 case ErrCodeArea::Io:
39 pArea = u"Io";
40 break;
42 pArea = u"Sfx";
43 break;
45 pArea = u"Inet";
46 break;
48 pArea = u"Vcl";
49 break;
51 pArea = u"Svx";
52 break;
53 case ErrCodeArea::So:
54 pArea = u"So";
55 break;
57 pArea = u"Sbx";
58 break;
60 pArea = u"Uui";
61 break;
62 case ErrCodeArea::Sc:
63 pArea = u"Sc";
64 break;
65 case ErrCodeArea::Sd:
66 pArea = u"Sd";
67 break;
68 case ErrCodeArea::Sw:
69 pArea = u"Sw";
70 break;
71 }
72 buf.append(OUString::Concat(" Area:") + pArea);
73
74 std::u16string_view pClass;
75 switch (GetClass())
76 {
78 pClass = u"NONE";
79 break;
81 pClass = u"Abort";
82 break;
84 pClass = u"General";
85 break;
87 pClass = u"NotExists";
88 break;
90 pClass = u"AlreadyExists";
91 break;
93 pClass = u"Access";
94 break;
96 pClass = u"Path";
97 break;
99 pClass = u"Locking";
100 break;
102 pClass = u"Parameter";
103 break;
105 pClass = u"Space";
106 break;
108 pClass = u"NotSupported";
109 break;
111 pClass = u"Read";
112 break;
114 pClass = u"Write";
115 break;
117 pClass = u"Unknown";
118 break;
120 pClass = u"Version";
121 break;
123 pClass = u"Format";
124 break;
126 pClass = u"Create";
127 break;
129 pClass = u"Import";
130 break;
132 pClass = u"Export";
133 break;
134 case ErrCodeClass::So:
135 pClass = u"So";
136 break;
138 pClass = u"Sbx";
139 break;
141 pClass = u"Runtime";
142 break;
144 pClass = u"Compiler";
145 break;
146 }
147 buf.append(OUString::Concat(" Class:") + pClass + " Code:" + OUString::number(GetCode()));
148 }
149 buf.append(")");
150 return buf.makeStringAndClear();
151}
152
153COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
154{
155 os << err.toString();
156 return os;
157}
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt8 GetCode() const
Definition: errcode.hxx:134
OUString toHexString() const
Definition: errcode.hxx:138
COMPHELPER_DLLPUBLIC OUString toString() const
Return a string suitable for debug output, the same as the operator<< function.
Definition: errcode.cxx:23
bool IsWarning() const
Definition: errcode.hxx:98
bool IsDynamic() const
Definition: errcode.hxx:110
constexpr ErrCodeArea GetArea() const
Definition: errcode.hxx:126
constexpr ErrCodeClass GetClass() const
Definition: errcode.hxx:130
#define COMPHELPER_DLLPUBLIC
float u
COMPHELPER_DLLPUBLIC std::ostream & operator<<(std::ostream &os, const ErrCode &err)
Definition: errcode.cxx:153
err