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

literals.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 __LITERALS_H__
00025 #define __LITERALS_H__
00026 
00027 BEGIN_NAMESPACE( classad )
00028 
00029 typedef std::vector<ExprTree*> ArgumentList;
00030 
00034 class Literal : public ExprTree 
00035 {
00036         public:
00038         ~Literal ();
00039 
00041         Literal(const Literal &literal);
00042 
00044         Literal &operator=(const Literal &literal);
00045 
00051                 static Literal* MakeAbsTime( abstime_t *now=NULL );
00052 
00053                 /* Creates an absolute time literal, from the string timestr, 
00054                  *parsing it as the regular expression:
00055                  D* dddd [D* dd [D* dd [D* dd [D* dd [D* dd D*]]]]] [-dddd | +dddd | z | Z]
00056                  D => non-digit, d=> digit
00057                  Ex - 2003-01-25T09:00:00-0600
00058                 */
00059                 static Literal* MakeAbsTime( std::string timestr);
00060 
00066                 static Literal* MakeRelTime( time_t secs=-1 );
00067 
00075                 static Literal* MakeRelTime( time_t t1, time_t t2 );
00076 
00077                 /* Creates a relative time literal, from the string timestr, 
00078                  *parsing it as [[[days+]hh:]mm:]ss
00079                  * Ex - 1+00:02:00
00080                 */              
00081                 static Literal* MakeRelTime(std::string str);
00082 
00083                 static Literal* MakeReal(std::string realstr);
00084 
00086                 virtual ExprTree* Copy( ) const;
00087 
00088         void CopyFrom(const Literal &literal);
00089 
00097                 static Literal*MakeLiteral( const Value& v, Value::NumberFactor f=
00098                                         Value::NO_FACTOR );
00099 
00104                 void GetComponents( Value& v, Value::NumberFactor &f ) const;
00105 
00109                 void GetValue( Value& v ) const;
00110                 
00111                 /* Takes the number of seconds since the epoch as argument - epochsecs, 
00112                  *and returns the timezone offset(relative to GMT) in the currect locality
00113                  */
00114                 static int findOffset(time_t epochsecs);
00115 
00116         virtual bool SameAs(const ExprTree *tree) const;
00117 
00118         friend bool operator==(Literal &literal1, Literal &literal2);
00119 
00120         protected:
00122         Literal ();
00123 
00124         private:
00125                 friend class FunctionCall;
00126                 friend class ClassAd;
00127                 friend class ExprList;
00128                 friend class Operation;
00129 
00130                 virtual void _SetParentScope( const ClassAd* ){ }
00131                 virtual bool _Flatten( EvalState&, Value&, ExprTree*&, int* ) const;
00132                 virtual bool _Evaluate (EvalState &, Value &) const;
00133                 virtual bool _Evaluate (EvalState &, Value &, ExprTree *&) const;
00134 
00135                 // literal specific information
00136         Value                           value;
00137                 Value::NumberFactor     factor;
00138 };
00139 
00140 END_NAMESPACE // classad
00141 
00142 #endif//__LITERALS_H__