[lttoolbox] 01/01: Add PCRE workaround helpers

Tino Didriksen tinodidriksen-guest at moszumanska.debian.org
Tue Oct 28 08:15:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

tinodidriksen-guest pushed a commit to branch master
in repository lttoolbox.

commit 34e1537dd4ea151112dd4a97a3bcc1f05c596752
Author: Tino Didriksen <mail at tinodidriksen.com>
Date:   Tue Oct 28 08:15:45 2014 +0000

    Add PCRE workaround helpers
---
 lttoolbox/compression.cc | 25 +++++++++++++++++++++++++
 lttoolbox/compression.h  | 19 ++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lttoolbox/compression.cc b/lttoolbox/compression.cc
index b30a5e6..736ee49 100644
--- a/lttoolbox/compression.cc
+++ b/lttoolbox/compression.cc
@@ -252,6 +252,7 @@ Compression::multibyte_read(istream &input)
   return result;
 }
 
+
 void
 Compression::wstring_write(wstring const &str, FILE *output)
 {
@@ -272,6 +273,30 @@ Compression::wstring_read(FILE *input)
   {
     retval += static_cast<wchar_t>(Compression::multibyte_read(input));
   }
+
+  return retval;
+}
+
+void
+Compression::string_write(string const &str, FILE *output)
+{
+  Compression::multibyte_write(str.size(), output);
+  for(unsigned int i = 0, limit = str.size(); i != limit; i++)
+  {
+    Compression::multibyte_write(static_cast<int>(str[i]), output);
+  }
+}
+
+string
+Compression::string_read(FILE *input)
+{
+  string retval = "";
+
+  for(unsigned int i = 0, limit = Compression::multibyte_read(input);
+      i != limit; i++)
+  {
+    retval += static_cast<char>(Compression::multibyte_read(input));
+  }
   
   return retval;
 }
diff --git a/lttoolbox/compression.h b/lttoolbox/compression.h
index 6b534e1..f5c3b7c 100644
--- a/lttoolbox/compression.h
+++ b/lttoolbox/compression.h
@@ -92,9 +92,26 @@ public:
    * This method reads a wide string from the input stream.
    * @see wstring_write()
    * @param input the input stream.
-   * @return the wide string readed.
+   * @return the wide string read.
    */
   static wstring wstring_read(FILE *input);
+
+  /**
+   * This method allows to write a plain string to an output stream
+   * using its UCSencoding as integer.
+   * @see string_read()
+   * @param str the string to write.
+   * @param output the output stream.
+   */
+  static void string_write(string const &str, FILE *output);
+
+  /**
+   * This method reads a plain string from the input stream.
+   * @see string_write()
+   * @param input the input stream.
+   * @return the string read.
+   */
+  static string string_read(FILE *input);
 };
 
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/lttoolbox.git



More information about the debian-science-commits mailing list