summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-03-10 22:24:20 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-03-10 22:29:46 +0100
commitb0e2c9de13ff1df2f0f1cba2ceed88c710efea3a (patch)
treeebaf8a489ef8a512abd3697550b084306c4ced3c /apt-pkg
parent61ebf627f766eb7f189042fc216bb822ac0ef7f4 (diff)
error: Extract operator<< into error.cc (de-inline it)
Extract the code, and reformat it with clang-format so we can modify it.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/error.cc42
-rw-r--r--apt-pkg/contrib/error.h28
2 files changed, 45 insertions, 25 deletions
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index 3c397eaf8..7fb68a35e 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -15,6 +15,7 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <algorithm>
@@ -242,3 +243,44 @@ void GlobalError::MergeWithStack() {
Stacks.pop_back();
}
/*}}}*/
+
+// GlobalError::Item::operator<< /*{{{*/
+APT_HIDDEN std::ostream &operator<<(std::ostream &out, GlobalError::Item i)
+{
+ switch (i.Type)
+ {
+ case GlobalError::FATAL:
+ case GlobalError::ERROR:
+ out << 'E';
+ break;
+ case GlobalError::WARNING:
+ out << 'W';
+ break;
+ case GlobalError::NOTICE:
+ out << 'N';
+ break;
+ case GlobalError::DEBUG:
+ out << 'D';
+ break;
+ }
+ out << ": ";
+ std::string::size_type line_start = 0;
+ std::string::size_type line_end;
+ while ((line_end = i.Text.find_first_of("\n\r", line_start)) != std::string::npos)
+ {
+ if (line_start != 0)
+ out << std::endl
+ << " ";
+ out << i.Text.substr(line_start, line_end - line_start);
+ line_start = i.Text.find_first_not_of("\n\r", line_end + 1);
+ if (line_start == std::string::npos)
+ break;
+ }
+ if (line_start == 0)
+ out << i.Text;
+ else if (line_start != std::string::npos)
+ out << std::endl
+ << " " << i.Text.substr(line_start);
+ return out;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index 1609b8702..24eead8d5 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -315,33 +315,11 @@ private: /*{{{*/
Item(char const *Text, MsgType const &Type) :
Text(Text), Type(Type) {};
- APT_HIDDEN friend std::ostream& operator<< (std::ostream &out, Item i) {
- switch(i.Type) {
- case FATAL:
- case ERROR: out << 'E'; break;
- case WARNING: out << 'W'; break;
- case NOTICE: out << 'N'; break;
- case DEBUG: out << 'D'; break;
- }
- out << ": ";
- std::string::size_type line_start = 0;
- std::string::size_type line_end;
- while ((line_end = i.Text.find_first_of("\n\r", line_start)) != std::string::npos) {
- if (line_start != 0)
- out << std::endl << " ";
- out << i.Text.substr(line_start, line_end - line_start);
- line_start = i.Text.find_first_not_of("\n\r", line_end + 1);
- if (line_start == std::string::npos)
- break;
- }
- if (line_start == 0)
- out << i.Text;
- else if (line_start != std::string::npos)
- out << std::endl << " " << i.Text.substr(line_start);
- return out;
- }
+ APT_HIDDEN friend std::ostream &operator<<(std::ostream &out, Item i);
};
+ APT_HIDDEN friend std::ostream &operator<<(std::ostream &out, Item i);
+
std::list<Item> Messages;
bool PendingFlag;