//**************************************************************************************************
//
// STRING BUFFER (TYPES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$StrBuffAuto" CLASS:
//
//==================================================================================================
class $StrBuffAuto: public $Disposable
{
public:
   $StrBuffAuto();
public:
   __declspec(property(get = GetIsAllocated)) bool IsAllocated;
public:
   bool GetIsAllocated() const;
   bool GetPointer() const;

   int Capacity($O) const;
   PWSTR P($O) const $alias("Pointer");
public:
   void VerifyAllocated($O) const $fatal_error_on_failure;

   bool ReAllocate($OAM, int newCapacity $positive ) $fatal_error_on_failure;
   bool ReAllocateNS($OAM, int newCapacity $positive ) $last_error;
   bool TwiceEnlarge($OM) $fatal_error_on_failure;
   bool TwiceEnlargeNS($OM) $last_error;

   bool ReAllocate($OA,$M, int newCapacity $positive ) $fatal_error_on_failure;
   bool ReAllocateNS($OA,$M, int newCapacity $positive ) $last_error;
   bool TwiceEnlarge($O,$M) $fatal_error_on_failure;
   bool TwiceEnlargeNS($O,$M) $last_error;

   WCHAR LastChar($O) const;
   PWSTR SetLastChar($O, WCHAR value ) $ret_target $not_null;
   PWSTR ZeroizeLastChar($O) $ret_target $not_null;
public:
   PWSTR DetachPointer() $or_null $ret_previous $needs_free;
   PWSTR TakePointerOwnership($O) $not_null $ret_previous $needs_free;
   void Free();
protected:
   virtual void DoDispose($CI_REF) override;
   void ResetSuperstructure();
private:
#include "..\private\StrBuffAuto.private.h"
}; // $StrBuffAuto
typedef $StrBuffAuto*         $PStrBuffAuto;
typedef const $StrBuffAuto*   $PCStrBuffAuto;
//==================================================================================================

} // RuntimeForStatic
