xref: /haiku/headers/private/debugger/types/SourceLocation.h (revision 7a73df5e2cdddb9dee833799ab428d2d3fcaf64a)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef SOURCE_LOCATION_H
6 #define SOURCE_LOCATION_H
7 
8 #include <SupportDefs.h>
9 
10 
11 class SourceLocation {
12 public:
13 	SourceLocation(int32 line = 0, int32 column = 0)
14 		:
fLine(line)15 		fLine(line),
16 		fColumn(column)
17 	{
18 	}
19 
20 	bool operator==(const SourceLocation& other) const
21 	{
22 		return fLine == other.fLine && fColumn == other.fColumn;
23 	}
24 
25 	bool operator!=(const SourceLocation& other) const
26 	{
27 		return !(*this == other);
28 	}
29 
30 	bool operator<(const SourceLocation& other) const
31 	{
32 		return fLine < other.fLine
33 			|| (fLine == other.fLine && fColumn < other.fColumn);
34 	}
35 
36 	bool operator<=(const SourceLocation& other) const
37 	{
38 		return fLine < other.fLine
39 			|| (fLine == other.fLine && fColumn <= other.fColumn);
40 	}
41 
Line()42 	int32 Line() const
43 	{
44 		return fLine;
45 	}
46 
Column()47 	int32 Column() const
48 	{
49 		return fColumn;
50 	}
51 
52 private:
53 	int32	fLine;
54 	int32	fColumn;
55 };
56 
57 
58 #endif	// SOURCE_LOCATION_H
59