On Sun, 06 Aug 2006 05:52:46 +0200, M. Warner Losh <[EMAIL PROTECTED]> wrote:
In message: <[EMAIL PROTECTED]>
NyOS <[EMAIL PROTECTED]> writes:
: #ifndef _FOO_H //capitals!
: #define _FOO_H //capitals!
You sould avoid using _FOO_H for the define here. That's in the
implementation space and strictly speaking off limits to programmers
that merely use the system. FOO_H is better, and likely sufficiently
unambiguous.
Warner
Ok, that's true.. corrected..
But defines have full capital names traditionally (as you wrote FOO_H and
not foo_h).. Files/modules are lowercase..
AFAIK, even the most complex (I think) IDE I tried, kdevelop supports only
a simple substitution, it cannot capitalize module name, neither allows to
concatenate with "_H". (Or does it an undocumented way)
[EMAIL PROTECTED]:~$ cat bin/newmodule
#!/bin/bash
#newmodule foo
#creates foo.cpp and foo.h
if [ "$1" == "--help" ];then
echo "usage: newmodule <modulename>"
exit 0
fi
MODULENAME=$1
DEFINENAME=`toupper $1`
HFILE=${MODULENAME}.h
CPPFILE=${MODULENAME}.cpp
DIR=~/src/nyfiletemplates/
NEWCPP=${DIR}/cpp
NEWH=${DIR}/h
if [ -f ${CPPFILE} ]; then
mv -f ${CPPFILE} /tmp/${CPPFILE}.old
fi
if [ -f ${HFILE} ]; then
mv -f ${HFILE} /tmp/${HFILE}.old
fi
sed -e "s/newfile/${MODULENAME}/g" -e "s/NEWFILE/${DEFINENAME}/g"
<${NEWCPP} >${CPPFILE}
sed -e "s/newfile/${MODULENAME}/g" -e "s/NEWFILE/${DEFINENAME}/g" <${NEWH}
${HFILE}
[EMAIL PROTECTED]:~/src/nyfiletemplates$ cat h
/*
description of newfile
*/
#ifndef NEWFILE_H
#define NEWFILE_H
//newfile class
class newfile
{
protected:
//attributes
public:
//default constructor of newfile
newfile();
//destructor of newfile
~newfile();
//methods
};
#endif
[EMAIL PROTECTED]:~/src/nyfiletemplates$ cat cpp
#include "headers.h"
#include "newfile.h"
newfile::newfile()
{
}
newfile::~newfile()
{
}
//methods
Sorry for typos.. I've translated variable names and comments in this
letter to English (and removed unnecessary parts)..
I think You can understand its point..
toupper makes uppercase letters (ok, it could be done with tr), sed
substitutes.. ugly, but works.. I've got similar scripts for creating
methods and putting in the code, adding attributes (and inserting default
getter/setter methods)..
But I'd like to get rid of them.. (Or at least call them a bit cultivated
way, use a hotkey and give parameters on an X/curses form)
So? What is Your advise? I'm open for new programs.
Nyos
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel