Valid
	XHTML 1.1! Valid CSS!
Created 2006-06-16   Modified 2009-04-11
Chelton Evans

proj misclib home

Intro
Source
Issues

Intro

This is a project space for miscellaeous tools and is a small library. As the need arises new tools will be added to this project space.

Source

Files

Makefile
aclock.h
array2D.h
array2Dtest.cpp
array2Dtest.h
arrays.h
callbacks.h
cirbuffarr.h
cirbuffarrtest.cpp
cirbuffarrtest.h
clockmisc.cpp
clockmisc.h
commandline.cpp
commandline.h
commandlinetest.cpp
commandlinetest.h
dumbarray.h
dumbarraytest.cpp
dumbarraytest.h
fnobj.h
fnobjT.h
fnobjTfn.h
fnobjtest.cpp
fnobjtest.h
functionalobjectoperators.h
indextable.h
indextabletest.cpp
indextabletest.h
iterators.h
iteratorstypedefs.h
main.cpp
message.cpp
message.h
messagetest.cpp
messagetest.h
print.h
printlist.h
printset.h
printtest.cpp
printtest.h
printvector.h
push_back.h
singleton.h
singletontest.cpp
singletontest.h
stringconvert.cpp
stringconvert.h
stringconverttest.cpp
stringconverttest.h
stringserialization.cpp
stringserialization.h
stringserializationtest.cpp
stringserializationtest.h
stringspace.cpp
stringspace.h
stringsublist.cpp
stringsublist.h
stringtagparser.cpp
stringtagparser.h
stringtagparsertest.cpp
stringtagparsertest.h
tokenizer.cpp
tokenizer.h
tokenizerfind.cpp
tokenizerfind.h
tokenizerlocal.cpp
tokenizerlocal.h
tokenizertest.cpp
tokenizertest.h
typedefs.h
typeop.h
xmlparser.h

debug.txt
error.txt
projcompile.txt
testscript01.txt
unittestsreport.txt

Doxygen

main.cpp
Makefile
Singleton
SingletonPtr
aclock
array2D
cirbuffarr
commandline
commandlinetest
dumbarray
filestring
fnobj0
fnobj0T
fnobj0Tfn
fnobj0const
fnobj0constT
fnobj0constTfn
fnobj1
fnobj1T
fnobj1Tfn
fnobj1const
fnobj1constT
fnobj1constTfn
fnobj2
fnobj2T
fnobj2Tfn
fnobj2const
fnobj2constT
fnobj2constTfn
fnobj3
fnobj3T
fnobj3Tfn
fnobj3const
fnobj3constT
fnobj3constTfn
htmlstring
message
messagecout
messagefile
messagelist
messagetest
mycomparexobject
mycompareyobject
mycomparezobject
myisspace
mynot2object
printcontainer
printtest
spacerdelete
spacertrim
stringconvert
stringserializationtest
stringtagiter
stringtagparser
stringtagparsertest
tokenizer
tokenizerfind
tokenizerlocal
tokenizerlocalvar
tokenizermisc
typeop
vectorfile
vectorstring
xmlparser

Issues

Functional Objects

These are a function that used the operator () with a signature. For example

class fcfragle
{
public:
 
  double operator()(double x)
    { return x*x; }
};
 ...
fcfragle f;
y = f(1.2);

STL's library is built on them working with templates. This is the primary use for them and is a massive topic. Presently I am going to avoid compile time binding and use functional objects for dynamic binding.

fnobj.h are the base classes with the virtual functions declared. Both const and non-const are supported.

fnobjT.h abstracts the type T away.

fnobjTfn.h is a different beast. It converts any classes member functions to functional objects.

If ever the need arises I can write non-virtual function code, but then I would probably use templates to solve the problem instead.

Command Line Arguments

Process command line arguments independent of order. The name of the option and its argument are separated by an equals sign. Further the argument does not contain whitespace.

For example location=/base/p1 associates a value /base/p1 with the location variable.

This command line processing is useful because it simplifies arguments supplied to the C++ program. The programmer doesn't have to deal with the details of argc and argv. Conversions are performed in a type safe way [if the user inputs garbage expect garbage returned ] by a binding of the identifier string with a reference to a data type.

History

An object orientated interface evolved. Through a templated class function the user can use implicit template construction making the process easier.

A primitive help utility was added allowing the client -h command line option to query the available bindings. The catch is the programmer has to call the function ostream & help(ostream & os ) const. After the bindings.

A just do it implementation, tokens and bindvar were added. So the programmer can test for tokens. This is how -h works. It looks for that token and if there performs the action of displaying bindings.

I added a callback mechanism for object member functions. mapcallback(...). Instead of writing a variable an objects function is called. This was intended for initialization. Here are two versions of the same code. The mapcallback takes one line whereas the simpler mapvar takes four. Less code to debug and clearer code result from the mapcallback code. While the code is complicated such that the user passes the address of the function, this code is clearly an improvement. The reduction of programmer written code and the automation of processes is a positive step.

cmd.mapcallback(tetd,&d4tessdraw::enablepoints,"points");

// Alternative code has 4 lines.
bool enablepoints(false);
cmd.mapvar(enablepoints);
if (enablepoints)
    tetd.enablepoints();

Proposed added functionality

Coding

stringstream was used to convert between a string and a variable type. e.g.

   stringstream s;
   s << i0 << ' ' << i1;
   cout << s.str();

   string ss("3.14");
   double d;
   stringstream s(ss);
   s >> d;

commandline Example

This class is really simple to use. The code in the interface is divided into three sections. Ignore the Specialized Functionality because its really specific and gives me a headache thinking about it.

The Input Reading Functions are concerned with initializing the data structure by reading the command line. You do need to input something.

The Binding section only has a major function to match a variable to some input.

int main( int argc, char** argv)
{
    commandline cmd(argc, argv);

    int count=-1;
    cmd.mapvar(count,"count");

    if (count!=-1)
    {
    // count was initialized at the command line
....