00001 #ifndef _STR_NewlineChopper_H_ // -*-c++-*- 00002 00003 /* 00004 * Copyright 1991-2002 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/NewlineChopper.h,v 1.7 2002/08/29 00:58:04 hopper Exp $ */ 00026 00027 // For a log, see ../ChangeLog 00028 // 00029 // Revision 1.1 1996/09/02 23:18:48 hopper 00030 // Added NewlineChopper class so users would have a simple class that 00031 // would break up and recombine streams using '\n' as a separator. 00032 // 00033 00034 #include <StrMod/CharChopper.h> 00035 00036 #define _STR_NewlineChopper_H_ 00037 00038 namespace strmod { 00039 namespace strmod { 00040 00041 /** \class NewlineChopper NewlineChopper.h StrMod/NewlineChopper.h 00042 * \brief Just a CharChopper that's hard wired to '\\n' as the character. 00043 * 00044 * This is such a common case, I thought it deserved its own class. 00045 */ 00046 class NewlineChopper : public CharChopper 00047 { 00048 public: 00049 typedef CharChopper parentclass; 00050 static const STR_ClassIdent identifier; 00051 00052 //! Just pass a newline character to parent consructor. 00053 NewlineChopper() : CharChopper('\n') { } 00054 // Derived class destructor doesn't do anything base class one doesn't do. 00055 00056 inline virtual int AreYouA(const lcore::ClassIdent &cid) const; 00057 00058 protected: 00059 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; } 00060 00061 private: 00062 NewlineChopper(const NewlineChopper &b); 00063 }; 00064 00065 //-----------------------------inline functions-------------------------------- 00066 00067 inline int NewlineChopper::AreYouA(const lcore::ClassIdent &cid) const 00068 { 00069 return((identifier == cid) || CharChopper::AreYouA(cid)); 00070 } 00071 00072 }; // namespace strmod 00073 }; // namespace strmod 00074 00075 #endif
1.3-rc1