55 if (_len == 0)
return false;
56 if (!p || (*p != *_str))
return false;
58 const char* s = _str+1;
62 if (l==0)
return false;
63 if (*s != *p)
return false;
89 const char* s = _str+1;
93 if ((l>0) && (c ==
'x') && (v==0)) {
100 if (c>=
'0' && c<=
'9')
102 else if (c>=
'a' && c<=
'f')
103 v = 16*v + 10 + (c-
'a');
104 else if (c>=
'A' && c<=
'F')
105 v = 16*v + 10 + (c-
'A');
117 if (c<'0' || c>
'9')
break;
144 while((_len>0) && (*_str==
' ')) {
150 while((_len>0) && (_str[_len-1]==
' ')) {
157 while((_len>0) && (*_str==
' ')) {
165 if (_len==0)
return false;
168 if (!
QChar(*_str).
isLetter() && (*_str !=
'_'))
return false;
171 const char* newStr = _str;
178 && (*_str !=
'_'))
break;
185 s.
set(newStr, newLen);
193 const char* newStr = _str;
218 if (c<'0' || c>
'9') {
224 const char* s = _str+1;
228 if ((l>0) && (c ==
'x') && (v==0)) {
235 if (c>=
'0' && c<=
'9')
237 else if (c>=
'a' && c<=
'f')
238 v = 16*v + 10 + (c-
'a');
239 else if (c>=
'A' && c<=
'F')
240 v = 16*v + 10 + (c-
'A');
251 if (c<'0' || c>
'9')
break;
281 if (c<'0' || c>
'9') {
287 const char* s = _str+1;
291 if ((l>0) && (c ==
'x') && (v==0)) {
298 if (c>=
'0' && c<=
'9')
300 else if (c>=
'a' && c<=
'f')
301 v = 16*v + 10 + (c-
'a');
302 else if (c>=
'A' && c<=
'F')
303 v = 16*v + 10 + (c-
'A');
315 if (c<'0' || c>
'9')
break;
351 _filename = filename;
352 if (!file->
isOpen() && !file->
open( QIODevice::ReadOnly ) ) {
366 #if QT_VERSION >= 0x040400
368 if (file->
size() >0) {
369 QFile* mappableDevice =
dynamic_cast<QFile*
>(file);
370 if (mappableDevice) {
371 addr = mappableDevice->
map( 0, file->
size() );
378 _base = (
char*) addr;
382 if (0) qDebug(
"Mapped '%s'", qPrintable( _filename ));
388 _base = _data.
data();
400 if (_used_mmap && _file) {
401 if (0) qDebug(
"Unmapping '%s'", qPrintable( _filename ));
402 #if QT_VERSION >= 0x040400
403 QFile* mappableDevice =
dynamic_cast<QFile*
>(_file);
404 Q_ASSERT(mappableDevice);
405 if (!mappableDevice->
unmap( (uchar*) _base ))
406 qWarning(
"munmap: %s", strerror( errno ) );
413 if (_currentLeft == 0)
return false;
415 unsigned left = _currentLeft;
419 if (*current == 0 || *current ==
'\n')
break;
426 int l = _currentLeft-left;
428 strncpy(tmp, _current, l);
430 qDebug(
"[FixFile::nextLine] At %lu, len %u: '%s'",
431 (
unsigned long) (_current - _base), _currentLeft-left, tmp);
434 int len = _currentLeft-left;
436 if ((len>0) && (*(current-1) ==
'\r')) len--;
437 str.
set(_current, len);
439 if (*current ==
'\n') {
451 if (pos > _len)
return false;
453 _current = _base + pos;
454 _currentLeft = _len - pos;
482 if (count <= firstLen) {
484 for (i=0;i<
count;i++)
void stripSpaces()
Strip leading spaces.
bool stripUInt(uint &, bool stripSpaces=true)
virtual bool seek(qint64 pos)
bool setCurrent(unsigned pos)
unsigned long long uint64
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
void stripSurroundingSpaces()
Strip leading and trailing spaces.
virtual qint64 size() const
bool stripInt64(int64 &, bool stripSpaces=true)
bool unmap(uchar *address)
A simple, constant string class.
FixFile(QIODevice *, const QString &)
bool stripName(FixString &)
Strip name: [A-Za-z_][0-9A_Za-z_]*.
bool stripPrefix(const char *)
void set(const char *s, int l)
FixString stripUntil(char)
Strip string until char appears or end.
bool nextLine(FixString &str)
Read next line into .
bool stripUInt64(uint64 &, bool stripSpaces=true)
uchar * map(qint64 offset, qint64 size, MemoryMapFlags flags)
QByteArray encodeName(const QString &fileName)
bool isLetterOrNumber() const