Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

nci/suif/suif2b/common/formatted.h

Go to the documentation of this file.
00001 #ifndef __FORMAT_H__
00002 #define __FORMAT_H__
00003 
00004 #include "MString.h"
00005 #include "simple_stack.h"
00006 #include "i_integer.h"
00007 
00019 class PrintAddress { 
00020     public:
00024         virtual String get_pointer_as_string(void *addr) = 0;
00025         virtual ~PrintAddress() {}
00026     };
00027 
00028 //      This class supports output of formatted text in a simple
00029 //      minded way.
00030 //
00031 //      Typical entries consist of the form
00032 //
00033 //              StartBlock
00034 //              Text with Separator calls
00035 //              EndBlock
00036 //
00037 // A typical use of this might be
00038 //   SuifObject *something;
00039 //   FormattedText txt;
00040 //   something->print(txt);
00041 //   String s = txt.get_value();
00042 //
00043 
00044 class TextBlock;
00045 
00051 class FormattedText
00052     {
00053         int max_line;
00054         int indent;
00055         bool no_line_merge;
00056 
00057         int max_header_len;
00058         TextBlock *root;
00059         TextBlock *current;
00060 
00061     public:
00062 
00068         FormattedText(  int maxline = 80,
00069                         int the_indent = 4,
00070                         bool nolinemerge=false);
00071 
00078         String pointer_header(class String, void *);
00079 
00084         void set_use_diff_mode(bool diff);  // set to use diff mode
00085 
00087         void set_special_print_mode(PrintAddress *p); // or your own pointer print 
00088 
00089         ~FormattedText();
00090 
00092         void start_block(const String &title);
00093 
00096         void set_value(const String &val);
00097         void set_value(const LString &val);
00098         void set_value(int i);
00099         void set_value(bool b);
00100         void set_value(long l);
00101         void set_value(double d);
00102         void set_value(LString &l);
00103         void set_value(const char *c);
00104         void set_value(const IInteger &v);
00105         void set_value(const void *p);
00106 
00108         void end_block();
00109 
00111         int get_indent(int cur,TextBlock *block) const;
00112         int total_len(TextBlock *block) const;
00114         String get_value() const;
00115 
00116         String get_value(const String cur_pad,const String indent,bool no_newlines,TextBlock *block) const;
00117       private:
00118 
00119         PrintAddress* _pa;
00120         FormattedText(const FormattedText &);
00121         FormattedText &operator=(const FormattedText &);
00122     };
00123 
00124 
00125 #endif
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 

Generated at Mon Jul 31 13:41:39 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000