FFDB1 is a simple C++ flat text file database implemented using STL. It consists of a single program, gen_ffdb, which generates a header file with a structure declaration, a rowset definition and two functions for reading/writing a complete rowset from/to a file. The datatypes it supports are:
Simply type
make
And it will build the executable. The Makefile assumes that you use g++, but you can change this in the Makefile. You may want to type make unittest to ensure that everything works as expected.
Synopsis
gen_ffdb tablename fielddef1 [fielddef2 ...]
The tablename is used as the name for the structure and the basename for the generated .h and .cc files. A field definition is in the form name:type
If you run
gen_ffdb foo id:i name:s password:r can_su:b quota:f
It will generate two files:foo.h and foo.cc. The header file foo.h will be:
#ifndef _foo_H_ #define _foo_H_ #include <vector> #include <inttypes.h> #include <string> struct foo { int64_t id; std::string name; std::string<uint8_t> password; bool can_su; double quota; }; typedef std::vector<foo> RowSet_foo; bool LoadFromFile(const char *filename, RowSet_foo *result); bool WriteToFile(const char *filename, const RowSet_foo &rowset); #endif
and foo.cc will implement the two functions.
Yes. But you didn't. Did you? And now you save some time by not having to implement it yourself.
(same as zlib/libpng license)
Copyright (c) 2003 Ivan Skytte Jørgensen This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.
ffdb1-1.0.tar.gz (3KB)