CTPL overview

Introduction
Advantages and disadvantages
Working design
The lexer
The parser
Syntax
Raw data
Template blocks
Examples

Introduction

CTPL is a template library written in C. It allows in-memory fast and easy parsing of templates and fine control over template parsing environment.

CTPL depends on the following libraries:

GLib

General purpose C utility library

LibMB

FILE-like API for memory buffer read/write

Advantages and disadvantages

Advantages

  • It is a library, then it can be easily used from programs

  • It is written in standard C, which gives portability, speed and easy portage to other languages (as most of languages supports additions written in C).

  • Simple syntax

  • Fast and strict parsing

  • In-memory parsing, allowing non-file data parsing and avoiding I/O-latencies.

Disadvantages

  • Full in-memory parsing requires to load the whole template in memory, which may lead to huge memory consumption with large templates. The memory usage is about 2 times the input template size.

    Note that the memory consumption may be reduced if we or LibMB start supporting file-stream read/write.