3 * Copyright (c) 2007 - 2011, Blue Static <http://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #import "Breakpoint.h"
20 @implementation Breakpoint
22 @synthesize file
= file_
;
23 @synthesize line
= line_
;
24 @synthesize debuggerId
= debuggerId_
;
27 * Initializes a breakpoint with a file and line
29 - (id)initWithLine
:(NSUInteger
)l inFile
:(NSString
*)f
31 if (self = [super init
])
49 * Creates a Breakpoint from the values of an NSDictionary
51 - (id)initWithDictionary
:(NSDictionary
*)dict
53 if (self = [super init
])
55 file_
= [[dict valueForKey
:@
"file"] retain
];
56 line_
= [[dict valueForKey
:@
"line"] intValue
];
62 * Returns the transformed path for the breakpoint, as Xdebug needs it
64 - (NSString
*)transformedPath
66 NSString
* path
= self.file
;
68 NSMutableArray
* transforms
= [[NSUserDefaults standardUserDefaults
] mutableArrayValueForKey
:@
"PathReplacements"];
69 if (!transforms ||
[transforms count
] < 1)
72 for (NSDictionary
* replacement
in transforms
)
75 stringByReplacingOccurrencesOfString
:[replacement valueForKey
:@
"local"]
76 withString
:[replacement valueForKey
:@
"remote"]
84 * Determines if two breakpoints are equal
86 - (BOOL)isEqual
:(id)obj
88 return ([[obj file
] isEqualToString
:self.file
] && [obj line
] == self.line
);
92 * Returns the hash value of a breakpoint
96 return ([self.file hash
] << 8) + self.line
;
100 * Returns an NSDictionary of the data so it can be stored in NSUserDefaults
102 - (NSDictionary
*)dictionary
104 return [NSDictionary dictionaryWithObjectsAndKeys
:
106 [NSNumber numberWithInt
:self.line
], @
"line",
114 - (NSString
*)description
116 return [NSString stringWithFormat
:@
"%@:%i", self.file
, self.line
];