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

position.h

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; -*-
00002 
00003 /* libutap - Uppaal Timed Automata Parser.
00004    Copyright (C) 2006 Uppsala University and Aalborg University.
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public License
00008    as published by the Free Software Foundation; either version 2.1 of
00009    the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful, but
00012    WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with this library; if not, write to the Free Software
00018    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00019    USA
00020 */
00021 
00022 #ifndef UTAP_POSITION
00023 #define UTAP_POSITION
00024 
00025 #include <vector>
00026 #include <string>
00027 #include <stdint.h>
00028 #include <iostream>
00029 #include <climits>
00030 
00031 namespace UTAP
00032 {
00033     struct position_t
00034     {
00035         uint32_t start, end;
00036         position_t() : start(0), end(UINT_MAX) {}
00037         position_t(uint32_t start, uint32_t end) : start(start), end(end) {}
00038     };
00039 
00058     class Positions
00059     {
00060     public:
00061         struct line_t
00062         {
00063             uint32_t position;
00064             uint32_t offset;
00065             uint32_t line;    
00066             std::string path;
00067             line_t(uint32_t position, uint32_t offset, uint32_t line, std::string path)
00068                 : position(position), offset(offset), line(line), path(path) {}
00069         };
00070         
00071     private:
00072         std::vector<line_t> elements;
00073         const line_t &find(uint32_t, uint32_t, uint32_t) const;
00074     public:
00076         void add(uint32_t position, uint32_t offset, uint32_t line, std::string path);
00077         
00083         const line_t &Positions::find(uint32_t position) const;
00084         
00086         void dump();
00087     };
00088     
00089     
00090     struct error_t
00091     {
00092         Positions::line_t start;
00093         Positions::line_t end;
00094         position_t position;
00095         std::string msg;
00096         error_t(Positions::line_t start, Positions::line_t end, 
00097                 position_t position, std::string msg)
00098             : start(start), end(end), position(position), msg(msg) {}
00099     };
00100 }
00101 
00102 std::ostream &operator <<(std::ostream &out, const UTAP::error_t &);
00103 
00104 #endif

Generated on Sat Apr 29 21:02:14 2006 for libutap by  doxygen 1.4.2