00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UTAP_POSITION
00023 #define UTAP_POSITION
00024
00025 #include "config.h"
00026
00027 #ifdef HAVE_INTTYPES_H
00028 #include <inttypes.h>
00029 #elif defined(HAVE_STDINT_H)
00030 #include <stdint.h>
00031 #else
00032 #error "No inttypes.h or stdint.h"
00033 #endif
00034
00035 #include <vector>
00036 #include <string>
00037 #include <iostream>
00038 #include <climits>
00039
00040 namespace UTAP
00041 {
00042 struct position_t
00043 {
00044 uint32_t start, end;
00045 position_t() : start(0), end(UINT_MAX) {}
00046 position_t(uint32_t start, uint32_t end) : start(start), end(end) {}
00047 };
00048
00067 class Positions
00068 {
00069 public:
00070 struct line_t
00071 {
00072 uint32_t position;
00073 uint32_t offset;
00074 uint32_t line;
00075 std::string path;
00076 line_t(uint32_t position, uint32_t offset, uint32_t line, std::string path)
00077 : position(position), offset(offset), line(line), path(path) {}
00078 };
00079
00080 private:
00081 std::vector<line_t> elements;
00082 const line_t &find(uint32_t, uint32_t, uint32_t) const;
00083 public:
00085 void add(uint32_t position, uint32_t offset, uint32_t line, std::string path);
00086
00092 const line_t &find(uint32_t position) const;
00093
00095 void dump();
00096 };
00097
00098
00099 struct error_t
00100 {
00101 Positions::line_t start;
00102 Positions::line_t end;
00103 position_t position;
00104 std::string msg;
00105 error_t(Positions::line_t start, Positions::line_t end,
00106 position_t position, std::string msg)
00107 : start(start), end(end), position(position), msg(msg) {}
00108 };
00109 }
00110
00111 std::ostream &operator <<(std::ostream &out, const UTAP::error_t &);
00112
00113 #endif