The LibTPT Book

A Template Language for C++

Isaac W. Foraker

Abstract

This is for the LibTPT template scripting language for C++, based on version 1.30. For the most up to date documentation, go to http://tazthecat.net/~isaac/libtpt/.


Table of Contents

Introduction
What is LibTPT?
Why LibTPT?
Who needs LibTPT?
1. Compilation and Installation
Supported Platforms/Compilers
Where to get LibTPT
Building on Windows
Building on Unix
2. The TPT template language
A quick sample
Reserved Characters
Variables
Comments
Expressions
Whitespace & Carriage Returns
Macros
3. The C++ Interface
A quick sample
4. Writing a TPT callback function
What is a callback?
Uses for Callbacks
The Callback Interface
TPT Callbacks and Security
A. TPT Reference
Preprocessor control
@# comment
@tpt_ignoreindent, @tpt_noignoreindent
@tpt_ignoreblankline, @tpt_noignoreblankline
@<, @>
@include
@includetext
Setting Variables
@set
@setif
@unset
@push
@pop
Conditional Parsing
@if/@elsif/@else
Loops
@while
@foreach
String Functions
@compare, @comp, @strcmp
@concat
@substr
@length
@empty
@lc
@uc
@lpad
@rpad
@repeat
Math Functions
@avg
@sum
Array Functions
@isarray
@size
Hash Functions
@ishash
@keys
General Functions
@eval
@rand
B. C++ Reference
Namespace TPT
Classes
TPT::Parser
TPT::IParser
TPT::Buffer
TPT::Symbols
TPT::Object
C. TPT Command Line Interface
CLI Description
Command Line Options
TPT CLI and CGI
D. Converting from PML to TPT
Strings
Carriage returns
Functions
Unsupported PML
E. Project Specifics
License
Credits
Reporting bugs

List of Examples

2.1. helloworld.tpt
2.2. Contents of a fruit basket
2.3. A fruit basket array
2.4. Random array index
4.1. A callback example: @fsum()
D.1. Strings in PML and TPT
D.2. Carriage Returns in PML and TPT