Changeset 413


Ignore:
Timestamp:
1999-07-21T19:23:18+12:00 (25 years ago)
Author:
rjmcnab
Message:

Added setmapfile function to map conversion utilities so the map file
does not need to be loaded when map conversion object is created.

Location:
trunk/gsdl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/gsdlunicode.cpp

    r329 r413  
    1212/*
    1313   $Log$
     14   Revision 1.9  1999/07/21 07:23:17  rjmcnab
     15   Added setmapfile function to map conversion utilities so the map file
     16   does not need to be loaded when map conversion object is created.
     17
    1418   Revision 1.8  1999/07/01 04:03:45  rjmcnab
    1519   Optimised utf8inconvertclass::convert slightly.
     
    259263}
    260264
     265// setmapfile will cause loadmapfile to be called when conversion is
     266// needed
     267bool mapconvert::setmapfile (const text_t &thegsdlhome, const text_t &theencoding,
     268                 unsigned short theabsentc) {
     269  // check to see if the mapfile has been already loaded
     270  if (mapdata.loaded && gsdlhome == thegsdlhome &&
     271      encoding == theencoding && absentc == theabsentc)
     272    return true;
     273
     274  unloadmapfile ();
     275  gsdlhome = thegsdlhome;
     276  encoding = theencoding;
     277  absentc = theabsentc;
     278 
     279  return true;
     280}
     281
     282
    261283
    262284// loadmapfile should be called before any conversion is done
     
    338360
    339361unsigned short mapconvert::convert (unsigned short c) {
    340   if (!mapdata.loaded) return absentc;
     362  if (!mapdata.loaded) {
     363    if (!gsdlhome.empty() && !encoding.empty() &&
     364    loadmapfile (gsdlhome, encoding, absentc)) {
     365      // do nothing, successfully loaded database
     366    } else return absentc;
     367  }
    341368
    342369  if (c == 0) return 0; // 0 always maps to 0...
  • trunk/gsdl/lib/gsdlunicode.h

    r320 r413  
    9898  ~mapconvert () {unloadmapfile();};
    9999
     100  // setmapfile will cause loadmapfile to be called when conversion is
     101  // needed
     102  bool setmapfile (const text_t &thegsdlhome, const text_t &theencoding,
     103           unsigned short theabsentc);
     104
    100105  // loadmapfile should be called before any conversion is done
    101106  bool loadmapfile (const text_t &thegsdlhome, const text_t &theencoding,
     
    125130  mapinconvertclass();
    126131  virtual ~mapinconvertclass() {};
     132
     133  // setmapfile will cause loadmapfile to be called when conversion is needed
     134  bool setmapfile (const text_t &thegsdlhome, const text_t &theencoding,
     135            unsigned short theabsentc) {
     136    return converter.setmapfile (thegsdlhome, theencoding, theabsentc);
     137  };
    127138
    128139  // loadmapfile should be called before any conversion takes
     
    163174  virtual ~mapoutconvertclass() {};
    164175
     176  // setmapfile will cause loadmapfile to be called when conversion is needed
     177  bool setmapfile (const text_t &thegsdlhome, const text_t &theencoding,
     178            unsigned short theabsentc) {
     179    return converter.setmapfile (thegsdlhome, theencoding, theabsentc);
     180  };
     181
    165182  // loadmapfile should be called before any conversion takes
    166183  // place
Note: See TracChangeset for help on using the changeset viewer.