OOFILE  1.9
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
oofCheckString Class Reference

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

#include <oofstr.h>

Inheritance diagram for oofCheckString:
Inheritance graph
[legend]
Collaboration diagram for oofCheckString:
Collaboration graph
[legend]

Public Types

enum  { CR = 13, LF = 10, kNotFound =-1 }
 
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) More...
 

Public Member Functions

void adopt (char *)
 Take ownership of incoming buffer, replacing current contents. More...
 
void adopt (oofString &)
 Take ownership of buffer from incoming string, replacing current contents. More...
 
void append (const char *, unsigned long appendLen)
 
double asDouble () const
 Attempt to return real value of string. More...
 
long asLong () const
 Attempt to return integer value of string. More...
 
short asShort () const
 Attempt to return integer value of string. More...
 
unsigned long asUnsignedLong () const
 Attempt to return integer value of string. More...
 
unsigned short asUnsignedShort () const
 Attempt to return integer value of string. More...
 
const char * chars () const
 Primary test: oofStringTest::stringInitOneCharFromConstant () More...
 
char * charsForOldInterfacesNotWriting () const
 
void clear ()
 Abandon string contents, resetting length. More...
 
bool contains (const char *, bool caseSensitive=false) const
 
bool contains (char, bool caseSensitive=false) 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)
 
void encodeURL ()
 
bool endsWith (char) const
 
bool endsWith (const char *, int inLen=-1) 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. More...
 
long find (char, unsigned long startFrom=0, bool caseSensitive=false) const
 Optionally caseSensitive find of first match. More...
 
long findEnd (const char *, unsigned long startFrom=0, bool caseSensitive=false) const
 
long findLast (const char *, bool caseSensitive=false, unsigned long inLen=ULONG_MAX) const
 Character-based reverse search with optional case sensitivity. More...
 
long findLast (char, bool caseSensitive=false) const
 
char firstChar () const
 Constant access to first char. More...
 
int format (const char *inStr,...)
 Create string content using printf formatting. More...
 
void getChars (char *ioBuff, unsigned long &ioLen) const
 
void getStr255 (Str255 s) const
 
void insertChars (const char *, unsigned long, unsigned long beforeChar=ULONG_MAX)
 
bool isAlphaNumeric () const
 
bool isEmpty () const
 Test based on either length or null pointer. More...
 
char lastChar () const
 Constant access to last char. More...
 
oofString left (unsigned long numChars) const
 Create new string containing leftmost numChars. More...
 
unsigned long length () const
 Primary test: oofStringTest::emptyStringByNullInitIsLenZero() More...
 
bool lineEndingsCurrentPlatform ()
 
bool lineEndingsDOS ()
 Convert all line endings in string to DOS standard - CRLF. More...
 
bool lineEndingsMac ()
 Convert all line endings in string to Mac standard - CR. More...
 
bool lineEndingsUnix ()
 Convert all line endings in string to Unix standard - LF. More...
 
void loadResource (unsigned long strID)
 
void makeRandomChars (unsigned long numChars)
 Generate string of len numChars with random content, replacing existing contents. More...
 
 oofCheckString (unsigned long, char sepChar=0x20)
 Ctor builds string from integer in typical "check" format. More...
 
 operator const char * () const
 Primary test: oofStringTest::stringAppendNullStrFromConstant() More...
 
 operator std::string () const
 
bool operator!= (const char *) const
 Unique negative comparison to avoid compiler ambiguity complaints. More...
 
bool operator!= (const oofString &rhs) const
 Unique negative comparison to avoid compiler ambiguity complaints. More...
 
void operator+= (char)
 
void operator+= (const char *)
 Primary test: oofStringTest::stringAppendStrFromConstant() More...
 
void operator+= (const oofString &)
 Primary test: oofStringTest::stringAppendFromString() More...
 
oofString operator- (const char *) const
 
bool operator== (const Str255) const
 
bool operator== (const oofString &rhs) const
 Primary test: oofStringTest::stringReassignFromString() More...
 
bool operator== (const char *) const
 case-sensitive direct comparison with c string. More...
 
char & operator[] (int) const
 Primary test: oofStringTest::stringInitStrFromConstant () More...
 
char & operator[] (short) const
 
char & operator[] (unsigned long) const
 Primary test: oofStringTest::stringInitOneCharFromConstant() More...
 
char * orphan (bool neverReturnNil=true)
 Give away our internal buffer, clearing our length and pointer. More...
 
void padTo (unsigned short paddedLength, char padWith=' ', bool rightAlign=false)
 
void replaceAt (unsigned long startAt, unsigned long numChars, const char *newStr, unsigned long newLen=ULONG_MAX)
 
unsigned long replaceBetween (const char *leftStr, const char *rightStr, const char *insertStr, bool caseSensitive=false)
 
unsigned long replaceChar (char fromChar, char toChar, unsigned long startAt=0)
 
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. More...
 
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. More...
 
oofString right (unsigned long numChars) const
 Create new string containing rightmost numChars. More...
 
void setChars (const char *, unsigned long)
 Replace current contents of string with incoming buffer. More...
 
void setStr255 (const Str255)
 
void shorten (unsigned short)
 Reduce string length by dropChars. More...
 
bool startsWith (char) const
 
bool startsWith (const char *) const
 
unsigned long stripChar (char, unsigned long startAt=0)
 
oofString subString (unsigned long fromChars, unsigned long numChars=ULONG_MAX) const
 
oofString subStringBetween (const char *, const char *) const
 
oofString subStringBetween (char, char) const
 

Static Public Member Functions

static oofString decodeEntity (const oofString &)
 Return a string decoded from HTML or XML. More...
 
static oofString encodeEntity (const oofString &)
 Return a string encoded suitable for use in HTML or XML. More...
 
static oofString legalName (const oofString &, char nonAlphaReplace='_', char leadingDigitReplace='n', char spaceReplace='_')
 
static char * lineEndingsCurrentPlatform (char *, unsigned long &ioLen)
 forward to appropriate platform method for static converters More...
 
static char * lineEndingsDOS (char *, unsigned long &ioLen)
 Convert all line endings in external buffer to DOS standard - CRLF. More...
 
static char * lineEndingsMac (char *, unsigned long &ioLen)
 Convert all line endings in external buffer to Mac standard - CR. More...
 
static char * lineEndingsUnix (char *, unsigned long &ioLen)
 Convert all line endings in external buffer to Unix standard - LF. More...
 
static oofString quoteString (const oofString &, char quoteChar='\'')
 
static oofString singular (const oofString &)
 
static oofString utf8To8BitAscii (const oofString &)
 
static oofString utf8To8BitAscii (const char *, unsigned long)
 Change string contents to decoded version of Unicode 8 bit string. More...
 

Protected Attributes

char * mBody
 
unsigned long mLen
 

Static Protected Attributes

static char sEmptyChar = '\0'
 

Detailed Description

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

Definition at line 310 of file oofstr.h.

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

Definition at line 114 of file oofstr.h.

Member Enumeration Documentation

anonymous enum
inherited
Enumerator
CR 
LF 
kNotFound 

Definition at line 103 of file oofstr.h.

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
sepCharis optional if you want other than space between letters.
Todo:
estimate size based on size of number & prealloc

Definition at line 2469 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and oofString::shorten().

Member Function Documentation

void oofString::adopt ( char *  str)
inherited
void oofString::adopt ( oofString rhs)
inherited

Take ownership of buffer from incoming string, replacing current contents.

Primary test: oofStringTest::stringAdoptString()

Definition at line 2312 of file oofstr.cpp.

References oofString::length(), oofString::mBody, oofString::mLen, and oofString::orphan().

void oofString::append ( const char *  str,
unsigned long  appendLen 
)
inherited
double oofString::asDouble ( ) const
inherited

Attempt to return real value of string.

Returns
zero if doesn't contain integer.
Todo:
add unit test

Definition at line 2253 of file oofstr.cpp.

References oofString::length(), and oofString::mBody.

long oofString::asLong ( ) const
inherited

Attempt to return integer value of string.

Returns
zero if doesn't contain integer.
Todo:
add unit test

Definition at line 2217 of file oofstr.cpp.

References oofString::length(), and oofString::mBody.

Referenced by dbGUIAdaptControl::equalsString(), dbGUIAdapter::getValue(), and dbGUIAdaptControl::setString().

short oofString::asShort ( ) const
inherited

Attempt to return integer value of string.

Returns
zero if doesn't contain integer.
Todo:
add unit test

Definition at line 2200 of file oofstr.cpp.

References oofString::length(), and oofString::mBody.

unsigned long oofString::asUnsignedLong ( ) const
inherited

Attempt to return integer value of string.

Returns
zero if doesn't contain integer.
Todo:
add unit test

Definition at line 2235 of file oofstr.cpp.

References oofString::length(), and oofString::mBody.

Referenced by oofXMLschemaParser::attributes2fieldtype().

unsigned short oofString::asUnsignedShort ( ) const
inherited

Attempt to return integer value of string.

Returns
zero if doesn't contain integer.
Todo:
add unit test

Definition at line 2184 of file oofstr.cpp.

References oofString::length(), and oofString::mBody.

const char * oofString::chars ( ) const
inlineinherited
char * oofString::charsForOldInterfacesNotWriting ( ) const
inlineinherited
void oofString::clear ( )
inherited
bool oofString::contains ( const char *  schStr,
bool  caseSensitive = false 
) const
inlineinherited
Todo:
add unit test

Definition at line 361 of file oofstr.h.

References oofString::find(), and oofString::kNotFound.

bool oofString::contains ( char  schChar,
bool  caseSensitive = false 
) const
inlineinherited
Todo:
add unit test

Definition at line 372 of file oofstr.h.

References oofString::find(), and oofString::kNotFound.

void oofString::convertNumber ( int  n,
const char *  printfMask = 0,
bool  appendIt = false 
)
inherited
void oofString::convertNumber ( unsigned long  n,
const char *  printfMask = 0,
bool  appendIt = false 
)
inherited

Definition at line 898 of file oofstr.cpp.

void oofString::convertNumber ( double  n,
const char *  printfMask = 0,
bool  appendIt = false 
)
inherited

Definition at line 914 of file oofstr.cpp.

oofString oofString::decodeEntity ( const oofString srcString)
staticinherited

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.

Todo:
add unit test

Definition at line 1501 of file oofstr.cpp.

oofString oofString::encodeEntity ( const oofString srcString)
staticinherited

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

Todo:
add unit test

Definition at line 1583 of file oofstr.cpp.

References oofString::adopt().

Referenced by oofRepGraphBand_XMLRender::describeLayout(), and oofTagMaker::makeSimpleBoundedElement().

void oofString::encodeURL ( )
inherited

Definition at line 1486 of file oofstr.cpp.

References oofString::replaceString().

bool oofString::endsWith ( char  inChar) const
inherited
Todo:
add unit test

Definition at line 1837 of file oofstr.cpp.

References oofString::lastChar().

Referenced by oofString::operator-(), and oofString::singular().

bool oofString::endsWith ( const char *  inStr,
int  inLen = -1 
) const
inherited
Todo:
add unit test

Definition at line 1848 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

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
caseSensitivedefault false
inLenoptional 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
Todo:
add unit test

Definition at line 1135 of file oofstr.cpp.

References oofString::firstChar(), oofString::kNotFound, oofString::mBody, and oofString::mLen.

Referenced by oofMaskMultiStrings::appendTarget(), oofString::contains(), oofString::findEnd(), oofString::replaceBetween(), oofString::replaceFirstString(), oofString::replaceString(), oofString::replaceStringWholeWord(), and oofString::subStringBetween().

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
caseSensitivedefaults false.
Todo:
add unit test

Definition at line 1055 of file oofstr.cpp.

References oofString::kNotFound, oofString::mBody, and oofString::mLen.

long oofString::findEnd ( const char *  schStr,
unsigned long  startFrom = 0,
bool  caseSensitive = false 
) const
inherited
Todo:
add unit test

Definition at line 1312 of file oofstr.cpp.

References oofString::find(), and oofString::kNotFound.

Referenced by oofString::replaceBetween(), and oofString::subStringBetween().

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
caseSensitivedefault false
inLenoptional 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
Todo:
add unit test

Definition at line 1232 of file oofstr.cpp.

References oofString::firstChar(), oofString::kNotFound, oofString::mBody, and oofString::mLen.

long oofString::findLast ( char  inChar,
bool  caseSensitive = false 
) const
inherited
Todo:
add unit test

Definition at line 1090 of file oofstr.cpp.

References oofString::kNotFound, oofString::mBody, and oofString::mLen.

char oofString::firstChar ( ) const
inherited

Constant access to first char.

Returns
0 if string empty.
Todo:
add unit test

Definition at line 2270 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by oofString::find(), oofString::findLast(), and oofString::startsWith().

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.

add unit test

Definition at line 935 of file oofstr.cpp.

References oofString::clear(), OOF_OOFSTR_FORMAT_BUFFERSIZE, and oofString::setChars().

void oofString::getChars ( char *  ioBuff,
unsigned long &  ioLen 
) const
inherited
Todo:
add unit test

Definition at line 750 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by dbViewAsTableStorage::GetCellData().

void oofString::getStr255 ( Str255  s) const
inherited
void oofString::insertChars ( const char *  chars,
unsigned long  charLen,
unsigned long  beforeChar = ULONG_MAX 
)
inherited
Todo:
add unit test

Definition at line 682 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

Referenced by oofDirectory::FSSpecToPath().

bool oofString::isAlphaNumeric ( ) const
inherited
Todo:
add unit test

Definition at line 2444 of file oofstr.cpp.

References oofString::isEmpty(), oofString::mBody, and oofString::mLen.

Referenced by oofTagMaker::decodeName(), and oofTagMaker::encodeName().

bool oofString::isEmpty ( ) const
inlineinherited
char oofString::lastChar ( ) const
inherited
oofString oofString::left ( unsigned long  numChars) const
inherited

Create new string containing leftmost numChars.

Returns
new string with up to numChars contents, just returns shorter if existing string is less than numChars long.
Todo:
add unit test

Definition at line 2363 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and oofString::oofString().

oofString oofString::legalName ( const oofString inString,
char  nonAlphaReplace = '_',
char  leadingDigitReplace = 'n',
char  spaceReplace = '_' 
)
staticinherited
Todo:
add unit test

Definition at line 1744 of file oofstr.cpp.

References oofString::length().

unsigned long oofString::length ( ) const
inlineinherited

Primary test: oofStringTest::emptyStringByNullInitIsLenZero()

Definition at line 447 of file oofstr.h.

References oofString::mLen.

Referenced by oofString::adopt(), dbText::adoptString(), oofMaskMultiStrings::allocBuffer(), dbView::AppendOwnedField(), oofMaskMultiStrings::appendTarget(), oofString::asDouble(), oofString::asLong(), oofString::asShort(), oofString::asUnsignedLong(), oofString::asUnsignedShort(), oofSizedTextArray::CalculateWrapping(), oofXMLdataParser::charData(), OOF_XMLrepLayoutParser::charData(), oofMaskMultiStrings::copyParam(), oofTagMaker::decodeName(), oofRepViewBand_WinRender::draw(), oofRepViewBand_MacRender::draw(), oofRepTextBlock_MacRender::draw(), oofRepViewBand_WinRender::drawColumnHeaders(), oofRepViewBand_MacRender::drawColumnHeaders(), oofRepViewBand_WinRender::DrawContinuingOverPage(), oofRepViewBand_MacRender::DrawContinuingOverPage(), oofGeoText::DrawSelf(), oofTagMaker::encodeName(), dbView::extract(), oofE_RamConnectionError::extract(), oofE_RampConnectionError::extract(), oofE_CtreeBlobError::extract(), oofE_MacOSErr::extract(), dbDate::extract(), dbDateTime::extract(), dbNumericField::fieldMinWrapWidth(), oofRepPromiseCompleter::findStringForID(), oofMaskMultiStrings::finishedParse(), dbBLOB::generateTestData(), oofRepWinEnv::getTextExtent(), oofString::legalName(), OOF_dbaseBackend::loadBlob(), dbConnect::MakeOOFSchemaString(), oofYNC::msgBox(), oofString::operator+=(), RepSaveDlgHook(), oofDirectory::setDirFromPath(), dbChar::setString(), dbText::setString(), oofString::singular(), oofMaskMultiStrings::totalChunkLen(), oofGeoText::Transform(), oofGeoTitle::Transform(), oofGeoXLabel::Transform(), oofGeoYLabel::Transform(), oofGeoXTickLabel::Transform(), oofGeoYTickLabel::Transform(), dbNumericFieldLink::updateDerivedFieldDisplay(), dbDateLink2Editor::updateDerivedFieldDisplay(), dbDateTimeLink2Editor::updateDerivedFieldDisplay(), oofString::utf8To8BitAscii(), and oofRepTextBlock_MacRender::width().

bool oofString::lineEndingsCurrentPlatform ( )
inlineinherited
char * oofString::lineEndingsCurrentPlatform ( char *  inChars,
unsigned long &  ioLen 
)
inlinestaticinherited

forward to appropriate platform method for static converters

Todo:
add unit test

Definition at line 500 of file oofstr.h.

References oofString::lineEndingsDOS(), oofString::lineEndingsMac(), and oofString::lineEndingsUnix().

bool oofString::lineEndingsDOS ( )
inherited

Convert all line endings in string to DOS standard - CRLF.

Todo:
add unit test

Definition at line 2093 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by oofString::lineEndingsCurrentPlatform().

char * oofString::lineEndingsDOS ( char *  inChars,
unsigned long &  ioLen 
)
staticinherited

Convert all line endings in external buffer to DOS standard - CRLF.

Todo:
add unit test

Definition at line 2112 of file oofstr.cpp.

References oofString::CR, oofString::LF, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

bool oofString::lineEndingsMac ( )
inherited

Convert all line endings in string to Mac standard - CR.

Todo:
add unit test

Definition at line 1945 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by oofString::lineEndingsCurrentPlatform(), OOF_dbaseBackend::loadBlob(), and oofSchemaParser::parseSchemaText().

char * oofString::lineEndingsMac ( char *  inChars,
unsigned long &  ioLen 
)
staticinherited

Convert all line endings in external buffer to Mac standard - CR.

Todo:
add unit test

Definition at line 1964 of file oofstr.cpp.

References oofString::CR, oofString::LF, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

bool oofString::lineEndingsUnix ( )
inherited

Convert all line endings in string to Unix standard - LF.

Todo:
add unit test

Definition at line 2020 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by oofString::lineEndingsCurrentPlatform(), and OOF_dbaseBackend::loadBlob().

char * oofString::lineEndingsUnix ( char *  inChars,
unsigned long &  ioLen 
)
staticinherited

Convert all line endings in external buffer to Unix standard - LF.

Todo:
add unit test

Definition at line 2039 of file oofstr.cpp.

References oofString::CR, oofString::LF, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

void oofString::loadResource ( unsigned long  strID)
inherited
Todo:
add unit test

Definition at line 519 of file oofstr.cpp.

References oofString::setChars(), and oofString::setStr255().

void oofString::makeRandomChars ( unsigned long  numChars)
inherited

Generate string of len numChars with random content, replacing existing contents.

Todo:
add unit test

Definition at line 1922 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

Referenced by dbChar::generateTestData(), dbBLOB::generateTestData(), dbText::generateTestData(), and dbFixedBinary::generateTestData().

oofString::operator const char * ( ) const
inherited

Primary test: oofStringTest::stringAppendNullStrFromConstant()

Definition at line 764 of file oofstr.cpp.

oofString::operator std::string ( ) const
inherited
bool oofString::operator!= ( const char *  rhs) const
inlineinherited

Unique negative comparison to avoid compiler ambiguity complaints.

Primary test: oofStringTest::stringAdoptConstant ()

Definition at line 437 of file oofstr.h.

bool oofString::operator!= ( const oofString rhs) const
inlineinherited

Unique negative comparison to avoid compiler ambiguity complaints.

Primary test: oofStringTest::stringReassignFromString ()

Definition at line 425 of file oofstr.h.

void oofString::operator+= ( char  c)
inherited
Todo:
add unit test

Definition at line 791 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

void oofString::operator+= ( const char *  str)
inherited

Primary test: oofStringTest::stringAppendStrFromConstant()

Definition at line 817 of file oofstr.cpp.

void oofString::operator+= ( const oofString src)
inherited

Primary test: oofStringTest::stringAppendFromString()

Definition at line 831 of file oofstr.cpp.

References oofString::chars(), and oofString::length().

oofString oofString::operator- ( const char *  inTail) const
inherited
Todo:
add unit test

Definition at line 1018 of file oofstr.cpp.

References oofString::endsWith(), oofString::mLen, oofString::oofString(), and oofString::subString().

bool oofString::operator== ( const Str255  s) const
inherited
Todo:
add unit test

Definition at line 498 of file oofstr.cpp.

bool oofString::operator== ( const oofString rhs) const
inherited

Primary test: oofStringTest::stringReassignFromString()

Definition at line 477 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

bool oofString::operator== ( const char *  chars) const
inherited

case-sensitive direct comparison with c string.

Primary test: oofStringTest::stringInitStrFromConstant()

Definition at line 565 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

char & oofString::operator[] ( int  index) const
inlineinherited

Primary test: oofStringTest::stringInitStrFromConstant ()

Todo:
add unit test for update.

Definition at line 341 of file oofstr.h.

Referenced by oofString::operator[]().

char & oofString::operator[] ( short  index) const
inlineinherited
Todo:
add unit test

Definition at line 351 of file oofstr.h.

References oofString::operator[]().

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

Primary test: oofStringTest::stringInitOneCharFromConstant()

Todo:
add unit test for update

Definition at line 778 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and oofString::sEmptyChar.

char * oofString::orphan ( bool  neverReturnNil = true)
inherited
void oofString::padTo ( unsigned short  paddedLength,
char  padWith = ' ',
bool  rightAlign = false 
)
inherited
Todo:
add unit test

Definition at line 719 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and OOF_MEM_DEBUG_FORCE_POOL_CHECK.

oofString oofString::quoteString ( const oofString srcString,
char  quoteChar = '\'' 
)
staticinherited
void oofString::replaceAt ( unsigned long  replaceAtOffset,
unsigned long  replaceLen,
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
Todo:
add unit test

Definition at line 1872 of file oofstr.cpp.

References oofString::find(), oofString::findEnd(), oofString::kNotFound, and oofString::replaceAt().

unsigned long oofString::replaceChar ( char  fromChar,
char  toChar,
unsigned long  startAt = 0 
)
inherited
Todo:
add unit test

Definition at line 963 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by dbView::getHeading(), and oofErrorReporter::raise().

unsigned long oofString::replaceFirstString ( const char *  replaceStr,
const char *  newStr,
bool  caseSensitive = false 
)
inherited
Todo:
add unit test

Definition at line 1370 of file oofstr.cpp.

References oofString::find(), oofString::kNotFound, and oofString::replaceAt().

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
Todo:
add unit test

Definition at line 1393 of file oofstr.cpp.

References oofString::find(), oofString::kNotFound, OOF_stricmp(), and oofString::replaceAt().

Referenced by oofString::encodeURL().

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

add unit test

Definition at line 1443 of file oofstr.cpp.

References oofString::find(), oofString::kNotFound, oofString::mBody, OOF_stricmp(), and oofString::replaceAt().

oofString oofString::right ( unsigned long  numChars) const
inherited

Create new string containing rightmost numChars.

Returns
new string with up to numChars contents, just returns shorter if existing string is less than numChars long.
Todo:
add unit test

Definition at line 2379 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, and oofString::oofString().

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.
Todo:
add unit test

Definition at line 624 of file oofstr.cpp.

References oofString::mBody, oofString::mLen, OOF_MEM_DEBUG_FORCE_POOL_CHECK, and OOF_OOFSTR_DONT_REALLOC_BELOW.

Referenced by dbQueryLiteralStrDelimited::current(), oofString::format(), oofString::loadResource(), oofString::operator=(), and oofString::setStr255().

void oofString::setStr255 ( const Str255  s)
inherited
void oofString::shorten ( unsigned short  dropChars)
inherited

Reduce string length by dropChars.

Parameters
dropCharsis amount to shorten by, can be greater than string length in which case string is cleared. Primary test: oofStringTest::stringShortened ()
Todo:
conditionally clear based on OOF_OOFSTR_DONT_REALLOC_BELOW when we have an mAllocLength to avoid hitting heap
Warning
never reallocates so a large buffer being shortened by a large amount wastes much space. This is for speed.

Definition at line 2396 of file oofstr.cpp.

References oofString::clear(), oofString::mBody, and oofString::mLen.

Referenced by oofCheckString(), oofRepBracketedTextBlock::oofRepBracketedTextBlock(), and oofString::utf8To8BitAscii().

oofString oofString::singular ( const oofString inString)
staticinherited
Todo:
add unit test

Definition at line 1779 of file oofstr.cpp.

References oofString::endsWith(), oofString::length(), and oofString::subString().

Referenced by dbTable::tableSingularName().

bool oofString::startsWith ( char  inChar) const
inherited
Todo:
add unit test

Definition at line 1804 of file oofstr.cpp.

References oofString::firstChar().

Referenced by oofTagMaker::decodeName().

bool oofString::startsWith ( const char *  inStr) const
inherited
Todo:
add unit test

Definition at line 1815 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

unsigned long oofString::stripChar ( char  toStrip,
unsigned long  startAt = 0 
)
inherited
Todo:
add unit test

Definition at line 1892 of file oofstr.cpp.

References oofString::mBody, and oofString::mLen.

Referenced by dbCharStripperCalculator::calc().

oofString oofString::subString ( unsigned long  fromChars,
unsigned long  numChars = ULONG_MAX 
) const
inherited
oofString oofString::subStringBetween ( const char *  leftStr,
const char *  rightStr 
) const
inherited
oofString oofString::subStringBetween ( char  leftChar,
char  rightChar 
) const
inherited
Todo:
add unit test

Definition at line 1033 of file oofstr.cpp.

References oofString::find(), oofString::kNotFound, oofString::oofString(), and oofString::subString().

oofString oofString::utf8To8BitAscii ( const oofString srcString)
inlinestaticinherited
Todo:
add unit test

Definition at line 458 of file oofstr.h.

References oofString::chars(), and oofString::length().

Referenced by oofXMLdataParser::charData(), and OOF_XMLrepLayoutParser::charData().

oofString oofString::utf8To8BitAscii ( const char *  srcString,
unsigned long  len 
)
staticinherited

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
srcString8 bit UTF as used in 8 bit XML.
Todo:
add unit test

Definition at line 1707 of file oofstr.cpp.

References oofString::length(), and oofString::shorten().

Member Data Documentation

char* oofString::mBody
protectedinherited
unsigned long oofString::mLen
protectedinherited
char oofString::sEmptyChar = '\0'
staticprotectedinherited

Definition at line 286 of file oofstr.h.

Referenced by oofString::operator[]().


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