//**************************************************************************************************
//
// SIMPLE CLASS FOR DYNAMICALLY ALLOCATED TEXT (NULL-TERMINATED STRINGS):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$DynText"-CLASS:
//
//==================================================================================================
class $DynText: public $Disposable
{
public:
   $DynText();
   $DynText($DynText& predecessor) $owner_transfer;
   $DynText($A, PCWSTR text ) $duplicate $fatal_error_on_failure;
   $DynText($A, const $DynText& dt ) $duplicate $fatal_error_on_failure;
   $DynText($A, PWSTR textPointer, bool needsFree );
   $DynText($A, PWSTR textPointer, $MemFreeRoutine specialFreeRoutine $optional );
public:
   $DynText& operator = ($DynText& predecessor) $owner_transfer;
public:
   __declspec(property(get = GetIsNull    )) bool IsNull;
   __declspec(property(get = GetHasPointer)) bool HasPointer;
public:
   PCWSTR T($O) const $alias("Text");
   int Length($O) const;
   bool NeedsFree($O) const;
public:
   PCWSTR Assign($OA, PCWSTR text ) $duplicate $fatal_error_on_failure;
   PCWSTR AssignNS($OA, PCWSTR text ) $duplicate $null_on_failure $last_error;
   PCWSTR SetPointer($OA, PWSTR textPointer ) $imaginary_param("needsFree",true);
   PCWSTR SetPointer($OA, PWSTR textPointer, bool needsFree );
   PCWSTR SetPointer($OA, PWSTR textPointer, $MemFreeRoutine specialFreeRoutine $optional );
   PCWSTR SetStaticText($OA, PCWSTR textPointer $static_pointer );
   PWSTR TakePointerOwnership($OM) $not_null $fatal_error_on_failure $needs_free;
   PWSTR TakePointerOwnershipNS($OM) $null_on_failure $last_error $needs_free;
   void Reset($O);
   void ResetToNull($O);
   bool GetIsNull() const;
   bool GetHasPointer() const;
   void VerifyHasPointer($O) const;
public:
   static $DynText NoError_Message();
   static $DynText UnknownError_Message();
   static $DynText MemoryAllocationFailure_Message();
public:
   bool SetMessage_NoError($O) $ret_true;
   bool SetMessage_UnknownError($O) $ret_false;
   bool SetMessage_MemoryAllocationFailure($O) $ret_false;
public:
   static $DynText CreateStatic($A, PCWSTR textPointer $static_pointer );
   static $DynText CreateNull();
   static $DynText FromAllocation( PWSTR textPointerOrNull $optional );
   static $DynText Format($A, PCWSTR messageFmt, ... ) $fatal_error_on_failure;
   static $DynText FormatVA($A, PCWSTR messageFmt, va_list argList ) $fatal_error_on_failure;
   static $DynText FormatNS($A, PCWSTR messageFmt, ... ) $null_on_failure $last_error;
   static $DynText FormatVANS($A, PCWSTR messageFmt, va_list argList ) $null_on_failure $last_error;
protected:
   virtual void DoDispose($CI_REF) override;
   void ResetSuperstructure();
private:
#include "..\private\DynText.private.h"
}; // $DynText
typedef $DynText*       $PDynText;
typedef const $DynText* $PCDynText;
//==================================================================================================

} // RuntimeForStatic
