[Aptitude-svn-commit] r3443 - in branches/aptitude-0.3/aptitude: . src/vscreen

Daniel Burrows dburrows@costa.debian.org
Sun, 26 Jun 2005 10:30:37 +0000


Author: dburrows
Date: Sun Jun 26 10:30:34 2005
New Revision: 3443

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/columnify.cc
   branches/aptitude-0.3/aptitude/src/vscreen/columnify.h
Log:
Implicitly transcode strings passed to the column_disposition constructor.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sun Jun 26 10:30:34 2005
@@ -1,3 +1,9 @@
+2005-06-26  Daniel Burrows  <dburrows@debian.org>
+
+	* src/vscreen/columnify.cc, src/vscreen/columnify.h:
+
+	  Add an implicit transcoding constructor for column_disposition.
+
 2005-06-25  Daniel Burrows  <dburrows@debian.org>
 
 	* src/load_pkgview.cc:

Modified: branches/aptitude-0.3/aptitude/src/vscreen/columnify.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/columnify.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/columnify.cc	Sun Jun 26 10:30:34 2005
@@ -19,8 +19,19 @@
 
 #include "columnify.h"
 
+#include "transcode.h"
+
 using namespace std;
 
+column_disposition::column_disposition(const std::string &_text,
+				       int _minx,
+				       const char *encoding)
+  :minx(_minx)
+{
+  if(!transcode(_text.c_str(), text, encoding))
+    text=L"TRANSCODING ERROR";
+}
+
 wstring columnify(const layout &format, int width)
 {
   wstring rval;

Modified: branches/aptitude-0.3/aptitude/src/vscreen/columnify.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/columnify.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/columnify.h	Sun Jun 26 10:30:34 2005
@@ -43,7 +43,11 @@
   int minx;          // The minimum x value to start this column at (useful for
                      // indenting stuff in trees)
 
-  column_disposition(std::wstring _text, int _minx):text(_text), minx(_minx) {}
+  column_disposition(const std::wstring &_text, int _minx):text(_text), minx(_minx) {}
+
+  /** Generate a column from the multibyte string _text. */
+  column_disposition(const std::string &_text, int _minx,
+		     const char *encoding=NULL);
 };
 
 struct column