• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Saving C++ based data structures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving C++ based data structures


  • Subject: Re: Saving C++ based data structures
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 5 Dec 2005 20:26:23 -0600


On Dec 4, 2005, at 7:25 PM, Ricky Sharp wrote:

Does the data that describes Shape need to be in human-readable form (i.e. you need to have one XML tag per attribute)? If not, you may want to consider flattening the object into a block of data (NSData) and archiving that.

I took a similar approach myself with some of my data. The original C++ version (Carbon) stored all data in a flat binary file. The Cocoa version archives many objects which all implement NSCoding. But for some things, data residing in C structs made the most sense (I didn't need to overhead of wrapping every last thing in a object). Those structs are just archived via NSData.

Because Intel Macs are coming soon...

I think it was mentioned that data read/written by the NSArchiver/ NSKeyedArchiver would do the proper byte-swapping for you. But in terms of archiving NSData objects, Cocoa couldn't know about the the contents of the object. It could be anything from a byte stream that wouldn't need swapping to a mixture of various container types and sizes that would.

Somebody correct me if I'm wrong about what I just wrote.

If byte-swapping is needed, you can use NSHostByteOrder to get the endianess of the host and the various NSSwapXXX APIs as needed.

For my needs, I'll pick one of the endian formats to be my data's normalized format. However, I'm going to re-evaluate using objects instead of C-structs. I could then archive everything using things that will get auto-swapped (e.g. NSNumber)

___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Saving C++ based data structures
      • From: Dan Price <email@hidden>
References: 
 >Saving C++ based data structures (From: Dan Price <email@hidden>)
 >Re: Saving C++ based data structures (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Are NSViews autoreleased or released?
  • Next by Date: scrolling with MightyMouse
  • Previous by thread: Re: Saving C++ based data structures
  • Next by thread: Re: Saving C++ based data structures
  • Index(es):
    • Date
    • Thread