Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

StrSubChunk.cxx

00001 /*
00002  * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org>
00003  * 
00004  *     This program is free software; you can redistribute it and/or modify it
00005  *     under the terms of the GNU Lesser General Public License as published
00006  *     by the Free Software Foundation; either version 2 of the License, or
00007  *     (at your option) any later version.
00008  * 
00009  *     This program is distributed in the hope that it will be useful, but
00010  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *     Lesser General Public License for more details.
00013  * 
00014  *     You should have received a copy of the GNU Lesser General Public
00015  *     License along with this program; if not, write to the Free Software
00016  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrSubChunk.cxx,v 1.7 2002/03/12 21:48:57 hopper Exp $ */
00020 
00021 // For a log, see ChangeLog
00022 //
00023 // Revision 1.2  1999/01/17 18:32:05  hopper
00024 // Changed to automatically make a StrSubChunk of a StrSubChunk into just a
00025 // StrSubChunk.
00026 //
00027 // Revision 1.1  1996/06/29 06:57:44  hopper
00028 // New class StrSubChunk used to make a part of an existing chunk look like
00029 // a full chunk to the outside world.
00030 //
00031 
00032 #ifdef __GNUG__
00033 #  pragma implementation "StrSubChunk.h"
00034 #endif
00035 
00036 #include "StrMod/StrSubChunk.h"
00037 #include "StrMod/StrChunkPtrT.h"
00038 #include "StrMod/StrChunkPtr.h"
00039 #include "StrMod/ChunkVisitor.h"
00040 #include <cassert>
00041 // #include <iostream>
00042 
00043 namespace strmod {
00044 namespace strmod {
00045 
00046 const STR_ClassIdent StrSubChunk::identifier(18UL);
00047 
00048 StrSubChunk::StrSubChunk(const StrChunkPtr &chunk, const LinearExtent &extent)
00049      : subchunk_(chunk), subext_(extent)
00050 {
00051    assert(subchunk_);
00052 
00053    if (subchunk_->AreYouA(identifier))
00054    {
00055       StrChunkPtrT<StrSubChunk> subc
00056          = static_cast<StrSubChunk *>(subchunk_.GetPtr());
00057 
00058       subext_ = subc->subext_.SubExtent(subext_);
00059       subchunk_ = subc->subchunk_;
00060    }
00061    else
00062    {
00063       unsigned int sublen = subchunk_->Length();
00064 
00065       if ((subext_.Offset() + subext_.Length()) > sublen) {
00066          LinearExtent chunkext(0, sublen);
00067 
00068 //      cerr << "chunkext == " << chunkext
00069 //         << " && subext_ == " << subext_ << "\n";
00070          subext_ = chunkext.SubExtent(subext_);
00071 //      cerr << "subext_ == " << subext_ << "\n";
00072       }
00073    }
00074 }
00075 
00076 void StrSubChunk::acceptVisitor(ChunkVisitor &visitor)
00077    throw(ChunkVisitor::halt_visitation)
00078 {
00079    call_visitStrChunk(visitor, subchunk_, subext_);
00080 }
00081 
00082 }  // End namespace strmod
00083 }  // End namespace strmod

Generated on Wed Jan 29 00:32:44 2003 for libNet by doxygen1.3-rc1