pilotRecord.cc
00001
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 #include "options.h"
00035
00036 #include <string.h>
00037
00038 #include <qtextcodec.h>
00039
00040
00041
00042
00043 #include "pilotAppCategory.h"
00044
00045
00046
00047 static const char *pilotRecord_id =
00048 "$Id: pilotRecord.cc,v 1.3.4.7 2003/03/10 23:06:19 adridg Exp $";
00049
00050 int PilotRecord::fAllocated = 0;
00051 int PilotRecord::fDeleted = 0;
00052
00053 void PilotRecord::allocationInfo()
00054 {
00055 #ifdef DEBUG
00056 FUNCTIONSETUP;
00057 DEBUGKPILOT << fname
00058 << ": Allocated " << fAllocated
00059 << " Deleted " << fDeleted;
00060 #endif
00061 }
00062
00063 PilotRecord::PilotRecord(void *data, int len, int attrib, int cat,
00064 pi_uid_t uid) :
00065 fData(0L),
00066 fLen(len),
00067 fAttrib(attrib),
00068 fCat(cat),
00069 fID(uid)
00070 {
00071 FUNCTIONSETUP;
00072 fData = new char[len];
00073
00074 memcpy(fData, data, len);
00075
00076 fAllocated++;
00077 (void) pilotRecord_id;
00078 }
00079
00080 PilotRecord::PilotRecord(PilotRecord * orig)
00081 {
00082 FUNCTIONSETUP;
00083 fData = new char[orig->getLen()];
00084
00085 memcpy(fData, orig->getData(), orig->getLen());
00086 fLen = orig->getLen();
00087 fAttrib = orig->getAttrib();
00088 fCat = orig->getCat();
00089 fID = orig->getID();
00090
00091 fAllocated++;
00092 }
00093
00094 PilotRecord & PilotRecord::operator = (PilotRecord & orig)
00095 {
00096 FUNCTIONSETUP;
00097 if (fData)
00098 delete[]fData;
00099 fData = new char[orig.getLen()];
00100
00101 memcpy(fData, orig.getData(), orig.getLen());
00102 fLen = orig.getLen();
00103 fAttrib = orig.getAttrib();
00104 fCat = orig.getCat();
00105 fID = orig.getID();
00106 return *this;
00107 }
00108
00109 void PilotRecord::setData(const char *data, int len)
00110 {
00111 FUNCTIONSETUP;
00112 if (fData)
00113 delete[]fData;
00114 fData = new char[len];
00115
00116 memcpy(fData, data, len);
00117 fLen = len;
00118 }
00119
00120
00121 QTextCodec *PilotAppCategory::pilotCodec = 0L;
00122
00123 static const char *latin1 = "ISO8859-1" ;
00124
00125
00126 QTextCodec *PilotAppCategory::createCodec(const char *p)
00127 {
00128 FUNCTIONSETUP;
00129
00130 if (!p) p=latin1;
00131 #ifdef DEBUG
00132 DEBUGKPILOT << ": Creating codec for " << p << endl;
00133 #endif
00134 QTextCodec *q = QTextCodec::codecForName(p);
00135 if (!q) q = QTextCodec::codecForName(latin1);
00136 pilotCodec = q;
00137 return q;
00138 }
00139
00140 QTextCodec *PilotAppCategory::setupPilotCodec(const QString &s)
00141 {
00142 FUNCTIONSETUP;
00143
00144 #ifdef DEBUG
00145 DEBUGKPILOT << fname
00146 << ": Creating codec " << s << endl;
00147 #endif
00148
00149 const char *p = 0L;
00150
00151
00152
00153 if (!s.isEmpty()) p=s.latin1();
00154
00155 (void) PilotAppCategory::createCodec(p);
00156
00157 #ifdef DEBUG
00158 DEBUGKPILOT << fname
00159 << ": Got codec " << codec()->name() << endl;
00160 #endif
00161 return codec();
00162 }
00163
This file is part of the documentation for kdelibs Version 3.1.5.