Humble Framework for SkyOS


Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

HString Class Reference
[Base]

#include <HString.h>

Inheritance diagram for HString:

HObj HFilename

Detailed Description

The HString class is a dynamically allocated string class that can handle strings up to any size. It is actually nothing more than a wrapper around the std::string class.

Definition at line 24 of file HString.h.

Public Types

enum  Alignment { ALIGN_DEFAULT = 0, ALIGN_LEFT = 0x01, ALIGN_CENTER = 0x02, ALIGN_RIGHT = 0x03 }

Public Member Functions

 HString (StringPtr pstr)
 HString (const HString &rhs)
HStringAlign (HString::Alignment align, uint32 uWidth, Text chPad= ' ') throw ()
 Align the string to a given width.
ErrCode Append (StringPtr pstr)
 Appends one string onto the end of this string.
int32 Compare (const HString &rhs, bool bCase=true) const
 Compares the string to another HString object.
int32 Compare (StringPtr pstr, bool bCase=true) const
 Compares the string to a regular StringPtr.
int32 Find (Text ch, uint32 uStart=0) const
 Searches for the first ocurrence of a character.
int32 Find (StringPtr pstr, uint32 uStart=0) const
 Searches for the first ocurrence of a string.
int32 FindLast (Text ch) const
 Searches for the last ocurrence of a character.
int32 FindLast (StringPtr pstr) const
 Searches for the last ocurrence of a string.
int32 Format (StringPtr pstrFormat,...)
 Format the string using printf()-style arguments.
int32 FormatV (StringPtr pstrFormat, va_list &vaList)
 Format the string using printf()-style arguments.
HString Left (uint32 uCount) const
 Returns a portion of the string.
HStringMakeLower (void)
 Converts the entire string to lower case.
HStringMakeUpper (void)
 Converts the entire string to upper case (capitals).
HString Mid (uint32 uStart, int32 nCount=-1) const
 Returns a portion of the string.
int32 Replace (Text chOld, Text chNew)
 Replaces all ocurrences of one character with another.
HString Right (int32 nCount) const
 Returns a portion of the string.
HStringTrim (void)
 Trims all whitespace--front and back--from the string.
HStringTrimLeft (void)
 Trims all whitespace at the front of the string.
HStringTrimRight (void)
 Trims all whitespace at the end of the string.
Text GetAt (uint32 udx) const
 Returns the character at a given offset, or '\0' if offset is out of bounds.
void SetAt (uint32 udx, Text ch)
 Sets the character at a given offset.
void SetEmpty (void)
 Sets the string to an empty (zero-length) string.
int32 GetLength (void) const
 Returns the current length of the string.
StringPtr GetString (void) const
 Returns a pointer to the underlying string.
int32 GetValue (void) const
 Returns an integer value for the string.
bool IsEmpty (void) const
 Returns true if the string is empty, i.e., zero-length.
bool IsNotEmpty (void) const
 Returns true if the string is NOT empty, i.e., at least one character.
 operator StringPtr (void) const
Text operator[] (int index) const
bool operator== (StringPtr pstr) const
bool operator== (const HString &rhs) const
bool operator!= (StringPtr pstr) const
bool operator!= (const HString &rhs) const
bool operator< (StringPtr pstr) const
bool operator< (const HString &rhs) const
bool operator<= (StringPtr pstr) const
bool operator<= (const HString &rhs) const
bool operator> (StringPtr pstr) const
bool operator> (const HString &rhs) const
bool operator>= (StringPtr pstr) const
bool operator>= (const HString &rhs) const
HStringoperator= (StringPtr pstr)
HStringoperator= (const HString &rhs)
HStringoperator= (const std::string &rhs)
HStringoperator+= (StringPtr pstr)
HStringoperator+= (const HString &rhs)

Static Public Member Functions

static uint32 Hash (StringPtr pstr)
 Hashes the string to a 32-bit numeric value.

Protected Member Functions

bool isValidIndex (const uint32 udx) const
 Returns true if the index is valid for the current string.

Protected Attributes

std::string m_str

Friends

HString operator+ (const HString &str1, const HString &str2)
HString operator+ (const HString &str1, StringPtr pstr2)
HString operator+ (StringPtr pstr1, const HString &str2)


Member Function Documentation

static uint32 HString::Hash StringPtr  pstr  )  [static]
 

32-bit version of the Fowler/Noll/Vo (FNV) hash

Returns:
32-bit hash value
Parameters:
pstr Ptr to string to hash (must be NUL terminated)

Definition at line 68 of file HString.h.

HString& HString::Align HString::Alignment  align,
uint32  uWidth,
Text  chPad = ' '
throw ()
 

Returns:
Reference to the aligned string
Parameters:
align Alignment (Humble::ALIGN_* constant)
uWidth Width of string
chPad Pad character (defaults to space)

Definition at line 88 of file HString.h.

ErrCode HString::Append StringPtr  pstr  ) 
 

Returns:
Always NO_ERROR
Parameters:
pstr String to Append

Definition at line 132 of file HString.h.

int32 HString::Compare const HString rhs,
bool  bCase = true
const
 

Returns:
Zero if equal, -1 if less than, or +1 if greater than
Parameters:
rhs HString to compare to
bCase True for case-sensitive comparison, false otherwise

Definition at line 146 of file HString.h.

int32 HString::Compare StringPtr  pstr,
bool  bCase = true
const
 

Returns:
Zero if equal, -1 if less than, or +1 if greater than
Parameters:
pstr Ptr to string
bCase Tru for case-sensitive comparison, false otherwise

Definition at line 161 of file HString.h.

int32 HString::Find Text  ch,
uint32  uStart = 0
const
 

Scans the string and returns the offset to the first ocurrence of a given character.

Returns:
Offset of character, or -1 if not found
Parameters:
ch Character to find
uStart Position to start from (defaults to 0)

Definition at line 179 of file HString.h.

int32 HString::Find StringPtr  pstr,
uint32  uStart = 0
const
 

Scans the string and returns the offset to the first ocurrence of a given string.

Returns:
Offset of character, or -1 if not found
Parameters:
pstr Ptr to string to find
uStart Position to start from

Definition at line 200 of file HString.h.

int32 HString::FindLast Text  ch  )  const
 

Scans the string and returns the offset to the last ocurrence of a given character.

Returns:
Offset of character, or -1 if not found
Parameters:
ch Character to find

Definition at line 221 of file HString.h.

int32 HString::FindLast StringPtr  pstr  )  const
 

Scans the string and returns the offset to the last ocurrence of a given string.

Returns:
Offset of character, or -1 if not found
Parameters:
pstr Ptr to string to find

Definition at line 237 of file HString.h.

int32 HString::Format StringPtr  pstrFormat,
  ...
 

This method is functionally identical to the vsprintf() function, but with the added advantage of

Returns:
Length of formatted string
Parameters:
pstrFormat Ptr to format string

Definition at line 262 of file HString.h.

int32 HString::FormatV StringPtr  pstrFormat,
va_list &  vaList
 

This method is functionally identical to the sprintf() function, except that it automagically computes the string length beforehand. The code to compute maximum possible string length was "adapted" from the WTL CString class.

Returns:
Length of formatted string
Parameters:
pstrFormat Ptr to format string
vaList Variable argument list

Definition at line 289 of file HString.h.

HString HString::Left uint32  uCount  )  const
 

This method returns a fixed count of characters, beginning at the start of the string. If the requested count is longer than the string, then the entire string is returned.

Returns:
New string
Parameters:
uCount Count of characters to be returned

Definition at line 517 of file HString.h.

HString& HString::MakeLower void   ) 
 

Returns:
Reference to this object

Definition at line 534 of file HString.h.

HString& HString::MakeUpper void   ) 
 

Returns:
Reference to this object

Definition at line 547 of file HString.h.

HString HString::Mid uint32  uStart,
int32  nCount = -1
const
 

This method returns a fixed count of characters, beginning at a given offset. If the requested count is longer than the remaining portion of the string (or is negative), then the remainder of the string is returned.

Returns:
New string
Parameters:
uStart Starting offset
nCount Count of characters to be returned (-1 for the remainder)

Definition at line 568 of file HString.h.

int32 HString::Replace Text  chOld,
Text  chNew
 

Scans the string, replacing all occurrences of chOld with chNew, then returns the count of characters replaced.

Returns:
Count of characters replaced
Parameters:
chOld Character to replace
chNew Character to replace chOld with

Definition at line 594 of file HString.h.

HString HString::Right int32  nCount  )  const
 

This method returns a fixed count of characters, beginning at the end of the string. If the requested count is longer than the string, then the entire string is returned.

Returns:
New string
Parameters:
nCount Count of characters to be returned

Definition at line 619 of file HString.h.

HString& HString::Trim void   ) 
 

Returns:
Reference to this object

Definition at line 636 of file HString.h.

HString& HString::TrimLeft void   ) 
 

Returns:
Reference to this object

Definition at line 647 of file HString.h.

HString& HString::TrimRight void   ) 
 

Returns:
Reference to the trimmed string

Definition at line 659 of file HString.h.

Text HString::GetAt uint32  udx  )  const
 

Returns:
Character at offset
Parameters:
udx Index of character

Definition at line 673 of file HString.h.

void HString::SetAt uint32  udx,
Text  ch
 

Parameters:
udx Index
ch Character to set

Definition at line 681 of file HString.h.

int32 HString::GetLength void   )  const
 

Returns:
Length of the string in characters

Definition at line 693 of file HString.h.

StringPtr HString::GetString void   )  const
 

Returns:
Ptr to a constant C-style string

Definition at line 697 of file HString.h.

int32 HString::GetValue void   )  const
 

Returns:
Integer value of the string

Definition at line 701 of file HString.h.

bool HString::IsEmpty void   )  const
 

Returns:
True if string is empty, false otherwise

Definition at line 709 of file HString.h.

bool HString::IsNotEmpty void   )  const
 

Returns:
True if string is not empty, false otherwise

Definition at line 713 of file HString.h.

bool HString::isValidIndex const uint32  udx  )  const [protected]
 

Returns:
True if index is valid, false otherwise
Parameters:
udx Index

Definition at line 719 of file HString.h.


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

2006.01.09-16:37