# BasicFileLocation.h

Go to the documentation of this file.

    00001 /*******************************************************************\
    00002
    00003               Copyright (C) 2003 Joseph Coffland
    00004
    00005     This program is free software; you can redistribute it and/or
    00006      modify it under the terms of the GNU General Public License
    00007     as published by the Free Software Foundation; either version 2
    00008         of the License, or (at your option) any later version.
    00009
    00010    This program is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013              GNU General Public License for more details.
    00014
    00015   You should have received a copy of the GNU General Public License
    00016      along with this program; if not, write to the Free Software
    00017       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    00018                            02111-1307, USA.
    00019
    00020             For information regarding this software email
    00021                    jcofflan@users.sourceforge.net
    00022
    00023 \*******************************************************************/
    00024
    00025
    00026 #ifndef BASICFILELOCATION_H
    00027 #define BASICFILELOCATION_H
    00028
    00029 #include <string>
    00030
    00036 class BasicFileLocation {
    00037   std::string filename;
    00038   long line;
    00039   long col;
    00040   bool empty;
    00041
    00042 public:
    00046   BasicFileLocation() : line(-1), col(-1), empty(true) {}
    00047
    00051   BasicFileLocation(const BasicFileLocation &x) :
    00052     filename(x.filename), line(x.line), col(x.col), empty(x.empty) {}
    00053
    00059   BasicFileLocation(const std::string filename, const long line,
    00060                     const long col) :
    00061     filename(filename), line(line), col(col), empty(false) {}
    00062
    00063   virtual ~BasicFileLocation() {}
    00064
    00065   const std::string getFilename() const {return filename;}
    00066
    00070   const long getLine() const {return line;}
    00071
    00075   const long getCol() const {return col;}
    00076
    00080   bool isEmpty() const {return empty;}
    00081
    00082   friend std::ostream &operator<<(std::ostream &stream,
    00083                                   const BasicFileLocation &fl);
    00084 };
    00085
    00095 std::ostream &operator<<(std::ostream &stream, const BasicFileLocation &fl);
    00096
    00097 #define FILE_LOCATION BasicFileLocation(__FILE__, __LINE__, -1)
    00098
    00099 #endif