BCS c++ App That Creates Eclipse c++ Project And Class

This application accepts a workspace path, family id and class name to create a fully functional Eclipse Oxygen c++ project.

After this application executes the developer should import the newly created project into the Eclipse Oxygen IDE for c++ and continue developing the application.

Initially all libraries for GTK3+ (via gtkmm), Boost and other capabilities are available as well as some custom routines which are useful for in the design and coding of c++ applications.

What is generated is the complete project development environment and the source code for the mainline as well as aforementioned class.  This is accomplished by using a completed project as a template  while simultaneously creating and naming all component parts based on the family id and the class name provided.

Below is the structure to suppling input to the application.

struct gen_params {
	string projHome = "/home/archman/workspace/cpp/";
	string famId = "Gen01";
	string clas = "cl01";
};

Here is the main flow for accomplishing this task.

void utils::gen02(gen_params gp) {
	cout << "In Gen 02" << endl;
	utils::forceDirectories(gp.td + "Debug");
	utils::forceDirectories(gp.td + "src");
	utils::forceDirectories(gp.td + ".settings");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/.cproject",
			gp.td + ".cproject");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/.project",
			gp.td + ".project");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/.settings/language.settings.xml", gp.td + ".settings/language.settings.xml");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/Debug/makefile", gp.td +"Debug/makefile");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/Debug/objects.mk", gp.td +"Debug/objects.mk");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/Debug/sources.mk", gp.td +"Debug/sources.mk");
	utils::forceDirectories(gp.td + "Debug/src/");
	utils::fileCopy("/home/archman/workspace/cpp/skelp/Debug/src/subdir.mk", gp.td +"Debug/src/subdir.mk");
	mod_rec mr;
	utils::init_repl(mr, gp);
	string str[sizeOfStringArray];
	int lcnt;
	lcnt = utils::fin("/home/archman/workspace/cpp/skelp/src/skelp.cpp", str);
	utils::upd(mr, str, lcnt);
	utils::fot(gp.td + "src/" + gp.famId + "p.cpp", str, lcnt);
	lcnt = utils::fin("/home/archman/workspace/cpp/skelp/src/skelh.h", str);
	utils::upd(mr, str, lcnt);
	utils::fot(gp.td + "src/" + gp.famId + "h.h", str, lcnt);
	lcnt = utils::fin("/home/archman/workspace/cpp/skelp/src/skelh.cpp", str);
	utils::upd(mr, str, lcnt);
	utils::fot(gp.td + "src/" + gp.famId + "h.cpp", str, lcnt);
}

The following structure identifies the replacement values from the skeleton template to the newly generated source code.

void utils::init_repl(mod_rec& mr, gen_params gp) {
	mr.numPair = 3;
	mr.mp[0].from = "skelp";
	mr.mp[0].to = gp.famId + "p";
	mr.mp[1].from = "skelh";
	mr.mp[1].to = gp.famId + "h";
	mr.mp[2].from = "SKELH";
	mr.mp[2].to = boost::to_upper_copy(gp.famId + "h");
	mr.mp[3].from = "utils";
	mr.mp[3].to = gp.clas;
}

 
The workhorse to the application is the section of code listed below.

void utils::upd(mod_rec rmrp, string stv[sizeOfStringArray], int cnt) {
	int ii = rmrp.numPair;
	string rline;
	int j = 0;
	while (j < cnt) {
		int i = 0;
		while (i <= ii) {
			boost::replace_all(stv[j], rmrp.mp[i].from, rmrp.mp[i].to);
			i++;
		}
		rline = stv[j];
		j++;
	}
}

 
The initial loop goes through each line of source code in the subject file. The innermost loop iterates from the first replacement pair until the last replacement pair is processed. This process is repeated until all lines in the subject source code is processed.

 

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

BCS Django Twitter Bootstrap


Django and the Twitter Bootstrap offers the ultimate environment for web development for multiple devices.

Create the project.

django-admin startproject yourAppName

Allow the appropriate access by updating the following in settings.py file.

ALLOWED_HOSTS = ['109.203.114.78', 'localhost', 'archbrooks.us']

Now configure the desired database.  Special imports are required for MySQL.

import pymysql
pymysql.install_as_MySQLdb()

Now include the database configuration parameters.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'YourDB',
        'USER' : 'YourUser',
        'PASSWORD' : 'Password',
        'HOSTS' : '',
        'PORT' : '',
    }
}

At this point I would start the server to check for errors.
python manage.py runserver 0.0.0.0:8000

The next step is to install the Twitter Bootstrap.
pip install django-twitter-bootstrap

The following is generated after sucessful install of bootstrap.
Enter root@server:~/django/nws# pip install django-twitter-bootstrap
Collecting django-twitter-bootstrap
  Downloading django-twitter-bootstrap-3.3.0.tar.gz (156kB)
    100% |████████████████████████████████| 163kB -276578bytes/s
Building wheels for collected packages: django-twitter-bootstrap
  Running setup.py bdist_wheel for django-twitter-bootstrap ... done
  Stored in directory: /root/.cache/pip/wheels/7b/b2/e7/93eebb9195c2f80c83ce543768b99629c3da5ec89fb81bfb1b
Successfully built django-twitter-bootstrap
Installing collected packages: django-twitter-bootstrap
Successfully installed django-twitter-bootstrap-3.3.0
code here

Now create the first application of the site.
django-admin startapp myapp

At this point I would start the server to check for errors.

python manage.py runserver 0.0.0.0:8000

If no errors were reported you are now ready to activate the first page of your site.

Modify the urls.py file for the application to reflect the following:

from django.conf.urls import include, url
from django.contrib import admin
from mws import views
 
urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^admin/', include(admin.site.urls)),
]

 

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.