1 // Copyright 2019 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef VK_DEBUG_LOCATION_HPP_
16 #define VK_DEBUG_LOCATION_HPP_
17
18 #include <memory>
19
20 namespace vk {
21 namespace dbg {
22
23 class File;
24
25 // Location holds a file path and line number.
26 struct Location
27 {
28 Location() = default;
29 inline Location(const std::shared_ptr<File> &file, int line, int column = 0);
30
31 inline bool operator==(const Location &o) const;
32 inline bool operator!=(const Location &o) const;
33
34 std::shared_ptr<File> file;
35 int line = 0; // 1 based. 0 represents no line.
36 int column = 0; // 1 based. 0 represents no particular column.
37 };
38
Location(const std::shared_ptr<File> & file,int line,int column)39 Location::Location(const std::shared_ptr<File> &file, int line, int column /* = 0 */)
40 : file(file)
41 , line(line)
42 , column(column)
43 {}
44
operator ==(const Location & o) const45 bool Location::operator==(const Location &o) const
46 {
47 return file == o.file && line == o.line && column == o.column;
48 }
49
operator !=(const Location & o) const50 bool Location::operator!=(const Location &o) const
51 {
52 return !(*this == o);
53 }
54
55 } // namespace dbg
56 } // namespace vk
57
58 #endif // VK_DEBUG_LOCATION_HPP_