Ignore:
Timestamp:
Jan 3, 2010, 7:13:32 PM (11 years ago)
Author:
rbri
Message:

DJVU plugin: djvulibre updated to version 3.5.22

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libdjvu/GString.h

    r206 r280  
    5454//C- +------------------------------------------------------------------
    5555//
    56 // $Id: GString.h,v 1.21 2007/03/25 20:48:32 leonb Exp $
    57 // $Name: release_3_5_19 $
     56// $Id: GString.h,v 1.25 2009/05/17 23:57:42 leonb Exp $
     57// $Name: release_3_5_22 $
    5858
    5959#ifndef _GSTRING_H_
     
    106106   
    107107    @version
    108     #$Id: GString.h,v 1.21 2007/03/25 20:48:32 leonb Exp $# */
     108    #$Id: GString.h,v 1.25 2009/05/17 23:57:42 leonb Exp $# */
    109109//@{
    110110
     
    127127#endif
    128128
     129#if !defined(AUTOCONF) || HAVE_STDINT_H
     130# include <stdint.h>
     131#elif HAVE_INTTYPES_H
     132# include <inttypes.h>
     133#endif
    129134
    130135#ifdef HAVE_NAMESPACES
     
    146151
    147152// Internal string representation.
    148 class GStringRep : public GPEnabled
     153class DJVUAPI GStringRep : public GPEnabled
    149154{
    150155public:
     
    167172  friend class GUTF8String;
    168173  friend class GNativeString;
    169   friend unsigned int hash(const GBaseString &ref);
     174  friend DJVUAPI unsigned int hash(const GBaseString &ref);
    170175
    171176public:
     
    241246
    242247  GP<GStringRep> substr(
    243     const unsigned short *s,const int start,const int length=(-1)) const;
     248    const uint16_t *s,const int start,const int length=(-1)) const;
    244249
    245250  GP<GStringRep> substr(
    246     const unsigned long *s,const int start,const int length=(-1)) const;
     251    const uint32_t *s,const int start,const int length=(-1)) const;
    247252
    248253  /** Initializes a string with a formatted string (as in #vprintf#).  The
     
    265270
    266271  /** Returns the next UCS4 character, and updates the pointer s. */
    267   static unsigned long UTF8toUCS4(
     272  static uint32_t UTF8toUCS4(
    268273    unsigned char const *&s, void const * const endptr );
    269274
     
    271276      and sets #w# to the next UCS4 chacter.  */
    272277  static int UTF8toUCS4(
    273     unsigned long &w, unsigned char const s[], void const * const endptr )
     278    uint32_t &w, unsigned char const s[], void const * const endptr )
    274279  { unsigned char const *r=s;w=UTF8toUCS4(r,endptr);return (int)((size_t)r-(size_t)s); }
    275280
    276281  /** Returns the next UCS4 word from the UTF16 string. */
    277282  static int UTF16toUCS4(
    278      unsigned long &w, unsigned short const * const s,void const * const eptr);
     283     uint32_t &w, uint16_t const * const s,void const * const eptr);
    279284
    280285  static int UCS4toUTF16(
    281     unsigned long w, unsigned short &w1, unsigned short &w2);
     286    uint32_t w, uint16_t &w1, uint16_t &w2);
    282287
    283288  int cmp(const char *s2, const int len=(-1)) const;
     
    292297
    293298  // Lookup the next character, and return the position of the next character.
    294   int getUCS4(unsigned long &w, const int from) const;
     299  int getUCS4(uint32_t &w, const int from) const;
    295300
    296301  virtual unsigned char *UCS4toString(
    297     const unsigned long w, unsigned char *ptr, mbstate_t *ps=0) const = 0;
     302    const uint32_t w, unsigned char *ptr, mbstate_t *ps=0) const = 0;
    298303
    299304  static unsigned char *UCS4toUTF8(
    300     const unsigned long w,unsigned char *ptr);
     305    const uint32_t w,unsigned char *ptr);
    301306
    302307  static unsigned char *UCS4toNative(
    303     const unsigned long w,unsigned char *ptr, mbstate_t *ps);
     308    const uint32_t w,unsigned char *ptr, mbstate_t *ps);
    304309
    305310  int search(char c, int from=0) const;
     
    317322protected:
    318323  // Return the next character and increment the source pointer.
    319   virtual unsigned long getValidUCS4(const char *&source) const = 0;
     324  virtual uint32_t getValidUCS4(const char *&source) const = 0;
    320325
    321326  GP<GStringRep> tocase(
     
    357362  // Tests if a string is legally encoded in the current character set.
    358363  virtual bool is_valid(void) const = 0;
    359 
     364#if HAS_WCHAR
    360365  virtual int ncopy(wchar_t * const buf, const int buflen) const = 0;
    361 
     366#endif
    362367protected:
    363368
     
    367372};
    368373
    369 class GStringRep::UTF8 : public GStringRep
     374class DJVUAPI GStringRep::UTF8 : public GStringRep
    370375{
    371376public:
     
    417422
    418423  static GP<GStringRep> create(
    419     const unsigned short *s,const int start,const int length=(-1));
     424    const uint16_t *s,const int start,const int length=(-1));
    420425
    421426  static GP<GStringRep> create(
    422     const unsigned long *s,const int start,const int length=(-1));
     427    const uint32_t *s,const int start,const int length=(-1));
    423428
    424429  static GP<GStringRep> create_format(const char fmt[],...);
     
    426431
    427432  virtual unsigned char *UCS4toString(
    428     const unsigned long w,unsigned char *ptr, mbstate_t *ps=0) const;
     433    const uint32_t w,unsigned char *ptr, mbstate_t *ps=0) const;
    429434
    430435  // Tests if a string is legally encoded in the current character set.
    431436  virtual bool is_valid(void) const;
    432 
     437#if HAS_WCHAR
    433438  virtual int ncopy(wchar_t * const buf, const int buflen) const;
    434 
     439#endif
    435440  friend class GBaseString;
    436441
    437442protected:
    438443  // Return the next character and increment the source pointer.
    439   virtual unsigned long getValidUCS4(const char *&source) const;
     444  virtual uint32_t getValidUCS4(const char *&source) const;
    440445};
    441446
     
    464469    position #-2# represents the second last character, etc.)  */
    465470
    466 class GBaseString : protected GP<GStringRep>
     471class DJVUAPI GBaseString : protected GP<GStringRep>
    467472{
    468473public:
     
    476481protected:
    477482  // Sets the gstr pointer;
    478   void init(void);
     483  inline void init(void);
    479484
    480485  ~GBaseString();
    481   GBaseString &init(const GP<GStringRep> &rep);
     486  inline GBaseString &init(const GP<GStringRep> &rep);
    482487
    483488  // -- CONSTRUCTORS
     
    680685      range by computing its remainder modulo the upper bound of
    681686      the range. */
    682   friend unsigned int hash(const GBaseString &ref);
     687  friend DJVUAPI unsigned int hash(const GBaseString &ref);
    683688  // -- HELPERS
    684689  friend class GStringRep;
     
    700705
    701706  /// copy to a wchar_t buffer
     707#if HAS_WCHAR
    702708  int ncopy(wchar_t * const buf, const int buflen) const;
    703 
     709#endif
    704710protected:
    705711  const char *gstr;
     
    712718  GUTF8String NativeToUTF8(void) const;
    713719protected:
    714   int CheckSubscript(int n) const;
     720  inline int CheckSubscript(int n) const;
    715721};
    716722
     
    736742    position #-2# represents the second last character, etc.)  */
    737743
    738 class GUTF8String : public GBaseString
     744class DJVUAPI GUTF8String : public GBaseString
    739745{
    740746public:
    741747  ~GUTF8String();
    742   void init(void);
    743 
    744   GUTF8String &init(const GP<GStringRep> &rep);
     748  inline void init(void);
     749
     750  inline GUTF8String &init(const GP<GStringRep> &rep);
    745751
    746752  // -- CONSTRUCTORS
     
    753759  /// Constructs a string from a null terminated character array.
    754760  GUTF8String(const unsigned char *str);
    755   GUTF8String(const unsigned short *dat);
    756   GUTF8String(const unsigned long *dat);
     761  GUTF8String(const uint16_t *dat);
     762  GUTF8String(const uint32_t *dat);
    757763  /** Constructs a string from a character array.  Elements of the
    758764      character array #dat# are added into the string until the
     
    760766      character (whichever comes first). */
    761767  GUTF8String(const char *dat, unsigned int len);
    762   GUTF8String(const unsigned short *dat, unsigned int len);
    763   GUTF8String(const unsigned long *dat, unsigned int len);
     768  GUTF8String(const uint16_t *dat, unsigned int len);
     769  GUTF8String(const uint32_t *dat, unsigned int len);
    764770
    765771  /// Construct from base class.
     
    779785  GUTF8String& operator= (const char str);
    780786  GUTF8String& operator= (const char *str);
    781   GUTF8String& operator= (const GP<GStringRep> &str);
    782   GUTF8String& operator= (const GBaseString &str);
    783   GUTF8String& operator= (const GUTF8String &str);
    784   GUTF8String& operator= (const GNativeString &str);
     787  inline GUTF8String& operator= (const GP<GStringRep> &str);
     788  inline GUTF8String& operator= (const GBaseString &str);
     789  inline GUTF8String& operator= (const GUTF8String &str);
     790  inline GUTF8String& operator= (const GNativeString &str);
    785791
    786792  /** Constructs a string with a formatted string (as in #vprintf#).
     
    874880  GUTF8String operator+(const GUTF8String &s2) const;
    875881  GUTF8String operator+(const GNativeString &s2) const;
    876   GUTF8String operator+(const char    *s2) const;
    877   friend GUTF8String operator+(const char    *s1, const GUTF8String &s2);
     882  GUTF8String operator+(const char *s2) const;
     883  friend DJVUAPI GUTF8String operator+(const char *s1, const GUTF8String &s2);
    878884
    879885  /** Provides a direct access to the string buffer.  Returns a
     
    908914  GP<GStringRep::Unicode> get_remainder(void) const;
    909915  static GUTF8String create( const char *buf, const unsigned int bufsize );
    910   static GUTF8String create( const unsigned short *buf, const unsigned int bufsize );
    911   static GUTF8String create( const unsigned long *buf, const unsigned int bufsize );
     916  static GUTF8String create( const uint16_t *buf, const unsigned int bufsize );
     917  static GUTF8String create( const uint32_t *buf, const unsigned int bufsize );
    912918};
    913919
     
    938944    position #-2# represents the second last character, etc.)  */
    939945
    940 class GNativeString : public GBaseString
     946class DJVUAPI GNativeString : public GBaseString
    941947{
    942948public:
     
    951957  /// Constructs a string from a null terminated character array.
    952958  GNativeString(const unsigned char *str);
    953   GNativeString(const unsigned short *str);
    954   GNativeString(const unsigned long *str);
     959  GNativeString(const uint16_t *str);
     960  GNativeString(const uint32_t *str);
    955961  /** Constructs a string from a character array.  Elements of the
    956962      character array #dat# are added into the string until the
     
    958964      character (whichever comes first). */
    959965  GNativeString(const char *dat, unsigned int len);
    960   GNativeString(const unsigned short *dat, unsigned int len);
    961   GNativeString(const unsigned long *dat, unsigned int len);
     966  GNativeString(const uint16_t *dat, unsigned int len);
     967  GNativeString(const uint32_t *dat, unsigned int len);
    962968  /// Construct from base class.
    963969  GNativeString(const GP<GStringRep> &str);
     
    10061012  GNativeString& operator= (const char str);
    10071013  GNativeString& operator= (const char *str);
    1008   GNativeString& operator= (const GP<GStringRep> &str);
    1009   GNativeString& operator= (const GBaseString &str);
    1010   GNativeString& operator= (const GUTF8String &str);
    1011   GNativeString& operator= (const GNativeString &str);
     1014  inline GNativeString& operator= (const GP<GStringRep> &str);
     1015  inline GNativeString& operator= (const GBaseString &str);
     1016  inline GNativeString& operator= (const GUTF8String &str);
     1017  inline GNativeString& operator= (const GNativeString &str);
    10121018  // -- CONCATENATION
    10131019  /// Appends character #ch# to the string.
     
    10381044  GUTF8String operator+(const GUTF8String &s2) const;
    10391045  GNativeString operator+(const char *s2) const;
    1040   friend GNativeString operator+(const char *s1, const GNativeString &s2);
     1046  friend DJVUAPI GNativeString operator+(const char *s1, const GNativeString &s2);
    10411047
    10421048  /** Initializes a string with a formatted string (as in #printf#).
     
    10861092
    10871093  static GNativeString create( const char *buf, const unsigned int bufsize );
    1088   static GNativeString create( const unsigned short *buf, const unsigned int bufsize );
    1089   static GNativeString create( const unsigned long *buf, const unsigned int bufsize );
     1094  static GNativeString create( const uint16_t *buf, const unsigned int bufsize );
     1095  static GNativeString create( const uint32_t *buf, const unsigned int bufsize );
    10901096#endif // WinCE
    10911097};
     
    13921398{ return ptr?((*this)->is_valid()):true; }
    13931399
     1400#if HAS_WCHAR
    13941401inline int
    13951402GBaseString::ncopy(wchar_t * const buf, const int buflen) const
    13961403{if(buf&&buflen)buf[0]=0;return ptr?((*this)->ncopy(buf,buflen)):0;}
     1404#endif
    13971405
    13981406inline int
     
    14391447
    14401448inline GUTF8String
    1441 GUTF8String::create( const unsigned short *buf, const unsigned int bufsize )
     1449GUTF8String::create( const uint16_t *buf, const unsigned int bufsize )
    14421450{
    14431451  return GUTF8String(buf,bufsize);
     
    14451453
    14461454inline GUTF8String
    1447 GUTF8String::create( const unsigned long *buf, const unsigned int bufsize )
     1455GUTF8String::create( const uint32_t *buf, const unsigned int bufsize )
    14481456{
    14491457  return GUTF8String(buf,bufsize);
     
    14761484
    14771485inline
    1478 GNativeString::GNativeString(const unsigned short *str)
     1486GNativeString::GNativeString(const uint16_t *str)
    14791487: GUTF8String(str) {}
    14801488
    14811489inline
    1482 GNativeString::GNativeString(const unsigned long *str)
     1490GNativeString::GNativeString(const uint32_t *str)
    14831491: GUTF8String(str) {}
    14841492
     
    14881496
    14891497inline
    1490 GNativeString::GNativeString(const unsigned short *dat, unsigned int len)
     1498GNativeString::GNativeString(const uint16_t *dat, unsigned int len)
    14911499: GUTF8String(dat,len) {}
    14921500
    14931501inline
    1494 GNativeString::GNativeString(const unsigned long *dat, unsigned int len)
     1502GNativeString::GNativeString(const uint32_t *dat, unsigned int len)
    14951503: GUTF8String(dat,len) {}
    14961504
     
    15831591
    15841592inline GNativeString
    1585 GNativeString::create( const unsigned short *buf, const unsigned int bufsize )
     1593GNativeString::create( const uint16_t *buf, const unsigned int bufsize )
    15861594{
    15871595  return GNativeString(buf,bufsize);
     
    15891597
    15901598inline GNativeString
    1591 GNativeString::create( const unsigned long *buf, const unsigned int bufsize )
     1599GNativeString::create( const uint32_t *buf, const unsigned int bufsize )
    15921600{
    15931601  return GNativeString(buf,bufsize);
Note: See TracChangeset for help on using the changeset viewer.