Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

oofCheckString Class Reference

#include <oofstr.h>

Inheritance diagram for oofCheckString:

Inheritance graph
[legend]
Collaboration diagram for oofCheckString:

Collaboration graph
[legend]
List of all members.

Detailed Description

strings for named numbers eg check (cheque) printing, eg: "one two zero"


Public Types

typedef short(* oofCompareFunc )(const void *inLeft, const void *inRight, long inLeftLength, long inRightLength)
 string comparison nearly directly compatible with PowerPlant's except doesn't have inherent size limits from assumption of Str255 types (Pascal strings)

enum  { CR = 13, LF = 10, kNotFound = -1 }

Public Member Functions

 oofCheckString (unsigned long, char sepChar=0x20)
 Ctor builds string from integer in typical "check" format.

void loadResource (unsigned long strID)
void insertChars (const char *, unsigned long, unsigned long beforeChar=ULONG_MAX)
void setChars (const char *, unsigned long)
 Replace current contents of string with incoming buffer.

void adopt (char *)
void adopt (oofString &)
void shorten (unsigned short)
void padTo (unsigned short paddedLength, char padWith=' ', bool rightAlign=false)
void operator+= (char)
void operator+= (const char *)
void operator+= (const oofString &)
void append (const char *, unsigned long appendLen)
void clear ()
char & operator[] (int) const
char & operator[] (short) const
char & operator[] (unsigned long) const
void convertNumber (int, const char *printfMask=0, bool appendIt=false)
void convertNumber (unsigned long, const char *printfMask=0, bool appendIt=false)
void convertNumber (double, const char *printfMask=0, bool appendIt=false)
int format (const char *inStr,...)
 Create string content using printf formatting.

unsigned long replaceChar (char fromChar, char toChar, unsigned long startAt=0)
void replaceAt (unsigned long startAt, unsigned long numChars, const char *newStr, unsigned long newLen=ULONG_MAX)
unsigned long replaceFirstString (const char *replaceStr, const char *newStr, bool caseSensitive=false)
unsigned long replaceString (const char *replaceStr, const char *newStr, unsigned long startAt=0, bool caseSensitive=false)
 Search and replace a substring with optional starting offset and case sensitivity.

unsigned long replaceBetween (const char *leftStr, const char *rightStr, const char *insertStr, bool caseSensitive=false)
unsigned long replaceStringWholeWord (const char *replaceStr, const char *newStr, unsigned long startAt=0, bool caseSensitive=false)
 Search and replace a substring with optional starting offset and case sensitivity.

unsigned long stripChar (char, unsigned long startAt=0)
void makeRandomChars (unsigned long numChars)
void encodeURL ()
void setStr255 (const Str255)
 operator const char * () const
const char * chars () const
char * charsForOldInterfacesNotWriting () const
char * orphan (bool neverReturnNil=true)
char firstChar () const
char lastChar () const
bool startsWith (char) const
bool startsWith (const char *) const
bool endsWith (char) const
bool endsWith (const char *, int inLen=-1) const
void getChars (char *ioBuff, unsigned long &ioLen) const
void getStr255 (Str255 s) const
 operator std::string () const
oofString left (unsigned long numChars) const
oofString right (unsigned long numChars) const
oofString subString (unsigned long fromChars, unsigned long numChars=ULONG_MAX) const
oofString subStringBetween (const char *, const char *) const
oofString subStringBetween (char, char) const
oofString operator- (const char *) const
long find (const char *, unsigned long startFrom=0, bool caseSensitive=false, unsigned long inLen=ULONG_MAX) const
 Character-based search with optional case sensitivity.

long find (char, unsigned long startFrom=0, bool caseSensitive=false) const
 Optionally caseSensitive find of first match.

long findLast (const char *, bool caseSensitive=false, unsigned long inLen=ULONG_MAX) const
 Character-based reverse search with optional case sensitivity.

long findLast (char, bool caseSensitive=false) const
bool contains (const char *, bool caseSensitive=false) const
bool contains (char, bool caseSensitive=false) const
long findEnd (const char *, unsigned long startFrom=0, bool caseSensitive=false) const
unsigned short asUnsignedShort () const
short asShort () const
long asLong () const
unsigned long asUnsignedLong () const
double asDouble () const
bool isEmpty () const
unsigned long length () const
bool isAlphaNumeric () const
bool operator== (const Str255) const
bool operator== (const oofString &rhs) const
bool operator== (const char *) const
bool operator!= (const char *) const
bool operator!= (const oofString &rhs) const
bool lineEndingsCurrentPlatform ()
bool lineEndingsMac ()
bool lineEndingsUnix ()
bool lineEndingsDOS ()

Static Public Member Functions

char * lineEndingsCurrentPlatform (char *, unsigned long &ioLen)
 forward to appropriate platform method for static converters

char * lineEndingsMac (char *, unsigned long &ioLen)
char * lineEndingsUnix (char *, unsigned long &ioLen)
char * lineEndingsDOS (char *, unsigned long &ioLen)
oofString encodeEntity (const oofString &)
 Return a string encoded suitable for use in HTML or XML.

oofString decodeEntity (const oofString &)
 Return a string decoded from HTML or XML.

oofString utf8To8BitAscii (const oofString &)
oofString utf8To8BitAscii (const char *, unsigned long)
 Change string contents to decoded version of Unicode 8 bit string.

oofString quoteString (const oofString &, char quoteChar='\'')
oofString singular (const oofString &)
oofString legalName (const oofString &, char nonAlphaReplace='_', char leadingDigitReplace='n', char spaceReplace='_')

Protected Attributes

char * mBody
unsigned long mLen

Static Protected Attributes

char sEmptyChar = '\0'


Member Typedef Documentation

typedef short(* oofString::oofCompareFunc)( const void* inLeft, const void* inRight, long inLeftLength, long inRightLength) [inherited]
 

string comparison nearly directly compatible with PowerPlant's except doesn't have inherent size limits from assumption of Str255 types (Pascal strings)

left == right, returns 0 left > right, returns 1 left < right, returns -1


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumeration values:
CR 
LF 
kNotFound 


Constructor & Destructor Documentation

oofCheckString::oofCheckString unsigned long  n,
char  sepChar = 0x20
 

Ctor builds string from integer in typical "check" format.

eg: 1234 becomes "one two three four"

Parameters:
sepChar is optional if you want other than space between letters.

Todo:
estimate size based on size of number & prealloc


Member Function Documentation

void oofString::adopt oofString  )  [inherited]
 

void oofString::adopt char *   )  [inherited]
 

void oofString::append const char *  ,
unsigned long  appendLen
[inherited]
 

double oofString::asDouble  )  const [inherited]
 

long oofString::asLong  )  const [inherited]
 

short oofString::asShort  )  const [inherited]
 

unsigned long oofString::asUnsignedLong  )  const [inherited]
 

unsigned short oofString::asUnsignedShort  )  const [inherited]
 

const char * oofString::chars  )  const [inline, inherited]
 

char * oofString::charsForOldInterfacesNotWriting  )  const [inline, inherited]
 

void oofString::clear  )  [inherited]
 

bool oofString::contains char  ,
bool  caseSensitive = false
const [inline, inherited]
 

bool oofString::contains const char *  ,
bool  caseSensitive = false
const [inline, inherited]
 

void oofString::convertNumber double  ,
const char *  printfMask = 0,
bool  appendIt = false
[inherited]
 

void oofString::convertNumber unsigned  long,
const char *  printfMask = 0,
bool  appendIt = false
[inherited]
 

void oofString::convertNumber int  ,
const char *  printfMask = 0,
bool  appendIt = false
[inherited]
 

oofString oofString::decodeEntity const oofString srcString  )  [static, inherited]
 

Return a string decoded from HTML or XML.

Doesn't do any special parsing, just decodes entities like & or other numbers. Uses the XML subset of encodings allowed in HTML, just lt, gt, amp, apos and quot.

oofString oofString::encodeEntity const oofString srcString  )  [static, inherited]
 

Return a string encoded suitable for use in HTML or XML.

void oofString::encodeURL  )  [inherited]
 

bool oofString::endsWith const char *  ,
int  inLen = -1
const [inherited]
 

bool oofString::endsWith char   )  const [inherited]
 

long oofString::find char  inChar,
unsigned long  startFrom = 0,
bool  caseSensitive = false
const [inherited]
 

Optionally caseSensitive find of first match.

Returns:
kNotFound or index of first substring found.
Parameters:
caseSensitive defaults false.

long oofString::find const char *  inStr,
unsigned long  startFrom = 0,
bool  caseSensitive = false,
unsigned long  inLen = ULONG_MAX
const [inherited]
 

Character-based search with optional case sensitivity.

Parameters:
caseSensitive default false
inLen optional length of search argument to save time doing strlen if known length
Warning:
only caseSensitive if pass in a totally alphabetic search string
Todo:
decide if caseSensitive policy should be changed

long oofString::findEnd const char *  ,
unsigned long  startFrom = 0,
bool  caseSensitive = false
const [inherited]
 

long oofString::findLast char  ,
bool  caseSensitive = false
const [inherited]
 

long oofString::findLast const char *  inStr,
bool  caseSensitive = false,
unsigned long  inLen = ULONG_MAX
const [inherited]
 

Character-based reverse search with optional case sensitivity.

Parameters:
caseSensitive default false
inLen optional length of search argument to save time doing strlen if known length
Warning:
only caseSensitive if pass in a totally alphabetic search string
Todo:
decide if caseSensitive policy should be changed

char oofString::firstChar  )  const [inherited]
 

int oofString::format const char *  inFormat,
... 
[inherited]
 

Create string content using printf formatting.

Warning:
may overrun buffer of size OOF_OOFSTR_FORMAT_BUFFERSIZE use at own risk!!
Todo:
possibly throw error instead of assert to guard overrun.

void oofString::getChars char *  ioBuff,
unsigned long &  ioLen
const [inherited]
 

void oofString::getStr255 Str255  s  )  const [inherited]
 

void oofString::insertChars const char *  ,
unsigned  long,
unsigned long  beforeChar = ULONG_MAX
[inherited]
 

bool oofString::isAlphaNumeric  )  const [inherited]
 

bool oofString::isEmpty  )  const [inline, inherited]
 

char oofString::lastChar  )  const [inherited]
 

oofString oofString::left unsigned long  numChars  )  const [inherited]
 

oofString oofString::legalName const oofString ,
char  nonAlphaReplace = '_',
char  leadingDigitReplace = 'n',
char  spaceReplace = '_'
[static, inherited]
 

unsigned long oofString::length  )  const [inline, inherited]
 

char * oofString::lineEndingsCurrentPlatform char *  ,
unsigned long &  ioLen
[inline, static, inherited]
 

forward to appropriate platform method for static converters

bool oofString::lineEndingsCurrentPlatform  )  [inline, inherited]
 

char * oofString::lineEndingsDOS char *  ,
unsigned long &  ioLen
[static, inherited]
 

bool oofString::lineEndingsDOS  )  [inherited]
 

char * oofString::lineEndingsMac char *  ,
unsigned long &  ioLen
[static, inherited]
 

bool oofString::lineEndingsMac  )  [inherited]
 

char * oofString::lineEndingsUnix char *  ,
unsigned long &  ioLen
[static, inherited]
 

bool oofString::lineEndingsUnix  )  [inherited]
 

void oofString::loadResource unsigned long  strID  )  [inherited]
 

void oofString::makeRandomChars unsigned long  numChars  )  [inherited]
 

oofString::operator const char *  )  const [inherited]
 

oofString::operator std::string  )  const [inherited]
 

bool oofString::operator!= const oofString rhs  )  const [inline, inherited]
 

bool oofString::operator!= const char *   )  const [inline, inherited]
 

void oofString::operator+= const oofString  )  [inherited]
 

void oofString::operator+= const char *   )  [inherited]
 

void oofString::operator+= char   )  [inherited]
 

oofString oofString::operator- const char *   )  const [inherited]
 

bool oofString::operator== const char *   )  const [inherited]
 

bool oofString::operator== const oofString rhs  )  const [inherited]
 

bool oofString::operator== const  Str255  )  const [inherited]
 

char & oofString::operator[] unsigned  long  )  const [inherited]
 

char & oofString::operator[] short   )  const [inline, inherited]
 

char & oofString::operator[] int   )  const [inline, inherited]
 

char * oofString::orphan bool  neverReturnNil = true  )  [inherited]
 

void oofString::padTo unsigned short  paddedLength,
char  padWith = ' ',
bool  rightAlign = false
[inherited]
 

oofString oofString::quoteString const oofString ,
char  quoteChar = '\''
[static, inherited]
 

void oofString::replaceAt unsigned long  startAt,
unsigned long  numChars,
const char *  newStr,
unsigned long  newLen = ULONG_MAX
[inherited]
 

unsigned long oofString::replaceBetween const char *  leftStr,
const char *  rightStr,
const char *  insertStr,
bool  caseSensitive = false
[inherited]
 

unsigned long oofString::replaceChar char  fromChar,
char  toChar,
unsigned long  startAt = 0
[inherited]
 

unsigned long oofString::replaceFirstString const char *  replaceStr,
const char *  newStr,
bool  caseSensitive = false
[inherited]
 

unsigned long oofString::replaceString const char *  replaceStr,
const char *  newStr,
unsigned long  startAt = 0,
bool  caseSensitive = false
[inherited]
 

Search and replace a substring with optional starting offset and case sensitivity.

Todo:
add an OOFILE sample to exercise edge conditions where input strings match

add an OOFILE sample to test if original string exactly matches replacement

check if David's increment is needed - startAt = foundAt + strlen(newStr);

Warning:
too much optimisation will may break - you may get substrings where the replace string in combination with surroundings causes a recurrence of the original

unsigned long oofString::replaceStringWholeWord const char *  replaceStr,
const char *  newStr,
unsigned long  startAt = 0,
bool  caseSensitive = false
[inherited]
 

Search and replace a substring with optional starting offset and case sensitivity.

Similar to replaceString except this only replaces whole word matches of sub string This to prevent calls like replaceStringWholeWord("htm", html) pm "html htm" giving htmll html A word is defined a s a sequence of matching chars, delimited by a non alpha/numeric char

Todo:
add an OOFILE sample to exercise edge conditions where input strings match

add an OOFILE sample to test if original string exactly matches replacement

check if David's increment is needed - startAt = foundAt + strlen(newStr);

Warning:
too much optimisation will may break - you may get substrings where the replace string in combination with surroundings causes a recurrence of the original

oofString oofString::right unsigned long  numChars  )  const [inherited]
 

void oofString::setChars const char *  chars,
unsigned long  charLen
[inherited]
 

Replace current contents of string with incoming buffer.

Still deletes current contents if incoming empty string or null pointer, which makes this a way to clear contents. Common idiom is myString = 0 or myString = ""; to clear a string.

optimal setting
To avoid thrashing heap with lots of similar allocs, if incoming string is over half size of existing or string small, just copy chars without a delete.

Todo:
smarter avoid reallocs if mBody within certain size range that will fit chars - would require keeping alloc length as well as mLen as repeated reallocs here will be in ignorance of true buffer size.

void oofString::setStr255 const  Str255  )  [inherited]
 

void oofString::shorten unsigned  short  )  [inherited]
 

oofString oofString::singular const oofString  )  [static, inherited]
 

bool oofString::startsWith const char *   )  const [inherited]
 

bool oofString::startsWith char   )  const [inherited]
 

unsigned long oofString::stripChar char  ,
unsigned long  startAt = 0
[inherited]
 

oofString oofString::subString unsigned long  fromChars,
unsigned long  numChars = ULONG_MAX
const [inherited]
 

oofString oofString::subStringBetween char  ,
char 
const [inherited]
 

oofString oofString::subStringBetween const char *  ,
const char * 
const [inherited]
 

oofString oofString::utf8To8BitAscii const char *  srcString,
unsigned long  len
[static, inherited]
 

Change string contents to decoded version of Unicode 8 bit string.

Note:
if normal ASCII printable characters are used, UTF8 looks same as an ASCII string
Parameters:
srcString 8 bit UTF as used in 8 bit XML.

oofString oofString::utf8To8BitAscii const oofString  )  [inline, static, inherited]
 


Member Data Documentation

char* oofString::mBody [protected, inherited]
 

unsigned long oofString::mLen [protected, inherited]
 

char oofString::sEmptyChar = '\0' [static, protected, inherited]
 


The documentation for this class was generated from the following files:
Generated on Thu Jan 1 21:31:14 2004 for OOFILE by doxygen 1.3.5