1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
6
* Author: Martin Vales, martin_gnu@mundo-r.com
8
******************************************************************************
9
* Copyright (c) 2008, Martin Vales
11
* All rights reserved.
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following
17
* * Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* * Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in
21
* the documentation and/or other materials provided
22
* with the distribution.
23
* * Neither the name of the Martin Isenburg or Iowa Department
24
* of Natural Resources nor the names of its contributors may be
25
* used to endorse or promote products derived from this software
26
* without specific prior written permission.
28
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
40
****************************************************************************/
43
using System.Collections.Generic;
45
using LASError = System.Int32;
46
using LASWriterH = System.IntPtr;
47
using LASReaderH = System.IntPtr;
48
using LASPointH = System.IntPtr;
49
using LASGuidH = System.IntPtr;
50
using LASVLRH = System.IntPtr;
51
using LASHeaderH = System.IntPtr;
58
public class LASGuid : IDisposable
60
private LASGuidH hguid;
63
/// The object user should call this method when they finished with the object.
68
CAPI.LASGuid_Destroy(hguid);
69
// Clean up unmanaged resources here.
70
// Dispose other contained disposable objects.
74
/// Create a new random GUID.
78
hguid = CAPI.LASGuid_Create();
82
/// Creates a new GUID using a opaque pointer.
84
/// <param name="hGuid">LASGuidH opaque pointer</param>
85
public LASGuid(LASGuidH hGuid)
91
/// Creates a new GUID opaque pointer using the given string.
93
/// <remarks>An example GUID might be something like '8388F1B8-AA1B-4108-BCA3-6BC68E7B062E'</remarks>
94
/// <param name="guidString">string A GUID string in the form "00000000-0000-0000-0000-000000000000"</param>
95
public LASGuid(String guidString)
97
hguid = CAPI.LASGuid_CreateFromString(guidString);
101
/// Gets the String value of the Guid
103
/// <returns>the String value of the Guid</returns>
104
public override string ToString()
106
return CAPI.LASGuid_AsString(hguid);
110
/// Gets the GUID opaque pointer
112
/// <returns>the GUID opaque pointer</returns>
113
internal LASGuidH GetPointer()
119
/// test if is equal to other object.
121
/// <param name="obj">object to compare</param>
122
/// <returns>true if both are equal</returns>
123
public override bool Equals(object obj)
125
//if parameter is null return false
131
//if parameter cannot be cast to Guid return false
132
LASGuid guidd = obj as LASGuid;
133
if ((object)guidd == null)
138
if (CAPI.LASGuid_Equals(hguid, guidd.GetPointer()) == 1)
151
/// <returns></returns>
152
public override int GetHashCode()
154
return base.GetHashCode();
158
/// test if is equal to other LASGuid.
160
/// <param name="obj">LASGuid to compare</param>
161
/// <returns>true if both are equal</returns>
162
public bool Equals(LASGuid obj)
164
//if parameter cannot be cast to Guid return false
166
if ((object)obj == null)
171
if (CAPI.LASGuid_Equals(hguid, obj.GetPointer()) == 1)