Data.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #region MIT License
  2. /*Copyright (c) 2012 Robert Rouhani <robert.rouhani@gmail.com>
  3. SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. this software and associated documentation files (the "Software"), to deal in
  6. the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.*/
  19. #endregion
  20. using System;
  21. using System.Runtime.InteropServices;
  22. namespace SharpFont
  23. {
  24. /// <summary>
  25. /// Read-only binary data represented as a pointer and a length.
  26. /// </summary>
  27. public sealed class Data
  28. {
  29. #region Fields
  30. private IntPtr reference;
  31. #endregion
  32. #region Constructors
  33. internal Data(IntPtr reference)
  34. {
  35. Reference = reference;
  36. }
  37. #endregion
  38. #region Properties
  39. /// <summary>
  40. /// Gets the data.
  41. /// </summary>
  42. public IntPtr Pointer
  43. {
  44. get
  45. {
  46. return Marshal.ReadIntPtr(reference, 0);
  47. }
  48. }
  49. /// <summary>
  50. /// Gets the length of the data in bytes.
  51. /// </summary>
  52. public int Length
  53. {
  54. get
  55. {
  56. return Marshal.ReadInt32(reference, IntPtr.Size);
  57. }
  58. }
  59. internal IntPtr Reference
  60. {
  61. get
  62. {
  63. return reference;
  64. }
  65. set
  66. {
  67. reference = value;
  68. }
  69. }
  70. #endregion
  71. }
  72. }