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

/home/tommi/tntdb/include/tntdb/iface/iblob.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_IFACE_IBLOB_H
00031 #define TNTDB_IFACE_IBLOB_H
00032 
00033 #include <cxxtools/refcounted.h>
00034 #include <cstddef>
00035 #include <cstring>
00036 
00037 namespace tntdb
00038 {
00039 
00050 class IBlob : public cxxtools::RefCounted
00051 {
00052     public:
00055         virtual ~IBlob();
00056 
00062         virtual void assign(const char* data, std::size_t len) = 0;
00063 
00066         virtual char* reserve(std::size_t len, bool shrink) = 0;
00067 
00074         virtual IBlob* create() const = 0;
00075 
00080         virtual void destroy() = 0;
00081 
00084         std::size_t size() const
00085         { return _size; }
00086 
00089         const char* data() const
00090         { return _data; }
00091 
00094         bool operator==(const IBlob& other) const
00095         {
00096             return _size == other._size &&
00097                 ( std::strncmp(_data, other._data, _size) == 0 );
00098         }
00099 
00100     protected:
00101         IBlob()
00102         : _data(0)
00103         , _size(0)
00104         { }
00105 
00106         char* _data;
00107         std::size_t _size;
00108 };
00109 
00110 }
00111 
00112 #endif
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6