Chapter 6. Utility classes and functions

Table of Contents

The Path class
Reporting errors, messages and questions.
String utilities

The TBX library provides a number of utility classes and functions to help writing RISC OS applications. None of these are required to be used in a TBX application, other libraries or direct SWI (software interupt calls) could be used instead.

The Path class

The Path class provides methods and properties to work with file/directory names and to interrogate and create them on the storage they are saved in.

One function that is most likely to be used in any application that manipulates a RISC OS file is the Path::file_type method that sets the file type of a RISC OS file.

The load_file and save_file methods are a simple way of loading and saving a block of memory as a file.

A directory can be easily iterated using the Path::Iterator that is returned from the begin and end methods.

The related PathInfo class can be returned from a Path with more details of the file/directory on the disc. This class can also be used to iterate a directory where the this extra information is required for each object iterated.

If you want a set of named properties that can be saved and loaded to a file it is worth considering the TBX PropertySet.

If you want to store textual data in a more hierarchical structure the TagDoc is worth considering.

It is also worth investigating the classes in the tbx::doc if you are writing a document based application.