HTTPS SSH

ncpplib - A C++ Class Generator v0.2.3

ncpplib is a command line utility for C++ programmers that creates stub files (.cpp and .hpp) for C++ classes from an easy to write JSON file. It was written as a personal utility for Oregon State's CS 162 class. It is the author's hope that this application can save neophyte, and possibly veteran, C++ programmers hours of effort in debugging the verbose definitions of a C++ class' skeleton so that they can focus their efforts on implementing application logic.

INSTALLATION

The command line program is written in PHP. The shebang path calls PHP via /usr/bin/env for maximum compatibility. You may need to adjust this if you are running this utility on an unusually configured system or you with to use a php binary that is different from the first one defined in your $PATH environment variable.

Environment Variables

If you set the environment variables in your shell FIRST_NAME and LAST_NAME to their logical values (such as placing them in the local equivalent of your .bash_profile file), your name will appear in the comments at the top of your .cpp file as the author. E.g.

export FIRST_NAME='Joe'
export LAST_NAME='Smith'

Class Configuration Files

As of version 0.2 ncpplib supports class configuration files. These files are in JSON format and are optional. When a file in the directory where nccplib is executed contains a file in the format CLASSNAME.json, the program will attempt to parse that file. It will generate class members and accessor and mutator functions according to the specified properties. It will also include specified libraries and header files as specified. See Example.json for a working example. Not all features in this file are supported yet. Specifically, the ability to specify method traits and generate stubs has not yet been implemented.

Configuration File Hints

One of the key design considerations of ncpplib was to minimize typing as C++ can be quite verbose. The names used in name: value pairs in the json files reflect this decision. The most commonly used keys are single letters which can be a bit cryptic at first, but make for much faster construction of the configuration files. The meaning of these single letter names are as follows:

a
access level - e.g. public, private, protected
t
type - e.g. int, float, string, etc.
n
name - The name of a method, property, or method argument.
v
value - The value of a property.

It is hoped that this shorthand can quickly become intuative.

Test Suite

As of version 0.2.2, ncpplib ships with a file called test.cpp and a makefile. The makefile is designed to compile ncpplib's output for Example.json, compile it, link it, and create and executable called test. To run the test suite, go the following:

./ncpplib Example .
make
./test

If these commands run without error, the program is running as expected. You can tidy your installation directory by running:

make clean

Contributing

ncpplib is beta quality software and is Open Source. If you fix a bug or extend its functionality, please consider submitting a pull request to help the next user of this application.

(c)2015-2016 David Cloutman, MIT License