[StructLayout(LayoutKind.Sequential)] should be at the head of your metadata
struct not Chararray.
So,
[StructLayout(LayoutKind.Sequential)]
struct metadata
{
public Chararray a;
public int b;
public float c;
public float d;
public Chararray f;
(and so on)
}
And define your strings within the HDF dataType as C_S1 and
H5T.setVariableSize().
Scott
> -----Original Message-----
> From: Hdf-forum [mailto:[email protected]] On Behalf Of
> Insane
> Sent: Tuesday, April 09, 2013 3:58 PM
> To: [email protected]
> Subject: Re: [Hdf-forum] c# read different datatypes
>
> Maybe, I am misunderstanding smth.
> I used this code
> [StructLayout(LayoutKind.Sequential)]
> public unsafe struct Chararray
> {
> private double* recordedText;
>
> //an initializer to get and set the char* since it is
> unsafe
> public double* RecordedText
> {
> get
> {
> return recordedText;
> }
> set
> {
> recordedText = value;
> }
> }
>
> public override string ToString()
> {
> string s = "";
> //the HDF5 STRING is not a string but in fact a char *
> //since it is we need to translate the return into a
> pointeraddress
>
> IntPtr ipp = (IntPtr)this.recordedText;
> //This call is used to transform the pointer into the
> valueof the pointer.
>
> //NOTE: this only works with null-terminated strings.
> s
> =System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ipp);
>
> return s;
> }
> }
> -------------
> and added <CharArray> instead of <char>
>
> now the returning value of "CharArray" (is "0x000007ce " double*)
>
>
>
>
>
> --
> View this message in context: http://hdf-forum.184993.n3.nabble.com/c-
> read-different-datatypes-tp4026057p4026061.html
> Sent from the hdf-forum mailing list archive at Nabble.com.
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> [email protected]
> http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
________________________________
This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of Exelis Inc. The
recipient should check this e-mail and any attachments for the presence of
viruses. Exelis Inc. accepts no liability for any damage caused by any virus
transmitted by this e-mail.
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org