views:

391

answers:

4

Do you have any visual assist macros that you write and you want to share?

it can be very useful on coding..

people who use Visual-Assist knows that..

A: 

just wanted to share macro for vector

unsigned int length = $vectorName$.size();
for (unsigned int $Index$ = 0; $Index$ < length ; $Index$++)
{
    $end$
}
ufukgun
That should be `$vectorName$::size_type` instead of `unsigned int`.
sbi
A: 

a macro for class creation. but the filename and class name should be same..

#ifndef _$FILE_BASE_UPPER$_H_
#define _$FILE_BASE_UPPER$_H_

namespace $NAMESPACE$
{
    /*
     * Class $FILE_BASE$
     */
    class $FILE_BASE$ : public $BASE_CLASS$
    {
    public:
     $FILE_BASE$();
     virtual ~$FILE_BASE$();

     $end$

    protected:
     $end$

    private:

    };
}
#endif // _$FILE_BASE_UPPER$_H_
ufukgun
+1  A: 

I don't have all that much to share, but I like these doxygen macros that pop up when I type /**:

/** $end$ */

/** 
* $end$
* 
*/

/** 
* \brief $end$
* 
* \details 
*          
* 
* \notes 
*/

And this one when I type /*<

/**< $end$ */

Oh, and I like this for #p:

#pragma message(MESSAGE_ORIGIN "<$end$>")

(MESSAGE_ORIGIN is a macro that expands to filename and line in the way the compiler emits it, so you can click on messages in the IDE's output pane.)

In a shop I worked for, we had the policy to leave remark in the code with date and author. For this, the following was useful:

// $YEAR$-$MONTH_02$-$DAY_02$ sbi: $end$
sbi
A: 
/**
 * \file    $FILE_BASE$.$FILE_EXT$
 * \brief 
 * \author 
 * \date    $DATE$
 */

#ifndef __$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_INCLUDED__
#define __$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_INCLUDED__

$end$

#endif //__$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_INCLUDED__
dd