home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.0 KB | 242 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBndStr.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FWBNDSTR_H
- #include "FWBndStr.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #include <Types.h>
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- //========================================================================================
- // File scope definitions
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment Strings
- #endif
-
- //========================================================================================
- // CLASS FW_CString32
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CString32)
- FW_DEFINE_CLASS_M1(FW_CString32, FW_CString)
-
- // This class is archivable, but we provide the archiving implementation in a separate
- // translation unit in order to enable deadstripping of the archiving-related code
- // in parts that do not use archiving with this class.
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::FW_CString32() :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::FW_CString32(const FW_CString32 &string) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(string);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::FW_CString32(const FW_CString &string) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(string);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::FW_CString32(const FW_Char *bytes, FW_ByteCount numberBytes) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(bytes, numberBytes);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::FW_CString32(const FW_Char *items) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(items);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::~FW_CString32
- //----------------------------------------------------------------------------------------
-
- FW_CString32::~FW_CString32()
- {
- FW_START_DESTRUCTOR
- FW_PlatformError error;
- FW_PrivString_ReleaseStaticBuffer(fRep, &error);
- FW_PRIV_ASSERT(error == 0);
- //
- // If an error is returned from above then we may be in BIG trouble.
- // The problem is that throwing exceptions from destructors is dangerous.
- // If the destructor has been called due to stack unwinding from a previous
- // exception, then throwing the exception from the destructor will call
- // terminate(). Note that ReleaseStaticBuffer will only fail if it was
- // impossible to allocate a block of 40 bytes.
- //
- FW_FailOnError(error);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString32::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CString32& FW_CString32::operator=(const FW_CString32& other)
- {
- if (&other != this)
- {
- ReplaceAll(other);
- }
- return *this;
- }
-
- //========================================================================================
- // CLASS FW_CString255
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CString255)
- FW_DEFINE_CLASS_M1(FW_CString255, FW_CString)
-
- // This class is archivable, but we provide the archiving implementation in a separate
- // translation unit in order to enable deadstripping of the archiving-related code
- // in parts that do not use archiving with this class.
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::FW_CString255() :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::FW_CString255(const FW_CString255 &string) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(string);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::FW_CString255(const FW_CString &string) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- FW_END_CONSTRUCTOR
- ReplaceAll(string);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::FW_CString255(const FW_Char *bytes, FW_ByteCount numberBytes) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(bytes, numberBytes);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::FW_CString255(const FW_Char *items) :
- FW_CString(FW_PrivString_NewRepWithStaticBuffer(fBuffer, sizeof(fBuffer)))
- {
- ReplaceAll(items);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::~FW_CString255
- //----------------------------------------------------------------------------------------
-
- FW_CString255::~FW_CString255()
- {
- FW_START_DESTRUCTOR
- FW_PlatformError error;
- FW_PrivString_ReleaseStaticBuffer(fRep, &error);
- FW_PRIV_ASSERT(error == 0);
- //
- // If an error is returned from above then we may be in BIG trouble.
- // The problem is that throwing exceptions from destructors is dangerous.
- // If the destructor has been called due to stack unwinding from a previous
- // exception, then throwing the exception from the destructor will call
- // terminate(). Note that ReleaseStaticBuffer will only fail if it was
- // impossible to allocate a block of 260 bytes.
- //
- FW_FailOnError(error);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CString255::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CString255& FW_CString255::operator=(const FW_CString255& other)
- {
- if (&other != this)
- {
- ReplaceAll(other);
- }
- return *this;
- }
-
-