DEV Community

Cover image for C++ web programming example
elanatframework
elanatframework

Posted on

C++ web programming example

The new version (2.1.0.0) of Elanat will be ready soon.

In this version, you can create add-on with programming languages such as C, C++, Pascal, etc. (programming languages that generate machine code).

The use of C and C++ programming language on the web has many opponents; Of course, few experts also find it useful to use C and C++ programming languages on the web. For some applications, using C and C++ programming languages has great results; For example, creating a returnable code and decoding with hardware-based programming languages when the theft of server-side codes happens is time-consuming for hackers and a more suitable option for security systems than interpreted programming languages and It is virtual machines; Or in another example, the use of C and C++ programming languages in text analysis among several million books has a much higher performance than common web platforms and programming languages.

In the Elanat framework, new add-ons can be created using C and C++ programming languages.

For this, you just need to write the main function as follows:

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    cout << "Hello world!" << endl;

    cout << argv[1]; // QueryString
    cout << argv[2]; // FormData
    cout << argv[3]; // Session
    cout << argv[4]; // Cookie

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

With a little ideation, you can have a View!
Create a cspx or ascx or chtml file side the executable file (exe in Windows).
When the form data does not exist (first request), read the values from the file with the programming language.
Don't be afraid to replace, in this type of programming language replace is done at the speed of light!

Receive information from formdata and write it on the page:

<form method="post" action="/page/cpp/main.exe">
  <label for="lbl_FirstName"><%=name=>:</label>
  <input id="txt_FirstName" name="txt_FirstName" type="text"><br>
  <label for="lbl_LastName"><%=name=>:</label>
  <input id="txt_LastName" name="txt_LastName" type="text"><br>
  <input name="btn_Submit" type="submit" value="Submit" onclick="el_AjaxPostBack(this)" class="el_button_input">
</form>
Enter fullscreen mode Exit fullscreen mode

Result in argv[2]; // FormData:
txt_LastName=my-last-name&txt_FirstName=my-name&btn_Submit=Submit

Because you are not using a framework with a listener for this type of programming language, the speed of accessing the published executable file is usually slow; But in the tests we did, we did not notice much difference. Meanwhile, this should not worry you because you can set the cache.

There are 8 types of add-on in Elanat. You can upload the executable file directly to page and plugin add-ons and see the result!.
If you are considering creating add-on of other types, or your add-on files are more than one executable or static file, you can check the links below and simply create an add-on.

Component:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/component/component_raw

Module:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/module/module_raw

Plugin:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/plugin/plugin_raw

Page:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/page/page_raw

Patch:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/patch/patch_raw

Extra helper:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/extra_helper/extra_helper_raw

Editor template:
https://github.com/elanatframework/Elanat_add-ons/tree/elanat_framework/editor_template/editor_template_raw

Note 1: In the previous versions of Elanat, which was based on the .NET standard, it was also possible to create an add-on using programming languages such as C, C++, Pascal, etc. But after migrating to .NET Core, a bug appeared in the version based on .NET Core (2.0.0.0)!

Note 2: Currently, you can create your own add-ons for Elanat with programming languages that generate machine code in the Windows operating system.

Note 3: You can also use a framework for C++; and create your add-ons in MVC.

Elanat is .NET Honor! More powerful than Dupal, more modern than WordPress, more structured than Microsoft SharePoint.

Elanat website:
https://elanat.net

Elanat repository link:
https://github.com/elanatframework/Elanat

CodeBehind repository link:
https://github.com/elanatframework/Code_behind

Top comments (0)