TypeStream-io.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Wed Jan 18 14:11:39 CET 2006  TypeStream.cxx
00003 
00004                         TypeStream.cxx -  description
00005                            -------------------
00006     begin                : Wed January 18 2006
00007     copyright            : (C) 2006 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #include "../types/TypeStream-io.hpp"
00039 
00040 namespace RTT {
00041     namespace types {
00042     // Code ripped from KDL 0.2
00043 
00044 
00045     // Eats space-like characters and comments
00046     // possibly returns the number of space-like characters eaten.
00047     int _EatSpace( std::istream& is,int* countp) {
00048         int ch;
00049         int count;
00050         count=-1;
00051         do {
00052             if( !is )
00053                 return '!';
00054 
00055             ch = is.get();
00056             count++;
00057         } while ((ch==' ')||(ch=='\n')||(ch=='\t'));
00058         if (countp!=NULL) *countp =  count;
00059         return ch;
00060     }
00061 
00062     // Eats whites, returns, tabs and the delim character
00063     //  Checks wether delim char. is encountered.
00064     bool Eat( std::istream& is, int delim )
00065     {
00066         if( !is )
00067             return false;
00068         int ch;
00069         ch=_EatSpace(is);
00070         if (ch != delim) {
00071             return false;
00072         }
00073         ch=_EatSpace(is);
00074         is.putback(ch);
00075         return true;
00076     }
00077 
00078     // Eats whites, returns, tabs and the delim character
00079     //  Checks wether delim char. is encountered.
00080     // EatEnd does not eat all space-like char's at the end.
00081     bool EatEnd( std::istream& is, int delim )
00082     {
00083         if( !is )
00084             return false;
00085         int ch;
00086         ch=_EatSpace(is);
00087         if (ch != delim) {
00088             return false;
00089         }
00090         return true;
00091     }
00092     }
00093 }
00094 


rtt
Author(s): RTT Developers
autogenerated on Mon Oct 6 2014 03:13:55