SourceForge.net Logo

One syntax to rule them all

Last modified on 2008/03/05



Download whole package (C++, C#) from Sourceforge: Harpoon-5.8....zip

(New: Types are implemented in C++ (beta version)).


These libraries are quite simple and easy to use. For example, to read information from file "sample.hrp" containing:


name = "John"

age = 28


one should use a code similar to this:

try {

Record* data =

deserialize_from_file( "sample.hrp" )->as< Record >();

string name = data->peek("name")->as< String >()->value();

int age = data->peek("age")->as< Int >()->value();

delete data;


catch ( Error& er ) {

printf("ERROR: %s\n", er.msg.c_str() );


For more information see the readme.txt file, or see the pseudo class diagram:


(beta version)

There are two functions declared in Types.h:

  • check_types - returns true iff the data is type-correct,

  • impose_types - tries to modify the data so that it is type-correct.

The functions take a data pointer, a type (optionally), a type dictionary and a list of type errors (to be fed).



const Data* data,

const Record* type,

const TypeDictionary& dict,

std::list<TypeError>& errors




Data*& data, // or std::auto_pt<Data>

const Record* type,

const TypeDictionary& dict,

std::list<TypeError>& errors


Parameter type is optional - without it the functions will check types accordingly to the data tags.

The type dictionary has to be created first. For example:

// Prepare a type dictionary

TypeDictionary dict;

// Add types from a file

dict.add( deserialize_from_file("types.hrp")->as< List >() );

// Get main type

const Record* root_type = dict.find("Document");

// Prepare list of type errors

std::list < TypeError > errors;

// Invoke type checking

if ( check_types( data, root_type, dict, errors ) )




For more details see the Types.h file.