Library Header file Snippet

This is an absurd, yet extremely useful snippet I use often. It is for creating a library header file in an existing file. This would be best as a File Template but since the filename is important, it won't work like that. First open up your Snippets file and copy & paste the following under the [Special] group:

license=\s* This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n * \n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  \n * 02110-1301  USA.\n

Of course you might want to use another License, so modify the above accordingly, though it's a pain to make it all on one line with the comment symbols and such. Now copy & paste the following under the [C] group:

_h=/*\n * {filename}\n * \n * Copyright {year} {developer} <{mail}>\n * \n%license% * \n */\n\n#ifndef {command:python -c "print '{filename}'.split('.')[0].upper()"}_H\n#define {command:python -c "print '{filename}'.split('.')[0].upper()"}_H\n#ifdef __cplusplus\nextern "C" {\n#endif\n\n\n%cursor%\n\n\n#ifdef __cplusplus\n} /* extern "C" */\n#endif\n#endif /* {command:python -c "print '{filename}'.split('.')[0].upper()"}_H */

Now create a new file and save it with the correct filename (ex. foo.h), then in the blank file type '_h' and press TAB. Now you have all the boilerplate for your new library header file. Note that the snippet above requires you have Python on your system.

Print/export