From: Arvin Schnell Date: Fri, 4 Feb 2011 15:53:03 +0000 (+0100) Subject: - added output operator for File X-Git-Tag: v0.1.3~515 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bf947cd3927f86df7e7b66fc82220f7f7cfd9a5;p=thirdparty%2Fsnapper.git - added output operator for File --- diff --git a/snapper/File.cc b/snapper/File.cc index 84740541..2b66505a 100644 --- a/snapper/File.cc +++ b/snapper/File.cc @@ -44,11 +44,27 @@ namespace snapper inline Snapshots::const_iterator getSnapshot2() { return getSnapper()->getSnapshot2(); } + std::ostream& operator<<(std::ostream& s, const File& file) + { + s << "name:\"" << file.name << "\""; + + s << " pre_to_post_status:\"" << statusToString(file.pre_to_post_status) << "\""; + + if (file.pre_to_system_status != (unsigned int)(-1)) + s << " pre_to_post_status:\"" << statusToString(file.pre_to_system_status) << "\""; + + if (file.post_to_system_status != (unsigned int)(-1)) + s << " post_to_post_status:\"" << statusToString(file.post_to_system_status) << "\n"; + + return s; + } + + void append_helper(const string& name, unsigned int status) { // TODO - getSnapper()->files.entries.push_back(File(name, status)); + getSnapper()->getFiles().entries.push_back(File(name, status)); } diff --git a/snapper/File.h b/snapper/File.h index 5c0d3e98..15a548a2 100644 --- a/snapper/File.h +++ b/snapper/File.h @@ -75,6 +75,8 @@ namespace snapper bool doRollback(); + friend std::ostream& operator<<(std::ostream& s, const File& file); + private: string name; diff --git a/snapper/Snapper.h b/snapper/Snapper.h index bfa2603f..5dba9c44 100644 --- a/snapper/Snapper.h +++ b/snapper/Snapper.h @@ -82,8 +82,6 @@ namespace snapper CompareCallback* compare_callback; - friend void append_helper(const string& name, unsigned int status); - }; }; diff --git a/snapper/Snapshot.cc b/snapper/Snapshot.cc index 0fac4307..6c8fb8c0 100644 --- a/snapper/Snapshot.cc +++ b/snapper/Snapshot.cc @@ -46,10 +46,10 @@ namespace snapper if (snapshot.pre_num != 0) s << " pre-num:" << snapshot.pre_num; - s << " date:" << snapshot.date; + s << " date:\"" << snapshot.date << "\""; if (!snapshot.description.empty()) - s << " description:" << snapshot.description; + s << " description:\"" << snapshot.description << "\""; return s; }