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

/magnus/back_end/GAP/include/PermutationParser.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: PermutationParser.h,v 1.1 2000/09/26 21:31:57 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 2000 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 //
00008 // Contents: Definition of class PermutationParser
00009 //
00010 // Principal Author: Dmitry Bormotov
00011 //
00012 // Status: Under development
00013 //
00014 // Usage:
00015 //
00016 // Revision History:
00017 //
00018 
00019 
00020 #ifndef _PermutationParser_h_
00021 #define _PermutationParser_h_
00022 
00023 #include "Permutation.h"
00024 
00025 
00026 //--------------------------- PermutationParser -----------------------------//
00027 
00028 
00029 class PermutationParser
00030 {
00031 
00032   // We represent permutation by it's bottom row, i.e., { 3 1 2 }
00033   // means 1 -> 3, 2 -> 1, 3 -> 2. It should be a list of integers
00034   // separated by spaces and enclosed in braces. The list must define
00035   // a permutation, i.e., it must be a list of integers without holes,
00036   // contain no integer twice, contain no integer not in the range
00037   // from 1 to the length of the list. Also, we assume that i -> i for
00038   // all i greater than the length of the list.
00039 
00040 public:
00041 
00042   //////////////////////////////////////////////////////////////
00043   //                                                          //
00044   // Constructors:                                            //
00045   //                                                          //
00046   //////////////////////////////////////////////////////////////
00047 
00048   PermutationParser(istream &str) : istr(str) { }
00049   // Initialize the parser with the istream from which to read.
00050 
00051   // Destructor, cc and op = supplied by compiler.
00052 
00053 
00054   //////////////////////////////////////////////////////////////
00055   //                                                          //
00056   // Accessors:                                               //
00057   //                                                          //
00058   //////////////////////////////////////////////////////////////
00059     
00060   Permutation parsePermutation( Chars& errMesg );
00061   // Read permutation from istream; errMesg explain errors if any, or
00062   // empty otherwise.
00063 
00064   int cursorPos( ) const { return pos; }
00065   // returns the current cursor position while parsing; useful
00066   // when error has occured to show where the error was
00067 
00068 private:
00069 
00070   //////////////////////////////////////////////////////////////
00071   //                                                          //
00072   // Data members:                                            //
00073   //                                                          //
00074   //////////////////////////////////////////////////////////////
00075 
00076   istream& istr;  // istream from which to read
00077   int pos;        // error position when possible
00078 
00079 
00080   //////////////////////////////////////////////////////////////
00081   //                                                          //
00082   // Private functions:                                       //
00083   //                                                          //
00084   //////////////////////////////////////////////////////////////
00085 
00086   bool isDigit( char c );
00087   // true if c is digit and not zero, i.e., 1..9
00088 
00089   bool isSpace( char c );
00090   // returns true if c is a space character or \t or \n
00091 
00092   void eatWhite( );
00093   // skips white space
00094 };
00095 
00096 #endif
00097 
00098 
00099 

Generated at Tue Jun 19 09:49:35 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001