00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __SINK_H__
00025 #define __SINK_H__
00026
00027 #include "common.h"
00028 #include "exprTree.h"
00029 #include <vector>
00030 #include <utility>
00031 #include <string>
00032
00033 BEGIN_NAMESPACE( classad )
00034
00035
00036 class ClassAdUnParser
00037 {
00038 public:
00040 ClassAdUnParser( );
00041
00043 virtual ~ClassAdUnParser( );
00044
00048 void setXMLUnparse(bool doXMLUnparse);
00049
00050
00051
00052 void setDelimiter(char delim);
00053
00058 void Unparse( std::string &buffer, const Value &val );
00059
00064 void Unparse( std::string &buffer, const ExprTree *expr );
00065
00066
00067 void SetOldClassAd( bool );
00068 bool GetOldClassAd();
00069
00070 virtual void UnparseAux( std::string &buffer,
00071 const Value&,Value::NumberFactor );
00072 virtual void UnparseAux( std::string &buffer,
00073 const ExprTree *tree,
00074 std::string &ref, bool absolute=false );
00075 virtual void UnparseAux( std::string &buffer, Operation::OpKind op,
00076 ExprTree *op1, ExprTree *op2, ExprTree *op3 );
00077 virtual void UnparseAux(std::string &buffer, std::string &fnName,
00078 std::vector<ExprTree*>& args);
00079 virtual void UnparseAux( std::string &buffer,
00080 std::vector< std::pair< std::string, ExprTree*> >& attrlist );
00081 virtual void UnparseAux( std::string &buffer, std::vector<ExprTree*>& );
00082
00083
00084 virtual void UnparseAux( std::string &buffer, std::string identifier);
00085
00086
00087 static char *opString[];
00088
00089 protected:
00090 bool oldClassAd;
00091 bool xmlUnparse;
00092 char delimiter;
00093 };
00094
00095
00097 class PrettyPrint : public ClassAdUnParser
00098 {
00099 public:
00101 PrettyPrint( );
00103 virtual ~PrettyPrint( );
00104
00106 void SetClassAdIndentation( int=4 );
00108 int GetClassAdIndentation( );
00109
00111 void SetListIndentation( int=4 );
00113 int GetListIndentation( );
00114
00115 void SetWantStringQuotes( bool );
00116 bool GetWantStringQuotes( );
00117
00119 void SetMinimalParentheses( bool );
00121 bool GetMinimalParentheses( );
00122
00123 virtual void UnparseAux( std::string &buffer, Operation::OpKind op,
00124 ExprTree *op1, ExprTree *op2, ExprTree *op3 );
00125 virtual void UnparseAux( std::string &buffer,
00126 std::vector< std::pair< std::string, ExprTree*> >& attrlist );
00127 virtual void UnparseAux( std::string &buffer, std::vector<ExprTree*>& );
00128
00129 private:
00130 int classadIndent;
00131 int listIndent;
00132 bool wantStringQuotes;
00133 bool minimalParens;
00134 int indentLevel;
00135 };
00136
00137 END_NAMESPACE
00138
00139 #endif//__DUMPER_H__