summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2011-12-30 11:55:02 +0000
committerRoger Leigh <rleigh@debian.org>2011-12-30 11:55:02 +0000
commitbb6ee3c1522607649d0589c2054f2b1b660bb23d (patch)
tree79eefeeddb790cd3b27be502debb5f7b59398e37
parente8015bb25b6e4501750f497c3cfcd3876cf55da8 (diff)
downloadschroot-bb6ee3c1522607649d0589c2054f2b1b660bb23d.tar.gz
sbuild: Add sbuild::feature
-rw-r--r--sbuild/sbuild-feature.cc59
-rw-r--r--sbuild/sbuild-feature.h55
2 files changed, 114 insertions, 0 deletions
diff --git a/sbuild/sbuild-feature.cc b/sbuild/sbuild-feature.cc
new file mode 100644
index 00000000..b14217d1
--- /dev/null
+++ b/sbuild/sbuild-feature.cc
@@ -0,0 +1,59 @@
+/* Copyright © 2011 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#include <config.h>
+
+#include <iostream>
+
+#include "sbuild-feature.h"
+
+using namespace sbuild;
+
+feature::feature(std::string const& feature,
+ std::string const& description)
+{
+ registered_features().insert(std::make_pair(feature, description));
+}
+
+feature::~feature()
+{
+}
+
+std::ostream&
+feature::print_features(std::ostream& stream)
+{
+ boost::format feature(" %1$-12s %2%\n");
+
+ std::map<std::string,std::string>& features = registered_features();
+ for (std::map<std::string,std::string>::const_iterator pos =
+ features.begin();
+ pos != features.end();
+ ++pos)
+ {
+ stream << feature % pos->first % gettext(pos->second.c_str());
+ }
+
+ return stream;
+}
+
+std::map<std::string,std::string>&
+feature::registered_features ()
+{
+ static std::map<std::string,std::string> features;
+ return features;
+}
diff --git a/sbuild/sbuild-feature.h b/sbuild/sbuild-feature.h
new file mode 100644
index 00000000..55594ad4
--- /dev/null
+++ b/sbuild/sbuild-feature.h
@@ -0,0 +1,55 @@
+/* Copyright © 2011 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#ifndef SBUILD_FEATURE_H
+#define SBUILD_FEATURE_H
+
+#include <map>
+#include <ostream>
+#include <string>
+
+#include <boost/format.hpp>
+
+namespace sbuild
+{
+
+ class feature
+ {
+ public:
+ feature (std::string const& feature,
+ std::string const& description);
+
+ ~feature ();
+
+ static std::ostream&
+ print_features (std::ostream& stream);
+
+ private:
+ static std::map<std::string,std::string>&
+ registered_features ();
+ };
+
+}
+
+#endif /* SBUILD_FEATURE_H */
+
+/*
+ * Local Variables:
+ * mode:C++
+ * End:
+ */