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

parsers.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 ***
00031 ***
00032 ***************************************************************************/
00033 
00034 
00035 #ifndef PARSERS_H
00036 #define PARSERS_H
00037 
00038 #include <string>
00039 #include <iostream>
00040 #include <iomanip>
00041 #include <fstream>
00042 #include <vector>
00043 #include <algorithm>
00044 #include <math.h>
00045 #include <stdlib.h>
00046 #include <time.h>
00047 
00048 using namespace std;
00049 
00050 namespace parse_utils
00051 {
00052    struct ltstr
00053    {
00054       inline bool operator ()(const char* s1, const char* s2) const
00055          {   return strcmp(s1, s2) < 0; }
00056    };
00057    
00058    struct Point
00059    {
00060       double x;
00061       double y;
00062    };
00063    
00064    struct IntPoint
00065    {
00066       int x;
00067       int y;
00068    };
00069    
00070    // global parsing functions
00071    inline void eatblank(ifstream& i);   
00072    inline void skiptoeol(ifstream& i);   
00073    inline void eathash(ifstream& i);   
00074    inline bool needCaseChar(ifstream& i, char character);
00075 }
00076 // namespace parse_utils
00077    
00078 // =========================
00079 //      IMPLEMENTATIONS
00080 // =========================
00081 inline void parse_utils::eatblank(ifstream& i)
00082 {
00083    while (i.peek()==' ' || i.peek()=='\t')
00084       i.get();
00085 }
00086 // --------------------------------------------------------
00087 inline void parse_utils::skiptoeol(ifstream& i)
00088 {
00089    while (!i.eof() && i.peek()!='\n' && i.peek()!='\r')
00090       i.get();
00091    i.get();
00092 }
00093 // --------------------------------------------------------
00094 inline bool parse_utils::needCaseChar(ifstream& i,
00095                                       char character)
00096 {
00097    while(!i.eof() && i.peek() != character)
00098       i.get();
00099    if(i.eof())
00100       return false;
00101    else
00102       return true;
00103 }
00104 // --------------------------------------------------------
00105 inline void parse_utils::eathash(ifstream& i)
00106 {
00107   skiptoeol(i);
00108 }
00109 // --------------------------------------------------------
00110 #endif

Generated on Mon Apr 25 01:09:24 2005 for Parquete by doxygen 1.3.2