00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include "sbuild-format-detail.h"
00023 #include "sbuild-i18n.h"
00024 #include "sbuild-log.h"
00025
00026 #include <boost/format.hpp>
00027
00028 using namespace sbuild;
00029
00030 format_detail::format_detail (std::string const& title,
00031 std::locale locale):
00032 title(title),
00033 locale(locale),
00034 items()
00035 {
00036 }
00037
00038 format_detail::~format_detail ()
00039 {
00040 }
00041
00042 format_detail&
00043 format_detail::add (std::string const& name,
00044 std::string const& value)
00045 {
00046 for (list_type::iterator pos = this->items.begin();
00047 pos != this->items.end();
00048 ++pos)
00049 {
00050 if (pos->first == name)
00051 {
00052 log_debug(DEBUG_WARNING) << "format_detail: name \""
00053 << name << "\" is already added"
00054 << std::endl;
00055 return *this;
00056 }
00057 }
00058
00059 this->items.push_back(value_type(name, value));
00060 log_debug(DEBUG_INFO) << "format_detail: added name \""
00061 << name << "\""
00062 << std::endl;
00063
00064 return *this;
00065 }
00066
00067 format_detail&
00068 format_detail::add (std::string const& name,
00069 bool value)
00070 {
00071 const char *desc = 0;
00072 if (value)
00073 desc = _("true");
00074 else
00075 desc = _("false");
00076
00077 return add(name, std::string(desc));
00078 }
00079
00080 format_detail&
00081 format_detail::add (std::string const& name,
00082 string_list const& value)
00083 {
00084 return add(name, string_list_to_string(value, " "));
00085 }
00086
00087 std::string
00088 format_detail::get_title () const
00089 {
00090
00091
00092 boost::format fmt(_("--- %1% ---"));
00093 fmt %this->title;
00094
00095 return fmt.str();
00096 }