WebBiscuit

WebBiscuit

The Webbiscuit Blog: Taking the Internet crumb by crumb…

  • Home
  • Software
    • Palette Parser
    • XHTML Generator
  • Articles
    • The Strategy Pattern
    • The Factory Pattern
    • Memory leaks
  • About Web Biscuit
  • Contact

An introduction to three VC++ Macros: How they came to be

Posted in C++, code, CodeProject, IDE, macro, Visual Studio by Daniel
Nov 25 2011
TrackBack Address.

I’ve been recently working on a C++ project and ran into a task where I had to move many inline header functions out of the header and into the corresponding .cpp file.

Visually, I wanted to convert:
Biscuit.h

class Biscuit
{
public:
    virtual void Taste(int chompiness) { m_ChompRating = chompiness; }
private:
    int m_ChompRating;
}

into
Biscuit.h

class Biscuit
{
public:
    virtual void Taste(int chompiness);
private:
    int m_ChompRating;
}

Biscuit.cpp

void Biscuit::Taste(int chompiness)
{
    m_ChompRating = tastiness; 
}

We’ve all been there. It is usually an exercise in our copy and paste skills, and an opportunity to work on our RSI. I thought there must be a better way! So I scoured the Internet but noone seems to talk about it. It seems every programmer has just accepted that the only way to get this done is to stop mucking about on Google and push your fingers to the keys.

I was still not satisfied. I asked the collective brains of Stack Overflow and the only solution I got was to purchase Visual Assist. I’ve tried Visual Assist. It is a brilliant product. It is also a brilliantly expensive product. Nawaz, from Stack Overflow (he is the one that looks like a baby) challenged me to write a macro myself, and share it, because “it wouldn’t be too difficult to write”.

Hah! It was not that difficult to get something that worked some of the time. It was difficult to create something that worked all of the time. I knew nothing about macros, other than how to record them and see the generated code. Finally, after a bit of reverse engineering, a tiny bit of reading and some code stealing inspired coding, I have a set of macros I am quite happy with. Over my next 3 blog posts I will share these macros with you, and on the way we will build up a few good utilities:

  1. How to flip between the header and cpp file
  2. Automatically adding an implementation skeleton to the cpp file from the header definition
  3. Moving a function defined inline in the header into the cpp file

And hopefully some Googler will be able to make use of these macros. See you soon.

Share
Tagged as: moving functions, vc++ macros, visual studio 2010

RSS Other Nibbles

  • Palette Parser Update – Now supports CMYK format
  • Are you a biscuit?
  • Base64 Encoder and Boost
  • The Sleep Experiment
  • A macro to create a C++ implementation from a header declaration
  • A macro to flip between the source and header file (and back again)
  • An introduction to three VC++ Macros: How they came to be
  • Making Eclipse more like Visual Studio
  • A tokeniser using STL
  • More of WebBiscuit’s WordPress Plugins

Categories

  • Boost
  • C++
  • code
  • CodeProject
  • CSharp
  • domains
  • Eclipse
  • experiments
  • funny
  • games
  • IDE
  • macro
  • migrating
  • plugins
  • productivity
  • reviews
  • sleeping
  • STL
  • Test
  • tips
  • VB
  • Visual Studio
  • web tips
  • WebBiscuit Software
  • wordpress
  • workarounds

Blogroll

  • Create colour palettes with Kuler
  • Free Icons with Axialis Software

Stale Biscuits

  • December 2012 (1)
  • August 2012 (1)
  • April 2012 (1)
  • January 2012 (1)
  • December 2011 (2)
  • November 2011 (1)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (9)

Eating the web bit by bit

Powered by WordPress | “Blend” from Spectacu.la WP Themes Club