###########################################################################
#                            TextMate Snippets                            #
###########################################################################

snippet ifndef "#ifndef ... #define ... #endif" !b
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
#define ${1:SYMBOL} ${2:value}
#endif
endsnippet

snippet #if "#if #endif" !b
#if ${1:0}
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
#endif
endsnippet

snippet main "main() (main)" !
int main(int argc, char *argv[]) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
  return 0;
}
endsnippet

snippet for "for loop (for)" !
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet


snippet enum "Enumeration" !
enum ${1:name} { 
  $0 
};
endsnippet

snippet wh "while loop" !
while(${1:/* condition */}) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet do "do...while loop (do)" !
do {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
} while(${1:/* condition */});
endsnippet

snippet if "if .. (if)" !
if (${1:/* condition */}) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet el "else .. (else)" !
else {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet eli "else if .. (eli)" !
else if (${1:/* condition */}) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

snippet ife "if .. else (ife)" !
if (${1:/* condition */}) {
  ${2:/* code */}
} else {
  ${3:/* else */}
}
endsnippet

snippet st "struct" !
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
  ${0:/* data */}
};
endsnippet

snippet fun "function" b!
${1:void} ${2:function_name}(${3}) {
  ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet

# vim:ft=snippets:
