"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/include/XcharMap.cxx" (14 May 2005, 1200 Bytes) of package /linux/misc/old/OpenSP-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "XcharMap.cxx" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1994 James Clark, 2000 Matthias Clasen
    2 // See the file COPYING for copying permission.
    3 
    4 #ifndef XcharMap_DEF_INCLUDED
    5 #define XcharMap_DEF_INCLUDED 1
    6 
    7 #include <stddef.h>
    8 
    9 #ifdef SP_NAMESPACE
   10 namespace SP_NAMESPACE {
   11 #endif
   12 
   13 template<class T>
   14 SharedXcharMap<T>::SharedXcharMap()
   15 {
   16 }
   17 
   18 template<class T>
   19 SharedXcharMap<T>::SharedXcharMap(T defaultValue)
   20 {
   21   for (size_t i = 0; i < sizeof(v)/sizeof(v[0]); i++)
   22     v[i] = defaultValue;
   23 }
   24 
   25 template<class T>
   26 XcharMap<T>::XcharMap()
   27 : ptr_(0)
   28 {
   29 }
   30 
   31 template<class T>
   32 XcharMap<T>::XcharMap(T defaultValue)
   33 : sharedMap_(new SharedXcharMap<T>(defaultValue))
   34 #ifdef SP_MULTI_BYTE
   35   , hiMap_(new CharMapResource<T>(defaultValue))
   36 #endif
   37 {
   38   ptr_ = sharedMap_->ptr();
   39 }
   40 
   41 template<class T>
   42 void XcharMap<T>::setRange(Char min, Char max, T val)
   43 {
   44   if (min <= max) {
   45 #ifdef SP_MULTI_BYTE
   46     if (min <= 0xffff) {
   47       Char m = max <= 0xffff ? max : 0xffff;
   48 #else
   49       Char m = max;
   50 #endif
   51       do {
   52     ptr_[min] = val;
   53       } while (min++ != m);
   54 #ifdef SP_MULTI_BYTE
   55     }
   56     if (max >= 0x10000)
   57       hiMap_->setRange(min < 0x10000 ? 0x10000 : min, max, val);
   58 #endif
   59   }
   60 }
   61 
   62 #ifdef SP_NAMESPACE
   63 }
   64 #endif
   65 
   66 #endif /* not XcharMap_DEF_INCLUDED */