[TxMt] [C Bundle] Better C++ Class Constructor, typedef snippet

Ryan Wilcox ryanwilcox at mac.com
Fri Dec 22 02:06:39 UTC 2006


Hello all,

I'd like to propose two additions to the C bundle.

First, an easy snippet: typedef.
    
    I know I can never remember how typedef works, so I propose this
    snippet:
    
    typedef ${1:WhatItIs} ${2:NowCallIt}
    
Second, a modification on an old favorite: the class snippet.

    Most of the classes I write are subclasses of something else.
    Except the class snippet echos my colon and subclass declaration.
    
    Meaning, I end up with class declarations like:
    
        class Customer : public Person
        {
        public:
            Customer : public Person (arguments);
            virtual ~Customer : public Person ();
        
        private:
            /* data */
        };
        
    (Note the ": public Person" echoed on both the constructor line,
    and the deconstructor like).
    
    I suggest modifying the class snippet like so:
    
        class ${1:name}${2: : public } $3
        {
        public:
            ${1:name} (${4:arguments});
            virtual ~${1:name} ();
        
        private:
            ${0:/* data */}
        };        
        
    There are a few things I don't like about this, mainly that if
    you don't inherit from something you know have to type
    "'class', tab, delete, tab, arguments. It also might handle
    multiple inheritance poorly, or protected/private inheritance.
    Maybe some TextMate snippet wizards (or people with more involved
    C++ classes than I) can revisit my snippet to make it work better
    with these cases.
    
Hope this helps,
_Ryan Wilcox

-- 
Wilcox Development Solutions:          <http://www.wilcoxd.com>
Toolsmiths for the Internet Age            PGP: 0x2F4E9C31



More information about the textmate mailing list