1 // NAnt - A .NET build tool
2 // Copyright (C) 2001 Gerry Shaw
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // Ian MacLean (ian_maclean@another.com)
19 // Gerry Shaw (gerry_shaw@yahoo.com)
21 namespace SourceForge
.NAnt
{
26 /// Stores the file name and line number in a file.
28 public class Location
{
33 public static readonly Location UnknownLocation
= new Location();
36 /// Creates a location consisting of a file name and line number.
38 public Location(string fileName
, int lineNumber
, int columnNumber
) {
39 Uri uri
= new Uri(fileName
);
40 string strfileName
= uri
.LocalPath
; // convert from URI syntax to local path
41 Init(strfileName
, lineNumber
, columnNumber
);
45 /// Creates a location consisting of a file name but no line number.
47 public Location(string fileName
) {
52 /// Creates an "unknown" location.
59 /// Private Init function.
61 private void Init(string fileName
, int lineNumber
, int columnNumber
) {
63 _lineNumber
= lineNumber
;
64 _columnNumber
= columnNumber
;
68 /// Returns the file name, line number and a trailing space. An error
69 /// message can be appended easily. For unknown locations, returns
72 public override string ToString() {
75 if (_fileName
!= null) {
78 if (_lineNumber
!= 0) {
80 message
+= _lineNumber
.ToString();