home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / value.h < prev    next >
C/C++ Source or Header  |  1992-10-19  |  2KB  |  82 lines

  1. /*
  2.  * Value.h - definition for value class, which stores real and string 
  3.  *           values.
  4.  *
  5.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #ifndef Value_H
  20. # define Value_H
  21.  
  22. #include <iostream.h>
  23. #include "rcString.h"
  24. #include "Globals.h"
  25.  
  26. //___________________________________________________________ Value
  27.  
  28. enum ValueType { REAL, STRING };
  29. enum ArgumentType { RR, RS, SR, SS, UNKNOWN };
  30.  
  31. class Value 
  32. {
  33. public:
  34.   Value();
  35.   Value(real);
  36.   Value(const char*);
  37.   Value(const rcString&);
  38.   Value(const Value&);
  39.  
  40.   ~Value();
  41.  
  42.   const Value& operator=(const Value&);
  43.  
  44.   operator real() const;
  45.   operator rcString() const;
  46.  
  47.   int toReal(real&) const;
  48.   rcString toString() const;
  49.  
  50.   Value operator-();
  51.   Value operator+(const Value&);
  52.   Value operator-(const Value&);
  53.   Value operator*(const Value&);
  54.   Value operator/(const Value&);
  55.   Value operator%(const Value&);
  56.   
  57.   Value operator!();
  58.   Value operator&&(const Value&);
  59.   Value operator||(const Value&);
  60.   Value operator==(const Value&);
  61.   Value operator!=(const Value&);
  62.   Value operator< (const Value&);
  63.   Value operator<=(const Value&);
  64.   Value operator> (const Value&);
  65.   Value operator>=(const Value&);
  66.  
  67.   friend ostream& operator<< (ostream&, const Value&);
  68.  
  69. private:
  70.   ValueType type;
  71.   union {
  72.     real realVal;
  73.     rcString* stringVal;
  74.   }; 
  75.   
  76.   ArgumentType binary_type(const Value&);
  77. };
  78.  
  79. typedef Value* ValuePtr;
  80.  
  81. #endif // Value_H 
  82.