00001 #ifndef LOCATION_H_
00002 #define LOCATION_H_
00003
00004
00005 #include <string>
00006 #include <iostream>
00007 #include "../types.h"
00008
00009
00010 using namespace std;
00011
00012
00013 #include <boost/serialization/string.hpp>
00014 #include <boost/serialization/version.hpp>
00015 #include <boost/serialization/split_member.hpp>
00016 #include <boost/serialization/shared_ptr.hpp>
00017 #include <boost/serialization/base_object.hpp>
00018 #include <boost/serialization/export.hpp>
00019 #include <boost/serialization/set.hpp>
00020
00021
00022
00023
00024
00025
00026 namespace il
00027 {
00028
00033 class location
00034 {
00035 friend class boost::serialization::access;
00036
00037 template<class Archive>
00038 void serialize(Archive & ar, const unsigned int version)
00039 {
00040 ar & byte_start;
00041 ar & byte_end;
00042 ar & line_start;
00043 ar & line_end;
00044 }
00045
00046 public:
00047
00048
00049
00050
00051 uint16 byte_start;
00052 uint16 byte_end;
00053 uint32 line_start;
00054 uint32 line_end;
00055
00056 static const uint32 INVALID = ~(0);
00057 public:
00058 friend ostream& operator <<(ostream &os, const location &obj);
00059 string to_string() const;
00060 location(uint16 start_byte, uint32 start_line, uint16 end_byte,
00061 uint32 end_line);
00062
00063 location(uint32 start_line, uint16 start_byte)
00064 {
00065 line_start = start_line;
00066 byte_start = start_byte;
00067 byte_end = line_end = INVALID;
00068 };
00069
00070 void set_end_loc(uint32 line, uint16 byte)
00071 {
00072 line_end = line;
00073 byte_end = byte;
00074 };
00075
00076 string to_string(bool pp);
00077
00078 location();
00079 bool is_valid();
00080 void print();
00081
00082 ~location();
00083 };
00084
00085 }
00086
00087 #endif