File: index.html

package info (click to toggle)
libtpl 1.5-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 4,284 kB
  • ctags: 748
  • sloc: sh: 10,059; ansic: 5,644; perl: 1,062; makefile: 119; cpp: 32
file content (162 lines) | stat: -rwxr-xr-x 4,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XTHML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <title>tpl home page</title>
  </head>
  <body>

  <div id="banner">
  <img src="img/banner.png" alt="easy data storage and retrieval in C" />
  </div> <!-- banner -->

  <div id="topnav">
  <a href="http://sourceforge.net/projects/tpl/">sf.net summary page</a> &gt;
  tpl home
  </div> <!-- topnav -->

  <hr />
  <div id="mid">

      <div id="nav">


        <h2>documentation</h2>
        <div><a href="userguide.html">user guide</a> (<a href="userguide.html">html</a>, <a href="userguide.pdf">pdf</a>)</div>

        <h2>download</h2>
        <h3>Linux, Mac OSX, Solaris, BSD</h3>
        <div><a href="http://downloads.sourceforge.net/tpl/libtpl-1.5.tar.bz2">libtpl-1.5.tar.bz2</a></div>
        <h3>Visual Studio 2008 Solution</h3>
        <div><a href="http://downloads.sourceforge.net/tpl/tpl-1.5-vs2008.zip">tpl-1.5-vs2008.zip</a></div>

        <h2>last release</h2>
        <div>February, 2010</div>
        <div><a href="ChangeLog.html">ChangeLog</a></div>

        <h2>license</h2>
        <div><a href="license.html">BSD revised</a></div>

        <h2>news feed</h2>
        <div><a href="http://troydhanson.wordpress.com/">updates blog</a> (<a href="http://troydhanson.wordpress.com/feed/">rss</a>)<img alt=" rss" src="img/rss.png"/></div>

        <h2>platforms</h2>
        <div>linux</div>
        <div>os x</div>
        <div>windows</div>
        <div>solaris</div>
        <div>openbsd</div>

        <h2>other projects</h2>
        <div><a href="http://uthash.sourceforge.net/">uthash</a></div>
        <div><a href="http://tkhanson.net/misc/">scripts & snippets</a></div>

        <h2>developer</h2>
        <div>Troy D. Hanson</div>
        <div>tdh at tkhanson.net</div>

      </div> <!-- nav -->

      <div id="main">

<div>
<div class="lead">Efficient serialization in C</div>
You can use tpl to store and reload your C data quickly and easily.
Tpl works with files, memory buffers and file descriptors so it's 
suitable for use as a file format, IPC message format or any scenario
where you need to store and retrieve your data.
</div>

<div>
<div class="lead">Express your data</div>
Just express the type of data you are working with as a tpl format string. For
example, if you have a list of numeric ids and corresponding usernames, your
format string is <em>A(is)</em>.  Map your C variables to the format string and
then pack or unpack data.  The format string lets you focus on your data,
rather than the storage format.
</div>

<div class="listing">
<table summary="example of storing and reloading an integer array">
<tr>
<th>
Storing ids and usernames
</th>
<th>
Reloading ids and usernames
</th>
</tr>
<tr>
<td>
<div class="code">
<pre>
#include "tpl.h"

int main(int argc, char *argv[]) {
    tpl_node *tn;
    int id=0;
    char *name, *names[] = { "joe", "bob", "cary" };

    tn = tpl_map("A(is)", &amp;id, &amp;name);

    for(name=names[0]; id &lt; 3; name=names[++id]) {
        tpl_pack(tn,1);
    }

    tpl_dump(tn, TPL_FILE, "users.tpl");
    tpl_free(tn);
}
</pre>
</div> <!-- code -->
</td>
<td>
<div class="code">
<pre>
#include "tpl.h"

int main(int argc, char *argv[]) {
    tpl_node *tn;
    int id;
    char *name;

    tn = tpl_map("A(is)", &amp;id, &amp;name);
    tpl_load(tn, TPL_FILE, "users.tpl");

    while ( tpl_unpack(tn,1) &gt; 0 ) {
        printf("id %d, user %s\n", id, name);
        free(name);
    }
    tpl_free(tn);
}
</pre>
</div> <!-- code -->
</td>
</tr>
</table>
</div> <!-- listing -->

<div>
<div class="lead">No library dependencies</div>
Tpl does not make your software dependent on any libraries. You can compile its
source code (one file) right into your program.
</div>

<div class="lead">For more information</div>
For a more thorough explanation and more examples, please read the 
<a href="userguide.html">User Guide.</a>

</div> <!-- main -->
</div> <!-- mid -->

   <hr />
  <div id="footer">
    <a href="http://sourceforge.net/projects/tpl"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=157637&amp;type=13" width="120" height="30" alt="SourceForge.net." /></a>
    <p>This project is hosted on SourceForge.net</p>
    <p>$Id: index.html 192 2009-04-24 10:35:30Z thanson $</p>
  </div> <!-- footer -->

  </body>

</html>