# TreeCreator in PPL

**URL:** https://d.strumenta.community/t/treecreator-in-ppl/1885
**Category:** Misc
**Created:** [February 1, 2024, 10:35am UTC](https://d.strumenta.community/t/treecreator-in-ppl/1885 "2024-02-01T10:35:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Oscar.K](https://d.strumenta.community/user_avatar/d.strumenta.community/oscar.k/32/772_2.png) [@Oscar.K](https://d.strumenta.community/u/Oscar.K)
#### Post date: [February 1, 2024, 10:35am UTC](https://d.strumenta.community/t/treecreator-in-ppl/1885/1 "2024-02-01T10:35:40Z")

</div>

Textual description of trees is one of the main elements of the PPL language. The module that implements this task is written in C#, as is the entire PPL project. I translated this module into C++ to demonstrate the possibility of translating the entire project into C++ to speed up work, as well as to implement the PPL language on various platforms.  
For this purpose, I decided to use -

> **[Free Csharp to C++ Converter — AI Code Translation | CodeConvert AI](https://www.codeconvert.ai/csharp-to-c++-converter)**
>
> Instantly convert Csharp to C++ code with AI. Free, fast, and accurate code translation — 60+ languages supported, no signup required.

As it turned out, it is impossible to translate a large code for free. In addition, freeing memory, creating objects in the stack and heap, etc. had to be adjusted manually.  
My knowledge of C++ and C# was enough to make this translation without the help of additional programs. It also allowed me to make interesting use of the free time I have.  
As a small example, I give a hierarchical description of countries and cities -

```auto
#include "TreeCreator.h"

int main()
{
  TreeCreator* tc = new TreeCreator();
  const char* countries =
    "Countries [Europe]"
      "(Italy"
        "(Roma)(Milan)(Turin))"
      "(France"
        "(Paris)(Marseile)(Provence))"
      "(Spain"
        "(Madrid)(Granada)(Alicante))";

  Composite* root = tc->CreateTree(countries);
  root->Display(1);
  delete tc;
}

```

```auto
/*
-Node root
---Node Countries Europe   
-----Node Italy
-------Leaf Name: Roma value:
-------Leaf Name: Milan value:
-------Leaf Name: Turin value:
-----Node France
-------Leaf Name: Paris value:
-------Leaf Name: Marseile value:
-------Leaf Name: Provence value:
-----Node Spain
-------Leaf Name: Madrid value:
-------Leaf Name: Granada value:
-------Leaf Name: Alicante value:
*/

```

You can use this code in your projects, supplementing it with the necessary solutions.

You can find the project here -

> <https://github.com/okogosov/PPL/blob/main/TreeCreatorTest.zip>
