#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto txt = "<p id='aa'>xyz</p><p id='bb'>Hello</p ><p id='cc'>World</p>";
   t.Text(txt);

   // Parent rule matches the <p> tag. Its local transformer then extracts the 'id' attribute.
   auto parentRule = t.Pattern("<p {etc}>");
   parentRule.LocalTransformer().FromTo("id={@string:id}", "{id}");
   t.Filter();

   cout << "--- All Matches (Parent and Child) ---" << endl;
   cout << t.GetMatches(MatchesOption::All).Text() << endl;
   cout << "" << endl;

   cout << "--- RootLevelOnly (Parent Matches) ---" << endl;
   cout << t.GetMatches(MatchesOption::RootLevelOnly).Text() << endl;
   cout << "" << endl;

   cout << "--- InnermostOnly (Child Matches) ---" << endl;
   cout << t.GetMatches(MatchesOption::InnermostOnly).Text() << endl;
}