// Copyright 2017-2018 Alexander Luzgarev namespace MatFileHandler { /// /// Character array. /// /// Element type. /// /// Possible values of T: UInt8 (for UTF-8 encoded arrays), UInt16 (for UTF-16 encoded arrays). /// internal class MatCharArrayOf : MatNumericalArrayOf, ICharArray where T : struct { /// /// Initializes a new instance of the class. /// /// Array parameters. /// Dimensions of the array. /// Array name. /// Raw data (UTF-8 or UTF-16). /// Contents as a string. internal MatCharArrayOf(ArrayFlags flags, int[] dimensions, string name, T[] rawData, string stringData) : base(flags, dimensions, name, rawData) { StringData = stringData; } /// /// Gets the contents of the array as a string. /// public string String => StringData; /// /// Gets the contents of the array as a char array. /// char[] IArrayOf.Data => StringData.ToCharArray(); private string StringData { get; set; } /// /// Provides access to the characters of the string contents. /// /// Indices of an element. /// Value of the element. char IArrayOf.this[params int[] indices] { get => StringData[Dimensions.DimFlatten(indices)]; set { var chars = StringData.ToCharArray(); chars[Dimensions.DimFlatten(indices)] = value; StringData = chars.ToString(); } } } }