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