4

I'm tasked with reading Apple's property list files within a c++ application. Focusing primarily on the xml-type plist files specified in OS X, which mimic a xml-type implementation.. Apple's implementation of their property list is described here:

http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/plist.5.html

I'm wondering if there are classes or libraries available that already can read this type of implementation within standard c++ (not Objective-C); hoping to find something rather than rolling our own. Are there any open-source implementations of this available?

cyrix
  • 308
  • 2
  • 7
  • Are you on the OS X environment? Can you make use of a C++/Obj-C Bridge to call the native API's to access the plist file? Otherwise I'd use Xerces and parse it as XML. – Alan Oct 08 '09 at 17:46
  • http://stackoverflow.com/questions/1061005/calling-objective-c-method-from-c-method has some info on how to call Obj-C from C++ – Alan Oct 08 '09 at 17:49
  • https://github.com/animetrics/PlistCpp this looks like recent and fairly nice contender. – berkus Oct 02 '13 at 20:26

3 Answers3

1

PList files are not only mimicing XML, they are XML, including valid XML headers.

Any XML reader should be able to parse these files as a result. If you're looking for a logical class that abstracts the files, I'm not aware of any existing ones. Given Apple's documentation, you should be able to write one yourself with an XML reader, although it would take some work for full compatibility.

Will Eddins
  • 13,628
  • 5
  • 51
  • 85
  • External dlls was not an option.. However it did validate, and we were able to use TinyXml to parse the plist file and manually throw the key/value pairs into a data structure.. – cyrix Oct 21 '09 at 06:05
1

For topic starter it is too late, I know, but maybe it helps somebody

https://github.com/animetrics/PlistCpp

This is a C++ Property List (plist) serialization library (MIT license). It supports both XML and binary versions of the plist format and is designed to be cross platform with minimal dependencies.

0

Is that target-specific?

For Windows, there is a crude solution which consists of using the functions of iTunes dynamic libraries to parse plist files (either binary or plain text format work).

That's a code originally written to interface an iPod, but you can easily extract the few functions you are interested in.

The repository is on this project page: http://code.google.com/p/t-pot/

Look for the file iPoTApi.h and iPoTApi.cpp, the function TranslatePLIST of the class CiPoTApi.

I wish there were a better solution, at the time I tried to compile it from Apple's sources targeted at Windows but it is a real nightmare, and files are missing. So using their libraries was a considerable shortcut.

RedGlyph
  • 11,309
  • 6
  • 37
  • 49