Harpoon library v 5.5 Author: Michal Czardybon Licensi: Public Domain Harpoon is a data description language. This library provides means for harpoon data representation, manipulation, serialization and deserialization. For more information about the language, visit the web site: http://harpoon.sourceforge.net Most important files: Data.h Declarations of classes representing harpoon data in memory (trees of objects). DataIO.h Declarations of functions loading and saving harpoon data from or to text files. Utils.h Additional functions. Io.h Definitions of data types required for deserialization and errors handling (exceptions). IoLib (directory) Parsing library created for Harpoon, but intended to be language-independent. Io.h file actually belongs to this library. Types.h Declaration of functions checking and imposing types. Reference: Basics: * Most often you will need to include Data.h and DataIO.h headers in your files. * All Harpoon data types and functions exist in 'hrp' namespace, so write 'hrp::Data' instead of just 'Data'. Optionally you can include the whole namespace with 'using namespace hrp;'. * Your code should be contained in a 'try' block followed by 'catch' blocks for at least 'hrp::Error' exception and, what is recommended, also for 'hrp::LexicalError', 'hrp::SyntaxError', 'hrp::DataAccessError'. * Header files (*.h) are written so that they should provide self-explaining documentation of data types and functions. * Use 'deserialize' (DataIO.h) functions to read Harpoon data from files. * Use 'serialize' (DataIO.h) functions to write Harpoon data to files. * Use methods of 'Data', 'Int', 'Record' etc. (Data.h) classes to access or modify in-memory data (see the class diagram). * Use 'as' methods to down-cast data, e.g. 'as()', 'as()'. Const-correctness will be preserved. * You can write 'as', 'as', 'as', 'as' and 'as' for fast access of primitive values. * In Visual Studio 2003 turn on "Enable Run-Time Type Info" option. Sample code: try { std::auto_ptr data( deserialize_from_file( "sample.hrp" )->as() ); printf("name = %d\n", data->peek("name")->as()->value().c_str() ); printf("age = %d\n", data->peek("age")->as()->value() ); } catch ( Error& er ) { printf("ERROR: %s\n", er.msg.c_str() ); } where "sample.hrp" contains: Person( name = "John" age = 28 )