NAME

OTC_RString - Envelope class for holder of string memory.

SYNOPSIS


#include <OTC/text/rstring.hh>

class OTC_RString
{
  public:
    ~OTC_RString();
    OTC_RString(
      u_int theLength,
      OTC_StringBuffering theType=OTCLIB_BUFFERED
    );
    OTC_RString(
      u_int theLength,
      void const* theObject,
      OTC_StringBuffering theType=OTCLIB_BUFFERED
    );
    OTC_RString(OTC_RString const& theString);
    inline u_int length() const;
    inline u_int capacity() const;
    inline OTC_Boolean isShared() const;
    inline OTC_Boolean isLocked() const;
    inline OTC_Boolean isSymbol() const;
    char const* string() const;
    char* string();
    inline char operator[](u_int theIndex) const;
    inline char& operator[](u_int theIndex);
    void reallocate(u_int theLength);
    inline void sync();
    void lock();
    void unlock();
    OTC_RString const& operator=(OTC_RString const& theString);
    friend ostream& operator<<(
      ostream& outs,
      OTC_RString const& theString
    );
};

CLASS TYPE

Concrete

DESCRIPTION

The OTC_RString class is a wrapper for OTC_StringData. This class implements the functionality for maintaining the string memory and the delayed copy mechanism. The OTC_StringData class holds all the data required. This class ensures that the string is null terminated on initial allocation and reallocation. If you overwrite the null terminator it is your own problem.

INITIALISATION

OTC_RString(
  u_int theLength,
  OTC_StringBuffering theType=OTCLIB_BUFFERED
);
OTC_RString(
  u_int theLength,
  void const* theObject,
  OTC_StringBuffering theType=OTCLIB_BUFFERED
);
OTC_RString(OTC_RString const& theString);

QUERY

inline u_int length() const;
inline u_int capacity() const;
inline OTC_Boolean isShared() const;
inline OTC_Boolean isLocked() const;
inline OTC_Boolean isSymbol() const;

ACCESS

Note that the following functions do nothing special if another instance of the class is referencing the same string. If modifications are going to be made to the memory, either sync() or reallocate() should be invoked to force a separate copy to be made. If you overwrite the null terminator added by this class via these functions, it is your problem.
char const* string() const;
char* string();
inline char operator[](u_int theIndex) const;
inline char& operator[](u_int theIndex);

ALLOCATION

void reallocate(u_int theLength);
inline void sync();

LOCKING

void lock();
void unlock();

ASSIGNMENT

OTC_RString const& operator=(OTC_RString const& theString);

STREAMS OUTPUT

friend ostream& operator<<(
  ostream& outs,
  OTC_RString const& theString
);

LIBRARY

OTC

AUTHOR(S)

Graham Dumpleton

COPYRIGHT

Copyright 1993 1994 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED