Classes | Macros | Typedefs | Functions
qcstring.h File Reference
#include "qarray.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>

Go to the source code of this file.

Classes

class  QCString
 
struct  QCString::LongStringRep
 
struct  QCString::ShortStringRep
 
struct  QCString::LSHeader
 
struct  QCString::LSData
 
class  QCString::StringRep
 
union  QCString::StringRep::ShortOrLongStringSelector
 

Macros

#define qsnprintf   snprintf
 
#define SHORT_STR_CAPACITY   ((int)sizeof(LongStringRep)-2)
 
#define SHORT_STR_MAX_LEN   (SHORT_STR_CAPACITY-1)
 

Typedefs

typedef QArray< char > QByteArray
 

Functions

Q_EXPORT void * qmemmove (void *dst, const void *src, uint len)
 
Q_EXPORT char * qstrdup (const char *)
 
Q_EXPORT uint cstrlen (const char *str)
 
Q_EXPORT uint qstrlen (const char *str)
 
Q_EXPORT char * cstrcpy (char *dst, const char *src)
 
Q_EXPORT char * qstrcpy (char *dst, const char *src)
 
Q_EXPORT char * qstrncpy (char *src, const char *dst, uint len)
 
Q_EXPORT int cstrcmp (const char *str1, const char *str2)
 
Q_EXPORT int qstrcmp (const char *str1, const char *str2)
 
Q_EXPORT int cstrncmp (const char *str1, const char *str2, uint len)
 
Q_EXPORT int qstrncmp (const char *str1, const char *str2, uint len)
 
Q_EXPORT int qstricmp (const char *str1, const char *str2)
 
Q_EXPORT int qstrnicmp (const char *str1, const char *str2, uint len)
 
Q_EXPORT QDataStreamoperator<< (QDataStream &, const QByteArray &)
 
Q_EXPORT QDataStreamoperator>> (QDataStream &, QByteArray &)
 
Q_EXPORT QDataStreamoperator<< (QDataStream &, const QCString &)
 
Q_EXPORT QDataStreamoperator>> (QDataStream &, QCString &)
 
Q_EXPORT bool operator== (const QCString &s1, const QCString &s2)
 
Q_EXPORT bool operator== (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator== (const char *s1, const QCString &s2)
 
Q_EXPORT bool operator!= (const QCString &s1, const QCString &s2)
 
Q_EXPORT bool operator!= (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator!= (const char *s1, const QCString &s2)
 
Q_EXPORT bool operator< (const QCString &s1, const QCString &s2)
 
Q_EXPORT bool operator< (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator< (const char *s1, const QCString &s2)
 
Q_EXPORT bool operator<= (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator<= (const char *s1, const QCString &s2)
 
Q_EXPORT bool operator> (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator> (const char *s1, const QCString &s2)
 
Q_EXPORT bool operator>= (const QCString &s1, const char *s2)
 
Q_EXPORT bool operator>= (const char *s1, const QCString &s2)
 
Q_EXPORT QCString operator+ (const QCString &s1, const QCString &s2)
 
QCString operator+ (const QCString &s1, const QGString &s2)
 
QCString operator+ (const QGString &s1, const QCString &s2)
 
Q_EXPORT QCString operator+ (const QCString &s1, const char *s2)
 
Q_EXPORT QCString operator+ (const char *s1, const QCString &s2)
 
Q_EXPORT QCString operator+ (const QCString &s1, char c2)
 
Q_EXPORT QCString operator+ (char c1, const QCString &s2)
 
const char * qPrint (const char *s)
 
const char * qPrint (const QCString &s)
 

Macro Definition Documentation

#define qsnprintf   snprintf

Definition at line 73 of file qcstring.h.

#define SHORT_STR_CAPACITY   ((int)sizeof(LongStringRep)-2)

Definition at line 349 of file qcstring.h.

#define SHORT_STR_MAX_LEN   (SHORT_STR_CAPACITY-1)

Definition at line 350 of file qcstring.h.

Typedef Documentation

typedef QArray<char> QByteArray

Definition at line 116 of file qcstring.h.

Function Documentation

Q_EXPORT int cstrcmp ( const char *  str1,
const char *  str2 
)
inline

Definition at line 92 of file qcstring.h.

93 { return strcmp(str1,str2); }
int strcmp(const String &s1, const String &s2)
Definition: relates.cpp:14
Q_EXPORT char* cstrcpy ( char *  dst,
const char *  src 
)
inline

Definition at line 84 of file qcstring.h.

85 { return strcpy(dst,src); }
Q_EXPORT uint cstrlen ( const char *  str)
inline

Definition at line 78 of file qcstring.h.

79 { return (uint)strlen(str); }
unsigned uint
Definition: qglobal.h:351
static QCString str
Q_EXPORT int cstrncmp ( const char *  str1,
const char *  str2,
uint  len 
)
inline

Definition at line 98 of file qcstring.h.

99 { return strncmp(str1,str2,len); }
Q_EXPORT bool operator!= ( const QCString s1,
const QCString s2 
)
inline

Definition at line 720 of file qcstring.h.

721 { return qstrcmp(s1.data(),s2.data()) != 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator!= ( const QCString s1,
const char *  s2 
)
inline

Definition at line 723 of file qcstring.h.

724 { return qstrcmp(s1.data(),s2) != 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator!= ( const char *  s1,
const QCString s2 
)
inline

Definition at line 726 of file qcstring.h.

727 { return qstrcmp(s1,s2.data()) != 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT QCString operator+ ( const QCString s1,
const QCString s2 
)
inline

Definition at line 756 of file qcstring.h.

757 {
758  QCString tmp(s1);
759  tmp += s2;
760  return tmp;
761 }
string tmp
Definition: languages.py:63
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
Q_EXPORT QCString operator+ ( const QCString s1,
const char *  s2 
)
inline

Definition at line 768 of file qcstring.h.

769 {
770  QCString tmp(s1);
771  tmp += s2;
772  return tmp;
773 }
string tmp
Definition: languages.py:63
Q_EXPORT QCString operator+ ( const char *  s1,
const QCString s2 
)
inline

Definition at line 775 of file qcstring.h.

776 {
777  QCString tmp(s1);
778  tmp += s2;
779  return tmp;
780 }
string tmp
Definition: languages.py:63
Q_EXPORT QCString operator+ ( const QCString s1,
char  c2 
)
inline

Definition at line 782 of file qcstring.h.

783 {
784  QCString tmp( s1.data() );
785  tmp += c2;
786  return tmp;
787 }
const char * data() const
Definition: qcstring.h:207
string tmp
Definition: languages.py:63
Q_EXPORT QCString operator+ ( char  c1,
const QCString s2 
)
inline

Definition at line 789 of file qcstring.h.

790 {
791  QCString tmp;
792  tmp += c1;
793  tmp += s2;
794  return tmp;
795 }
string tmp
Definition: languages.py:63
Q_EXPORT bool operator< ( const QCString s1,
const QCString s2 
)
inline

Definition at line 729 of file qcstring.h.

730 { return qstrcmp(s1.data(),s2.data()) < 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator< ( const QCString s1,
const char *  s2 
)
inline

Definition at line 732 of file qcstring.h.

733 { return qstrcmp(s1.data(),s2) < 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator< ( const char *  s1,
const QCString s2 
)
inline

Definition at line 735 of file qcstring.h.

736 { return qstrcmp(s1,s2.data()) < 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT QDataStream& operator<< ( QDataStream ,
const QByteArray  
)

Definition at line 600 of file qcstring.cpp.

601 {
602  return s.writeBytes( a.data(), a.size() );
603 }
const double a
static QCString * s
Definition: config.cpp:1042
Q_EXPORT QDataStream& operator<< ( QDataStream ,
const QCString  
)

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
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
static QCString str
Q_EXPORT bool operator<= ( const QCString s1,
const char *  s2 
)
inline

Definition at line 738 of file qcstring.h.

739 { return qstrcmp(s1.data(),s2) <= 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator<= ( const char *  s1,
const QCString s2 
)
inline

Definition at line 741 of file qcstring.h.

742 { return qstrcmp(s1,s2.data()) <= 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator== ( const QCString s1,
const QCString s2 
)
inline

Definition at line 711 of file qcstring.h.

712 { return qstrcmp(s1.data(),s2.data()) == 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator== ( const QCString s1,
const char *  s2 
)
inline

Definition at line 714 of file qcstring.h.

715 { return qstrcmp(s1.data(),s2) == 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator== ( const char *  s1,
const QCString s2 
)
inline

Definition at line 717 of file qcstring.h.

718 { return qstrcmp(s1,s2.data()) == 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator> ( const QCString s1,
const char *  s2 
)
inline

Definition at line 744 of file qcstring.h.

745 { return qstrcmp(s1.data(),s2) > 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator> ( const char *  s1,
const QCString s2 
)
inline

Definition at line 747 of file qcstring.h.

748 { return qstrcmp(s1,s2.data()) > 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator>= ( const QCString s1,
const char *  s2 
)
inline

Definition at line 750 of file qcstring.h.

751 { return qstrcmp(s1.data(),s2) >= 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT bool operator>= ( const char *  s1,
const QCString s2 
)
inline

Definition at line 753 of file qcstring.h.

754 { return qstrcmp(s1,s2.data()) >= 0; }
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT QDataStream& operator>> ( QDataStream ,
QByteArray  
)

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 }
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
const double a
unsigned int Q_UINT32
Definition: qglobal.h:420
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
Q_EXPORT QDataStream& operator>> ( QDataStream ,
QCString  
)

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
unsigned int Q_UINT32
Definition: qglobal.h:420
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
static QCString str
Q_EXPORT 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
const char* qPrint ( const char *  s)
inline

Definition at line 797 of file qcstring.h.

798 {
799  if (s) return s; else return "";
800 }
static QCString * s
Definition: config.cpp:1042
const char* qPrint ( const QCString s)
inline

Definition at line 802 of file qcstring.h.

803 {
804  if (!s.isEmpty()) return s.data(); else return "";
805 }
bool isEmpty() const
Definition: qcstring.h:189
const char * data() const
Definition: qcstring.h:207
Q_EXPORT int qstrcmp ( const char *  str1,
const char *  str2 
)
inline

Definition at line 95 of file qcstring.h.

96 { return (str1 && str2) ? strcmp(str1,str2) : (int)((intptr_t)str2 - (intptr_t)str1); }
int strcmp(const String &s1, const String &s2)
Definition: relates.cpp:14
Q_EXPORT char* qstrcpy ( char *  dst,
const char *  src 
)
inline

Definition at line 87 of file qcstring.h.

88 { return src ? strcpy(dst, src) : 0; }
Q_EXPORT char* qstrdup ( const char *  )

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
Q_EXPORT 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
Q_EXPORT uint qstrlen ( const char *  str)
inline

Definition at line 81 of file qcstring.h.

82 { return str ? (uint)strlen(str) : 0; }
unsigned uint
Definition: qglobal.h:351
static QCString str
Q_EXPORT int qstrncmp ( const char *  str1,
const char *  str2,
uint  len 
)
inline

Definition at line 101 of file qcstring.h.

102 { return (str1 && str2) ? strncmp(str1,str2,len) :
103  (int)((intptr_t)str2 - (intptr_t)str1); }
Q_EXPORT char* qstrncpy ( char *  src,
const char *  dst,
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 }
Q_EXPORT 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