Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/116566

Removed zorbatypes/transcoder.h & .cpp.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/116566
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/transcode_stream.h'
--- include/zorba/transcode_stream.h	2012-07-24 08:48:48 +0000
+++ include/zorba/transcode_stream.h	2012-07-24 23:06:21 +0000
@@ -189,6 +189,20 @@
 }
 
 /**
+ * Gets the original streambuf of the given iostream.
+ *
+ * @param ios The stream to get the original streambuf of.
+ * @return the original streambuf.
+ */
+template<typename charT,typename Traits> inline
+std::streambuf* orig_streambuf( std::basic_ios<charT,Traits> &ios ) {
+  std::streambuf *const buf = ios.rdbuf();
+  if ( streambuf *const tbuf = dynamic_cast<streambuf*>( buf ) )
+    return tbuf->orig_streambuf();
+  return buf;
+}
+
+/**
  * A %transcode::auto_attach is a class that attaches a transcode::streambuf to
  * a stream and automatically detaches it when the %auto_attach object is
  * destroyed.

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2012-07-24 08:48:48 +0000
+++ src/api/serialization/serializer.cpp	2012-07-24 23:06:21 +0000
@@ -19,8 +19,8 @@
 #include <iomanip>
 
 #include <zorba/zorba_string.h>
-#include <zorbamisc/ns_consts.h>
-#include "zorbatypes/numconversions.h"
+#include <zorba/transcode_stream.h>
+
 #include "diagnostics/xquery_diagnostics.h"
 #include "diagnostics/assert.h"
 
@@ -38,12 +38,14 @@
 #include "util/xml_util.h"
 
 #include "system/globalenv.h"
+#include "zorbamisc/ns_consts.h"
+#include "zorbatypes/numconversions.h"
 
 #include "store/api/iterator.h"
 #include "store/api/iterator_factory.h"
 #include "store/api/item.h"
-#include <store/api/item_factory.h>
-#include <store/api/copymode.h>
+#include "store/api/item_factory.h"
+#include "store/api/copymode.h"
 
 namespace zorba {
 
@@ -116,11 +118,11 @@
 ********************************************************************************/
 serializer::emitter::emitter(
     serializer* the_serializer, 
-    transcoder& the_transcoder,
+    std::ostream& the_stream,
     bool aEmitAttributes)
   :
   ser(the_serializer),
-  tr(the_transcoder),
+  tr(the_stream),
   previous_item(INVALID_ITEM),
   theChildIters(8),
   theFirstFreeChildIter(0),
@@ -341,13 +343,12 @@
   {
     if (ser->encoding == PARAMETER_VALUE_UTF_8 )
     {
-      tr << (char)0xEF << (char)0xBB << (char)0xBF;
+      transcode::orig_streambuf( tr )->sputn( "\xEF\xBB\xBF", 3 );
     }
     else if (ser->encoding == PARAMETER_VALUE_UTF_16)
     {
       // Little-endian
-      tr.verbatim((char)0xFF);
-      tr.verbatim((char)0xFE);
+      transcode::orig_streambuf( tr )->sputn( "\xFF\xFE", 2 );
     }
   }
 }
@@ -862,10 +863,10 @@
 ********************************************************************************/
 serializer::xml_emitter::xml_emitter(
   serializer* the_serializer,
-  transcoder& the_transcoder,
+  std::ostream& the_stream,
   bool aEmitAttributes)
   :
-  emitter(the_serializer, the_transcoder, aEmitAttributes)
+  emitter(the_serializer, the_stream, aEmitAttributes)
 {
 }
 
@@ -947,8 +948,8 @@
 
 serializer::json_emitter::json_emitter(
   serializer* the_serializer,
-  transcoder& the_transcoder)
-  : emitter(the_serializer, the_transcoder),
+  std::ostream& the_stream)
+  : emitter(the_serializer, the_stream),
     theXMLStringStream(nullptr),
     theMultipleItems(false)
 {
@@ -1174,8 +1175,8 @@
   // and output it as a "JSONiq XDM node".
   if (!theXMLEmitter) {
     theXMLStringStream = new std::stringstream();
-    theXMLTranscoder = ser->create_transcoder(*theXMLStringStream);
-    theXMLEmitter = new serializer::xml_emitter(ser, *theXMLTranscoder);
+    ser->attach_transcoder(*theXMLStringStream);
+    theXMLEmitter = new serializer::xml_emitter(ser, *theXMLStringStream);
   }
   theXMLEmitter->emit_item(item);
   zstring xml(theXMLStringStream->str());
@@ -1259,12 +1260,12 @@
 
 serializer::jsoniq_emitter::jsoniq_emitter(
   serializer* the_serializer,
-  transcoder& the_transcoder)
+  std::ostream& the_stream)
   :
-    emitter(the_serializer, the_transcoder),
+    emitter(the_serializer, the_stream),
     theEmitterState(JESTATE_UNDETERMINED),
-    theXMLEmitter(new xml_emitter(the_serializer, the_transcoder)),
-    theJSONEmitter(new json_emitter(the_serializer, the_transcoder))
+    theXMLEmitter(new xml_emitter(the_serializer, the_stream)),
+    theJSONEmitter(new json_emitter(the_serializer, the_stream))
 {
 }
 
@@ -1458,9 +1459,9 @@
 ********************************************************************************/
 serializer::html_emitter::html_emitter(
   serializer* the_serializer,
-  transcoder& the_transcoder)
+  std::ostream& the_stream)
   :
-  emitter(the_serializer, the_transcoder)
+  emitter(the_serializer, the_stream)
 {
 }
 
@@ -1720,9 +1721,9 @@
 ********************************************************************************/
 serializer::xhtml_emitter::xhtml_emitter(
     serializer* the_serializer,
-    transcoder& the_transcoder)
+    std::ostream& the_stream)
   :
-  xml_emitter(the_serializer, the_transcoder)
+  xml_emitter(the_serializer, the_stream)
 {
 }
 
@@ -1856,11 +1857,11 @@
 ********************************************************************************/
 serializer::sax2_emitter::sax2_emitter(
   serializer* the_serializer,
-  transcoder& the_transcoder,
+  std::ostream& the_stream,
   std::stringstream& aSStream,
   SAX2_ContentHandler * aSAX2ContentHandler )
   :
-  emitter(the_serializer, the_transcoder),
+  emitter(the_serializer, the_stream),
   theSAX2ContentHandler( aSAX2ContentHandler ),
   theSAX2LexicalHandler( 0 ),
   theSStream(aSStream)
@@ -2122,9 +2123,9 @@
 ********************************************************************************/
 serializer::text_emitter::text_emitter(
     serializer* the_serializer,
-    transcoder& the_transcoder)
+    std::ostream& the_stream)
   :
-  emitter(the_serializer, the_transcoder)
+  emitter(the_serializer, the_stream)
 {
 }
 
@@ -2296,9 +2297,9 @@
 ********************************************************************************/
 serializer::binary_emitter::binary_emitter(
     serializer* the_serializer,
-    transcoder& the_transcoder)
+    std::ostream& the_stream)
   :
-  emitter(the_serializer, the_transcoder)
+  emitter(the_serializer, the_stream)
 {
 }
 
@@ -2692,10 +2693,7 @@
 ********************************************************************************/
 bool serializer::setup(std::ostream& os, bool aEmitAttributes)
 {
-  tr = create_transcoder(os);
-  if (!tr) {
-    return false;
-  }
+  tr = &os;
   if (method == PARAMETER_VALUE_XML)
     e = new xml_emitter(this, *tr, aEmitAttributes);
   else if (method == PARAMETER_VALUE_HTML)
@@ -2730,22 +2728,21 @@
   return true;
 }
 
-transcoder* serializer::create_transcoder(std::ostream &os)
+void serializer::attach_transcoder(std::ostream &os)
 {
   if (encoding == PARAMETER_VALUE_UTF_8)
   {
-    return new transcoder(os, false);
+    // do nothing
   }
 #ifndef ZORBA_NO_UNICODE
   else if (encoding == PARAMETER_VALUE_UTF_16)
   {
-    return new transcoder(os, true);
+    transcode::attach( os, "UTF-16LE" );
   }
 #endif
   else
   {
     ZORBA_ASSERT(0);
-    return nullptr;
   }
 }
 
@@ -2780,44 +2777,51 @@
     return;
   }
 
-  // in case we use SAX event notifications
-  if (aHandler)
-  {
-    // only allow XML-based methods for SAX notifications. For now at least,
-    // the "JSONIQ" method is consider "XML-based", although you will certainly
-    // get errors if you attempt to serialize JDM this way.
-    if (method != PARAMETER_VALUE_XML &&
-        method != PARAMETER_VALUE_XHTML
+  try {
+
+    // in case we use SAX event notifications
+    if (aHandler)
+    {
+      // Only allow XML-based methods for SAX notifications. For now at least,
+      // the "JSONIQ" method is consider "XML-based", although you will
+      // certainly get errors if you attempt to serialize JDM this way.
+      if (method != PARAMETER_VALUE_XML &&
+          method != PARAMETER_VALUE_XHTML
 #ifdef ZORBA_WITH_JSON
-        && method != PARAMETER_VALUE_JSONIQ
+          && method != PARAMETER_VALUE_JSONIQ
 #endif
-      ) {
-      throw ZORBA_EXCEPTION(
-        zerr::ZAPI0070_INVALID_SERIALIZATION_METHOD_FOR_SAX,
-        ERROR_PARAMS( method )
-      );
+        ) {
+        throw ZORBA_EXCEPTION(
+          zerr::ZAPI0070_INVALID_SERIALIZATION_METHOD_FOR_SAX,
+          ERROR_PARAMS( method )
+        );
+      }
+      // it's OK now, build a SAX emmiter
+      tr = &temp_sstream;
+      e = new sax2_emitter(this, *tr, temp_sstream, aHandler);
     }
-    // it's OK now, build a SAX emmiter
-    tr = new transcoder(temp_sstream, false);
-    e = new sax2_emitter(this, *tr, temp_sstream, aHandler);
-  }
-
-  e->emit_declaration();
-
-  store::Item_t lItem;
-  //+  aObject->open();
-  while (aObject->next(lItem))
-  {
-    // PUL's cannot be serialized
-    if (lItem->isPul())
+
+    e->emit_declaration();
+
+    store::Item_t lItem;
+    //+  aObject->open();
+    while (aObject->next(lItem))
     {
-      throw ZORBA_EXCEPTION(zerr::ZAPI0007_CANNOT_SERIALIZE_PUL);
+      // PUL's cannot be serialized
+      if (lItem->isPul())
+      {
+        throw ZORBA_EXCEPTION(zerr::ZAPI0007_CANNOT_SERIALIZE_PUL);
+      }
+
+      e->emit_item(&*lItem);
     }
-
-    e->emit_item(&*lItem);
-  }
-//+  aObject->close();
-  e->emit_end();
+  //+  aObject->close();
+    e->emit_end();
+  }
+  catch ( ... ) {
+    transcode::detach( aOStream );
+    throw;
+  }
 }
 
 
@@ -2837,33 +2841,39 @@
     return;
   }
 
-  e->emit_declaration();
-
-  store::Item_t lItem;
-  //object->open();
-  while (object->next(lItem))
-  {
-    Zorba_SerializerOptions_t* lSerParams = aHandler(aHandlerData);
-    if (lSerParams)
-    {
-      SerializerImpl::setSerializationParameters(*this, *lSerParams);
-      if (!setup(stream))
-      {
-        return;
-      }
-    }
-
-    // PUL's cannot be serialized
-    if (lItem->isPul())
-    {
-      throw ZORBA_EXCEPTION(zerr::ZAPI0007_CANNOT_SERIALIZE_PUL);
-    }
-
-    e->emit_item(&*lItem);
-  }
-
-  //object->close();
-  e->emit_end();
+  try {
+    e->emit_declaration();
+
+    store::Item_t lItem;
+    //object->open();
+    while (object->next(lItem))
+    {
+      Zorba_SerializerOptions_t* lSerParams = aHandler(aHandlerData);
+      if (lSerParams)
+      {
+        SerializerImpl::setSerializationParameters(*this, *lSerParams);
+        if (!setup(stream))
+        {
+          return;
+        }
+      }
+
+      // PUL's cannot be serialized
+      if (lItem->isPul())
+      {
+        throw ZORBA_EXCEPTION(zerr::ZAPI0007_CANNOT_SERIALIZE_PUL);
+      }
+
+      e->emit_item(&*lItem);
+    }
+
+    //object->close();
+    e->emit_end();
+  }
+  catch ( ... ) {
+    transcode::detach( stream );
+    throw;
+  }
 }
 
 } // namespace zorba

=== modified file 'src/api/serialization/serializer.h'
--- src/api/serialization/serializer.h	2012-07-24 08:48:48 +0000
+++ src/api/serialization/serializer.h	2012-07-24 23:06:21 +0000
@@ -23,7 +23,6 @@
 #include <zorba/options.h>
 
 #include "zorbatypes/schema_types.h"
-#include "zorbatypes/transcoder.h"
 
 #include "common/shared_types.h"
 
@@ -124,7 +123,7 @@
   bool version_has_default_value;  // Used during validation to set version to
                                    // "4.0" when output method is "html"
   rchandle<emitter>    e;
-  rchandle<transcoder> tr;
+  std::ostream         *tr;
 
   // Used to hold the QNames of the cdata section elements after they have been tokenized
   std::vector<zstring> cdata_section_elements_tokens;
@@ -193,7 +192,7 @@
 
   bool setup(std::ostream& os, bool aEmitAttributes = false);
 
-  transcoder* create_transcoder(std::ostream& os);
+  void attach_transcoder(std::ostream& os);
 
   ///////////////////////////////////////////////////////////
   //                                                       //
@@ -210,12 +209,12 @@
      * Creates a new emitter object.
      *
      * @param the_serializer The parent serializer object.
-     * @param output_stream Target output stream.
+     * @param the_stream Target output stream.
      * @param aEmitAttributes If true, attributes are emitted.
      */
     emitter(
         serializer* the_serializer, 
-        transcoder& the_transcoder,
+        std::ostream& the_stream,
         bool aEmitAttributes = false);
 
     /**
@@ -319,7 +318,7 @@
 
   protected:
     serializer                          * ser;
-    transcoder                          & tr;
+    std::ostream                        & tr;
     std::vector<store::NsBindings>        theBindings;
 
     enum ItemState
@@ -349,7 +348,7 @@
   public:
     xml_emitter(
         serializer* the_serializer, 
-        transcoder& the_transcoder, 
+        std::ostream& the_stream, 
         bool aEmitAttributes = false
     );
 
@@ -373,7 +372,7 @@
   class json_emitter : public emitter
   {
   public:
-    json_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    json_emitter(serializer* the_serializer, std::ostream& the_stream);
 
     virtual ~json_emitter();
 
@@ -410,7 +409,6 @@
     store::Item_t theJSONiqXDMNodeName;
 
     rchandle<emitter> theXMLEmitter;
-    rchandle<transcoder> theXMLTranscoder;
     std::stringstream* theXMLStringStream;
     bool theMultipleItems;
   };
@@ -425,7 +423,7 @@
   class jsoniq_emitter : public emitter
   {
   public:
-    jsoniq_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    jsoniq_emitter(serializer* the_serializer, std::ostream& the_stream);
 
     virtual ~jsoniq_emitter();
 
@@ -459,7 +457,7 @@
   class xhtml_emitter : public xml_emitter
   {
   public:
-    xhtml_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    xhtml_emitter(serializer* the_serializer, std::ostream& the_stream);
 
   protected:
     virtual void emit_node(const store::Item* item, int depth);
@@ -475,7 +473,7 @@
   class html_emitter : public emitter
   {
   public:
-    html_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    html_emitter(serializer* the_serializer, std::ostream& the_stream);
 
     virtual void emit_declaration();
     virtual void emit_end();
@@ -495,7 +493,7 @@
   class text_emitter : public emitter
   {
   public:
-    text_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    text_emitter(serializer* the_serializer, std::ostream& the_stream);
 
     virtual void emit_declaration();
 
@@ -530,7 +528,7 @@
   public:
     sax2_emitter(
           serializer* the_serializer,
-          transcoder& the_transcoder,
+          std::ostream& the_stream,
           std::stringstream& aSStream,
           SAX2_ContentHandler* aSAX2ContentHandler);
 
@@ -574,7 +572,7 @@
   class binary_emitter : public emitter
   {
   public:
-    binary_emitter(serializer* the_serializer, transcoder& the_transcoder);
+    binary_emitter(serializer* the_serializer, std::ostream& the_stream);
 
     void emit_item(store::Item* item);
   };

=== modified file 'src/util/json_parser.cpp'
--- src/util/json_parser.cpp	2012-07-24 08:48:48 +0000
+++ src/util/json_parser.cpp	2012-07-24 23:06:21 +0000
@@ -235,9 +235,9 @@
         t->loc_ = cur_loc_;
         parse_number( c, &t->value_ );
         return true;
-      case 'f':
-      case 'n':
-      case 't':
+      case 'f': // false
+      case 'n': // null
+      case 't': // true
         t->type_ = parse_literal( c, &t->value_ );
         t->loc_ = cur_loc_;
         return true;

=== modified file 'src/util/xml_util.h'
--- src/util/xml_util.h	2012-07-24 08:48:48 +0000
+++ src/util/xml_util.h	2012-07-24 23:06:21 +0000
@@ -19,6 +19,8 @@
 
 #include <iostream>
 
+#include <zorba/internal/ztd.h>
+
 #include "unicode_util.h"
 #include "utf8_util.h"
 
@@ -120,10 +122,12 @@
  * @param v The XML version to use.
  * @return Returns \c true only if the code-point is valid.
  */
-template<class CodePointType>
-inline bool is_valid( CodePointType c, version v = v1_0 ) {
+template<typename CodePointType> inline
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CodePointType>::value,
+                        bool>::type
+is_valid( CodePointType c, version v = v1_0 ) {
   //
-  // See "Extensible Markup Language (XML) 1.0 (Fifth Edition)", and
+  // See "Extensible Markup Language (XML) 1.0 (Fifth Edition)" and
   // "Extensible Markup Language (XML) 1.1 (Second Edition)", section 2.2,
   // "Characters", [2] Char.
   //

=== modified file 'src/zorbatypes/CMakeLists.txt'
--- src/zorbatypes/CMakeLists.txt	2012-07-24 08:48:48 +0000
+++ src/zorbatypes/CMakeLists.txt	2012-07-24 23:06:21 +0000
@@ -19,7 +19,6 @@
   numconversions.cpp
   binary.cpp
   URI.cpp
-  transcoder.cpp
   collation_manager.cpp
   chartype.cpp
   rchandle.cpp)

=== removed file 'src/zorbatypes/transcoder.cpp'
--- src/zorbatypes/transcoder.cpp	2012-07-24 08:48:48 +0000
+++ src/zorbatypes/transcoder.cpp	1970-01-01 00:00:00 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include <stdexcept>
-
-#include "diagnostics/assert.h"
-#include "util/unicode_util.h"
-#include "util/utf8_util.h"
-
-#include "transcoder.h"
-
-namespace zorba {
-
-///////////////////////////////////////////////////////////////////////////////
-
-transcoder::transcoder( std::ostream& output_stream, bool in_utf16 ) :
-  os( output_stream ),
-  utf16( in_utf16 )
-{
-#ifndef ZORBA_NO_ICU
-  utf8_buf_len_ = 0;
-  utf8_char_len_ = 1;
-#endif /* ZORBA_NO_ICU */
-}
-
-#ifndef ZORBA_NO_ICU
-
-void transcoder::write_utf16( char const *s, std::streamsize len ) {
-  unicode::char_type *u_s;
-  unicode::size_type u_len;
-  if ( !unicode::to_string( s, len, &u_s, &u_len ) )
-    throw std::runtime_error( "unicode::to_string() failed" );
-
-  char const *const byte = reinterpret_cast<char const*>( u_s );
-  for ( int i = 0; i < u_len * (int)sizeof( unicode::char_type ); ++i )
-    os << byte[i];
-
-  delete[] u_s;
-}
-
-void transcoder::write_utf16_char( char ch ) {
-  if ( utf8::is_start_byte( ch ) ) {
-    if ( utf8_char_len_ > 1 )
-      throw std::runtime_error( "incomplete UTF-8 character" );
-    utf8_char_len_ = utf8::char_length( ch );
-  } else if ( utf8::is_continuation_byte( ch ) ) {
-    if ( !utf8_buf_len_ )
-      throw std::runtime_error( "invalid UTF-8 byte" );
-  }
-
-  utf8_buf_[ utf8_buf_len_++ ] = ch;
-
-  if ( utf8_buf_len_ == utf8_char_len_ ) {
-    unicode::char_type u_ch;
-    if ( !unicode::to_char( utf8_buf_, &u_ch ) )
-      throw std::runtime_error( "unicode::to_char() failed" );
-
-    char const *const byte = reinterpret_cast<char const*>( &u_ch );
-    for ( int i = 0; i < (int)sizeof( unicode::char_type ); ++i )
-      os << byte[i];
-
-    utf8_buf_len_ = 0;
-    utf8_char_len_ = 1;
-  }
-}
-
-#endif /* ZORBA_NO_ICU */
-
-///////////////////////////////////////////////////////////////////////////////
-
-} // namespace zorba
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/zorbatypes/transcoder.h'
--- src/zorbatypes/transcoder.h	2012-07-24 08:48:48 +0000
+++ src/zorbatypes/transcoder.h	1970-01-01 00:00:00 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-#ifndef ZORBA_TRANSCODER_H
-#define ZORBA_TRANSCODER_H
-
-#include <cstring>
-#include <ostream>
-
-#include <zorba/config.h>
-
-#include "util/utf8_util.h"
-#include "zorbatypes/rchandle.h"
-#include "zorbatypes/zstring.h"
-
-
-namespace zorba {
-
-///////////////////////////////////////////////////////////
-//                                                       //
-//  class transcoder                                     //
-//                                                       //
-///////////////////////////////////////////////////////////
-
-class ZORBA_DLL_PUBLIC transcoder : public SimpleRCObject {
-protected:
-  std::ostream &os;
-  bool const utf16;
-
-#ifndef ZORBA_NO_ICU
-  utf8::encoded_char_type utf8_buf_;
-  int utf8_buf_len_;
-  int utf8_char_len_;
-#endif /* ZORBA_NO_ICU */
-
-public:
-  transcoder(std::ostream& output_stream, bool in_utf16);
-
-  transcoder& write( char const *s, std::streamsize n ) {
-#ifndef ZORBA_NO_ICU
-    if ( utf16 )
-      write_utf16( s, n );
-    else
-#endif /* ZORBA_NO_ICU */
-      os.write( s, n );
-    return *this;
-  }
-
-  transcoder& operator<<( zstring const &s ) {
-    return write( s.data(), (std::streamsize)s.size() );
-  }
-
-  transcoder& operator<<( char const *s ) {
-    return write( s, (std::streamsize)std::strlen( s ) );
-  }
-
-  transcoder& operator<<( char ch ) {
-#ifndef ZORBA_NO_ICU
-    if ( utf16 )
-      write_utf16_char(ch);
-    else
-#endif /* ZORBA_NO_ICU */
-      os << ch;
-    return *this;
-  }
-
-  // Support for manipulators (e.g. tr << flush)
-  transcoder& operator<<( transcoder& (*pf)(transcoder&) ) {
-    return pf( *this );
-  }
-
-  /**
-   * Output a byte to the stream without transcoding it.
-   *
-   * @param ch the byte to be output
-   */
-  void verbatim( char ch ) {
-    os << ch;
-  }
-
-  transcoder& flush() {
-    os.flush();
-    return *this;
-  }
-
-private:
-#ifndef ZORBA_NO_ICU
-  void write_utf16(const char* str, std::streamsize n);
-  void write_utf16_char(char ch);
-#endif /* ZORBA_NO_ICU */
-};
-
-} // namespace zorba
-#endif /* ZORBA_TRANSCODER_H */
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to