"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/lib/InternalInputSource.cxx" (21 Jul 2005, 1334 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 "InternalInputSource.cxx" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1994 James Clark
    2 // See the file COPYING for copying permission.
    3 
    4 #ifdef __GNUG__
    5 #pragma implementation
    6 #endif
    7 #include "splib.h"
    8 #include <string.h>
    9 #include "InternalInputSource.h"
   10 #include "macros.h"
   11 
   12 #ifdef SP_NAMESPACE
   13 namespace SP_NAMESPACE {
   14 #endif
   15 
   16 InternalInputSource::InternalInputSource(const StringC &str,
   17                      InputSourceOrigin *origin)
   18 : InputSource(origin, str.data(), str.data() + str.size()), buf_(0),
   19   contents_(&str)
   20 {
   21 }
   22 
   23 InternalInputSource::~InternalInputSource()
   24 {
   25   if (buf_)
   26     delete [] buf_;
   27 }
   28 
   29 Xchar InternalInputSource::fill(Messenger &)
   30 {
   31   return eE;
   32 }
   33 
   34 void InternalInputSource::pushCharRef(Char c, const NamedCharRef &ref)
   35 {
   36   ASSERT(cur() == start());
   37   noteCharRef(startIndex() + (cur() - start()), ref);
   38   if (buf_ == 0) {
   39     buf_ = new Char[end() - start() + 1];
   40     memcpy(buf_ + 1, cur(), (end() - start())*sizeof(Char));
   41     changeBuffer(buf_ + 1, cur());
   42   }
   43   moveLeft();
   44   *(Char *)cur() = c;
   45 }
   46 
   47 Boolean InternalInputSource::rewind(Messenger &)
   48 {
   49   reset(contents_->data(),
   50     contents_->data() + contents_->size());
   51   if (buf_) {
   52     delete [] buf_;
   53     buf_ = 0;
   54   }
   55   return 1;
   56 }
   57 
   58 const StringC *InternalInputSource::contents() {
   59   return contents_;
   60 }
   61 
   62 InternalInputSource *InternalInputSource::asInternalInputSource()
   63 {
   64   return this;
   65 }
   66 
   67 
   68 #ifdef SP_NAMESPACE
   69 }
   70 #endif