One of the missing default features i noticed in Xcode 3, coming from Eclipse ( classic or CDT ), is the automatic class template filling when using function “add C++ file”.
Programming in Object Oriented this save you lot a time and even silly errors.
What we want is to fill the files created when adding new C++ File with Header like this:
Let’s say we want to create a new Neuron class:
Neuron.cpp
/*
* Neuron.cpp
* NeuralNetTest
*
* Created by Lorenzo Tognalini on 26/07/11.
* Copyright 2011 jalone.net. All rights reserved.
*
*/
#include "Neuron.h"
Neuron::Neuron(){
}
Neuron::~Neuron(){
}
Neuron.h
/*
* Neuron.h
* NeuralNetTest
*
* Created by Lorenzo Tognalini on 26/07/11.
* Copyright 2011 jalone.net. All rights reserved.
*
*/
#ifndef Neuron_H
#define Neuron_H
class Neuron{
public:
Neuron();
virtual ~Neuron();
};
#endif //Neuron_H
To achieve this just follow this path
/Developer/Library/Xcode/File Templates/C and C++
and you’ll find two fails file.h and file.cpp
open them with any texteditor and edit their content using some provided tags ( pay attention to tag character ).
This is the way i edited them:
file.h
/*
* «FILENAME»
* «PROJECTNAME»
*
* Created by «FULLUSERNAME» on «DATE».
* Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
*
*/
#ifndef «FILEBASENAMEASIDENTIFIER»_H
#define «FILEBASENAMEASIDENTIFIER»_H
class «FILEBASENAMEASIDENTIFIER»{
public:
«FILEBASENAMEASIDENTIFIER»();
virtual ~«FILEBASENAMEASIDENTIFIER»();
};
#endif //«FILEBASENAMEASIDENTIFIER»_H
file.cpp
/*
* «FILENAME»
* «PROJECTNAME»
*
* Created by «FULLUSERNAME» on «DATE».
* Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
*
*/
«OPTIONALHEADERINCLUDELINE»
«FILEBASENAMEASIDENTIFIER»::«FILEBASENAMEASIDENTIFIER»(){
}
«FILEBASENAMEASIDENTIFIER»::~«FILEBASENAMEASIDENTIFIER»(){
}
I’d like to make the include guard symbol uppercase and word underscore-separated, but i couldn’t find a way. So please let me know if you find more tags.
EDIT: files in previous path could not survive a developer tools change to solve this edit file following this link
0 Comments
Trackbacks/Pingbacks