Internal Test: Verifies the 'live view' behavior by modifying an extracted block and showing the change reflected in the parent string.

ID: 1277

				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("root [child] end")) {
   
   // Get a live view of the block including the brackets
   var view = s.BetweenInclusive("'['", "']'");

   Console.WriteLine($"Initial parent string: {s}");
   Console.WriteLine($"Initial view: {view}");

   // Modify the view. The change will propagate to the parent.
   view.Replace("child", "MODIFIED");

   Console.WriteLine($"Final parent string: {s}");
}
				
			
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("root [child] end");
      s.Owned(); // Causes s to be released when it goes out of scope

      // Get a live view of the block including the brackets
      auto view = s.BetweenInclusive("'['", "']'");

      cout << "Initial parent string: " << s << endl;
      cout << "Initial view: " << view << endl;

      // Modify the view. The change will propagate to the parent.
      view.Replace("child", "MODIFIED");

      cout << "Final parent string: " << s << endl;
   }
}
				
			
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("root [child] end")
         
         '// Get a live view of the block including the brackets
         Dim view = s.BetweenInclusive("'['", "']'")
         
         Console.WriteLine($"Initial parent string: {s}")
         Console.WriteLine($"Initial view: {view}")
         
         '// Modify the view. The change will propagate to the parent.
         view.Replace("child", "MODIFIED")
         
         Console.WriteLine($"Final parent string: {s}")
      End Using
   End Sub
End Module
				
			
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end