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"
19 #import "PreferenceNames.h"
21 @implementation Breakpoint
23 @synthesize file
= file_
;
24 @synthesize line
= line_
;
25 @synthesize debuggerId
= debuggerId_
;
28 * Initializes a breakpoint with a file and line
30 - (id)initWithLine
:(NSUInteger
)l inFile
:(NSString
*)f
32 if (self = [super init
])
50 * Creates a Breakpoint from the values of an NSDictionary
52 - (id)initWithDictionary
:(NSDictionary
*)dict
54 if (self = [super init
])
56 file_
= [[dict valueForKey
:@
"file"] retain
];
57 line_
= [[dict valueForKey
:@
"line"] intValue
];
63 * Returns the transformed path for the breakpoint, as Xdebug needs it
65 - (NSString
*)transformedPath
67 NSString
* path
= self.file
;
69 NSMutableArray
* transforms
= [[NSUserDefaults standardUserDefaults
] mutableArrayValueForKey
:kPrefPathReplacements
];
70 if (!transforms ||
[transforms count
] < 1)
73 for (NSDictionary
* replacement
in transforms
)
76 stringByReplacingOccurrencesOfString
:[replacement valueForKey
:@
"local"]
77 withString
:[replacement valueForKey
:@
"remote"]
85 * Determines if two breakpoints are equal
87 - (BOOL)isEqual
:(id)obj
89 return ([[obj file
] isEqualToString
:self.file
] && [obj line
] == self.line
);
93 * Returns the hash value of a breakpoint
97 return ([self.file hash
] << 8) + self.line
;
101 * Returns an NSDictionary of the data so it can be stored in NSUserDefaults
103 - (NSDictionary
*)dictionary
105 return [NSDictionary dictionaryWithObjectsAndKeys
:
107 [NSNumber numberWithInt
:self.line
], @
"line",
115 - (NSString
*)description
117 return [NSString stringWithFormat
:@
"%@:%lu", self.file
, self.line
];