2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include <windows.h>
\r
31 using System::InvalidOperationException;
\r
32 using System::ArgumentException;
\r
33 using System::ArgumentNullException;
\r
34 using System::ArgumentOutOfRangeException;
\r
35 using System::NotSupportedException;
\r
36 using System::IO::EndOfStreamException;
\r
41 ref class ComObject;
\r
42 ref class DataStream;
\r
44 ref class Utilities sealed
\r
50 static GUID GetNativeGuidForType( System::Type^ type );
\r
52 static System::Guid ConvertNativeGuid( const GUID &guid );
\r
53 static GUID ConvertManagedGuid( System::Guid guid );
\r
55 static int SizeOfFormatElement( DXGI_FORMAT format );
\r
57 static System::Drawing::Rectangle ConvertRect(RECT rect);
\r
58 static void ConvertRect(System::Drawing::Rectangle& source, RECT& dest);
\r
60 static System::String^ BlobToString( ID3D10Blob *blob );
\r
61 static System::String^ BufferToString( ID3DXBuffer *buffer );
\r
63 static array<System::Byte>^ ReadStream( System::IO::Stream^ stream, DataStream^* dataStream );
\r
64 static array<System::Byte>^ ReadStream( System::IO::Stream^ stream, int% readLength, DataStream^* dataStream );
\r
66 generic<typename T> where T : value class
\r
67 static array<T>^ ReadRange( ID3DXBuffer *buffer, int count );
\r
69 //These doc comments are mostly intended to copy to other places.
\r
72 /// Checks that a range to be read are within the boundaries of a source.
\r
74 /// <param name="lowerBound">The minimum bound that can be read from the source, and fills in the number of elements to read if necessary.</param>
\r
75 /// <param name="size">The total size of the source.</param>
\r
76 /// <param name="offset">The index at which the caller intends to begin reading from the source.</param>
\r
77 /// <param name="count">The number of elements intended to be read from the source. If 0 is passed, count will be adjusted to be size - offset.</param>
\r
78 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset" /> is less than <paramref name="lowerBound" />.</exception>
\r
79 /// <exception cref="ArgumentOutOfRangeException"><paramref name="count" /> is negative.</exception>
\r
80 /// <exception cref="ArgumentException">The sum of <paramref name="offset" /> and <paramref name="count" /> is greater than the buffer length.</exception>
\r
81 static void CheckBounds( int lowerBound, int size, int offset, int% count );
\r
84 /// Checks that a range to be read is within the boundaries of a source array, and fills in the number of elements to read if necessary.
\r
86 /// <param name="data">The source array to be read from.</param>
\r
87 /// <param name="offset">The index at which the caller intends to begin reading from the source.</param>
\r
88 /// <param name="count">The number of elements intended to be read from the source. If 0 is passed, count will be adjusted to be size - offset.</param>
\r
89 /// <exception cref="ArgumentNullException"><paramref name="data" /> is a null reference.</exception>
\r
90 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset" /> or <paramref name="count" /> is negative.</exception>
\r
91 /// <exception cref="ArgumentException">The sum of <paramref name="offset" /> and <paramref name="count" /> is greater than the buffer length.</exception>
\r
92 static void CheckArrayBounds( System::Array^ data, int offset, int% count );
\r
95 static bool CheckElementEquality( array<T>^ left, array<T>^ right );
\r
97 static bool CheckElementEquality( System::Collections::Generic::IList<T>^ left, System::Collections::Generic::IList<T>^ right );
\r
99 [System::Security::Permissions::SecurityPermission( System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::UnmanagedCode )]
\r
100 static void FreeNativeString( LPCSTR string );
\r
102 [System::Security::Permissions::SecurityPermission( System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::UnmanagedCode )]
\r
103 static void FreeNativeString( LPSTR string );
\r
105 [System::Security::Permissions::SecurityPermission( System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::UnmanagedCode )]
\r
106 static LPSTR AllocateNativeString( System::String^ string );
\r
108 generic<typename T> where T : value class
\r
109 static T FromIntToT( int value );
\r