Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

UStr Class Reference

Active String class. More...

#include <ustr.hpp>

Inheritance diagram for UStr:

UElem UBrick List of all members.

Public Member Functions

 UStr ()
 UStr (const char *)
 UStr (const UStr &)
 UStr (const std::string &)
 UStr (const UIntgBase &)
 UStr (const UFloatBase &)
 constructors
  • arg is a C, C++ or Ubit string or a Ubit Number.

virtual ~UStr ()
 destructor.
virtual void clear ()
 clears the string's content.
virtual bool empty () const
 true if content is empty
int length () const
 returns the length of the string.
UStroperator= (const char *s2)
UStroperator= (const UStr &s2)
UStroperator= (const std::string &s2)
UStroperator= (const UIntgBase &v2)
UStroperator= (const UFloatBase &v2)
 copy the value of the argument to this string.
virtual void set (const char *s2)
virtual void set (const UStr &s2)
virtual void set (const std::string &s2)
virtual void set (const UIntgBase &v2)
virtual void set (const UFloatBase &v2)
virtual void setNum (int v2)
virtual void setNum (double v2)
 copy the value of the argument to this string.
bool operator== (const char *s2) const
bool operator== (const UStr &s2) const
bool operator== (const std::string &s2) const
virtual bool equals (const char *) const
virtual bool equals (const std::string &) const
virtual bool equals (const UStr &) const
 returns true if string contents are the same.
virtual int compare (const char *) const
virtual int compare (const std::string &) const
virtual int compare (const UStr &) const
virtual int compareTo (const char *, bool ignore_case=false) const
virtual int compareTo (const std::string &, bool ignore_case=false) const
virtual int compareTo (const UStr &, bool ignore_case=false) const
 compare strings lexicographically.
const char * chars () const
const char * c_str () const
 returns a C string that should not be changed nor deleted.
virtual char charAt (int pos) const
virtual char at (int pos) const
 returns the character at offset 'pos'
virtual char setCharAt (int pos, char c, bool update=true)
 changes the character at offset 'pos'.
virtual bool copyTo (UStr &to, int pos=0, unsigned int nbchars=npos) const
virtual bool copyTo (std::string &to, int pos=0, unsigned int nbchars=npos) const
 copies a substring of *this string into the argument string.
virtual UStr substring (int from_pos=0, unsigned int nbchars=npos) const
virtual std::string toString (int from_pos=0, unsigned int nbchars=npos) const
 returns a substring.
virtual UStr split (int pos, bool delete_char_at_pos=false)
 splits the string: removes contents from offset 'pos' and returns the remaining chars.
virtual void trim (bool strip_beginning=true, bool strip_end=true)
virtual void strip (bool strip_beginning=true, bool strip_end=true)
 removes white spaces, tabs and newlines at the beginning and end of string.
int find (char)
int rfind (char)
int find (const char *)
int find (const UStr &)
int find (const std::string &)
 returns -1 if not found.
UStroperator &= (const UStr &s2)
UStroperator &= (const char *s2)
UStroperator &= (const std::string &s2)
UStroperator &= (int v2)
UStroperator &= (float v2)
UStroperator &= (const UIntgBase &v2)
UStroperator &= (const UFloatBase &v2)
 appends argument to this
virtual void append (char)
virtual void append (const char *)
virtual void append (const char *, unsigned int nbchars)
virtual void append (const UStr &)
virtual void append (const UStr &, unsigned int nbchars)
virtual void append (const std::string &)
virtual void append (const std::string &, unsigned int nbchars)
virtual void append (int)
virtual void append (float)
virtual void append (const UIntgBase &)
virtual void append (const UFloatBase &)
 appends the string given as an argument to the end of *this string.
virtual bool insert (int to_pos, char)
virtual bool insert (int to_pos, const char *from, int from_pos=0, unsigned int from_nbchars=npos)
virtual bool insert (int to_pos, const UStr &from, int from_pos=0, unsigned int from_nbchars=npos)
virtual bool insert (int to_pos, const std::string &from, int from_pos=0, unsigned int from_nbchars=npos)
 inserts 'from' string at offset 'to_pos' in *this string.
virtual void remove (int pos, unsigned int nbchars)
 removes 'nbchars' characters from offset 'pos' details:
  • pos = 0 specifies the first char of the string
  • pos = -1 specifies the last char of the string

virtual void replace (int pos, unsigned int nbchars, const UStr &)
virtual void replace (int pos, unsigned int nbchars, const char *)
virtual void replace (int pos, unsigned int nbchars, const std::string &)
 replaces 'nbchars' characters from offset 'pos' in this string by the argument string.
virtual UStr getFileName (bool with_suffix=true) const
 returns the file name of a file path (= without the directory); removes the suffix if arg is false.
virtual UStr getFileSuffix () const
 returns the suffix of a file path (= the end of the pathname after the dot)
virtual UStr getFileDir (bool with_final_slash=true) const
 returns the directory of a file path (= without the file name).
virtual UStr getFilePath (const UStr &new_suffix) const
 returns the file path with a new suffix.
virtual long getFileType () const
virtual long getFileType (bool &is_regular_file, bool &is_directory) const
 returns the Unix file type (0 if the file does not exist)
virtual bool isFileFound (bool is_regular_file=true) const
 returns true if file exists (also checks that this is a regular file if arg is true)
virtual int readFile (const UStr &pathname)
 reads this file into the UStr and returns the loading status (see UFilestat).
virtual void changed (bool update_now)
 [impl] called when object's content is changed.
virtual void update ()
 updates grahics.

Static Public Member Functions

static int readFile (const UStr &filename, std::vector< UStr * > &slist, bool strip_beg_line=false, bool strip_end_line=false)
 reads this file into the UStr vector and returns the loading status (see UFilestat).

Static Public Attributes

static const unsigned int npos = static_cast<unsigned int>(-1)
static UStr none
static UStr newline

Friends

UStrustr ()
UStrustr (const char *_s)
UStrustr (const UStr &_s)
UStrustr (const std::string &_s)
 creator shortcuts (same as *new UStr()).
std::ostream & operator<< (std::ostream &, const UStr &)
 prints string on ostream, for instance: cout << str.
UStr operator & (const UStr &s1, const UStr &s2)
UStr operator & (const UStr &s1, const char *s2)
UStr operator & (const char *s1, const UStr &s2)
UStr operator & (const UStr &s1, const std::string &s2)
UStr operator & (const std::string &s1, const UStr &s2)
UStr operator & (const UStr &, int)
UStr operator & (const UStr &, float)
UStr operator & (const UStr &, const UIntgBase &)
UStr operator & (const UStr &, const UFloatBase &)
 creates a new string that collates the 2 arguments.

Detailed Description

Active String class.

Notes:


Constructor & Destructor Documentation

UStr::UStr  ) 
 

dont forget: checked by _set() for freeing memory!

UStr::UStr const char *  chs  ) 
 

dont forget: checked by _set() for freeing memory!

UStr::UStr const UStr str  ) 
 

!

UStr::UStr const std::string &  str  ) 
 

!

UStr::UStr const UFloatBase  ) 
 

constructors

  • arg is a C, C++ or Ubit string or a Ubit Number.

  • data is copied internally (that the arg can be freely destroyed)


Member Function Documentation

virtual char UStr::at int  pos  )  const [virtual]
 

returns the character at offset 'pos'

  • pos = -1 refers to the last char of the string
  • returns the character or 0 if the position is invalid
  • does not throw exception (check the returned value)

void UStr::changed bool  update_now  )  [virtual]
 

[impl] called when object's content is changed.

This function:

  • updates grahics (if arg is true)
  • then fires object's UOn::change callbacks
  • then fires parents' UOn::changeProp callbacks
  • then fires parents' UOn::changeStr callbacks

Reimplemented from UElem.

int UStr::compareTo const UStr ,
bool  ignore_case = false
const [virtual]
 

compare strings lexicographically.

ignores case considerations if second argument is true (checks case by default)

bool UStr::copyTo std::string &  to,
int  pos = 0,
unsigned int  nbchars = npos
const [virtual]
 

copies a substring of *this string into the argument string.

details:

  • nbchars = npos means "copy to the end of *this string".
  • the data is appended to the end of the argument string (if it is not empty)

bool UStr::insert int  to_pos,
const std::string &  from,
int  from_pos = 0,
unsigned int  from_nbchars = npos
[virtual]
 

inserts 'from' string at offset 'to_pos' in *this string.

details:

  • pos = 0 specifies the beginning of the string (BEFORE the first char)
  • pos = -1 specifies the end of the string (AFTER the last char)
  • from_nbchars = npos means "to the end of the string"

UStr& UStr::operator &= const UFloatBase v2  ) 
 

appends argument to this

Notes:

  • this is modified, the argument is not modified
  • we use &= rather than += because the + operator is used for argument lists.

char UStr::setCharAt int  pos,
char  c,
bool  update = true
[virtual]
 

changes the character at offset 'pos'.

  • pos = -1 refers to the last char of the string
    • returns the character or 0 if the position is invalid
    • does not throw exception (check the returned value)

std::string UStr::toString int  from_pos = 0,
unsigned int  nbchars = npos
const [virtual]
 

returns a substring.

details:

  • nbchars = npos means "copy to the end of *this string".


Friends And Related Function Documentation

UStr operator & const UStr s1,
const UFloatBase v2
[friend]
 

creates a new string that collates the 2 arguments.

Notes:

  • arguments are not modified
  • we use & rather than + because the + operator is used for argument lists.


The documentation for this class was generated from the following files:
Generated on Thu May 19 11:40:00 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.2