/// <summary> /// Gets the element at the specified index. /// </summary> /// <remarks>Used for pre-R 3.5 </remarks> /// <param name="index">The zero-based index of the element to get.</param> /// <returns>The element at the specified index.</returns> protected override string GetValue(int index) { int offset = GetOffset(index); IntPtr pointerItem = Marshal.ReadIntPtr(DataPointer, offset); if (pointerItem == Engine.NaStringPointer) { return(null); } IntPtr pointer = IntPtr.Add(pointerItem, Marshal.SizeOf(typeof(Internals.PreALTREP.VECTOR_SEXPREC))); return(InternalString.StringFromNativeUtf8(pointer)); }
private string ReadString(IntPtr pointer, int offset) { pointer = Marshal.ReadIntPtr(pointer, offset); if (Engine.Compatibility == REngine.CompatibilityMode.ALTREP) { pointer = GetFunction <DATAPTR_OR_NULL>()(pointer); } else { pointer = IntPtr.Add(pointer, Marshal.SizeOf(Engine.GetVectorSexprecType())); } return(InternalString.StringFromNativeUtf8(pointer)); }
/// <summary> /// Gets the element at the specified index. /// </summary> /// <remarks>Used for R 3.5 and higher, to account for ALTREP objects</remarks> /// <param name="index">The zero-based index of the element to get.</param> /// <returns>The element at the specified index.</returns> protected override string GetValueAltRep(int index) { // To work with ALTREP (introduced in R 3.5.0) and non-ALTREP objects, we will get strings // via STRING_ELT, instead of offseting the DataPointer. This lets R manage the details of // ALTREP conversion for us. IntPtr objPointer = GetFunction <STRING_ELT>()(this.DangerousGetHandle(), (IntPtr)index); if (objPointer == Engine.NaStringPointer) { return(null); } IntPtr stringData = GetFunction <DATAPTR_OR_NULL>()(objPointer); return(InternalString.StringFromNativeUtf8(stringData)); }
/// <summary> /// Gets the element at the specified index. /// </summary> /// <remarks>Used for R 3.5 and higher, to account for ALTREP objects</remarks> /// <param name="index">The zero-based index of the element to get.</param> /// <returns>The element at the specified index.</returns> protected override string GetValueAltRep(int index) { // To work with ALTREP (introduced in R 3.5.0) and non-ALTREP objects, we will get strings // via STRING_ELT, instead of offseting the DataPointer. This lets R manage the details of // ALTREP conversion for us. IntPtr objPointer = GetFunction <STRING_ELT>()(this.DangerousGetHandle(), (ulong)index); if (objPointer == Engine.NaStringPointer) { return(null); } IntPtr stringData = IntPtr.Add(objPointer, Marshal.SizeOf(typeof(Internals.ALTREP.VECTOR_SEXPREC))); return(InternalString.StringFromNativeUtf8(stringData)); }
private string ReadString(IntPtr pointer, int offset) { pointer = Marshal.ReadIntPtr(pointer, offset); pointer = IntPtr.Add(pointer, Marshal.SizeOf(Engine.GetVectorSexprecType())); return(InternalString.StringFromNativeUtf8(pointer)); }
private string ReadString(IntPtr pointer, int offset) { pointer = Marshal.ReadIntPtr(pointer, offset); pointer = IntPtr.Add(pointer, Marshal.SizeOf(typeof(VECTOR_SEXPREC))); return(InternalString.StringFromNativeUtf8(pointer)); }