// // $Id$ //----------------------------------------------------------------------- // // (c) Copyright 2006 by GATS, Inc., // 11864 Canon Blvd, Suite 101, Newport News VA 23606 // // All Rights Reserved. No part of this software or publication may be // reproduced, stored in a retrieval system, or transmitted, in any form // or by any means, electronic, mechanical, photocopying, recording, or // otherwise without the prior written permission of GATS, Inc. // //----------------------------------------------------------------------- // // Module: Value.cpp // // Author: John Burton // // Date: Tue Apr 18 18:05:18 2006 // //----------------------------------------------------------------------- // // Modification History: // // $Log$ // //----------------------------------------------------------------------- // //----------------------------------------------------------------------- // Include Files: //----------------------------------------------------------------------- // #include #include #include #include #include #include "Value.h" // //----------------------------------------------------------------------- // Defines and Macros: //----------------------------------------------------------------------- // using namespace std; // //----------------------------------------------------------------------- // Global Variables: //----------------------------------------------------------------------- // // //----------------------------------------------------------------------- // Utility Routines: //----------------------------------------------------------------------- // void ValueClass::AddValue(string val) { if (type == NONE) type = STRING; if (type != STRING){ switch(type) { case INT: cerr << "Type clash! Trying to add a String to an Integer value list\n"; break; case REAL: cerr << "Type clash! Trying to add a String to an Real value list\n"; break; default: cerr << val << " String Parse Error! Giving up!\n"; exit(-1); break; } } s.push_back(val); } void ValueClass::AddValue(int val) { if (type == NONE) type = INT; if (type != INT){ switch(type) { case STRING: cerr << "Type clash! Trying to add an Integer to a String value list\n"; break; case REAL: cerr << "Type clash! Trying to add an Integer to an Real value list\n"; break; default: cerr << val << " Int Parse Error! Giving up!\n"; exit(-1); break; } } i.push_back(val); } void ValueClass::AddValue(float val) { if (type == NONE) type = REAL; if (type != REAL){ switch(type) { case INT: cerr << "Type clash! Trying to add a Real to an Integer value list\n"; break; case STRING: cerr << "Type clash! Trying to add a Real to a String value list\n"; break; default: cerr << val << " Float Parse Error! Giving up!\n"; exit(-1); break; } } f.push_back(val); } void ValueClass::AddValueList(vector vlist) { int i; if (type != STRING){ switch(type) { case INT: cerr << "Type clash! Trying to add a String to an Integer value list\n"; break; case REAL: cerr << "Type clash! Trying to add a String to an Real value list\n"; break; default: // cerr << vlist << " Parse Error! Giving up!\n"; exit(-1); break; } } for(i=0;i vlist) { int j; if (type != INT){ switch(type) { case STRING: cerr << "Type clash! Trying to add an Integer to a String value list\n"; break; case REAL: cerr << "Type clash! Trying to add an Integer to an Real value list\n"; break; default: // cerr << vlist <<" Parse Error! Giving up!\n"; exit(-1); break; } } for(j=0;j vlist) { int i; if (type != REAL){ switch(type) { case INT: cerr << "Type clash! Trying to add a Real to an Integer value list\n"; break; case STRING: cerr << "Type clash! Trying to add a Real to a String value list\n"; break; default: // cerr << vlist <<" Parse Error! Giving up!\n"; exit(-1); break; } } for(i=0;iGetType()){ cerr << "Type clash! \n"; }else { switch(type) { case INT: AddValueList(val->GetIntValue()); break; case STRING: AddValueList(val->GetStringValue()); break; case REAL: AddValueList(val->GetRealValue()); break; default: cerr << " ValueClass Parse Error! Giving up!\n"; cerr << " type = " << type << "\n"; cerr << " val->GetType() = " << val->GetType() << "\n"; val->PrintValues(); exit(-1); break; } } } void ValueClass::PrintValues() { int nvals; int l; switch(type) { case INT: nvals = i.size(); if(nvals == 1) cerr << i[0] << "\n"; else { cerr << "{"; for(l=0;l