Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ifprintf.h File Reference

#include <string.h>
#include <cassert>
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Functions

void set_indent (const char *s)
void indent ()
void outdent ()
void ifprintf (FILE *f, const char *c,...)


Function Documentation

void ifprintf FILE *  f,
const char *  c,
  ...
 

Definition at line 28 of file ifprintf.cc.

References indent_current.

Referenced by AST::Node::toASTFile().

00028                                           {
00029     fprintf(f, indent_current);
00030     va_list valist;
00031     va_start(valist, c);
00032     vfprintf(f, c, valist);
00033     va_end(valist);
00034 }

void indent  ) 
 

Definition at line 14 of file ifprintf.cc.

References indent_amount, indent_current, indentLevel, and maxIndentLevel.

Referenced by AST::Node::toASTFile().

00014              {
00015     indentLevel++;
00016     assert(indentLevel < maxIndentLevel);
00017     strcat(indent_current, indent_amount);
00018     assert(strlen(indent_current) == strlen(indent_amount) * indentLevel);
00019 }

void outdent  ) 
 

Definition at line 21 of file ifprintf.cc.

References indent_amount, indent_current, and indentLevel.

Referenced by AST::Node::toASTFile().

00021               {
00022     indentLevel--;
00023     assert(indentLevel >= 0 && "unindented too many times");
00024     indent_current[indentLevel * strlen(indent_amount)] = '\0';
00025     assert(strlen(indent_current) == strlen(indent_amount) * indentLevel);
00026 }

void set_indent const char *  s  ) 
 

Definition at line 7 of file ifprintf.cc.

References indent_amount, indent_current, indentLevel, and maxIndentLevel.

Referenced by main().

00007                               {
00008     assert(indent_current == 0 && "I am to lazy to allow changing of this");
00009     indent_amount = strdup(s);
00010     indent_current = new char[strlen(indent_amount) * maxIndentLevel];
00011     indentLevel = 0;
00012 }


Generated on Thu Oct 20 12:00:04 2005 for ASTree by  doxygen 1.4.2-20050421