1 4. Writing your own reader
Jeroen De Meerleer edited this page 2019-06-05 16:02:22 +02:00

Libpairtwo has built in several readers for different pairing application. However, you might be using an excel file for your competition or you might have built your own application. Libpairtwo provides an interface that enables your to use that file with libpairtwo without the need to make a pull request to the main repository.

The basics

To start creating your own reader, you can easily start with the reader boilerplate. This provides all required methods and probably all required use statements you'll need.

Within the MyReader::read method you should place all your code that reads out your excel file, xml code, etc. Whenever you have a field that should be included for reading out to your application, you can set the with Class::setProperty('value') where Class::getProperty() should be the getter for the same field.

To add players, pairings and other items that should not be alone you can use the Tournament::AddPlayer($player) method (example: to add a player).

If your created implementation does not generate rounds, you can easily generate these by calling the Tournament::pairingsToRounds() method

Examples of readers

You can find some readers in the src/Readers of our repository.