[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accepting arbitrary strings as structure field names
From: |
John W. Eaton |
Subject: |
Re: Accepting arbitrary strings as structure field names |
Date: |
Fri, 10 Nov 2006 19:06:43 -0500 |
On 10-Nov-2006, Rafael Laboissiere wrote:
| Is it possible to insert a NUL character in an Octave string?
Yes:
char ([102, 0, 0, 98, 97, 114])
After sending my message this morning, I tried saving a character
string like this and that part worked, but reloading it failed, only
loading up to the first NUL, so I fixed that problem. I didn't check
all formats, though looking at the code it seemed that the HDF5 format
would not correctly save character strings with embedded NUL
characters because it appears to use a C-style string with no
associated length to pass the data.
When saving a struct, the field name is not saved like character
data. Instead, it is saved like the name of a variable, like this:
# name: NAME
using code like this:
os << name << std::endl
and it is read back in a similar way, so I think it will fail for
field names with embedded NUL characters. This is not a problem
currently because the names of variables are restricted.
Instead of overloading structures directly for this purpose, what
about making a new data type instead and using functions to add
elements to the table?
jwe
- Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/04
- Re: Accepting arbitrary strings as structure field names, Bill Denney, 2006/11/04
- Re: Accepting arbitrary strings as structure field names, Etienne Grossmann, 2006/11/04
- Re: Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/05
- Re: Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/05
- Re: Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/05
- Re: Accepting arbitrary strings as structure field names, John W. Eaton, 2006/11/10
- Re: Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/10
- Re: Accepting arbitrary strings as structure field names,
John W. Eaton <=
- Re: Accepting arbitrary strings as structure field names, Rafael Laboissiere, 2006/11/11