Functions
qcstring.cpp File Reference
#include "qcstring.h"
#include "qgstring.h"
#include <qstring.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <qregexp.h>
#include <qdatastream.h>

Go to the source code of this file.

Functions

void * qmemmove (void *dst, const void *src, uint len)
 
char * qstrdup (const char *str)
 
char * qstrncpy (char *dst, const char *src, uint len)
 
int qstricmp (const char *str1, const char *str2)
 
int qstrnicmp (const char *str1, const char *str2, uint len)
 
QDataStreamoperator<< (QDataStream &s, const QByteArray &a)
 
QDataStreamoperator>> (QDataStream &s, QByteArray &a)
 
QDataStreamoperator<< (QDataStream &s, const QCString &str)
 
QDataStreamoperator>> (QDataStream &s, QCString &str)
 
QCString operator+ (const QCString &s1, const QGString &s2)
 
QCString operator+ (const QGString &s1, const QCString &s2)
 

Function Documentation

QCString operator+ ( const QCString s1,
const QGString s2 
)
inline

Definition at line 650 of file qcstring.cpp.

651 {
652  QCString tmp(s1);
653  tmp += s2.data();
654  return tmp;
655 }
char * data() const
Definition: qgstring.h:42
string tmp
Definition: languages.py:63
QCString operator+ ( const QGString s1,
const QCString s2 
)
inline

Definition at line 657 of file qcstring.cpp.

658 {
659  QCString tmp(s1.data());
660  tmp += s2;
661  return tmp;
662 }
char * data() const
Definition: qgstring.h:42
string tmp
Definition: languages.py:63
QDataStream& operator<< ( QDataStream s,
const QByteArray a 
)

Definition at line 600 of file qcstring.cpp.

601 {
602  return s.writeBytes( a.data(), a.size() );
603 }
type * data() const
Definition: qarray.h:63
QDataStream & writeBytes(const char *, uint len)
uint size() const
Definition: qarray.h:65
QDataStream& operator<< ( QDataStream s,
const QCString str 
)

Definition at line 624 of file qcstring.cpp.

625 {
626  return s.writeBytes( str.data(), str.size() );
627 }
uint size() const
Definition: qcstring.h:201
QDataStream & writeBytes(const char *, uint len)
const char * data() const
Definition: qcstring.h:207
QDataStream& operator>> ( QDataStream s,
QByteArray a 
)

Definition at line 605 of file qcstring.cpp.

606 {
607  Q_UINT32 len;
608  s >> len; // read size of array
609  if ( len == 0 || s.eof() ) { // end of file reached
610  a.resize( 0 );
611  return s;
612  }
613  if ( !a.resize( (uint)len ) ) { // resize array
614 #if defined(CHECK_NULL)
615  qWarning( "QDataStream: Not enough memory to read QByteArray" );
616 #endif
617  len = 0;
618  }
619  if ( len > 0 ) // not null array
620  s.readRawBytes( a.data(), (uint)len );
621  return s;
622 }
bool resize(uint size)
Definition: qarray.h:69
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
type * data() const
Definition: qarray.h:63
bool eof() const
Definition: qdatastream.h:129
QDataStream & readRawBytes(char *, uint len)
unsigned int Q_UINT32
Definition: qglobal.h:420
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
QDataStream& operator>> ( QDataStream s,
QCString str 
)

Definition at line 629 of file qcstring.cpp.

630 {
631  Q_UINT32 len;
632  s >> len; // read size of string
633  if ( len == 0 || s.eof() ) { // end of file reached
634  str.resize( 0 );
635  return s;
636  }
637  if ( !str.resize( (uint)len )) {// resize string
638 #if defined(CHECK_NULL)
639  qWarning( "QDataStream: Not enough memory to read QCString" );
640 #endif
641  len = 0;
642  }
643  if ( len > 0 ) // not null array
644  s.readRawBytes( str.rawData(), (uint)len );
645  return s;
646 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
bool eof() const
Definition: qdatastream.h:129
QDataStream & readRawBytes(char *, uint len)
unsigned int Q_UINT32
Definition: qglobal.h:420
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
void* qmemmove ( void *  dst,
const void *  src,
uint  len 
)

Definition at line 530 of file qcstring.cpp.

531 {
532  register char *d;
533  register char *s;
534  if ( dst > src ) {
535  d = (char *)dst + len - 1;
536  s = (char *)src + len - 1;
537  while ( len-- )
538  *d-- = *s--;
539  } else if ( dst < src ) {
540  d = (char *)dst;
541  s = (char *)src;
542  while ( len-- )
543  *d++ = *s++;
544  }
545  return dst;
546 }
static QCString * s
Definition: config.cpp:1042
char* qstrdup ( const char *  str)

Definition at line 548 of file qcstring.cpp.

549 {
550  if ( !str )
551  return 0;
552  char *dst = new char[qstrlen(str)+1];
553  CHECK_PTR( dst );
554  return strcpy( dst, str );
555 }
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
#define CHECK_PTR(p)
Definition: qglobal.h:601
static QCString str
int qstricmp ( const char *  str1,
const char *  str2 
)

Definition at line 567 of file qcstring.cpp.

568 {
569  register const uchar *s1 = (const uchar *)str1;
570  register const uchar *s2 = (const uchar *)str2;
571  int res;
572  uchar c;
573  if ( !s1 || !s2 )
574  return s1 == s2 ? 0 : (int)((long)s2 - (long)s1);
575  for ( ; !(res = (c=tolower(*s1)) - tolower(*s2)); s1++, s2++ )
576  if ( !c ) // strings are equal
577  break;
578  return res;
579 }
unsigned char uchar
Definition: nybbler.cc:11
char* qstrncpy ( char *  dst,
const char *  src,
uint  len 
)

Definition at line 557 of file qcstring.cpp.

558 {
559  if ( !src )
560  return 0;
561  strncpy( dst, src, len );
562  if ( len > 0 )
563  dst[len-1] = '\0';
564  return dst;
565 }
int qstrnicmp ( const char *  str1,
const char *  str2,
uint  len 
)

Definition at line 581 of file qcstring.cpp.

582 {
583  register const uchar *s1 = (const uchar *)str1;
584  register const uchar *s2 = (const uchar *)str2;
585  int res;
586  uchar c;
587  if ( !s1 || !s2 )
588  return (int)((long)s2 - (long)s1);
589  for ( ; len--; s1++, s2++ ) {
590  if ( (res = (c=tolower(*s1)) - tolower(*s2)) )
591  return res;
592  if ( !c ) // strings are equal
593  break;
594  }
595  return 0;
596 }
unsigned char uchar
Definition: nybbler.cc:11