BCS c++ Class Source Code Generator

This application creates a new c++ class (header and cpp file). A dialog allows the user to supply the target for the source and new module name and a new class name.

The resulting header file is depicted below.

/*
 * newclassh.h
 *
 *  Created on: Apr 5, 2018
 *      Author: Mr. Arch Brooks
 */
 
#ifndef NEWCLASSH_H_
#define NEWCLASSH_H_
 
/**
 * This is some test Doc Text
 */
 
class ncl {
 
/**
 * Private  Declarations Go Here
 */
 
private:
 
/**
 * Public  Declarations Go Here
 */
 
public:
	void gui();
	void mainProc();
};
 
#endif /* NEWCLASSH_H_ */

The associated c++ file is depicted below.

/*
 * newclassh.cpp
 *
 *  Created on: Apr 5, 2018
 *      Author: Mr. Arch Brooks
 */
 
#include "newclassh.h"
 
using namespace std; // @suppress("Symbol is not resolved")
 
void ncl::gui(){
 
}
void ncl::mainProc(){
 
}

This simple code generator reads skeleton files and scripts them in order to produce newly created source code.

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

BCS c++ Source Code Generator

When this utility is invaded the source code produced includes a utility class, a main program and all the associated files for en Eclipse c++ project.

The header file for the utility is as follows.

/**
 * db01h.h
 *
 *  Created on: Aug 28, 2017
 *  @author    Author: archman
 */
 
#ifndef DB01H_H_
#define DB01H_H_
 
#include <boost/algorithm/string/replace.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <string>
using namespace std;
const int sizeOfStringArray = 1000;
 
/**
 * This is some test Doc Text
 */
 
class dbc {
 
/**
 * Private  Declarations Go Here
 */
 
private:
 
/**
 * Public  Declarations Go Here
 */
 
public:
 
	int fin(string, string[]);
	void fot(string otf, string stv[sizeOfStringArray], int cnt);
	void fileCopy(string fin, string fot);
	bool forceDirectories(string path);
};
 
#endif /* DB01H_H_ */

The procedure file for the utility is as follows.

/*
 * db01h.cpp
 *
 *  Created on: Aug 28, 2017
 *      Author: archman
 */
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string.hpp>
#include "db01h.h"
using namespace std;
 
/**
 *This program designed
 */
 
void dbc::fileCopy(string fin, string fot) {
	std::ifstream src(fin, std::ios::binary);
	std::ofstream dst(fot, std::ios::binary);
 
	dst << src.rdbuf();
}
 
int dbc::fin(string inf, string stv[sizeOfStringArray]) {
	string line;
	int lcnt = 0;
 
	ifstream myfile(inf);
	if (myfile.is_open()) {
		while (getline(myfile, line)) {
			stv[lcnt] = line + "\n";
			lcnt++;
		}
 
		myfile.close();
		return lcnt;
 
	}
 
	else
		cout << "Unable to open file";
	return lcnt;
}
 
bool dbc::forceDirectories(string path) {
	boost::filesystem::path dir(path);
 
	if (!(boost::filesystem::exists(dir))) {
		std::cout << path << " Doesn't Exists" << std::endl;
 
		if (boost::filesystem::create_directory(dir))
			std::cout << path << " Successfully Created !" << std::endl;
		return true;
	} else {
		return false;
	}
}
 
void dbc::fot(string otf, string stv[sizeOfStringArray], int cnt) {
	string line;
	int ii = 0;
	ofstream myfile(otf);
	while (ii < cnt) {
		line = stv[ii];
		myfile << line;
		ii++;
	}
	myfile.close();
}

The main program is as follows.

//============================================================================
// Name        : db01p.cpp
// Author      : Mr. Arch Brooks
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
 
/*! \mainpage My Personal Index Page
 *
 * \section intro_sec Introduction
 *
 * This is the introduction.
 *
 * \section install_sec Installation
 *
 * \subsection step1 Step 1: Opening the box
 *
 * etc...
 */
 
#include <iostream>
#include "db01h.h"
 
 
using namespace std;
 
int main(int argc, char* argv[]) {
	Gnome::
	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	return 0;
}

 

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

BCS c++ function

To use c++ functions the header definitions, implementation methods and the mainline must be properly configured.

The header file for our class is first.

/**
 * fxgen2h.h
 *
 *  Created on: Aug 28, 2017
 *  @author    Author: archman
 */
 
#ifndef FXGENH_H_
#define FXGENH_H_
 
#include <boost/algorithm/string/replace.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <string>
using namespace std;
const int sizeOfStringArray = 1000;
 
/**
 * This is some test Doc Text
 */
 
struct mods {
	string from;
	string to;
};
 
struct mod_rec {
	int numPair;
	mods mp[15];
};
 
class fxcl {
 
/**
 * Private  Declarations Go Here
 */
 
private:
 
/**
 * Public  Declarations Go Here
 */
 
public:
 
	int fin(string, string[]);
	void fot(string otf, string stv[sizeOfStringArray], int cnt);
	void fileCopy(string fin, string fot);
	bool forceDirectories(string path);
	void upd(mod_rec rmrp, string stv[sizeOfStringArray], int cnt);
	string fixPath(string inPath, string fName);
};
 
#endif /* FXGENH_H_ */

The implementation of the class follows.

/*
 * fxgen2h.cpp
 *
 *  Created on: Aug 28, 2017
 *      Author: archman
 */
#include "fxgenh.h"
 
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string.hpp>
using namespace std;
 
/**
 *This program designed
 */
 
void fxcl::fileCopy(string fin, string fot) {
	std::ifstream src(fin, std::ios::binary);
	std::ofstream dst(fot, std::ios::binary);
 
	dst << src.rdbuf();
}
 
int fxcl::fin(string inf, string stv[sizeOfStringArray]) {
	string line;
	int lcnt = 0;
 
	ifstream myfile(inf);
	if (myfile.is_open()) {
		while (getline(myfile, line)) {
			stv[lcnt] = line + "\n";
			lcnt++;
		}
 
		myfile.close();
		return lcnt;
 
	}
 
	else
		cout << "Unable to open file";
	return lcnt;
}
 
bool fxcl::forceDirectories(string path) {
	boost::filesystem::path dir(path);
 
	if (!(boost::filesystem::exists(dir))) {
		std::cout << path << " Doesn't Exists" << std::endl;
 
		if (boost::filesystem::create_directory(dir))
			std::cout << path << " Successfully Created !" << std::endl;
		return true;
	} else {
		return false;
	}
}
 
void fxcl::fot(string otf, string stv[sizeOfStringArray], int cnt) {
	string line;
	int ii = 0;
	ofstream myfile(otf);
	while (ii < cnt) {
		line = stv[ii];
		myfile << line;
		ii++;
	}
	myfile.close();
}
 
void fxcl::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++;
	}
 
}
 
string fxcl::fixPath(string inPath, string fName){
 
  return inPath + fName;
 
}

Finally we include out main or calling program.

//============================================================================
// Name        : fxgen2p.cpp
// Author      : Mr. Arch Brooks
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
 
/*! \mainpage My Personal Index Page
 *
 * \section intro_sec Introduction
 *
 * This is the introduction.
 *
 * \section install_sec Installation
 *
 * \subsection step1 Step 1: Opening the box
 *
 * etc...
 */
 
#include <iostream>
 
#include "fxgenh.h"
using namespace std;
 
int main(int argc, char* argv[]) {
	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	fxcl fx;
	string rp;
	rp = fx.fixPath("/root/", "TestProg");
	cout << rp << endl;
	return 0;
}

The output from the execution is as follows.

!!!Hello World!!!
/root/TestProg

 

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

BCS WaterFox Browser of Choice

FireFox has exhausted my patience. The discontinuance of tools that makes my programming job easier, their willingness to install plugins without permission, selling my information as well as unbridled advertising has made me switch to WaterFox web browser.

The WaterFox web site home page is available by clicking here.

To learn more about WaterFox by clicking here and selecting the About option.

The source code may be located by clicking here.

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

BCS Install Unreal Engine 4 on Linux Mint

This article explains an installation process for the Unreal Engine after the source code is downloaded to its target location.

The first script to execute is Setup.sh. As the name implies this script will check dependencies and install the application.

./Setup.sh

The second script to execute is the GenerateProjectFiles.sh. As its name implies project file will be setup for the Mint environment.

./GenerateProjectFiles.sh

Each process may be quite lengthy in execution time.  The speed of your machine and the Internet connection determine the actual length execution.

Now we are ready to make all the associated executables.

make -j4 ShaderCompileWorker UnrealLightmass UnrealPak UE4Editor

We are now ready to execute the unreal editor.

cd /home/ure/Desktop/UnrealEngine-release/Engine/Binaries/Linux
 
./UE4Editor

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

BCS Eclipse Oxygen c++ Compiler Installation

The first task is to install the Eclipse Installer. Click here to download the 64 bit Eclipse Installer for Ubuntu. Extract the contents of the downloaded zip to the primary Eclipse sub folder in your workstation.
When occasionally there are updates for the installer. There will be an orange blot on the hamburger for the Eclipse Installer. Be sure and keep the installer up to date.

Traverse the installer until the Eclipse Platform option appears and click on it.

Click on the Eclipse Platform to install Eclipse.

Now the c++ Oxygen Eclipse compiler is installed. Click on the Launch option after install.

Click on the Help Option Followed by the Install New Software Option to arrive at the next screen.

Select All Available Sites and key in marketplace in the available search box. When the list box is populated select the Eclipse Marketplace item and click Next. Click Next again and Accept Terms and License Agreement. Next click on the Finish Option.

After the Marketplace software is intalled Eclipse will need to restart select the Yes option.

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

BCS gtkmm Simple Application

The minimal source code for Gtk c++ application is listed below.

//============================================================================
// Name        : gla01.cpp
// Author      : Mr. Arch Brooks
// Version     : 0.0
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
 
#include <iostream>
#include <gtkmm.h>
using namespace std;
 
int main(int argc, char *argv[]) {
	Gtk::Main kit(argc, argv);
	Gtk::Window window;
	Gtk::Main::run(window);
	return 0;
}

 

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

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 WT Basics

Wt (pronounced as witty) is a C++ library for developing web applications.

The official Wt web site may be accessed by clicking here.

After Witty is installed the source code may be accessed by visiting
/usr/lib/Wt/examples

An extensive trove of source code is available here.

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

BCS Begin Programming Computers

There are many approaches to begin programming a computer language. I recommend c++ as a beginner’s language. While many will disagree with my position I have found that much of the hype about c++ being too difficult to learn initially is a misnomer.

In my humble opinion Ubuntu or a Linux distribution is best suited for software development unless you develop only for Microsoft windows platform. In the case of the latter Windows 10 or some lesser derivative would be the operating platform.

Many of the tools used for software development are easily configured in a Linux distribution.  The audience for developing employing the Linux platform is considerably larger than Microsoft suite developers.

While there are many Integrated Development Environments (IDE) I recommend Eclipse.  There is a learning curve with Eclipse but there will be a learning curve with any IDE if this would be your primary voyage in developing computer software.

You will have to install a Java Development Kit (JDK) before you would be able to successfully use the Eclipse IDE.  That is a requirement of Eclipse.

I would use the GCC compiler for program development.  Follow one of the many Hello World examples for c++ and observe that it functions properly.

There are many books available for programming c++.  I would recommend c++ For Dummies as an beginning point for new developers.  I recommend having a PDF version of the book available.  This approach makes following along with the examples much easier.

Be sure and follow the examples and exercises.  Diligence is the factor that will guarantee success in completing your goal.

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