Classes

TPT::Parser

#include <libtpt/parse.h>

The TPT::Parser class is the primary interface to the TPT library. For basic template processing, TPT::Parser is the only class you will need.

Parser(const char* filename);
Parser(const char* filename, const Symbols& st);
Parser(const char* buf, unsigned long size);
Parser(const char* buf, unsigned long size, const Symbols& st);
Parser(Buffer& buf);
Parser(Buffer& buf, const Symbols& st);

TPT::IParser

(1.20+)

#include <libtpt/iparse.h>

The TPT::IParser class is the Interactive version of the TPT::Parser class. This version writes updates to the Symbols table back to the Symbols table passed in by the user. This is useful when there is a need to maintain state information between processing templates, or to pass state information back to the calling C++ program.

IParser(const char* filename, Symbols& st);
IParser(const char* buf, unsigned long size, Symbols& st);
IParser(Buffer& buf, Symbols& st);

TPT::Buffer

#include <libtpt/buffer.h>

The TPT::Buffer class is the base IO class for reading TPT source. Instantiating a TPT::Buffer directly is a useful optimization when you will be parsing the same template repeatedly. A TPT::Buffer is not required to parse a TPT template.

explicit Buffer(const char* filename);
explicit Buffer(std::istream* is);
explicit Buffer(const char* buffer, unsigned long size);
explicit Buffer(const Buffer& buf, unsigned long start, unsigned long end);

TPT::Symbols

#include <libtpt/symbols.h>

The TPT::Symbols class may be used to predefine a symbols table for a TPT template before the template is passed to TPT::Parser. The TPT::Symbols object must be populated before it is passed to the TPT::Parser. A TPT::Symbols table is not required to parse a TPT template.

TPT::Object

#include <libtpt/object.h>

The TPT::Object class is intended for intermediate to advanced users. The TPT::Object is the internal representation of data used within LibTPT. TPT::Object is designed with speed and exception safety in mind.

TPT::Object is designed to hold generic data including scalars or strings, arrays, and hashes. TPT::Objects are versatile, so an array or hash container may hold another array or hash container. The gettype() method is used to determine the type of Object being stored, and the either the scalar(), array(), or hash() method is used to access the object. If the incorrect accessor is used, TPT::Object will throw an exception.

There are two basic uses for TPT::Object in your code. First, to access variables passed to a user defined callback function. Second, to set up complex data structures before entering the TPT Parser.