• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

GBaseString Class Reference

General purpose character string. More...

#include <GString.h>

Inheritance diagram for GBaseString:

Inheritance graph
[legend]

List of all members.


Public Types

enum  EscapeMode { UNKNOWN_ESCAPED = GStringRep::UNKNOWN_ESCAPED, IS_ESCAPED = GStringRep::IS_ESCAPED, NOT_ESCAPED = GStringRep::NOT_ESCAPED }

Public Member Functions

int cmp (const char s2) const
int cmp (const char *s2, const int len=(-1)) const
int cmp (const GBaseString &s2, const int len=(-1)) const
int contains (const char accept[], const int from=0) const
void empty (void)
int firstEndSpace (const int from=0, const int len=(-1)) const
GUTF8String getNative2UTF8 (void) const
GNativeString getUTF82Native (EscapeMode escape=UNKNOWN_ESCAPED) const
bool is_float (void) const
bool is_int (void) const
bool is_valid (void) const
unsigned int length (void) const
GUTF8String NativeToUTF8 (void) const
int ncopy (wchar_t *const buf, const int buflen) const
int nextChar (const int from=0) const
int nextNonSpace (const int from=0, const int len=(-1)) const
int nextSpace (const int from=0, const int len=(-1)) const
 operator const char * (void) const
bool operator! (void) const
bool operator!= (const char *s2) const
bool operator!= (const GBaseString &s2) const
GNativeString operator+ (const GNativeString &s2) const
GUTF8String operator+ (const GUTF8String &s2) const
bool operator< (const char s2) const
bool operator< (const char *s2) const
bool operator< (const GBaseString &s2) const
bool operator<= (const char s2) const
bool operator<= (const char *s2) const
bool operator<= (const GBaseString &s2) const
bool operator== (const char *s2) const
bool operator== (const GBaseString &s2) const
bool operator> (const char s2) const
bool operator> (const char *s2) const
bool operator> (const GBaseString &s2) const
bool operator>= (const char s2) const
bool operator>= (const char *s2) const
bool operator>= (const GBaseString &s2) const
char operator[] (int n) const
int rcontains (const char accept[], const int from=0) const
int rsearch (const char *str, const int from=0) const
int rsearch (char c, const int from=0) const
int search (const char *str, int from=0) const
int search (char c, int from=0) const
double toDouble (const int pos, int &endpos) const
int toInt (void) const
long toLong (const int pos, int &endpos, const int base=10) const
unsigned long toULong (const int pos, int &endpos, const int base=10) const
GNativeString UTF8ToNative (const bool currentlocale=false, const EscapeMode escape=UNKNOWN_ESCAPED) const

Static Public Member Functions

static int cmp (const char *s1, const char *s2, const int len=(-1))
static double toDouble (const GNativeString &src, const int pos, int &endpos)
static double toDouble (const GUTF8String &src, const int pos, int &endpos)
static long toLong (const GNativeString &src, const int pos, int &endpos, const int base=10)
static long toLong (const GUTF8String &src, const int pos, int &endpos, const int base=10)
static unsigned long toULong (const GNativeString &src, const int pos, int &endpos, const int base=10)
static unsigned long toULong (const GUTF8String &src, const int pos, int &endpos, const int base=10)

Protected Member Functions

int CheckSubscript (int n) const
 GBaseString (void)
GBaseString & init (const GP< GStringRep > &rep)
void init (void)
 ~GBaseString ()

Static Protected Member Functions

static void throw_illegal_subscript () no_return

Protected Attributes

const char * gstr

Static Protected Attributes

static const char * nullstr = ""

Friends

unsigned int hash (const GBaseString &ref)
bool operator!= (const char *s1, const GBaseString &s2)
bool operator< (const char s1, const GBaseString &s2)
bool operator< (const char *s1, const GBaseString &s2)
bool operator<= (const char s1, const GBaseString &s2)
bool operator<= (const char *s1, const GBaseString &s2)
bool operator== (const char *s1, const GBaseString &s2)
bool operator> (const char s1, const GBaseString &s2)
bool operator> (const char *s1, const GBaseString &s2)
bool operator>= (const char s1, const GBaseString &s2)
bool operator>= (const char *s1, const GBaseString &s2)

Detailed Description

General purpose character string.

Each dirivied instance of class GBaseString# represents a character string. Overloaded operators provide a value semantic to GBaseString# objects. Conversion operators and constructors transparently convert between GBaseString# objects and const char*# pointers. The GBaseString# class has no public constructors, since a dirived type should always be used to specify the desired multibyte character encoding.

Functions taking strings as arguments should declare their arguments as "#const char*#". Such functions will work equally well with dirived GBaseString# objects since there is a fast conversion operator from the dirivied GBaseString# objects to "#const char*#". Functions returning strings should return GUTF8String# or GNativeString# objects because the class will automatically manage the necessary memory.

Characters in the string can be identified by their position. The first character of a string is numbered zero. Negative positions represent characters relative to the end of the string (i.e. position #-1# accesses the last character of the string, position #-2# represents the second last character, etc.)

Definition at line 464 of file GString.h.


Member Enumeration Documentation

enum GBaseString::EscapeMode

Enumerator:
UNKNOWN_ESCAPED 
IS_ESCAPED 
NOT_ESCAPED 

Definition at line 467 of file GString.h.


Constructor & Destructor Documentation

GBaseString::~GBaseString (  )  [protected]

Definition at line 112 of file GString.cpp.

GBaseString::GBaseString ( void   )  [inline, protected]

Null constructor.

Constructs an empty string.

Definition at line 1409 of file GString.h.


Member Function Documentation

int GBaseString::CheckSubscript ( int  n  )  const [inline, protected]

Definition at line 1397 of file GString.h.

int GBaseString::cmp ( const char *  s1,
const char *  s2,
const int  len = (-1) 
) [inline, static]

Returns an int#.

Compares s2# with s2# and returns sorting order.

Definition at line 1305 of file GString.h.

int GBaseString::cmp ( const char  s2  )  const [inline]

Returns an int#.

Compares string with s2# and returns sorting order.

Definition at line 1301 of file GString.h.

int GBaseString::cmp ( const char *  s2,
const int  len = (-1) 
) const [inline]

Returns an int#.

Compares string with s2# and returns sorting order.

Definition at line 1297 of file GString.h.

int GBaseString::cmp ( const GBaseString &  s2,
const int  len = (-1) 
) const [inline]

Returns an int#.

Compares string with s2# and returns sorting order.

Definition at line 1293 of file GString.h.

int GBaseString::contains ( const char  accept[],
const int  from = 0 
) const [inline]

Searches for any of the specified characters in the accept string.

It returns #-1# if the none of the characters and be found, otherwise the position of the first match.

Definition at line 1285 of file GString.h.

void GBaseString::empty ( void   ) 

Reinitializes a string with the null string.

Definition at line 1224 of file GString.cpp.

int GBaseString::firstEndSpace ( const int  from = 0,
const int  len = (-1) 
) const [inline]

return the position after the last non-whitespace character.

Definition at line 1385 of file GString.h.

GUTF8String GBaseString::getNative2UTF8 ( void   )  const

GNativeString GBaseString::getUTF82Native ( EscapeMode  escape = UNKNOWN_ESCAPED  )  const

Converts strings between native & UTF8.

GBaseString & GBaseString::init ( const GP< GStringRep > &  rep  )  [inline, protected]

Reimplemented in GUTF8String.

Definition at line 1261 of file GString.h.

void GBaseString::init ( void   )  [inline, protected]

Reimplemented in GUTF8String.

Definition at line 1163 of file GString.h.

bool GBaseString::is_float ( void   )  const

Returns TRUE# if the string contains a float number.

Definition at line 1851 of file GString.cpp.

bool GBaseString::is_int ( void   )  const

Returns TRUE# if the string contains an integer number.

Definition at line 1835 of file GString.cpp.

bool GBaseString::is_valid ( void   )  const [inline]

Tests if the string is legally encoded in the current codepage.

Definition at line 1389 of file GString.h.

unsigned int GBaseString::length ( void   )  const [inline]

Returns the string length.

Definition at line 1100 of file GString.h.

GUTF8String GBaseString::NativeToUTF8 ( void   )  const

int GBaseString::ncopy ( wchar_t *const   buf,
const int  buflen 
) const [inline]

copy to a wchar_t buffer

Definition at line 1393 of file GString.h.

int GBaseString::nextChar ( const int  from = 0  )  const [inline]

Returns next character position.

Definition at line 1377 of file GString.h.

int GBaseString::nextNonSpace ( const int  from = 0,
const int  len = (-1) 
) const [inline]

Returns next non space position.

Definition at line 1373 of file GString.h.

int GBaseString::nextSpace ( const int  from = 0,
const int  len = (-1) 
) const [inline]

Returns next non space position.

Definition at line 1381 of file GString.h.

GBaseString::operator const char * ( void   )  const [inline]

Converts a string into a constant null terminated character array.

This conversion operator is very efficient because it simply returns a pointer to the internal string data. The returned pointer remains valid as long as the string is unmodified.

Definition at line 1094 of file GString.h.

bool GBaseString::operator! ( void   )  const [inline]

Returns true if and only if the string contains zero characters.

This operator is useful for conditional expression in control structures. {verbatim} if (! str) { ... } while (!! str) { ... } -- Note the double operator! {verbatim} Class GBaseString# does not to support syntax "#if# #(str)# #{}#" because the required conversion operator introduces dangerous ambiguities with certain compilers.

Reimplemented from GP< GStringRep >.

Definition at line 1106 of file GString.h.

bool GBaseString::operator!= ( const char *  s2  )  const [inline]

Definition at line 1321 of file GString.h.

bool GBaseString::operator!= ( const GBaseString &  s2  )  const [inline]

String comparison.

Returns true if and only if character strings s1# and s2# are not equal (as with strcmp#.)

Definition at line 1317 of file GString.h.

GNativeString GBaseString::operator+ ( const GNativeString &  s2  )  const

Reimplemented in GUTF8String.

GUTF8String GBaseString::operator+ ( const GUTF8String &  s2  )  const

Concatenates strings.

Returns a string composed by concatenating the characters of strings s1# and s2#.

Reimplemented in GUTF8String.

Definition at line 2716 of file GString.cpp.

bool GBaseString::operator< ( const char  s2  )  const [inline]

Definition at line 1345 of file GString.h.

bool GBaseString::operator< ( const char *  s2  )  const [inline]

Definition at line 1341 of file GString.h.

bool GBaseString::operator< ( const GBaseString &  s2  )  const [inline]

String comparison.

Returns true if and only if character strings s1# is lexicographically less than string s2# (as with strcmp#.)

Definition at line 1337 of file GString.h.

bool GBaseString::operator<= ( const char  s2  )  const [inline]

Definition at line 1369 of file GString.h.

bool GBaseString::operator<= ( const char *  s2  )  const [inline]

Definition at line 1365 of file GString.h.

bool GBaseString::operator<= ( const GBaseString &  s2  )  const [inline]

String comparison.

Returns true if and only if character strings s1# is lexicographically less than or equal to string s2# (as with strcmp#.)

Definition at line 1361 of file GString.h.

bool GBaseString::operator== ( const char *  s2  )  const [inline]

Definition at line 1313 of file GString.h.

bool GBaseString::operator== ( const GBaseString &  s2  )  const [inline]

Returns a boolean.

The Standard C strncmp takes two string and compares the first N characters. static bool GBaseString::ncmp will compare s1# with s2# with the len# characters starting from the beginning of the string. String comparison. Returns true if and only if character strings s1# and s2# are equal (as with strcmp#.)

Definition at line 1309 of file GString.h.

bool GBaseString::operator> ( const char  s2  )  const [inline]

Definition at line 1357 of file GString.h.

bool GBaseString::operator> ( const char *  s2  )  const [inline]

Definition at line 1353 of file GString.h.

bool GBaseString::operator> ( const GBaseString &  s2  )  const [inline]

String comparison.

Returns true if and only if character strings s1# is lexicographically greater than string s2# (as with strcmp#.)

Definition at line 1349 of file GString.h.

bool GBaseString::operator>= ( const char  s2  )  const [inline]

Definition at line 1333 of file GString.h.

bool GBaseString::operator>= ( const char *  s2  )  const [inline]

Definition at line 1329 of file GString.h.

bool GBaseString::operator>= ( const GBaseString &  s2  )  const [inline]

String comparison.

Returns true if and only if character strings s1# is lexicographically greater than or equal to string s2# (as with strcmp#.)

Definition at line 1325 of file GString.h.

char GBaseString::operator[] ( int  n  )  const [inline]

Returns the character at position n#.

An exception {GException} is thrown if number n# is not in range #-len# to len-1#, where len# is the length of the string. The first character of a string is numbered zero. Negative positions represent characters relative to the end of the string.

Definition at line 1265 of file GString.h.

int GBaseString::rcontains ( const char  accept[],
const int  from = 0 
) const [inline]

Searches for any of the specified characters in the accept string.

It returns #-1# if the none of the characters and be found, otherwise the position of the last match.

Definition at line 1289 of file GString.h.

int GBaseString::rsearch ( const char *  str,
const int  from = 0 
) const [inline]

Searches sub-string str# in the string, starting at position from# and scanning backwards until reaching the beginning of the string.

This function returns the position of the first matching character of the sub-string. It returns #-1# if string str# cannot be found.

Definition at line 1281 of file GString.h.

int GBaseString::rsearch ( char  c,
const int  from = 0 
) const [inline]

Searches character c# in the string, starting at position from# and scanning backwards until reaching the beginning of the string.

This function returns the position of the matching character. It returns #-1# if character c# cannot be found.

Definition at line 1277 of file GString.h.

int GBaseString::search ( const char *  str,
int  from = 0 
) const [inline]

Searches sub-string str# in the string, starting at position from# and scanning forward until reaching the end of the string.

This function returns the position of the first matching character of the sub-string. It returns #-1# if string str# cannot be found.

Definition at line 1273 of file GString.h.

int GBaseString::search ( char  c,
int  from = 0 
) const [inline]

Searches character c# in the string, starting at position from# and scanning forward until reaching the end of the string.

This function returns the position of the matching character. It returns #-1# if character c# cannot be found.

Definition at line 1269 of file GString.h.

void GBaseString::throw_illegal_subscript (  )  [static, protected]

Definition at line 1877 of file GString.cpp.

double GBaseString::toDouble ( const GNativeString &  src,
const int  pos,
int &  endpos 
) [inline, static]

Definition at line 1254 of file GString.h.

double GBaseString::toDouble ( const GUTF8String &  src,
const int  pos,
int &  endpos 
) [inline, static]

Definition at line 1247 of file GString.h.

double GBaseString::toDouble ( const int  pos,
int &  endpos 
) const [inline]

Returns a double.

Implements the i18n strtod.

Definition at line 1232 of file GString.h.

int GBaseString::toInt ( void   )  const [inline]

Returns an integer.

Implements i18n atoi.

Definition at line 1169 of file GString.h.

long GBaseString::toLong ( const GNativeString &  src,
const int  pos,
int &  endpos,
const int  base = 10 
) [inline, static]

Returns a long intenger.

Implments i18n strtol.

Definition at line 1195 of file GString.h.

long GBaseString::toLong ( const GUTF8String &  src,
const int  pos,
int &  endpos,
const int  base = 10 
) [inline, static]

Returns a long intenger.

Implments i18n strtol.

Definition at line 1188 of file GString.h.

long GBaseString::toLong ( const int  pos,
int &  endpos,
const int  base = 10 
) const [inline]

Returns a long intenger.

Implments i18n strtol.

Definition at line 1174 of file GString.h.

unsigned long GBaseString::toULong ( const GNativeString &  src,
const int  pos,
int &  endpos,
const int  base = 10 
) [inline, static]

Definition at line 1224 of file GString.h.

unsigned long GBaseString::toULong ( const GUTF8String &  src,
const int  pos,
int &  endpos,
const int  base = 10 
) [inline, static]

Definition at line 1217 of file GString.h.

unsigned long GBaseString::toULong ( const int  pos,
int &  endpos,
const int  base = 10 
) const [inline]

Returns a unsigned long integer.

Implements i18n strtoul.

Definition at line 1203 of file GString.h.

GNativeString GBaseString::UTF8ToNative ( const bool  currentlocale = false,
const EscapeMode  escape = UNKNOWN_ESCAPED 
) const


Friends And Related Function Documentation

unsigned int hash ( const GBaseString &  ref  )  [friend]

Returns an integer.

Implements a functional i18n atoi. Note that if you pass a GBaseString that is not in Native format the results may be disparaging. Returns a hash code for the string. This hashing function helps when creating associative maps with string keys (see {GMap}). This hash code may be reduced to an arbitrary range by computing its remainder modulo the upper bound of the range.

Definition at line 1867 of file GString.cpp.

bool operator!= ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1631 of file GString.h.

bool operator< ( const char  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1647 of file GString.h.

bool operator< ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1643 of file GString.h.

bool operator<= ( const char  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1663 of file GString.h.

bool operator<= ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1659 of file GString.h.

bool operator== ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1627 of file GString.h.

bool operator> ( const char  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1655 of file GString.h.

bool operator> ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1651 of file GString.h.

bool operator>= ( const char  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1639 of file GString.h.

bool operator>= ( const char *  s1,
const GBaseString &  s2 
) [friend]

Definition at line 1635 of file GString.h.


Member Data Documentation

const char* GBaseString::gstr [protected]

Definition at line 703 of file GString.h.

const char * GBaseString::nullstr = "" [static, protected]

Definition at line 705 of file GString.h.


The documentation for this class was generated from the following files:
  • GString.h
  • GString.cpp

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal