kpilot

pilotDOCBookmark.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2002 by Reinhold Kainhofer
00004 **
00005 ** This is a C++ class for the DOC bookmark record structure
00006 */
00007 
00008 /*
00009 ** This program is free software; you can redistribute it and/or modify
00010 ** it under the terms of the GNU General Public License as published by
00011 ** the Free Software Foundation; either version 2 of the License, or
00012 ** (at your option) any later version.
00013 **
00014 ** This program is distributed in the hope that it will be useful,
00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 ** GNU General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022 ** MA 02110-1301, USA.
00023 */
00024 
00025 /*
00026 ** Bug reports and questions can be sent to kde-pim@kde.org
00027 */
00028 
00029 #include "options.h"
00030 #include "pilotDOCBookmark.h"
00031 
00032 
00033 
00034 PilotDOCBookmark::PilotDOCBookmark():PilotRecordBase(), pos(0)
00035 {
00036     FUNCTIONSETUP;
00037     memset(&bookmarkName[0], 0, 16);
00038 }
00039 
00040 
00041 
00042 /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDOCBookmark()
00043 */
00044 PilotDOCBookmark::PilotDOCBookmark(PilotRecord * rec):PilotRecordBase(rec)
00045 {
00046     if (rec)
00047     {
00048         const pi_buffer_t *b = rec->buffer();
00049         unsigned int offset = 0;
00050         Pilot::dlp<char *>::read(b,offset,bookmarkName,16);
00051         bookmarkName[16]='\0';
00052         pos = Pilot::dlp<long>::read(b,offset);
00053     }
00054 }
00055 
00056 
00057 
00058 PilotDOCBookmark::PilotDOCBookmark(const PilotDOCBookmark & e):PilotRecordBase(e)
00059 {
00060     FUNCTIONSETUP;
00061     *this = e;
00062 }
00063 
00064 
00065 
00066 PilotDOCBookmark & PilotDOCBookmark::operator =(const PilotDOCBookmark & e)
00067 {
00068     if (this != &e)
00069     {
00070         strncpy(&bookmarkName[0], &e.bookmarkName[0], 16);
00071         bookmarkName[16]='\0';
00072         pos = e.pos;
00073     }
00074     return *this;
00075 }
00076 
00077 
00078 
00079 PilotRecord *PilotDOCBookmark::pack() const
00080 {
00081     pi_buffer_t *b = pi_buffer_new( 16 + Pilot::dlp<long>::size );
00082     pi_buffer_append(b, bookmarkName, 16);
00083     b->data[16] = 0;
00084     Pilot::dlp<long>::append(b,pos);
00085     PilotRecord* rec =  new PilotRecord(b, this);
00086     return rec;
00087 }