Listing 1. Hello Persistent World
#include "texas.hh"
#include <stream.h>
PStore* ps = 0;
int main(int argc, const char **argv) {
TEXAS_MAIN_INIT(argc, argv); // initialize the Texas lib
ps = open_pstore("hello.pstore"); // open the persistent store
int* count = 0;
if (!is_root(ps, "COUNT")) { // does a named root already exist?
count = pnew(ps, int)(0); // create a new persistent integer
add_root(ps, int, "COUNT", count); // add a named root
} else {
count = get_root(ps, int, "COUNT"); // get the named root
}
(*count)++;// increment count
count << "Hello Persistent World " << *count << endl;
close_pstore(ps); // close the persistent store, committing
TEXAS_MAIN_UNINIT(); // uninitialize the library
return 0;
}