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

# OSCL_HeapStringA Class Reference
[OSCL Util]

`#include <oscl_string_containers.h>`

Inheritance diagram for OSCL_HeapStringA:

## Public Types
typedef OSCL_String::chartype | chartype
typedef TOSCL_StringOp | optype
typedef OSCL_wString::chartype | other_chartype
## Public Methods
OSCL_IMPORT_REF | OSCL_HeapStringA ()
OSCL_IMPORT_REF | OSCL_HeapStringA (Oscl_DefAlloc *alloc, OsclRefCounter *ref=NULL)
OSCL_IMPORT_REF | OSCL_HeapStringA (const OSCL_HeapStringA &src)
OSCL_IMPORT_REF | OSCL_HeapStringA (const OSCL_HeapStringA &src, Oscl_DefAlloc *alloc, OsclRefCounter *ref=NULL)
OSCL_IMPORT_REF | OSCL_HeapStringA (const OSCL_String &src, Oscl_DefAlloc *alloc=NULL, OsclRefCounter *ref=NULL)
OSCL_IMPORT_REF | OSCL_HeapStringA (const chartype *cstr, Oscl_DefAlloc *alloc=NULL, OsclRefCounter *ref=NULL)
OSCL_IMPORT_REF | OSCL_HeapStringA (const chartype *buf, uint32 length, Oscl_DefAlloc *alloc=NULL, OsclRefCounter *ref=NULL)
OSCL_IMPORT_REF | ~OSCL_HeapStringA ()
OSCL_IMPORT_REF uint32 | get_size () const
OSCL_IMPORT_REF uint32 | get_maxsize () const
OSCL_IMPORT_REF const chartype * | get_cstr () const
OSCL_IMPORT_REF chartype * | get_str () const
OSCL_IMPORT_REF OSCL_HeapStringA & | operator= (const OSCL_HeapStringA &src)
OSCL_IMPORT_REF OSCL_HeapStringA & | operator= (const OSCL_String &src)
OSCL_IMPORT_REF OSCL_HeapStringA & | operator= (const chartype *cstr)
OSCL_IMPORT_REF void | set (const chartype *buf, uint32 length)
OSCL_IMPORT_REF void | set (const other_chartype *buf, optype op)
OSCL_IMPORT_REF void | set (const other_chartype *buf, uint32 length, optype op)
## Friends
class | OSCL_String

## Detailed Description

OSCL_HeapStringA is a simple string class, compatible with regular character array strings. It is similar to OSCL_HeapString, except that the allocator is passed at run-time instead of compile-time. The allocator pointer is passed in the constructor, and may be a reference-counted object. If the allocator is not a reference-counted object then it must persist over the lifetime of all OSCL_HeapStringA objects that use it. If no allocator is provided, then an OsclMemAllocator will be used.

The string array is variable length, is allocated from the heap, and is modifiable. A copy-on-write mechanism is used to minimize unnecessary copying when multiple instances of a string are created for reading. Allocated memory is automatically freed by the class destructor when the last string referencing the memory is destroyed.

The class HAS NO thread synchronization built-in, so it is NOT MT-SAFE. External locks should be used if the class is to be shared across threads.

## Member Typedef Documentation

typedef OSCL_String::chartype OSCL_HeapStringA::chartype

| Reimplemented from OSCL_String.

typedef TOSCL_StringOp OSCL_HeapStringA::optype

typedef OSCL_wString::chartype OSCL_HeapStringA::other_chartype

## Constructor & Destructor Documentation

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( |  | ) |

| The default constructor creates an empty string. am: (optional) allocator or reference-counted allocator. am: (optional) reference counter associated with allocator object. If no allocator is provided, this this object will use an OsclMemAllocator.

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | Oscl_DefAlloc * | alloc,
|  | OsclRefCounter * | ref = NULL
| ) |

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | const OSCL_HeapStringA & | src | ) |

  | Creates a heap string that contains a copy of the input string. Parameters:
  src: | input string.
am: (optional) allocator or reference-counted allocator. am: (optional) reference counter associated with allocator object. If no allocator is provided, this this object will use an OsclMemAllocator.

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | const OSCL_HeapStringA & | src,
|  | Oscl_DefAlloc * | alloc,
|  | OsclRefCounter * | ref = NULL
| ) |

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | const OSCL_String & | src,
|  | Oscl_DefAlloc * | alloc = NULL,
|  | OsclRefCounter * | ref = NULL
| ) |

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | const chartype * | cstr,
|  | Oscl_DefAlloc * | alloc = NULL,
|  | OsclRefCounter * | ref = NULL
| ) |

  | Creates a heap string that contains a copy of the input string. Parameters:
  cp: | null-terminated string.
am: (optional) allocator or reference-counted allocator. am: (optional) reference counter associated with allocator object. If no allocator is provided, this this object will use an OsclMemAllocator.

OSCL_IMPORT_REF OSCL_HeapStringA::OSCL_HeapStringA | ( | const chartype * | buf,
|  | uint32 | length,
|  | Oscl_DefAlloc * | alloc = NULL,
|  | OsclRefCounter * | ref = NULL
| ) |

  | Creates a heap string that contains a copy of the input string or character array. Parameters:
  src: | character array, not necessarily null-terminated.
  length: | number of characters to copy.
am: (optional) allocator or reference-counted allocator. am: (optional) reference counter associated with allocator object. If no allocator is provided, this this object will use an OsclMemAllocator.

OSCL_IMPORT_REF OSCL_HeapStringA::~OSCL_HeapStringA | ( |  | ) |

## Member Function Documentation

OSCL_IMPORT_REF const chartype* OSCL_HeapStringA::get_cstr | ( |  | ) | `[virtual]`

| This function returns the C-style string for read access. Implements OSCL_String.

OSCL_IMPORT_REF uint32 OSCL_HeapStringA::get_maxsize | ( |  | ) | `[virtual]`

| This function returns the maximum available storage size, not including null terminator. The maximum size may be larger than the current string size. Implements OSCL_String.

OSCL_IMPORT_REF uint32 OSCL_HeapStringA::get_size | ( |  | ) | `[virtual]`

| Pure virtuals from OSCL_String Implements OSCL_String.

OSCL_IMPORT_REF chartype* OSCL_HeapStringA::get_str | ( |  | ) | `[virtual]`

| This function returns the C-style string for write access. If the string is not writable it returns NULL. Implements OSCL_String.

OSCL_IMPORT_REF OSCL_HeapStringA& OSCL_HeapStringA::operator= | ( | const chartype * | cstr | ) |

| Assignment operator am: null-terminated string Reimplemented from OSCL_String.

OSCL_IMPORT_REF OSCL_HeapStringA& OSCL_HeapStringA::operator= | ( | const OSCL_String & | src | ) |

| Assignment operator Reimplemented from OSCL_String.

OSCL_IMPORT_REF OSCL_HeapStringA& OSCL_HeapStringA::operator= | ( | const OSCL_HeapStringA & | src | ) |

| Assignment operators

OSCL_IMPORT_REF void OSCL_HeapStringA::set | ( | const other_chartype * | buf,
|  | uint32 | length,
|  | optype | op
| ) |

  | Set the contents of this string to a new string or character array, with conversion operation. Parameters:
  buf: | string or character array.
  length: | number of characters to copy.
  op: | conversion operation to apply

OSCL_IMPORT_REF void OSCL_HeapStringA::set | ( | const other_chartype * | buf,
|  | optype | op
| ) |

  | Set the contents of this string to a new string, with conversion operation. Parameters:
  buf: | NULL-terminated wide string.
  op: | conversion operation to apply

OSCL_IMPORT_REF void OSCL_HeapStringA::set | ( | const chartype * | buf,
|  | uint32 | length
| ) |

  | Set the contents of this string to a new string or character array. Parameters:
  buf: | string or character array.
  length: | number of characters to copy.

## Friends And Related Function Documentation

friend class OSCL_String`[friend]`

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

- oscl_string_containers.h