3065 some functions in the tcp module can be static
[unleashed.git] / usr / src / cmd / man / src / util / nsgmls.src / lib / InternalInputSource.cxx
blob54e8bd5181f68bcaf20a9201095d6287d9585c5f
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
5 #ifdef __GNUG__
6 #pragma implementation
7 #endif
8 #include "splib.h"
9 #include <string.h>
10 #include "InternalInputSource.h"
11 #include "macros.h"
13 #ifdef SP_NAMESPACE
14 namespace SP_NAMESPACE {
15 #endif
17 InternalInputSource::InternalInputSource(const StringC &str,
18 InputSourceOrigin *origin)
19 : InputSource(origin, str.data(), str.data() + str.size()), buf_(0),
20 contents_(&str)
24 InternalInputSource::~InternalInputSource()
26 if (buf_)
27 delete [] buf_;
30 Xchar InternalInputSource::fill(Messenger &)
32 return eE;
35 void InternalInputSource::pushCharRef(Char c, const NamedCharRef &ref)
37 ASSERT(cur() == start());
38 noteCharRef(startIndex() + (cur() - start()), ref);
39 if (buf_ == 0) {
40 buf_ = new Char[end() - start() + 1];
41 memcpy(buf_ + 1, cur(), (end() - start())*sizeof(Char));
42 changeBuffer(buf_ + 1, cur());
44 moveLeft();
45 *(Char *)cur() = c;
48 Boolean InternalInputSource::rewind(Messenger &)
50 reset(contents_->data(),
51 contents_->data() + contents_->size());
52 if (buf_) {
53 delete [] buf_;
54 buf_ = 0;
56 return 1;
59 #ifdef SP_NAMESPACE
61 #endif