Skip to content

A library for representing hierarchical data in a uniform way across multiple platforms

License

Notifications You must be signed in to change notification settings

oneill1979/protean

 
 

Repository files navigation

Protean

Description

Protean is a library for representing hierarchical data in a uniform way across multiple platforms.

The library defines a variant object that can hold primitive data as well as collections (e.g. lists, dictionaries) with arbitrary depth. The variant can be inspected, enumerated, and/or serialised to XML/binary format.

Protean has implementations in C++ and C#.

Compilation

Unfortunately, compilation methods are currently mostly untested. We plan to add further methods later. If you figure out another method not yet described here, please submit a pull request.

One method, which is known to work on Windows, is the following:

  • Install Boost. (Known to work with version 1.53.0.)
  • Install Xerces. (Known to work with version 3.1.1.)
  • Copy projects/vc1x/vc1x-paths.props.template to projects/vc1x/vc1x-paths.props, and edit projects/vc1x/vc1x-paths.props, setting BOOST_VERSION, BOOST_ROOT, and XERCES_ROOT appropriately.
  • Open projects/vc1x-protean.sln in Visual Studio 2010/2012.
  • If you don't have NUnit installed, install NUnit or unload project "vc1x-test-protean.net".
  • Choose a configuration, e.g. vc110 Debug and x64, and Build Solution.

Usage examples

Generating and outputting XML

using namespace protean;
variant root(variant::Dictionary);
variant books(variant::Dictionary);
variant book(variant::Dictionary);
variant book_attrs(variant::Dictionary);
book_attrs.insert("author", variant("XYZ"));
book_attrs.insert("year", variant(2013));
book.insert(xml_attributes, book_attrs);
book.insert(xml_text, variant("some text"));
books.insert("book", book);
root.insert("books", books);
std::stringstream contents;
xml_writer xw(contents, xml_mode::Preserve | xml_mode::Indent);
xw << root;
std::cout << contents.str() << std::endl;

This will output:

<?xml version="1.0" encoding="utf-8"?>
<books>
  <book author="XYZ" year="2013">some text</book>
</books>

Contributing

We welcome constructive feedback. Please make use of GitHub's issue tracking and pull requests.

About

A library for representing hierarchical data in a uniform way across multiple platforms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 66.7%
  • C# 30.2%
  • Python 1.7%
  • Shell 1.4%