Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <vlCore/VLXValue.hpp>
00033
00034 using namespace vl;
00035
00036
00037 void VLXValue::release()
00038 {
00039 switch(mType)
00040 {
00041 case Structure:
00042 if (mUnion.mStructure)
00043 mUnion.mStructure->decReference();
00044 break;
00045
00046 case List:
00047 if (mUnion.mList)
00048 mUnion.mList->decReference();
00049 break;
00050
00051 case RawtextBlock:
00052 if (mUnion.mRawtextBlock)
00053 mUnion.mRawtextBlock->decReference();
00054 break;
00055
00056
00057
00058
00059
00060
00061 case ArrayInteger:
00062 case ArrayReal:
00063 if (mUnion.mArray)
00064 mUnion.mArray->decReference();
00065 break;
00066
00067 case String:
00068 case ID:
00069 case Identifier:
00070 VL_CHECK(mUnion.mString)
00071 delete mUnion.mString;
00072 mUnion.mString = NULL;
00073 break;
00074
00075 default:
00076 break;
00077 }
00078
00079 mType = Integer;
00080 mUnion.mInteger = 0;
00081 }
00082
00083 VLXValue& VLXValue::operator=(const VLXValue& other)
00084 {
00085 mLineNumber = other.mLineNumber;
00086
00087
00088 switch(other.mType)
00089 {
00090 case Structure:
00091 if (other.mUnion.mStructure)
00092 other.mUnion.mStructure->incReference();
00093 break;
00094
00095 case List:
00096 if (other.mUnion.mList)
00097 other.mUnion.mList->incReference();
00098 break;
00099
00100 case RawtextBlock:
00101 if (other.mUnion.mRawtextBlock)
00102 other.mUnion.mRawtextBlock->incReference();
00103 break;
00104
00105
00106
00107
00108
00109
00110 case ArrayInteger:
00111 case ArrayReal:
00112 if (other.mUnion.mArray)
00113 other.mUnion.mArray->incReference();
00114 break;
00115
00116 default:
00117 break;
00118 }
00119
00120
00121 release();
00122
00123 mUnion = other.mUnion;
00124 mType = other.mType;
00125
00126
00127 if (mType == String || mType == Identifier || mType == ID)
00128 mUnion.mString = new std::string(*mUnion.mString);
00129
00130 return *this;
00131 }
00132
00133 VLXStructure* VLXValue::setStructure(VLXStructure* obj)
00134 {
00135 release();
00136 mType = Structure;
00137 mUnion.mStructure = obj;
00138 if (mUnion.mStructure)
00139 mUnion.mStructure->incReference();
00140 return obj;
00141 }
00142
00143 VLXList* VLXValue::setList(VLXList* list)
00144 {
00145 VL_CHECK(list);
00146
00147 release();
00148 mType = List;
00149 mUnion.mList = list;
00150 if (mUnion.mList)
00151 mUnion.mList->incReference();
00152 return list;
00153 }
00154
00155 VLXRawtextBlock* VLXValue::setRawtextBlock(VLXRawtextBlock* fblock)
00156 {
00157 VL_CHECK(fblock);
00158
00159 release();
00160 mType = RawtextBlock;
00161 mUnion.mRawtextBlock = fblock;
00162 if (mUnion.mRawtextBlock)
00163 mUnion.mRawtextBlock->incReference();
00164 return fblock;
00165 }
00166
00167 VLXArrayInteger* VLXValue::setArrayInteger(VLXArrayInteger* arr)
00168 {
00169 VL_CHECK(arr);
00170 release();
00171 mType = ArrayInteger;
00172 mUnion.mArray = arr;
00173 if (mUnion.mArray)
00174 mUnion.mArray->incReference();
00175 return arr;
00176 }
00177
00178 VLXArrayReal* VLXValue::setArrayReal(VLXArrayReal* arr)
00179 {
00180 VL_CHECK(arr);
00181 release();
00182 mType = ArrayReal;
00183 mUnion.mArray = arr;
00184 if (mUnion.mArray)
00185 mUnion.mArray->incReference();
00186 return arr;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 VLXArray* VLXValue::setArray(VLXArray* arr)
00225 {
00226 if (arr->classType() == VLXArrayInteger::Type())
00227 return setArrayInteger(arr->as<VLXArrayInteger>());
00228 else
00229 if (arr->classType() == VLXArrayReal::Type())
00230 return setArrayReal(arr->as<VLXArrayReal>());
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 else
00243 {
00244 VL_TRAP();
00245 return NULL;
00246 }
00247 }
00248