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

TelnetChunkBuilder.h

00001 #ifndef _STR_TelnetChunkBuilder_H_  // -*-c++-*-
00002 
00003 /*
00004  * Copyright 2002 by Eric M. Hopper <hopper@omnifarious.org>
00005  * 
00006  *     This program is free software; you can redistribute it and/or modify it
00007  *     under the terms of the GNU Lesser General Public License as published
00008  *     by the Free Software Foundation; either version 2 of the License, or
00009  *     (at your option) any later version.
00010  * 
00011  *     This program is distributed in the hope that it will be useful, but
00012  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *     Lesser General Public License for more details.
00015  * 
00016  *     You should have received a copy of the GNU Lesser General Public
00017  *     License along with this program; if not, write to the Free Software
00018  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifdef __GNUG__
00022 #  pragma interface
00023 #endif
00024 
00025 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrMod/TelnetChunkBuilder.h,v 1.5 2002/08/29 00:58:05 hopper Exp $ */
00026 
00027 // For a log, see ../ChangeLog
00028 
00029 #include <cstddef>
00030 #include <LCore/Protocol.h>
00031 #include <LCore/HopClTypes.h>
00032 #include <StrMod/STR_ClassIdent.h>
00033 #include <StrMod/TelnetChars.h>
00034 
00035 #define _STR_TelnetChunkBuilder_H_
00036 
00037 namespace strmod {
00038 namespace strmod {
00039 
00040 class BufferChunk;
00041 template <class T> class StrChunkPtrT;
00042 
00043 /** \class TelnetChunkBuilder TelnetChunkBuilder.h StrMod/TelnetChunkBuilder.h
00044  * Interface class for things that build telnet protocol data streams.
00045  *
00046  * This is an abstract interface used for building up telnet protocol elements
00047  * block by block.  The TelnetParser uses it, and the TelnetChunker implements
00048  * it to build up TelnetChunker::TelnetChunk objects.
00049  */
00050 class TelnetChunkBuilder : virtual public lcore::Protocol
00051 {
00052  public:
00053    static const STR_ClassIdent identifier;
00054 
00055    inline virtual int AreYouA(const lcore::ClassIdent &cid) const;
00056 
00057    /** Add a data block to the stream.
00058     * \param regionbegin Where the region begins in some data buffer the child
00059     * class should know about (STL style).
00060     * \param regionend Where the region begins in some data buffer the child
00061     * class should know about (STL style).
00062     */
00063    virtual void addDataBlock(size_t regionbegin, size_t regionend) = 0;
00064    //! Add a single character telnet command to the stream.
00065    virtual void addCharCommand(TelnetChars::Commands command) = 0;
00066    /** Add a negotiation command to the stream.
00067     * Negotiations are where two sides of a telnet conversation agree to turn an
00068     * option off or on.  Sometimes turning an option on merely means being
00069     * willing to communicate more about it through suboption negotiation.
00070     */
00071    virtual void addNegotiationCommand(TelnetChars::OptionNegotiations negtype,
00072                                       lcore::U1Byte opt_type) = 0;
00073    /** Add a suboption to the data stream.
00074     * This function will cause a suboption of the specified type to be added to
00075     * the stream.
00076     * \param opt_type The telnet option this suboption is for.
00077     * \param regionbegin Where the raw suboption data region begins in some data
00078     * buffer the child class should know about (STL style).
00079     * \param regionend Where the raw suboption data region ends in some data
00080     * buffer the child class should know about (STL style).
00081     * \param cooked The 'cooked' data with all the escapes processed.
00082     */
00083    virtual void addSuboption(lcore::U1Byte opt_type,
00084                              size_t regionbegin, size_t regionend,
00085                              StrChunkPtrT<BufferChunk> &cooked) = 0;
00086 
00087  protected:
00088    virtual const lcore::ClassIdent *i_GetIdent() const  { return &identifier; }
00089 };
00090 
00091 //-----------------------------inline functions--------------------------------
00092 
00093 inline int TelnetChunkBuilder::AreYouA(const lcore::ClassIdent &cid) const
00094 {
00095    return((identifier == cid) || Protocol::AreYouA(cid));
00096 }
00097 
00098 };  // namespace strmod
00099 };  // namespace strmod
00100 
00101 #endif

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