kpilot/lib
pilotRecord.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <config.h>
00036 #include "options.h"
00037 #include "fakes.h"
00038
00039 #include <string.h>
00040
00041 #include <qregexp.h>
00042
00043 #include <kglobal.h>
00044 #include <kcharsets.h>
00045
00046 #include "pilot.h"
00047 #include "pilotRecord.h"
00048
00049
00050
00051 QString PilotRecordBase::textRepresentation() const
00052 {
00053 return CSL1("[ %1,%2,%3 ]") . arg(attributes(),category(),id());
00054 }
00055
00056 QString PilotRecord::textRepresentation() const
00057 {
00058 return CSL1("[ %1,%2 ]")
00059 .arg(PilotRecordBase::textRepresentation())
00060 .arg(size());
00061 }
00062
00063
00064
00065 int PilotRecord::fAllocated = 0;
00066 int PilotRecord::fDeleted = 0;
00067
00068 void PilotRecord::allocationInfo()
00069 {
00070 #ifdef DEBUG
00071 FUNCTIONSETUP;
00072 DEBUGLIBRARY << fname
00073 << ": Allocated " << fAllocated
00074 << " Deleted " << fDeleted << endl;
00075 #endif
00076 }
00077
00078 PilotRecord::PilotRecord(void *data, int len, int attrib, int cat, recordid_t uid) :
00079 PilotRecordBase(attrib,cat,uid),
00080 fData(0L),
00081 fLen(len),
00082 fBuffer(0L)
00083 {
00084 FUNCTIONSETUPL(4);
00085 fData = new char[len];
00086
00087 memcpy(fData, data, len);
00088
00089 fAllocated++;
00090 }
00091
00092 PilotRecord::PilotRecord(PilotRecord * orig) :
00093 PilotRecordBase( orig->attributes(), orig->category(), orig->id() ) ,
00094 fBuffer(0L)
00095 {
00096 FUNCTIONSETUPL(4);
00097 fData = new char[orig->size()];
00098
00099 memcpy(fData, orig->data(), orig->size());
00100 fLen = orig->size();
00101 fAllocated++;
00102 }
00103
00104 PilotRecord & PilotRecord::operator = (PilotRecord & orig)
00105 {
00106 FUNCTIONSETUP;
00107 if (fBuffer)
00108 {
00109 pi_buffer_free(fBuffer);
00110 fBuffer=0L;
00111 fData=0L;
00112 }
00113
00114 if (fData)
00115 delete[]fData;
00116 fData = new char[orig.size()];
00117
00118 memcpy(fData, orig.data(), orig.size());
00119 fLen = orig.size();
00120 setAttributes( orig.attributes() );
00121 setCategory( orig.category() );
00122 setID( orig.id() );
00123 return *this;
00124 }
00125
00126 void PilotRecord::setData(const char *data, int len)
00127 {
00128 FUNCTIONSETUP;
00129 if (fData)
00130 delete[]fData;
00131 fData = new char[len];
00132
00133 memcpy(fData, data, len);
00134 fLen = len;
00135 }
00136
|