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

Daniel Burrows dburrows@costa.debian.org
Sun, 26 Jun 2005 17:15:13 +0000


Author: dburrows
Date: Sun Jun 26 17:15:10 2005
New Revision: 3464

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/transcode.h
Log:
Add inline convenience functions to let transcode apply to strings, not
character pointers.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sun Jun 26 17:15:10 2005
@@ -1,5 +1,10 @@
 2005-06-26  Daniel Burrows  <dburrows@debian.org>
 
+	* src/vscreen/transcode.h:
+
+	  Add inline convenience functions to "directly" go from
+	  strings to strings.
+
 	* src/vscreen/vs_button.cc, src/vscreen/vs_button.h:
 
 	  Change the argument type of handle_char() so it gets correctly

Modified: branches/aptitude-0.3/aptitude/src/vscreen/transcode.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/transcode.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/transcode.h	Sun Jun 26 17:15:10 2005
@@ -37,6 +37,13 @@
 	       std::wstring &out,
 	       const char *encoding=NULL);
 
+inline bool transcode(const std::string &s,
+		      std::wstring &out,
+		      const char *encoding=NULL)
+{
+  return transcode(s.c_str(), out, encoding);
+}
+
 // Note: would it be saner to express errors via exceptions?
 
 /** Convenience function to convert the native wide character encoding
@@ -50,10 +57,16 @@
  *  \return \b true if the entire string was successfully transcoded;
  *  if transcoding failed, returns \b false and sets errno.
  */
-#if 0
 bool transcode(const wchar_t *s,
 	       std::string &out,
 	       const char *encoding=NULL);
-#endif
+
+
+inline bool transcode(const std::wstring &s,
+		      std::string &out,
+		      const char *encoding=NULL)
+{
+  return transcode(s.c_str(), out, encoding);
+}
 
 #endif // TRANSCODE_H