PikeAero::CString Class Reference

#include <cstring.h>

Inheritance diagram for PikeAero::CString:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CString:

Collaboration graph
[legend]

Public Member Functions

CStringappend (CMachine::bit8 ch)
CStringappend (CMachine::ubit8 ch)
CStringappend (CMachine::ubit8 *data)
CStringappend (CString &other)
CMachine::bit32 compare (CString &other)
CStringcopy (CString &other)
CStringcopy (CMachine::ubit8 *data)
 CString (CMachine::bit8 *str)
 CString ()
CArray< CString * > explode (CMachine::bit8 separator, CMachine::bit32 index=0)
CMachine::bit32 find (CMachine::bit8 ch, CMachine::ubit32 index=0)
CStringfromBit32 (CMachine::bit32 i)
CStringfromUbit32 (CMachine::ubit32 i, bool sgn=false)
 Convert an unsigned integer to ASCII in base 10.
bool isEmpty ()
bool isNull ()
CString left (CMachine::bit32 n)
CMachine::ubit32 length ()
CString mid (CMachine::bit32 index, CMachine::bit32 n)
bool operator!= (CMachine::bit8 *data)
bool operator!= (CMachine::ubit8 *data)
bool operator!= (CString &other)
CStringoperator+= (CMachine::bit8 ch)
CStringoperator+= (CMachine::ubit8 ch)
CStringoperator+= (CMachine::ubit8 *data)
CStringoperator+= (CString &other)
bool operator< (CMachine::bit8 *data)
bool operator< (CMachine::ubit8 *data)
bool operator< (CString &other)
bool operator<= (CMachine::bit8 *data)
bool operator<= (CMachine::ubit8 *data)
bool operator<= (CString &other)
CStringoperator= (CMachine::ubit8 *data)
CStringoperator= (CString &other)
bool operator== (const CMachine::bit8 *data)
bool operator== (const CMachine::ubit8 *data)
bool operator== (CMachine::bit8 *data)
bool operator== (CMachine::ubit8 *data)
bool operator== (CString &other)
bool operator> (CMachine::bit8 *data)
bool operator> (CMachine::ubit8 *data)
bool operator> (CString &other)
bool operator>= (CMachine::bit8 *data)
bool operator>= (CMachine::ubit8 *data)
bool operator>= (CString &other)
CStringprepend (CMachine::ubit8 data)
CStringresize (CMachine::ubit32 size)
CString right (CMachine::bit32 n)
void setData (CMachine::ubit8 *)
CStringsprintf (CMachine::bit8 *fmt,...)
 sprintf( fmt, ... ) Appends formted text and returns a reference. b - ubit8 - hex 2 digits c - character s - string x - ubit16 - hex 4 digits X - ubit32 - hex 8 digits f - float - 32 bit signed ieee754
CStringstrcat (CMachine::ubit8 *, CMachine::bit32 len=0)
 The strcat() function appends the d string,The strings may not overlap.
CMachine::bit32 strcmp (const CMachine::ubit8 *s)
CStringstrcpy (CMachine::ubit8 *, CMachine::bit32 len=0)
 Copies the string pointed to by d, The strings may not overlap.
CMachine::bit32 toBit32 ()
 Convert to a signed integer.
CStringtoHex (CMachine::ubit32 n)
CStringtoLower ()
CMachine::ubit32 toUBit32 ()
 Convert to an unsigned integer.
CStringtoUpper ()
virtual ~CString ()

Private Member Functions

void sprintff (CMachine::ubit32 fbinary)
 (private) sprintff( fbinary ) Convert binary IEEE754 floating point to string. INFO - Derived by reading http://en.wikipedia.org/wiki/IEEE_754

Detailed Description

Implements an ASCII string class. Member variable mData is stored privately as a '' terminated string (zstring). Various accessor methods are available to provide the common string operations. New memory is aquired from CMemHeap.

Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 37 of file cstring.h.


Constructor & Destructor Documentation

PikeAero::CString::CString (  ) 

TODO - use const where applicable

Definition at line 31 of file cstring.cpp.

Referenced by explode().

00032  : inherited()
00033 {
00034 }

Here is the caller graph for this function:

PikeAero::CString::CString ( CMachine::bit8 str  ) 

Definition at line 36 of file cstring.cpp.

References copy().

00037 : inherited()
00038 {
00039     copy((CMachine::ubit8*)str);
00040 }

Here is the call graph for this function:

PikeAero::CString::~CString (  )  [virtual]

Definition at line 44 of file cstring.cpp.

References PikeAero::CByteArray::clear().

00045 {
00046     clear();
00047 }

Here is the call graph for this function:


Member Function Documentation

CString& PikeAero::CString::append ( CMachine::bit8  ch  )  [inline]

Definition at line 49 of file cstring.h.

References append().

Referenced by append().

00049 {return append((CMachine::ubit8)ch);}

Here is the call graph for this function:

Here is the caller graph for this function:

CString& PikeAero::CString::append ( CMachine::ubit8  ch  )  [inline]

Reimplemented from PikeAero::CByteArray.

Definition at line 48 of file cstring.h.

References strcat().

00048 {return strcat(&ch,1);}

Here is the call graph for this function:

CString& PikeAero::CString::append ( CMachine::ubit8 data  )  [inline]

Definition at line 47 of file cstring.h.

References strcat().

00047 {return strcat(data);}

Here is the call graph for this function:

CString& PikeAero::CString::append ( CString other  )  [inline]

Definition at line 46 of file cstring.h.

References append(), and PikeAero::CByteArray::data().

Referenced by append(), left(), mid(), operator+=(), prepend(), PikeAero::CTaskConsolePacket::run(), PikeAero::CTaskConsole::run(), sprintf(), and toHex().

00046 {return append(other.data());}

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CString::compare ( CString other  )  [inline]

Definition at line 57 of file cstring.h.

References PikeAero::CByteArray::data(), and strcmp().

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

00057 {return ::strcmp((const char*)data(), (const char*)other.data());}

Here is the call graph for this function:

Here is the caller graph for this function:

CString& PikeAero::CString::copy ( CString other  )  [inline]

Definition at line 55 of file cstring.h.

References copy(), and PikeAero::CByteArray::data().

Referenced by copy().

00055 {return copy(other.data());}

Here is the call graph for this function:

Here is the caller graph for this function:

CString& PikeAero::CString::copy ( CMachine::ubit8 data  )  [inline]

Definition at line 54 of file cstring.h.

References strcpy().

Referenced by CString(), fromUbit32(), and operator=().

00054 {return strcpy(data);}

Here is the call graph for this function:

Here is the caller graph for this function:

CArray< CString * > PikeAero::CString::explode ( CMachine::bit8  separator,
CMachine::bit32  index = 0 
)

Definition at line 49 of file cstring.cpp.

References PikeAero::CArray< T >::append(), CString(), find(), length(), mid(), and PikeAero::CByteArray::size().

Referenced by PikeAero::CTaskConsolePacket::execute(), and PikeAero::CTaskConsole::execute().

00050 {
00051     CArray<CString*> array;
00052     CMachine::bit32 begin = index;
00053     CMachine::bit32 end;
00054     if ( begin < length() )
00055     {
00056         do {
00057             end = find( separator, begin );
00058             if ( begin < end )
00059             {
00060                 array.append( new CString( mid( begin, end-begin ) ) );
00061             }
00062             else if ( end < 0 )
00063             {
00064                 array.append( new CString( mid( begin, size()-begin ) ) );
00065             }
00066             begin = end+1;
00067         } while ( end >= 0 );
00068     }
00069     return array;
00070 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CString::find ( CMachine::bit8  ch,
CMachine::ubit32  index = 0 
)

Definition at line 134 of file cstring.cpp.

References PikeAero::CByteArray::data(), and length().

Referenced by explode().

00135 {
00136     for ( CMachine::bit32 i = index; i < length(); i++ )
00137     {
00138         if ( data()[i] == ch )
00139         {
00140             return i;
00141         }
00142     }
00143     return -1;
00144 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString& PikeAero::CString::fromBit32 ( CMachine::bit32  i  )  [inline]

Definition at line 90 of file cstring.h.

References fromUbit32().

Referenced by sprintf(), and PikeAero::CVariant::update().

00090 {return fromUbit32( (CMachine::ubit32)i, true );}

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::fromUbit32 ( CMachine::ubit32  i,
bool  sgn = false 
)

Convert an unsigned integer to ASCII in base 10.

Returns:
self reference.

Definition at line 208 of file cstring.cpp.

References copy(), and PikeAero::CTaskScheduler::yield().

Referenced by fromBit32().

00209 {
00210     CMachine::ubit8 buf[16];
00211     CMachine::ubit32 index=0;
00212     CMachine::ubit32 power=1000000000;
00213     bool got_digit=false;
00214 
00215     if ( sgn && ((i & 0x80000000) != 0) )
00216     {
00217         buf[index++] = '-';
00218         buf[index] = '\0';
00219     }
00220     buf[0]='\0';
00221     while ( power ) {
00222         int digit=0;
00223         while ( i >= power ) {
00224             i -= power;
00225             ++digit;
00226             CTaskScheduler::yield();
00227         }
00228         if ( digit != 0 || power==1 ) {
00229             got_digit=true;
00230         }
00231         if ( got_digit ) {
00232             buf[index++] = digit + '0';
00233             buf[index]='\0';
00234         }
00235         power /= 10;
00236         CTaskScheduler::yield();
00237     }
00238     copy(buf);
00239     return *this;
00240 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PikeAero::CString::isEmpty (  )  [inline]

Reimplemented from PikeAero::CByteArray.

Definition at line 88 of file cstring.h.

References PikeAero::CByteArray::data(), and isNull().

00088 {return ( isNull() || data()[0] != (CMachine::ubit8)'\0' );}

Here is the call graph for this function:

bool PikeAero::CString::isNull (  )  [inline]

Reimplemented from PikeAero::CByteArray.

Definition at line 87 of file cstring.h.

References PikeAero::CByteArray::data().

Referenced by isEmpty(), and prepend().

00087 {return data()==NULL;}

Here is the call graph for this function:

Here is the caller graph for this function:

CString PikeAero::CString::left ( CMachine::bit32  n  ) 

Definition at line 86 of file cstring.cpp.

References append(), and PikeAero::CByteArray::data().

Referenced by sprintff().

00087 {
00088     CString str;
00089     for ( CMachine::bit32 i = 0; i < n; i++ )
00090     {
00091         str.append( data()[i] );
00092     }
00093     return str;
00094 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::ubit32 PikeAero::CString::length (  )  [inline, virtual]

Reimplemented from PikeAero::CByteArray.

Definition at line 86 of file cstring.h.

References PikeAero::CByteArray::data(), and strlen.

Referenced by explode(), find(), right(), PikeAero::CTaskConsole::run(), sprintf(), strcat(), toBit32(), toLower(), toUBit32(), toUpper(), PikeAero::CCommunication::tx(), and PikeAero::CCommunication::txnl().

00086 {return data()!=NULL?strlen((const char*)data()):0;}

Here is the call graph for this function:

Here is the caller graph for this function:

CString PikeAero::CString::mid ( CMachine::bit32  index,
CMachine::bit32  n 
)

Definition at line 106 of file cstring.cpp.

References append(), and PikeAero::CByteArray::data().

Referenced by explode().

00107 {
00108     CString str;
00109     for ( CMachine::bit32 i = index; n > 0; n--,i++ )
00110     {
00111         str.append( data()[i] );
00112     }
00113     return str;
00114 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PikeAero::CString::operator!= ( CMachine::bit8 data  )  [inline]

Definition at line 72 of file cstring.h.

References strcmp().

00072 {return strcmp((CMachine::ubit8*)data)!=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator!= ( CMachine::ubit8 data  )  [inline]

Definition at line 71 of file cstring.h.

References strcmp().

00071 {return strcmp(data)!=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator!= ( CString other  )  [inline]

Definition at line 70 of file cstring.h.

References compare().

00070 {return compare(other)!=0;}

Here is the call graph for this function:

CString& PikeAero::CString::operator+= ( CMachine::bit8  ch  )  [inline]

Definition at line 64 of file cstring.h.

References append().

00064 {return append(ch);}

Here is the call graph for this function:

CString& PikeAero::CString::operator+= ( CMachine::ubit8  ch  )  [inline]

Definition at line 63 of file cstring.h.

References append().

00063 {return append(ch);}

Here is the call graph for this function:

CString& PikeAero::CString::operator+= ( CMachine::ubit8 data  )  [inline]

Definition at line 62 of file cstring.h.

References append().

00062 {return append(data);}

Here is the call graph for this function:

CString& PikeAero::CString::operator+= ( CString other  )  [inline]

Definition at line 61 of file cstring.h.

References append().

00061 {return append(other);}

Here is the call graph for this function:

bool PikeAero::CString::operator< ( CMachine::bit8 data  )  [inline]

Definition at line 78 of file cstring.h.

References strcmp().

00078 {return strcmp((CMachine::ubit8*)data)<0;}

Here is the call graph for this function:

bool PikeAero::CString::operator< ( CMachine::ubit8 data  )  [inline]

Definition at line 77 of file cstring.h.

References strcmp().

00077 {return strcmp(data)<0;}

Here is the call graph for this function:

bool PikeAero::CString::operator< ( CString other  )  [inline]

Definition at line 76 of file cstring.h.

References compare().

00076 {return compare(other)<0;}

Here is the call graph for this function:

bool PikeAero::CString::operator<= ( CMachine::bit8 data  )  [inline]

Definition at line 84 of file cstring.h.

References strcmp().

00084 {return strcmp((CMachine::ubit8*)data)<=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator<= ( CMachine::ubit8 data  )  [inline]

Definition at line 83 of file cstring.h.

References strcmp().

00083 {return strcmp(data)<=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator<= ( CString other  )  [inline]

Definition at line 82 of file cstring.h.

References compare().

00082 {return compare(other)<=0;}

Here is the call graph for this function:

CString& PikeAero::CString::operator= ( CMachine::ubit8 data  )  [inline]

Definition at line 60 of file cstring.h.

References copy().

00060 {return copy(data);}

Here is the call graph for this function:

CString& PikeAero::CString::operator= ( CString other  )  [inline]

Definition at line 59 of file cstring.h.

References copy().

00059 {return copy(other);}

Here is the call graph for this function:

bool PikeAero::CString::operator== ( const CMachine::bit8 data  )  [inline]

Definition at line 69 of file cstring.h.

References strcmp().

00069 {return strcmp((CMachine::ubit8*)data)==0;}

Here is the call graph for this function:

bool PikeAero::CString::operator== ( const CMachine::ubit8 data  )  [inline]

Definition at line 68 of file cstring.h.

References strcmp().

00068 {return strcmp((CMachine::ubit8*)data)==0;}

Here is the call graph for this function:

bool PikeAero::CString::operator== ( CMachine::bit8 data  )  [inline]

Definition at line 67 of file cstring.h.

References strcmp().

00067 {return strcmp((CMachine::ubit8*)data)==0;}

Here is the call graph for this function:

bool PikeAero::CString::operator== ( CMachine::ubit8 data  )  [inline]

Definition at line 66 of file cstring.h.

References strcmp().

00066 {return strcmp(data)==0;}

Here is the call graph for this function:

bool PikeAero::CString::operator== ( CString other  )  [inline]

Definition at line 65 of file cstring.h.

References compare().

00065 {return compare(other)==0;}

Here is the call graph for this function:

bool PikeAero::CString::operator> ( CMachine::bit8 data  )  [inline]

Definition at line 75 of file cstring.h.

References strcmp().

00075 {return strcmp((CMachine::ubit8*)data)>0;}

Here is the call graph for this function:

bool PikeAero::CString::operator> ( CMachine::ubit8 data  )  [inline]

Definition at line 74 of file cstring.h.

References strcmp().

00074 {return strcmp(data)>0;}

Here is the call graph for this function:

bool PikeAero::CString::operator> ( CString other  )  [inline]

Definition at line 73 of file cstring.h.

References compare().

00073 {return compare(other)>0;}

Here is the call graph for this function:

bool PikeAero::CString::operator>= ( CMachine::bit8 data  )  [inline]

Definition at line 81 of file cstring.h.

References strcmp().

00081 {return strcmp((CMachine::ubit8*)data)>=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator>= ( CMachine::ubit8 data  )  [inline]

Definition at line 80 of file cstring.h.

References strcmp().

00080 {return strcmp(data)>=0;}

Here is the call graph for this function:

bool PikeAero::CString::operator>= ( CString other  )  [inline]

Definition at line 79 of file cstring.h.

References compare().

00079 {return compare(other)>=0;}

Here is the call graph for this function:

CString & PikeAero::CString::prepend ( CMachine::ubit8  data  ) 

Reimplemented from PikeAero::CByteArray.

Definition at line 178 of file cstring.cpp.

References append(), and isNull().

Referenced by right(), and sprintf().

00179 {
00180     if ( isNull() )
00181     {
00182         append( (CMachine::ubit8)'\0' );
00183     }
00184     inherited::prepend(data);
00185     return *this;
00186 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::resize ( CMachine::ubit32  size  ) 

Reimplemented from PikeAero::CByteArray.

Definition at line 72 of file cstring.cpp.

References PikeAero::CByteArray::clear(), and PikeAero::CByteArray::size().

Referenced by PikeAero::CTaskConsole::run(), strcat(), and strcpy().

00073 {
00074     if ( size == 0 )
00075     {
00076         inherited::clear();
00077     }
00078     else
00079     {
00080         inherited::resize( size+1 );
00081         set( inherited::size()-1, 0 );
00082     }
00083     return *this;
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString PikeAero::CString::right ( CMachine::bit32  n  ) 

Definition at line 96 of file cstring.cpp.

References PikeAero::CByteArray::data(), length(), and prepend().

00097 {
00098     CString str;
00099     for ( CMachine::bit32 i = length()-1; i >= 0; i-- )
00100     {
00101         str.prepend( data()[i] );
00102     }
00103     return str;
00104 }

Here is the call graph for this function:

void PikeAero::CString::setData ( CMachine::ubit8 d  ) 

CAUTION Use only memory from CMemHeap as setData(CMachine::ubit8*) takes pointer ownership!! CAUTION Use only if you know EXACTLY what you are doing!!

CAUTION Take ownership of the pointer. CAUTION use only memory allocated from the CMemHeap. CAUTION

Definition at line 172 of file cstring.cpp.

References PikeAero::CByteArray::clear(), and PikeAero::CByteArray::mData.

00173 {
00174     clear();
00175     mData=d;
00176 }

Here is the call graph for this function:

CString & PikeAero::CString::sprintf ( CMachine::bit8 fmt,
  ... 
)

sprintf( fmt, ... ) Appends formted text and returns a reference. b - ubit8 - hex 2 digits c - character s - string x - ubit16 - hex 4 digits X - ubit32 - hex 8 digits f - float - 32 bit signed ieee754

Returns:
returns reference

Definition at line 296 of file cstring.cpp.

References append(), PikeAero::CByteArray::clear(), fromBit32(), isnum, length(), prepend(), toHex(), toUBit32(), and PikeAero::CTaskScheduler::yield().

Referenced by PikeAero::CTaskTerminal::clearAttributes(), PikeAero::CCommandHandler::commandQM2C(), PikeAero::CCommandHandler::commandQM2S(), PikeAero::CCommandHandler::commandQMC(), PikeAero::CCommandHandler::commandQMDT(), PikeAero::CCommandHandler::commandQMS(), PikeAero::CCommandHandler::commandQSM2C(), PikeAero::CCommandHandler::commandQSM2S(), PikeAero::CCommandHandler::commandQSM2X(), PikeAero::CCommandHandler::commandQSM2Y(), PikeAero::CCommandHandler::commandQSMC(), PikeAero::CCommandHandler::commandQSMS(), PikeAero::CCommandHandler::commandQSMV(), PikeAero::CCommandHandler::commandSM2C(), PikeAero::CCommandHandler::commandSM2S(), PikeAero::CCommandHandler::commandSMC(), PikeAero::CCommandHandler::commandSMDT(), PikeAero::CCommandHandler::commandSMS(), PikeAero::CCommandHandler::commandSSM2C(), PikeAero::CCommandHandler::commandSSM2S(), PikeAero::CCommandHandler::commandSSM2X(), PikeAero::CCommandHandler::commandSSM2Y(), PikeAero::CCommandHandler::commandSSMC(), PikeAero::CCommandHandler::commandSSMS(), PikeAero::CCommandHandler::commandSSMV(), PikeAero::CTaskTerminal::cursorMoveAbsolute(), PikeAero::CTaskTerminal::cursorMoveBackward(), PikeAero::CTaskTerminal::cursorMoveDown(), PikeAero::CTaskTerminal::cursorMoveForward(), PikeAero::CTaskTerminal::cursorMoveUp(), PikeAero::CTaskConsole::drawCommandPrompt(), PikeAero::CTaskConsole::drawStatusBar(), PikeAero::CTaskTerminal::eraseDisplay(), PikeAero::CTaskTerminal::eraseLine(), PikeAero::CTaskConsolePacket::monitor(), PikeAero::CTaskConsole::monitor(), PikeAero::CCommandHandler::replyReturn(), PikeAero::CTaskTerminal::setAttributeReverseVideo(), and sprintff().

00297 {
00298     va_list ap;
00299     va_start(ap,fmt);
00300     const CMachine::bit8 *p=fmt;
00301 
00302     bool zeros=false;
00303     CMachine::ubit32 fill=0;
00304     CString tBuf;
00305 
00306     clear();
00307 
00308     while( *p != '\0' ) {
00309         if ( *p == '%' ) {
00310             ++p;
00311 
00312             if ( *p == '0' )
00313             {
00314                 zeros = true;
00315                 ++p;
00316             }
00317             else
00318             {
00319                 zeros = false;
00320             }
00321 
00322             tBuf.clear();
00323             while ( isnum( *p ) )
00324             {
00325                 tBuf.append( *p );
00326                 ++p;
00327             }
00328             fill = tBuf.toUBit32();
00329 
00330             switch (*p ) {
00331                 case 'x':
00332                 case 'd':
00333                     {
00334                         CString dec;
00335                         if ( *p == 'x' )
00336                         {
00337                             dec.toHex( (CMachine::ubit32)va_arg(ap,CMachine::ubit32) );
00338                         }
00339                         else
00340                         {
00341                             dec.fromBit32( (CMachine::bit32)va_arg(ap,CMachine::bit32) );
00342                         }
00343                         while ( dec.length() < fill )
00344                         {
00345                             dec.prepend( zeros ? '0' : ' ' );
00346                         }
00347                         append( dec );
00348                     }
00349                     break;
00350                 case 'c':
00351                     append( (CMachine::bit8)va_arg(ap,int) );
00352                     break;
00353                 case 's':
00354                     append( (CMachine::ubit8*)va_arg(ap,CMachine::bit8 *) );
00355                     break;
00356                 case 'g':
00357                 case 'f':
00358                     // (CMachine::real)va_arg(ap,double);
00359                     break;
00360             }
00361             ++p;
00362         }
00363         else
00364         {
00365             append( *p++ );
00366         }
00367         CTaskScheduler::yield();
00368     }
00369     va_end(ap);
00370     return *this;
00371 }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CString::sprintff ( CMachine::ubit32  fbinary  )  [private]

(private) sprintff( fbinary ) Convert binary IEEE754 floating point to string. INFO - Derived by reading http://en.wikipedia.org/wiki/IEEE_754

compute whole number

can't do yet

compute fraction

Number < 1.0

Definition at line 377 of file cstring.cpp.

References PikeAero::CByteArray::data(), left(), and sprintf().

00378 {
00379     CMachine::bit8 sign;
00380     CMachine::ubit8 exp;
00381     CMachine::bit32 bias;
00382     CMachine::bit32 data;
00383     CMachine::bit32 left;
00384 
00385     sign = ' ';
00386     if ((fbinary & 0x80000000) != 0) sign = '-';
00387 
00388     exp = (fbinary & 0x7F800000) >> 23;
00389 
00390     /** compute whole number */
00391     bias = (int)exp - (int)127;
00392     if (bias >= 0)
00393     {
00394         if (bias <= 30)
00395         {
00396             data = 0x1;
00397             while (bias > 0)
00398             {
00399                 data <<= 1;
00400                 if ((fbinary & 0x00400000) != 0)
00401                     data |= 0x1;
00402                 fbinary <<= 1;
00403                 --bias;
00404             }
00405             sprintf( "%c%d.", sign, data );
00406         }
00407         else
00408         {
00409         /** can't do yet */
00410             sprintf( "**.****\n");
00411             return;
00412         }
00413 
00414         /** compute fraction */
00415         data = 0;
00416         left = 500000000;
00417         fbinary &= 0x007FFFFF;
00418         while (fbinary != 0)
00419         {
00420             if ((fbinary & 0x00400000) != 0)
00421                 data += left;
00422             fbinary <<= 1;
00423             fbinary &= 0x007FFFFF;
00424             left = left >> 1;
00425         }
00426         sprintf( "%09d\n", data );
00427     }
00428     else
00429     {
00430         /** Number < 1.0 */
00431         sprintf( "%c0.", sign );
00432         bias = -bias;
00433         if (bias < 24 )
00434         {
00435             data = 0;
00436             left = 500000000;
00437             fbinary &= 0x00FFFFFF;
00438             fbinary |= 0x00800000;
00439             fbinary >>= (bias-1);
00440             while (fbinary != 0)
00441             {
00442                 if ((fbinary & 0x00800000) != 0)
00443                     data += left;
00444                 fbinary <<= 1;
00445                 fbinary &= 0x00FFFFFF;
00446                 left = left >> 1;
00447             }
00448             sprintf( "%09d\n", data );
00449         }
00450         else
00451         {
00452             sprintf( "%09d\n", 0 );
00453         }
00454     }
00455     return;
00456 }

Here is the call graph for this function:

CString & PikeAero::CString::strcat ( CMachine::ubit8 d,
CMachine::bit32  len = 0 
)

The strcat() function appends the d string,The strings may not overlap.

Returns:
self reference.

Definition at line 161 of file cstring.cpp.

References length(), resize(), PikeAero::CByteArray::set(), and strlen.

Referenced by append().

00162 {
00163     CMachine::ubit32 t=length();
00164     len = ( len==0 ? strlen((const char*)d) : len);
00165     resize((t+len)+1).set((t+len),'\0');
00166     return static_cast<CString&>(set(t,d,len));
00167 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CString::strcmp ( const CMachine::ubit8 s  )  [inline]

Definition at line 56 of file cstring.h.

References PikeAero::CByteArray::data().

Referenced by compare(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

00056 {return ::strcmp((const char*)data(), (const char*)s);}

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::strcpy ( CMachine::ubit8 d,
CMachine::bit32  len = 0 
)

Copies the string pointed to by d, The strings may not overlap.

Returns:
self reference.

Definition at line 150 of file cstring.cpp.

References resize(), PikeAero::CByteArray::set(), and strlen.

Referenced by copy().

00151 {
00152     len = ( len==0 ? strlen((const char*)d) : len);
00153     resize(len+1).set(len,'\0');
00154     return static_cast<CString&>(set(0,d,len));
00155 }

Here is the call graph for this function:

Here is the caller graph for this function:

CMachine::bit32 PikeAero::CString::toBit32 (  ) 

Convert to a signed integer.

Definition at line 264 of file cstring.cpp.

References PikeAero::CByteArray::data(), isnum, length(), and PikeAero::CTaskScheduler::yield().

Referenced by PikeAero::CVariant::update().

00265 {
00266     CMachine::bit32 rc=0;
00267     if ( length() )
00268     {
00269         CMachine::bit32 multiplyer=1;
00270         for( CMachine::bit32 digit=length()-1; digit >= 0 && ( isnum(data()[digit]) || data()[digit]=='-' ); digit-- )
00271         {
00272             if ( data()[digit] == '-' )
00273             {
00274                 rc = -rc;
00275                 break;
00276             }
00277             rc += (data()[digit] - '0') * multiplyer;
00278             multiplyer = multiplyer * 10;
00279             CTaskScheduler::yield();
00280         }
00281     }
00282     return rc;
00283 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::toHex ( CMachine::ubit32  n  ) 

Definition at line 188 of file cstring.cpp.

References append(), PikeAero::CByteArray::clear(), hex, and PikeAero::CTaskScheduler::yield().

Referenced by sprintf().

00189 {
00190     bool started=false;
00191     clear();
00192     for( CMachine::bit32 i=7; i >=0; i-- )
00193     {
00194         CMachine::ubit8 ch = (CMachine::ubit8)((n >> (4*i))&0xf);
00195         if ( ch != 0 )
00196             started = true;
00197         if ( started )
00198             append( (CMachine::ubit8)hex(ch) );
00199         CTaskScheduler::yield();
00200     }
00201     return *this;
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::toLower (  ) 

Definition at line 116 of file cstring.cpp.

References PikeAero::CByteArray::data(), length(), and tolower.

00117 {
00118     for ( CMachine::bit32 i = 0; i < length(); i++ )
00119     {
00120         set( i, tolower( data()[i] ) );
00121     }
00122     return *this;
00123 }

Here is the call graph for this function:

CMachine::ubit32 PikeAero::CString::toUBit32 (  ) 

Convert to an unsigned integer.

Definition at line 245 of file cstring.cpp.

References PikeAero::CByteArray::data(), isnum, length(), and PikeAero::CTaskScheduler::yield().

Referenced by PikeAero::CCommandHandler::commandA(), PikeAero::CCommandHandler::commandCLOSE(), PikeAero::CCommandHandler::commandCOMMIT(), PikeAero::CCommandHandler::commandCOPY(), PikeAero::CCommandHandler::commandERASE(), PikeAero::CCommandHandler::commandOPEN(), and sprintf().

00246 {
00247     CMachine::ubit32 rc=0;
00248     if ( length() )
00249     {
00250         CMachine::bit32 multiplyer=1;
00251         for( CMachine::bit32 digit=length()-1; digit >= 0 && isnum(data()[digit]); digit-- )
00252         {
00253             rc += (data()[digit] - '0') * multiplyer;
00254             multiplyer = multiplyer * 10;
00255             CTaskScheduler::yield();
00256         }
00257     }
00258     return rc;
00259 }

Here is the call graph for this function:

Here is the caller graph for this function:

CString & PikeAero::CString::toUpper (  ) 

Definition at line 125 of file cstring.cpp.

References PikeAero::CByteArray::data(), length(), and toupper.

00126 {
00127     for ( CMachine::bit32 i = 0; i < length(); i++ )
00128     {
00129         set( i, toupper( data()[i] ) );
00130     }
00131     return *this;
00132 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:

Generated on Sun Oct 25 14:00:20 2009 for stingray3 by  doxygen 1.5.8