Diff for /parser3/src/include/pa_charset.h between versions 1.37 and 1.49

version 1.37, 2008/07/16 17:07:11 version 1.49, 2012/06/09 12:13:50
Line 1 Line 1
 /** @file  /** @file
         Parser: Charset connection decl.          Parser: Charset connection decl.
   
         Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
   
 #ifndef PA_CHARSET_H  #ifndef PA_CHARSET_H
 #define PA_CHARSET_H  #define PA_CHARSET_H
   
 static const char * const IDENT_CHARSET_H="$Date$";  #define IDENT_PA_CHARSET_H "$Id$"
   
   
 #include "pa_exception.h"  #include "pa_exception.h"
Line 16  static const char * const IDENT_CHARSET_ Line 16  static const char * const IDENT_CHARSET_
 #include "pa_hash.h"  #include "pa_hash.h"
 #include "pa_array.h"  #include "pa_array.h"
   
 // hiding into namespace so to avoid stupid conflict  // pcre.h must be included BEFORE pcre_internal.h
 namespace PCRE {  
 #include "pcre.h"  #include "pcre.h"
 #       include "internal.h"  // have to call config.h for using pcre_internal.h as well
 };  #include "pcre_internal.h"
   
 #ifdef XML  #ifdef XML
 #include "libxml/encoding.h"  #include "libxml/encoding.h"
Line 32  namespace PCRE { Line 31  namespace PCRE {
   
 #define MAX_CHARSET_UNI_CODES 500  #define MAX_CHARSET_UNI_CODES 500
   
 #       ifndef XMLCh   #ifndef XMLCh 
                 typedef unsigned int XMLCh;          typedef unsigned int XMLCh;
 #       endif  #endif
 #       ifndef XMLByte  #ifndef XMLByte
                 typedef unsigned char XMLByte;          typedef unsigned char XMLByte;
 #       endif  #endif
   
 // helpers  // helpers
   
 typedef Hash<const String::Body, String::Body> HashStringString;  typedef HashString<String::Body> HashStringString;
   
 /**     charset holds name & transcode tables   /**     charset holds name & transcode tables 
         registers libxml transcoders          registers libxml transcoders
Line 58  public: Line 57  public:
   
         static String::C transcode(const String::C src,          static String::C transcode(const String::C src,
                 const Charset& source_charset,                   const Charset& source_charset, 
                 const Charset& dest_charset                  const Charset& dest_charset);
         );  
   
         static String& transcode(const String& src,          static String& transcode(const String& src,
                 const Charset& source_transcoder,                   const Charset& source_transcoder, 
Line 79  public: Line 77  public:
   
         static String::C escape(const String::C src,          static String::C escape(const String::C src,
                 const Charset& source_charset);                  const Charset& source_charset);
           static String::Body escape(const String::Body src,
                   const Charset& source_charset);
           static String& escape(const String& src,
                   const Charset& source_charset);
   
           static String::C escape_JSON(const String::C src,
                   const Charset& source_charset);
           static String::Body escape_JSON(const String::Body src,
                   const Charset& source_charset);
           static String& escape_JSON(const String& src,
                   const Charset& source_charset);
   
         void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found);          void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found);
   
Line 130  private: Line 139  private:
         bool fisUTF8;          bool fisUTF8;
         Tables tables;          Tables tables;
   
           static size_t calc_escaped_length_UTF8(XMLByte* src, size_t src_length);
           static size_t calc_escaped_length(const XMLByte* src, size_t src_length, const Charset::Tables& tables);
           static size_t calc_escaped_length(const String::C src, const Charset& source_charset);
           static size_t escape_UTF8(const XMLByte* src, size_t src_length, XMLByte* dest);
           static size_t escape(const XMLByte* src, size_t src_length, XMLByte* dest, const Charset::Tables& tables);
   
           static size_t calc_JSON_escaped_length_UTF8(XMLByte* src, size_t src_length);
           static size_t calc_JSON_escaped_length(const XMLByte* src, size_t src_length, const Charset::Tables& tables);
           static size_t calc_JSON_escaped_length(const String::C src, const Charset& source_charset);
           static size_t escape_JSON_UTF8(const XMLByte* src, size_t src_length, XMLByte* dest);
           static size_t escape_JSON(const XMLByte* src, size_t src_length, XMLByte* dest, const Charset::Tables& tables);
   
 #ifdef XML  #ifdef XML
   
 private:  private:
         void addEncoding(char* name_cstr);          void addEncoding(char* name_cstr);
         void initTranscoder(const String::Body name, const char* name_cstr);          void initTranscoder(const String::Body name, const char* name_cstr);
           
 public:  public:
         /// converts xmlChar* null-terminated string to char*           /// converts xmlChar* null-terminated string to char* 
         String::C transcode_cstr(const xmlChar* s);          String::C transcode_cstr(const xmlChar* s);
Line 165  private: Line 186  private:
 extern Charset::UTF8CaseTable UTF8CaseToUpper;  extern Charset::UTF8CaseTable UTF8CaseToUpper;
 extern Charset::UTF8CaseTable UTF8CaseToLower;  extern Charset::UTF8CaseTable UTF8CaseToLower;
 void change_case_UTF8(const XMLByte* srcData, size_t srcLen,  void change_case_UTF8(const XMLByte* srcData, size_t srcLen,
                                           XMLByte* toFill, size_t toFillLen,                                          XMLByte* toFill, size_t toFillLen,
                                           const Charset::UTF8CaseTable& table);                                          const Charset::UTF8CaseTable& table);
 size_t getUTF8BytePos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t charPos/*position in characters*/);  size_t getUTF8BytePos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t charPos/*position in characters*/);
 size_t getUTF8CharPos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t bytePos/*position in bytes*/);  size_t getUTF8CharPos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t bytePos/*position in bytes*/);
 size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd);  size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd);
   unsigned int lengthUTF8Char(const XMLByte c);
   
   
   class UTF8_string_iterator {
           public:
                   UTF8_string_iterator(const String& astring): fsrcPtr((XMLByte*)astring.cstr()), fsrcEnd(fsrcPtr + astring.length()) {}
                   UTF8_string_iterator(XMLByte* asrcPtr, size_t length): fsrcPtr(asrcPtr), fsrcEnd(fsrcPtr + length) {}
   
                   bool has_next();
                   XMLCh next() { return fUTF8Char; }
                   XMLByte getFirstByte(){ return ffirstByte; }
                   size_t getCharSize(){ return fcharSize; }
           private:
                   const XMLByte* fsrcPtr;
                   const XMLByte* fsrcEnd;
                   size_t fcharSize;
                   XMLByte ffirstByte;
                   XMLCh fUTF8Char;
   };
   
 #endif  #endif

Removed from v.1.37  
changed lines
  Added in v.1.49


E-mail: