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

ErrorValue.cpp

Go to the documentation of this file.
00001 // ErrorValue.cpp: implementation of the CErrorValue class.
00002 /*
00003  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>

00004  *
00005  * Permission to use, copy, modify, distribute and sell this software

00006  * and its documentation for any purpose is hereby granted without fee,

00007  * provided that the above copyright notice appear in all copies and

00008  * that both that copyright notice and this permission notice appear

00009  * in supporting documentation.  Erwin Coumans makes no

00010  * representations about the suitability of this software for any

00011  * purpose.  It is provided "as is" without express or implied warranty.

00012  *
00013  */
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "ErrorValue.h"
00021 
00022 
00024 // Construction/Destruction
00026 
00027 CErrorValue::CErrorValue()
00028 /*
00029 pre:

00030 effect: constructs a new CErrorValue containing errormessage "Error"

00031 */
00032 {
00033         m_strErrorText = "Error";
00034         SetError(true);
00035 }
00036 
00037 CErrorValue::CErrorValue(CCString errmsg)
00038 /*
00039 pre:

00040 effect: constructs a new CErrorValue containing errormessage errmsg

00041 */
00042 {
00043   m_strErrorText = "[" + errmsg + "]";
00044   SetError(true);
00045 }
00046 
00047 CErrorValue::~CErrorValue()
00048 /*
00049 pre:

00050 effect: deletes the object

00051 */
00052 {
00053 
00054 }
00055 
00056 CValue* CErrorValue::Calc(VALUE_OPERATOR op, CValue *val)
00057 /*
00058 pre:

00059 ret: a new object containing the result of applying operator op to this

00060          object and val

00061 */
00062 {
00063         CValue* errorval;
00064 
00065         switch (op) {
00066         case (VALUE_NEG_OPERATOR):
00067         case (VALUE_NOT_OPERATOR):
00068                 errorval = new CErrorValue (op2str(op) + GetText());
00069                 break;
00070         default:
00071                 errorval = val->CalcFinal(VALUE_ERROR_TYPE, op, this);
00072         }
00073         
00074         return errorval;
00075 }
00076 
00077 CValue* CErrorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
00078 /*
00079 pre: the type of val is dtype

00080 ret: a new object containing the result of applying operator op to val and

00081          this object

00082 */
00083 {
00084         return new CErrorValue (val->GetText() + op2str(op) + GetText());
00085 }
00086 
00087 
00088 float CErrorValue::GetNumber()

00089 {
00090         return -1;
00091 }
00092 
00093 
00094 const CCString & CErrorValue::GetText()

00095 {
00096         return m_strErrorText;
00097 }
00098 

Generated at Thu Feb 1 13:03:02 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000