Main   Class Hierarchy   Classes   Compound List   Files   Compound Members   File Members   Pages  

util.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 /** @file util.h
00003     General utilities.
00004 
00005     $Id: util_8h-source.html,v 1.1.1.1 2003/08/07 19:41:39 emarkus Exp $
00006     $Source: /usr/cvsroot/www_pathfind/libpathfind/0.1.0/doc/util_8h-source.html,v $
00007 */
00008 //-----------------------------------------------------------------------------
00009 
00010 #ifndef PATHFIND_UTIL_H
00011 #define PATHFIND_UTIL_H
00012 
00013 #include <iostream>
00014 #include <string>
00015 #include "error.h"
00016 #include "math.h"
00017 
00018 //-----------------------------------------------------------------------------
00019 
00020 namespace PathFind
00021 {
00022     /** Exception thrown by LineReader. */
00023     class ReadError
00024         : public Error
00025     {
00026     public:
00027         ReadError(int line, const string& info);
00028     };
00029 
00030     /** Wrapper class around std::istream for reading line by line.
00031         Allows keeping track of the line number for generating meaningful
00032         error messages.
00033     */
00034     class LineReader
00035     {
00036     public:
00037         static const int MAX_LINE = 2048;
00038 
00039         LineReader(std::istream& in);
00040 
00041         /** Creates a new error with a message and the current line number */
00042         Error createError(const string& message);
00043 
00044         int getLineNumber()
00045         {
00046             return m_lineNumber;
00047         }
00048 
00049         /** Read next line.
00050             @exception ReadError Reading failed.
00051         */
00052         std::string readLine();
00053 
00054     private:
00055         int m_lineNumber;
00056 
00057         std::istream& m_in;
00058     };
00059 
00060     /** Get a label useful for implementations of Search::getVisitedNodes.
00061         The char label is built with the iteration number and uses
00062         '0'-'9', 'a'-'z' if the iteration number is less than 37,
00063         '+' otherwise.
00064      */
00065     char getVisitedNodeLabel(int iteration);
00066 }
00067 
00068 //-----------------------------------------------------------------------------
00069 
00070 #endif


Generated on Thu Aug 7 13:04:50 2003 by Doxygen1.3.1