Blender V2.61 - r43446

ErrorValue.cpp

Go to the documentation of this file.
00001 
00004 // ErrorValue.cpp: implementation of the CErrorValue class.
00005 /*
00006  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
00007  *
00008  * Permission to use, copy, modify, distribute and sell this software
00009  * and its documentation for any purpose is hereby granted without fee,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.  Erwin Coumans makes no
00013  * representations about the suitability of this software for any
00014  * purpose.  It is provided "as is" without express or implied warranty.
00015  *
00016  */
00017 
00018 #include "ErrorValue.h"
00019 
00021 // Construction/Destruction
00023 
00024 CErrorValue::CErrorValue()
00025 /*
00026 pre:
00027 effect: constructs a new CErrorValue containing errormessage "Error"
00028 */
00029 {
00030     m_strErrorText = "Error";
00031     SetError(true);
00032 }
00033 
00034 
00035 
00036 CErrorValue::CErrorValue(const char *errmsg)
00037 /*
00038 pre:
00039 effect: constructs a new CErrorValue containing errormessage errmsg
00040 */
00041 {
00042   m_strErrorText = "[";
00043   m_strErrorText += errmsg;
00044   m_strErrorText += "]";
00045   SetError(true);
00046 }
00047 
00048 
00049 
00050 CErrorValue::~CErrorValue()
00051 /*
00052 pre:
00053 effect: deletes the object
00054 */
00055 {
00056 
00057 }
00058 
00059 
00060 
00061 CValue* CErrorValue::Calc(VALUE_OPERATOR op, CValue *val)
00062 /*
00063 pre:
00064 ret: a new object containing the result of applying operator op to this
00065      object and val
00066 */
00067 {
00068     CValue* errorval;
00069 
00070     switch (op)
00071     {
00072     case VALUE_POS_OPERATOR:
00073     case VALUE_NEG_OPERATOR:
00074     case VALUE_NOT_OPERATOR:
00075         {
00076             errorval = new CErrorValue (op2str(op) + GetText());
00077             break;
00078         }
00079     default:
00080         {
00081             errorval = val->CalcFinal(VALUE_ERROR_TYPE, op, this);
00082             break;
00083         }
00084     }
00085     
00086     return errorval;
00087 }
00088 
00089 
00090 
00091 CValue* CErrorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
00092 /*
00093 pre: the type of val is dtype
00094 ret: a new object containing the result of applying operator op to val and
00095      this object
00096 */
00097 {
00098     return new CErrorValue (val->GetText() + op2str(op) + GetText());
00099 }
00100 
00101 
00102 
00103 double CErrorValue::GetNumber()
00104 {
00105     return -1;
00106 }
00107 
00108 
00109 
00110 const STR_String & CErrorValue::GetText()
00111 {
00112     return m_strErrorText;
00113 }
00114 
00115 
00116 
00117 CValue* CErrorValue::GetReplica()
00118 { 
00119     // who would want a copy of an error ?
00120     trace ("Error: ErrorValue::GetReplica() not implemented yet");
00121     assertd(false);
00122 
00123     return NULL;
00124 }