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

sink.h

00001 /*********************************************************************
00002  *
00003  * Condor ClassAd library
00004  * Copyright (C) 1990-2003, Condor Team, Computer Sciences Department,
00005  * University of Wisconsin-Madison, WI and Rajesh Raman.
00006  *
00007  * This source code is covered by the Condor Public License, which can
00008  * be found in the accompanying LICENSE file, or online at
00009  * www.condorproject.org.
00010  *
00011  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00012  * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR
00013  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00014  * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS
00015  * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT
00016  * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON
00017  * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS,
00018  * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY
00019  * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY
00020  * RIGHT.
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>      // for pair template
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                 // The default delimiter for strings is '\"'
00051                 // This can be changed to '\'' to unparse quoted attributes, with this function
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                         //      for backcompatibility only - NAC
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                 // to unparse attribute names (quoted & unquoted attributes)
00084                 virtual void UnparseAux( std::string &buffer, std::string identifier);
00085 
00086                 // table of string representation of operators
00087                 static char *opString[];
00088 
00089  protected:
00090                 bool oldClassAd;
00091                 bool xmlUnparse;
00092                 char delimiter; // string delimiter - initialized to '\"' in the constructor
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 // classad
00138 
00139 #endif//__DUMPER_H__