Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

/home/tommi/tntdb/include/tntdb/impl/blob.h

00001 /*
00002  * Copyright (C) 2007-2008 Tommi Maekitalo
00003  * Copyright (C) 2007-2008 Marc Boris Duerner
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  * 
00010  * As a special exception, you may use this file as part of a free
00011  * software library without restriction. Specifically, if other files
00012  * instantiate templates or use macros or inline functions from this
00013  * file, or you compile this file and link it with other files to
00014  * produce an executable, this file does not by itself cause the
00015  * resulting executable to be covered by the GNU General Public
00016  * License. This exception does not however invalidate any other
00017  * reasons why the executable file might be covered by the GNU Library
00018  * General Public License.
00019  * 
00020  * This library is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023  * Lesser General Public License for more details.
00024  * 
00025  * You should have received a copy of the GNU Lesser General Public
00026  * License along with this library; if not, write to the Free Software
00027  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00028  */
00029 
00030 #ifndef TNTDB_IMPL_BLOB_H
00031 #define TNTDB_IMPL_BLOB_H
00032 
00033 #include <tntdb/iface/iblob.h>
00034 
00035 namespace tntdb
00036 {
00037 
00044 class BlobImpl : public IBlob
00045 {
00046     public:
00047         BlobImpl()
00048         { }
00049 
00050         ~BlobImpl()
00051         {
00052             delete[] _data;
00053         }
00054 
00055         virtual void assign(const char* data, std::size_t len);
00056 
00057         virtual char* reserve(std::size_t len, bool shrink);
00058 
00059         virtual IBlob* create() const;
00060 
00061         virtual void destroy();
00062 
00063         static BlobImpl* emptyInstance()
00064         {
00065             static BlobImpl empty(1);
00066             return &empty;
00067         }
00068 
00069     protected:
00070         // ctor, which constructs a instance, with a reference-counter of 1
00071         BlobImpl(int)
00072         { addRef(); }
00073 };
00074 
00075 
00080 static struct BlobDataInitializer
00081 {
00082     BlobDataInitializer()
00083     {
00084         BlobImpl::emptyInstance();
00085     }
00086 } tntdb_blobdata_initializer;
00087 
00088 
00089 }
00090 
00091 #endif // TNTDB_IMPL_BLOB_H
00092 
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6