Material PDF: Restore animated entry and exit of viewer toolbars
[chromium-blink-merge.git] / tools / gn / location.h
blobb56e73de777837deeaea6ede3b665d62d26cddb9
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_LOCATION_H_
6 #define TOOLS_GN_LOCATION_H_
8 #include <string>
10 class InputFile;
12 // Represents a place in a source file. Used for error reporting.
13 class Location {
14 public:
15 Location();
16 Location(const InputFile* file, int line_number, int char_offset, int byte);
18 const InputFile* file() const { return file_; }
19 int line_number() const { return line_number_; }
20 int char_offset() const { return char_offset_; }
21 int byte() const { return byte_; }
23 bool operator==(const Location& other) const;
24 bool operator!=(const Location& other) const;
25 bool operator<(const Location& other) const;
27 // Returns a string with the file, line, and (optionally) the character
28 // offset for this location. If this location is null, returns an empty
29 // string.
30 std::string Describe(bool include_char_offset) const;
32 private:
33 const InputFile* file_; // Null when unset.
34 int line_number_; // -1 when unset. 1-based.
35 int char_offset_; // -1 when unset. 1-based.
36 int byte_; // Index into the buffer, 0-based.
39 // Represents a range in a source file. Used for error reporting.
40 // The end is exclusive i.e. [begin, end)
41 class LocationRange {
42 public:
43 LocationRange();
44 LocationRange(const Location& begin, const Location& end);
46 const Location& begin() const { return begin_; }
47 const Location& end() const { return end_; }
49 LocationRange Union(const LocationRange& other) const;
51 private:
52 Location begin_;
53 Location end_;
56 #endif // TOOLS_GN_LOCATION_H_