kpilot

pilotDOCHead.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 dealing with PalmDOC text records
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 #include "options.h"
00029 #include "pilotDOCHead.h"
00030 
00031 #include "makedoc9.h"
00032 
00033 
00034 
00035 const int PilotDOCHead::textRecordSize = 4096;
00036 
00037 PilotDOCHead::PilotDOCHead():PilotRecordBase(),
00038 version(0),
00039 spare(0), storyLen(0), numRecords(0), recordSize(textRecordSize), position(0)
00040 {
00041     FUNCTIONSETUP;
00042 }
00043 
00044 
00045 
00046 /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDOCHead()
00047 */
00048 PilotDOCHead::PilotDOCHead(PilotRecord * rec):PilotRecordBase(rec)
00049 {
00050     const unsigned char *b = (const unsigned char *) rec->data();
00051     unsigned int offset = 0;
00052 
00053     version = Pilot::dlp<short>::read(b,offset);
00054     spare = Pilot::dlp<short>::read(b,offset);
00055     storyLen = Pilot::dlp<long>::read(b,offset);
00056     numRecords = Pilot::dlp<short>::read(b,offset);
00057     recordSize = Pilot::dlp<short>::read(b,offset);
00058     position = Pilot::dlp<long>::read(b,offset);
00059 }
00060 
00061 
00062 PilotDOCHead::PilotDOCHead(const PilotDOCHead & e):PilotRecordBase(e)
00063 {
00064     FUNCTIONSETUP;
00065     *this = e;
00066 }
00067 
00068 
00069 
00070 PilotDOCHead & PilotDOCHead::operator =(const PilotDOCHead & e)
00071 {
00072     if (this != &e)
00073     {
00074         version = e.version;
00075         spare = e.spare;
00076         storyLen = e.storyLen;
00077         numRecords = e.numRecords;
00078         recordSize = e.recordSize;
00079         position = e.position;
00080     }
00081     return *this;
00082 }
00083 
00084 
00085 
00086 
00087 PilotRecord *PilotDOCHead::pack() const
00088 {
00089     pi_buffer_t *b = pi_buffer_new(16);
00090 
00091     Pilot::dlp<short>::append(b,version);
00092     Pilot::dlp<short>::append(b,spare);
00093     Pilot::dlp<long>::append(b,storyLen);
00094     Pilot::dlp<short>::append(b,numRecords);
00095     Pilot::dlp<short>::append(b,recordSize);
00096     Pilot::dlp<long>::append(b,position);
00097 
00098     PilotRecord *rec =  new PilotRecord(b, this);
00099     return rec;
00100 }
00101