source: trunk/debathena/third/schroot/sbuild/sbuild-format-detail.cc @ 24167

Revision 24167, 2.2 KB checked in by broder, 15 years ago (diff)
Import schroot upstream into subversion.
Line 
1/* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
2 *
3 * schroot is free software: you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * schroot is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 *********************************************************************/
18
19#include <config.h>
20
21#include "sbuild-format-detail.h"
22#include "sbuild-i18n.h"
23#include "sbuild-log.h"
24
25#include <boost/format.hpp>
26
27using namespace sbuild;
28
29format_detail::format_detail (std::string const& title,
30                              std::locale        locale):
31  title(title),
32  locale(locale),
33  items()
34{
35}
36
37format_detail::~format_detail ()
38{
39}
40
41format_detail&
42format_detail::add (std::string const& name,
43                    std::string const& value)
44{
45  for (list_type::iterator pos = this->items.begin();
46       pos != this->items.end();
47       ++pos)
48    {
49      if (pos->first == name)
50        {
51          log_debug(DEBUG_WARNING) << "format_detail: name \""
52                                   << name << "\" is already added"
53                                   << std::endl;
54          return *this;
55        }
56    }
57
58  this->items.push_back(value_type(name, value));
59  log_debug(DEBUG_INFO) << "format_detail: added name \""
60                        << name << "\""
61                        << std::endl;
62
63  return *this;
64}
65
66format_detail&
67format_detail::add (std::string const& name,
68                    bool               value)
69{
70  const char *desc = 0;
71  if (value)
72    desc =  _("true");
73  else
74    desc = _("false");
75
76  return add(name, std::string(desc));
77}
78
79format_detail&
80format_detail::add (std::string const& name,
81                    string_list const& value)
82{
83  return add(name, string_list_to_string(value, " "));
84}
85
86std::string
87format_detail::get_title () const
88{
89  // TRANSLATORS: %1% = title of section
90  // TRANSLATORS: Please format the --- as a continuous line, e.g. U+2500
91  boost::format fmt(_("--- %1% ---"));
92  fmt %this->title;
93
94  return fmt.str();
95}
Note: See TracBrowser for help on using the repository browser.