sbuild-format-detail.cc

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software; you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation; either version 2 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
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   // TRANSLATORS: %1% = title of section
00091   // TRANSLATORS: Please format the --- as a continuous line, e.g. U+2500
00092   boost::format fmt(_("--- %1% ---"));
00093   fmt %this->title;
00094 
00095   return fmt.str();
00096 }

Generated on Sat Jan 27 16:11:03 2007 for schroot by  doxygen 1.5.1