2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef TARGET_ADDRESS_RANGE_H
6 #define TARGET_ADDRESS_RANGE_H
13 class TargetAddressRange
{
22 TargetAddressRange(target_addr_t start
, target_size_t size
)
29 TargetAddressRange(const TargetAddressRange
& other
)
36 TargetAddressRange
& operator=(const TargetAddressRange
& other
)
38 fStart
= other
.fStart
;
43 bool operator==(const TargetAddressRange
& other
) const
45 return fStart
== other
.fStart
&& fSize
== other
.fSize
;
48 bool operator!=(const TargetAddressRange
& other
) const
50 return !(*this == other
);
53 target_addr_t
Start() const
58 target_size_t
Size() const
63 target_addr_t
End() const
65 return fStart
+ fSize
;
68 bool Contains(target_addr_t address
) const
70 return address
>= Start() && address
< End();
73 bool Contains(const TargetAddressRange
& other
) const
75 return Start() <= other
.Start() && End() >= other
.End();
78 bool IntersectsWith(const TargetAddressRange
& other
) const
80 return Contains(other
.Start()) || other
.Contains(Start());
83 TargetAddressRange
& operator|=(const TargetAddressRange
& other
)
88 if (other
.fSize
> 0) {
89 target_addr_t end
= std::max(End(), other
.End());
90 fStart
= std::min(fStart
, other
.fStart
);
103 #endif // TARGET_ADDRESS_RANGE_H