aboutsummaryrefslogtreecommitdiff
path: root/src/clients/cave/cmd_contents.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-31 11:18:59 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-06-04 07:40:47 +0100
commit5f03e4a9ccc71b027f09f93f3e48ed399ee38281 (patch)
tree0526be6925efcb153a7681ffcb9ab2ad2977f214 /src/clients/cave/cmd_contents.cc
parent69b7b1d8961503771d03217e41669ca12e6852b5 (diff)
downloadpaludis-5f03e4a9ccc71b027f09f93f3e48ed399ee38281.tar.gz
paludis-5f03e4a9ccc71b027f09f93f3e48ed399ee38281.tar.xz
Convert to fancy new visitors
Diffstat (limited to 'src/clients/cave/cmd_contents.cc')
-rw-r--r--src/clients/cave/cmd_contents.cc63
1 files changed, 28 insertions, 35 deletions
diff --git a/src/clients/cave/cmd_contents.cc b/src/clients/cave/cmd_contents.cc
index e893005a0..46e35c4fe 100644
--- a/src/clients/cave/cmd_contents.cc
+++ b/src/clients/cave/cmd_contents.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -77,41 +77,34 @@ namespace
}
};
- struct StringifyContentsEntry
+ std::string stringify_contents_entry(const std::shared_ptr<const ContentsEntry> & entry)
{
- std::string visit(const ContentsFileEntry & e) const
- {
- return fuc(fs_file(),
- fv<'p'>(e.part_key()
- ? stringify(e.part_key()->parse_value())
- : ""),
- fv<'s'>(stringify(e.location_key()->parse_value())));
- }
-
- std::string visit(const ContentsDirEntry & e) const
- {
- return fuc(fs_dir(), fv<'s'>(stringify(e.location_key()->parse_value())));
- }
-
- std::string visit(const ContentsSymEntry & e) const
- {
- return fuc(fs_sym(),
- fv<'p'>(e.part_key()
- ? stringify(e.part_key()->parse_value())
- : ""),
- fv<'s'>(stringify(e.location_key()->parse_value())),
- fv<'t'>(stringify(e.target_key()->parse_value())));
- }
-
- std::string visit(const ContentsOtherEntry & e) const
- {
- return fuc(fs_other(), fv<'s'>(stringify(e.location_key()->parse_value())));
- }
- };
-
- std::string stringify_contents_entry(const std::shared_ptr<const ContentsEntry> & e)
- {
- return e->accept_returning<std::string>(StringifyContentsEntry());
+ return entry->make_accept_returning(
+ [&] (const ContentsFileEntry & e) {
+ return fuc(fs_file(),
+ fv<'p'>(e.part_key()
+ ? stringify(e.part_key()->parse_value())
+ : ""),
+ fv<'s'>(stringify(e.location_key()->parse_value())));
+ },
+
+ [&] (const ContentsDirEntry & e) {
+ return fuc(fs_dir(), fv<'s'>(stringify(e.location_key()->parse_value())));
+ },
+
+ [&] (const ContentsSymEntry & e) {
+ return fuc(fs_sym(),
+ fv<'p'>(e.part_key()
+ ? stringify(e.part_key()->parse_value())
+ : ""),
+ fv<'s'>(stringify(e.location_key()->parse_value())),
+ fv<'t'>(stringify(e.target_key()->parse_value())));
+ },
+
+ [&] (const ContentsOtherEntry & e) {
+ return fuc(fs_other(), fv<'s'>(stringify(e.location_key()->parse_value())));
+ }
+ );
}
}