Article View: comp.sys.next.programmer
Article #567Re: Writing a Storage Object
From: Tony Zamora
Date: Wed, 08 Apr 1992 03:34
Date: Wed, 08 Apr 1992 03:34
46 lines
2448 bytes
2448 bytes
In article <1992Apr8.023553.17506@uwm.edu> xepo@csd4.csd.uwm.edu (Scott R
Violet) writes:
> Hi,
> Lately I have been playing around with Storage objects and have
> encountered a few problems. So, hopefully someone out there knows how
> to use them and would be willing to help. First off if I had the following
> structure
>
> struct test {
> int aTestInt;
> int arrayTest[25][3];
> };
>
> Would the descriptor string be "{i[25[3i]]}"?
It is a good idea to use the @encode directive and typeof operator to generate
descriptor strings. @encode(struct test) should give you the correct
descriptor for your structure. If you need the encoding of a variable, you can
use @encode(typeof(variable_name)). This way you never have to remember all
the rules for descriptors (and you don't get hosed if they change).
> Writing the object to a NXTypedStream seems to go ok. But then when
> I try to read it back in I get a bus error. When you want to read back
> in the stream, how should you initialize the object? I have tried it
> with just testStorage = [[Storage alloc] init]; but that doesn't seem
> to work. And I have also tried initialiving it the same way that I did
> with the first, with an initCount..., but that doesn't seem to work either.
> In both cases I get a Bus error. I am hopping that it is something
> simple, anyone have any suggestions?
> Thanks in advance,
> -Scott Violet (xepo@csd4.csd.uwm.edu)
I use code like
storage = NXReadObject(stream); // to read a storage object (Storage *storage)
NXWriteObject(stream, storage); // write a storage object
and that works for me. NXReadObject should allocate the memory for the object,
so you shouldn't have to do anything special.
Tony
--
Tony Zamora
Department of Computer Science, Indiana University
azamora@cs.indiana.edu
"They thought it was love, but it was only the caffeine."
Technical Details
Message-ID:
<1992Apr7.223410.25768@news.cs.indiana.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!news.cs.indiana.edu!azamora@hexagon.cs.indiana.eduReferences:
<1992Apr8.023553.17506@uwm.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!news.cs.indiana.edu!azamora@hexagon.cs.indiana.edu From: azamora@hexagon.cs.indiana.edu (Tony Zamora) Newsgroups: comp.sys.next.programmer Subject: Re: Writing a Storage Object Message-ID: <1992Apr7.223410.25768@news.cs.indiana.edu> Date: 8 Apr 92 03:34:02 GMT Article-I.D.: news.1992Apr7.223410.25768 References: <1992Apr8.023553.17506@uwm.edu> Reply-To: azamora@cs.indiana.edu Organization: Computer Science, Indiana University Lines: 46