diff options
| author | Ryan Kavanagh <ryanakca@kubuntu.org> | 2011-08-14 17:16:55 -0400 | 
|---|---|---|
| committer | Ryan Kavanagh <ryanakca@kubuntu.org> | 2011-08-25 07:42:57 -0400 | 
| commit | 1c019761dfaf6be82de9284fa5e2b9dbfbdec27d (patch) | |
| tree | 7ed6bd2f437d3a334bd7a81f62e6dfa63689272b /.vim/c-support/templates/cpp.idioms.template | |
Initial import
Diffstat (limited to '.vim/c-support/templates/cpp.idioms.template')
| -rw-r--r-- | .vim/c-support/templates/cpp.idioms.template | 98 | 
1 files changed, 98 insertions, 0 deletions
| diff --git a/.vim/c-support/templates/cpp.idioms.template b/.vim/c-support/templates/cpp.idioms.template new file mode 100644 index 0000000..febc375 --- /dev/null +++ b/.vim/c-support/templates/cpp.idioms.template @@ -0,0 +1,98 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function == +void<CURSOR> +|?FUNCTION_NAME| (  ) +{ +<SPLIT>	return ; +}		// -----  end of function |FUNCTION_NAME|  ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function-static == +static void<CURSOR> +|?FUNCTION_NAME| (  ) +{ +<SPLIT>	return ; +}		// -----  end of static function |FUNCTION_NAME|  ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.main == +int +main ( int argc, char *argv[] ) +{<CURSOR> +<SPLIT>	return EXIT_SUCCESS; +}				// ----------  end of function main  ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.enum == +enum |?ENUM_NAME| {<CURSOR> +<SPLIT>};				// ----------  end of enum |ENUM_NAME|  ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.struct == +struct |?STRUCT_NAME| {<CURSOR> +<SPLIT>};				// ----------  end of struct |STRUCT_NAME|  ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.union == +union |?UNION_NAME| {<CURSOR> +<SPLIT>};				// ----------  end of union |UNION_NAME|  ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.calloc == +|?POINTER|	= (<CURSOR>TYPE*)calloc ( (size_t)(COUNT), sizeof(TYPE) ); +if ( |POINTER|==NULL ) { +	fprintf ( stderr, "\ndynamic memory allocation failed\n" ); +	exit (EXIT_FAILURE); +} + +free (|POINTER|); + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.malloc == +|?POINTER|	= (<CURSOR>TYPE*)malloc ( sizeof(TYPE) ); +if ( |POINTER|==NULL ) { +	fprintf ( stderr, "\ndynamic memory allocation failed\n" ); +	exit (EXIT_FAILURE); +} + +free (|POINTER|); + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-input-file == +FILE	*|?FILEPOINTER|;										// input-file pointer +char	*|FILEPOINTER|_file_name = "<CURSOR>";		// input-file name + +|FILEPOINTER|	= fopen( |FILEPOINTER|_file_name, "r" ); +if ( |FILEPOINTER| == NULL ) { +	fprintf ( stderr, "couldn't open file '%s'; %s\n", +			|FILEPOINTER|_file_name, strerror(errno) ); +	exit (EXIT_FAILURE); +} + + +if( fclose(|FILEPOINTER|) == EOF ) {			// close input file +	fprintf ( stderr, "couldn't close file '%s'; %s\n", +			|FILEPOINTER|_file_name, strerror(errno) ); +	exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-output-file == +FILE	*|?FILEPOINTER|;										// output-file pointer +char	*|FILEPOINTER|_file_name = "<CURSOR>";		// output-file name + +|FILEPOINTER|	= fopen( |FILEPOINTER|_file_name, "w" ); +if ( |FILEPOINTER| == NULL ) { +	fprintf ( stderr, "couldn't open file '%s'; %s\n", +			|FILEPOINTER|_file_name, strerror(errno) ); +	exit (EXIT_FAILURE); +} + + +if( fclose(|FILEPOINTER|) == EOF ) {			// close output file +	fprintf ( stderr, "couldn't close file '%s'; %s\n", +			|FILEPOINTER|_file_name, strerror(errno) ); +	exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.fprintf == +fprintf ( |?FILEPOINTER|, "<CURSOR>\n",  ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.fscanf == +fscanf ( |?FILEPOINTER|, "<CURSOR>", & ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
