(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.PEToolkit / RVA.cs
blob49cc060e39bb28841ee66c084698519d8fe9a3c4
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>
26 using System;
27 using System.IO;
29 namespace Mono.PEToolkit {
31 /// <summary>
32 /// Relative Virtual Address.
33 /// </summary>
34 public struct RVA {
36 public static readonly RVA Null;
38 public uint value;
40 static RVA()
42 Null = new RVA(0);
46 public RVA(uint val)
48 value = val;
52 public uint Value {
53 get {
54 return value;
56 set {
57 this.value = value;
61 public void Write (BinaryWriter writer)
63 writer.Write (value);
66 public static implicit operator RVA (uint val)
68 return new RVA(val);
71 public static implicit operator uint (RVA rva)
73 return rva.value;
76 public override int GetHashCode()
78 return (int) value;
81 public override bool Equals(object o)
83 bool res = o is RVA;
84 if (res) res = (this.value == ((RVA)o).value);
85 return res;
88 public static bool operator == (RVA rva1, RVA rva2)
90 return rva1.Equals(rva2);
93 public static bool operator != (RVA rva1, RVA rva2)
95 return !rva1.Equals(rva2);
98 public static bool operator < (RVA rva1, RVA rva2)
100 return (rva1.value < rva2.value);
103 public static bool operator > (RVA rva1, RVA rva2) {
104 return (rva1.value > rva2.value);
107 public static bool operator <= (RVA rva1, RVA rva2)
109 return (rva1.value <= rva2.value);
112 public static bool operator >= (RVA rva1, RVA rva2)
114 return (rva1.value >= rva2.value);
117 public static RVA operator + (RVA rva, uint x)
119 return new RVA (rva.value + x);
122 public static RVA operator - (RVA rva, uint x)
124 return new RVA (rva.value - x);
128 public override string ToString()
130 if (this == Null) return "NULL";
131 return ("0x" + value.ToString("X"));
134 unsafe public static int Size {
135 get {
136 return sizeof (uint);