String_16 Class Reference

Extends its String base class to become fixed-length and atomically allocatable, ie. a failed constructor call for this class will never leave the object in an illegal state. More...

#include <fixstr16.h>

Inheritance diagram for String_16:

StringBase CCObject SimpleCCObject List of all members.

Public Member Functions

 String_16 (const TCHAR *psz=TEXT(""))
 Constructs a string of the appropriate maximum length.
 String_16 (const StringBase &other)
 String_16 (const String_16 &other)
 String_16 (UINT32 resID, UINT32 hinst=0)
 Loads the string resource into this String.
 String_16 (const wxString &wxs)
 Constructs a string of the appropriate maximum length.
virtual ~String_16 ()
 Destroys this fixed-length string.
virtual BOOL Alloc (INT32 nSize)
 Fixes Alloc() for fixed-length strings, which CAN be safely changed# to use a buffer on the heap. Scope: Public.

Private Member Functions

void CopyConstruct (const StringBase &other)
 Duplicates the text of the other string.

Private Attributes

TCHAR fixedbuf [(((16)+1)*2)]

Static Private Attributes

static const INT32 FIX_LEN_BUFSIZE

Detailed Description

Extends its String base class to become fixed-length and atomically allocatable, ie. a failed constructor call for this class will never leave the object in an illegal state.

class String_16 : public StringBase

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12th August 1993

Definition at line 116 of file fixstr16.h.


Constructor & Destructor Documentation

String_16::String_16 const TCHAR psz = TEXT("")  ) 
 

Constructs a string of the appropriate maximum length.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12th August 1993
Parameters:
An optional pointer to a (constant) Unicode character array - if [INPUTS] omitted then the String becomes empty (NOT the null pointer).
Returns:
Errors: ASSERTion failure if the passed character array is too long for this length of string, or if psz is NULL. Scope: Public

Definition at line 117 of file fixstr16.cpp.

00118 {
00119     *(text = fixedbuf) = 0;
00120     length = FIX_LEN_BUFSIZE;
00121     if (psz != 0)
00122     {
00123         ERROR3IF(camStrlen(psz) >= length, "String_16::String_16 overflow");
00124         camStrcpy(text, psz);
00125     }
00126 }

String_16::String_16 const StringBase other  )  [inline]
 

Definition at line 125 of file fixstr16.h.

00125 { CopyConstruct( other ); }

String_16::String_16 const String_16 other  )  [inline]
 

Definition at line 126 of file fixstr16.h.

00126 { CopyConstruct( other ); }

String_16::String_16 UINT32  resID,
UINT32  hinst = 0
 

Loads the string resource into this String.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12th August 1993
Parameters:
A string resource numeric identifier, an optional resource module [INPUTS] handle (if not supplied, the default resource module is used).
Returns:
Errors: ENSURE failure if this string is not long enough to hold the resource, or if the resource cannot be found in the module. If it cannot be found, a very short temp string is built of the form "<%X:%X>" containing the ID and the module number, or if that is too long then simply "!". Scope: Public
See also:
SmartLoadString

Definition at line 172 of file fixstr16.cpp.

00173 {
00174     *(text = fixedbuf) = 0;
00175     length = FIX_LEN_BUFSIZE;
00176     if (!Load(resID, hinst))
00177     {
00178         ERROR3("String resource failed to load");
00179         TCHAR buf[128];
00180         camSnprintf(buf, 128, TEXT("<%X:%X>"), (INT32) resID, (INT32) hinst);
00181         camStrcpy(text, (camStrlen(buf) <= 16) ? buf : TEXT("!"));
00182     }
00183 }

String_16::String_16 const wxString &  wxs  ) 
 

Constructs a string of the appropriate maximum length.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
28th January 2006
Parameters:
A wxString [INPUTS]
Returns:
Errors: ASSERTion failure if the passed character array is too long for this length of string, or if psz is NULL. Scope: Public

Definition at line 199 of file fixstr16.cpp.

00200 {
00201     *(text = fixedbuf) = 0;
00202     length = FIX_LEN_BUFSIZE;
00203     ERROR3IF(wxs.Len() >= length, "String_16::String_16 overflow");
00204     camStrcpy(text, (LPCTSTR)wxs);
00205 }

String_16::~String_16  )  [inline, virtual]
 

Destroys this fixed-length string.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12th August 1993

Definition at line 148 of file fixstr16.h.

00149 {
00150     // If the string is using the fixed-length buffer then make sure the
00151     // base class doesn't try to delete[] it.
00152     if (text == fixedbuf) text = 0;
00153 }


Member Function Documentation

BOOL String_16::Alloc INT32  nSize  )  [virtual]
 

Fixes Alloc() for fixed-length strings, which CAN be safely changed# to use a buffer on the heap. Scope: Public.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> & Andy
Date:
12th August 1993
See also:
StringBase::Alloc

Reimplemented from StringBase.

Definition at line 220 of file fixstr16.cpp.

00221 {
00222     if (text == fixedbuf) text = 0;
00223     return StringBase::Alloc(nSize);
00224 }

void String_16::CopyConstruct const StringBase other  )  [private]
 

Duplicates the text of the other string.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12th August 1993
Parameters:
A constant reference to another string (can be of any length) [INPUTS]
Returns:
Errors: ASSERTion failure if this string is not long enough to hold a copy of the other string's text, or if the copied String has not been allocated. Scope: Public

Definition at line 143 of file fixstr16.cpp.

00144 {
00145     *(text = fixedbuf) = 0;
00146     length = FIX_LEN_BUFSIZE;
00147     ERROR3IF((const TCHAR*) other == 0, "StringBase to be copied has not been ALLOCated");
00148     ERROR3IF(camStrlen((const TCHAR*) other) >= length,
00149                 "Constructed String_16 not large enough to hold StringBase copy");
00150     camStrcpy(text, (const TCHAR*) other);
00151 }


Member Data Documentation

const INT32 String_16::FIX_LEN_BUFSIZE [static, private]
 

Definition at line 118 of file fixstr16.h.

TCHAR String_16::fixedbuf[(((16)+1)*2)] [private]
 

Definition at line 134 of file fixstr16.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:27 2007 for Camelot by  doxygen 1.4.4