Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SourceLocation.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.IO;
5 
6 namespace SiliconStudio.Shaders.Ast
7 {
8  /// <summary>
9  /// A Source location.
10  /// </summary>
11  public struct SourceLocation
12  {
13  #region Constants and Fields
14 
15  /// <summary>
16  /// Filename source.
17  /// </summary>
18  public string FileSource;
19 
20  /// <summary>
21  /// Absolute position in the file.
22  /// </summary>
23  public int Position;
24 
25  /// <summary>
26  /// Line in the file (1-based).
27  /// </summary>
28  public int Line;
29 
30  /// <summary>
31  /// Column in the file (1-based).
32  /// </summary>
33  public int Column;
34 
35  #endregion
36 
37  #region Constructors and Destructors
38 
39  /// <summary>
40  /// Initializes a new instance of the <see cref="SourceLocation"/> struct.
41  /// </summary>
42  /// <param name="fileSource">The file source.</param>
43  /// <param name="position">The position.</param>
44  /// <param name="line">The line.</param>
45  /// <param name="column">The column.</param>
46  public SourceLocation(string fileSource, int position, int line, int column)
47  {
48  FileSource = fileSource;
49  Position = position;
50  Line = line;
51  Column = column;
52  }
53 
54  /// <summary>
55  /// Initializes a new instance of the <see cref="SourceLocation"/> struct.
56  /// </summary>
57  /// <param name="position">The position.</param>
58  /// <param name="line">The line.</param>
59  /// <param name="column">The column.</param>
60  public SourceLocation(int position, int line, int column)
61  : this()
62  {
63  Position = position;
64  Line = line;
65  Column = column;
66  }
67 
68  /// <inheritdoc/>
69  public override string ToString()
70  {
71  return this.ToString(false);
72  }
73 
74  public string ToString(bool useShortFileName)
75  {
76  return string.Format("{0}({1},{2})", FileSource ?? string.Empty, Line, Column);
77  }
78 
79  #endregion
80  }
81 }
int Position
Absolute position in the file.
int Line
Line in the file (1-based).
string ToString(bool useShortFileName)
int Column
Column in the file (1-based).
SourceLocation(int position, int line, int column)
Initializes a new instance of the SourceLocation struct.
SourceLocation(string fileSource, int position, int line, int column)
Initializes a new instance of the SourceLocation struct.