cMsgPayload.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*
00002 *  Copyright (c) 2007        Jefferson Science Associates,                   *
00003 *                            Thomas Jefferson National Accelerator Facility  *
00004 *                                                                            *
00005 *    This software was developed under a United States Government license    *
00006 *    described in the NOTICE file included as part of this distribution.     *
00007 *                                                                            *
00008 *    C.Timmer, 3-Aug-2007, Jefferson Lab                                     *
00009 *                                                                            *
00010 *    Authors: Carl Timmer                                                    *
00011 *             timmer@jlab.org                   Jefferson Lab, MS-12B3       *
00012 *             Phone: (757) 269-5130             12000 Jefferson Ave.         *
00013 *             Fax:   (757) 269-6248             Newport News, VA 23606       *
00014 *                                                                            *
00015 *----------------------------------------------------------------------------*/
00016 
00017 
00018 #include <cMsg.hxx>
00019 #include <cMsgPrivate.h>
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <unistd.h>
00023 #include <pthread.h>
00024 #include <vector>
00025 #include <map>
00026 #include <sstream>
00027 
00028 using namespace std;
00029 using namespace cmsg;
00030 
00031 namespace cmsg {
00032 
00033     //-----------------------------------------------------------------------------
00034     //  cMsgPayload methods
00035     //-----------------------------------------------------------------------------
00036 
00037 
00038     //-----------------------------------------------------------------------------
00039 
00046     void cMsgMessage::payloadClear(void) {
00047         cMsgPayloadClear(myMsgPointer);
00048     }
00049 
00050     //-----------------------------------------------------------------------------
00051 
00058     void cMsgMessage::payloadReset(void) {
00059         cMsgPayloadReset(myMsgPointer);
00060     }
00061 
00062     //-------------------------------------------------------------------
00063 
00067     void cMsgMessage::payloadPrint(void) const {
00068         cMsgPayloadPrint(myMsgPointer);
00069     }
00070 
00071     //-------------------------------------------------------------------
00072 
00078     bool cMsgMessage::hasPayload() const {
00079         int hasPayload;
00080         cMsgHasPayload(myMsgPointer, &hasPayload);
00081         return hasPayload ? true : false;
00082     }
00083 
00084     //-------------------------------------------------------------------
00085 
00092     bool cMsgMessage::payloadContainsName(const string &name) const {
00093         return cMsgPayloadContainsName(myMsgPointer, name.c_str()) ? true : false;
00094     }
00095 
00096     //-------------------------------------------------------------------
00097 
00103     int cMsgMessage::payloadGetCount() const {
00104         int count;
00105         cMsgPayloadGetCount(myMsgPointer, &count);
00106         return count;
00107     }
00108 
00109     //-------------------------------------------------------------------
00110 
00150     int cMsgMessage::payloadGetType(const string &name) const
00151             throw(cMsgException) {
00152         int err, type;
00153         err = cMsgPayloadGetType(myMsgPointer, name.c_str(), &type);
00154         if (err != CMSG_OK) {
00155             if (err == CMSG_BAD_ARGUMENT)
00156                 throw(cMsgException("Name is null"));
00157             else
00158               throw(cMsgException(string("No payload item named ") + name));
00159         }
00160         return type;
00161     }
00162 
00163     //-------------------------------------------------------------------
00164 
00172     void cMsgMessage::payloadCopy(const cMsgMessage &msg) throw(cMsgException) {
00173         int err = cMsgPayloadCopy(msg.myMsgPointer, myMsgPointer);
00174         if (err!= CMSG_OK) {
00175             throw(cMsgException(cMsgPerror(err),err));
00176         }
00177     }
00178 
00179     //-------------------------------------------------------------------
00180 
00187     string cMsgMessage::payloadGetText() const {
00188         const char *txt;
00189         cMsgGetPayloadText(myMsgPointer, &txt);
00190         string s(txt);
00191         return s;
00192     }
00193 
00194     //-------------------------------------------------------------------
00195 
00203     void cMsgMessage::payloadSetFromText(const string &txt)
00204           throw(cMsgException) {
00205         int err = cMsgPayloadSetAllFieldsFromText(myMsgPointer, txt.c_str());
00206         if (err != CMSG_OK) {
00207             throw(cMsgException(cMsgPerror(err),err));
00208         }
00209         return;
00210     }
00211 
00212     //-------------------------------------------------------------------
00213 
00220     string cMsgMessage::payloadGetFieldDescription(const string &name) const
00221             throw(cMsgException) {
00222         const char *field = cMsgPayloadFieldDescription(myMsgPointer, name.c_str());
00223         if (field == NULL) {
00224             string err("No such field as ");
00225             err += field;
00226             throw(cMsgException(err));
00227         }
00228         string s(field);
00229         return s;
00230     }
00231 
00232     //-------------------------------------------------------------------
00233 
00242     map<string,int> *cMsgMessage::payloadGet() const throw(cMsgException) {
00243         char **names;
00244         int *types, len;
00245 
00246         int err = cMsgPayloadGetInfo(myMsgPointer, &names, &types, &len);
00247         if (err != CMSG_OK) {
00248             if (err == CMSG_BAD_ARGUMENT)
00249                 throw(cMsgException("Name is null"));
00250             else if (err == CMSG_ERROR)
00251                 throw(cMsgException("No payload exists"));
00252             else
00253                 throw(cMsgException("Out of memory"));
00254         }
00255 
00256         map<string,int> *mp = new map<string,int>;
00257         for (int i=0; i<len; i++) {
00258             (*mp)[names[i]] = types[i];
00259         }
00260         return mp;
00261     }
00262 
00263     //-------------------------------------------------------------------
00264 
00273     bool cMsgMessage::payloadRemoveField(const string &name) {
00274         return cMsgPayloadRemove(myMsgPointer, name.c_str()) == 0 ? false : true;
00275     }
00276 
00277 
00278     //-------------------------------------------------------------------
00279 
00289     void cMsgMessage::setHistoryLengthMax(int len) const throw(cMsgException) {
00290         int err = cMsgSetHistoryLengthMax(myMsgPointer, len);
00291         if (err != CMSG_OK) throw (cMsgException("len must be >= 0 and < CMSG_HISTORY_LENGTH_ABS_MAX"));
00292     }
00293 
00294 
00295 //-------------------------------------------------------------------
00296 // GET VALUE METHODS
00297 //-------------------------------------------------------------------
00298 
00299 //-------------------------------------------------------------------
00300 // BINARY
00301 //-------------------------------------------------------------------
00302 
00314 void cMsgMessage::getBinary(const string &name, const char **val, int &len, int &endian)
00315         const throw(cMsgException) {
00316     int err = cMsgGetBinary(myMsgPointer, name.c_str(), val, &len, &endian);
00317     if (err != CMSG_OK) {
00318         if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type"));
00319         else throw(cMsgException(string("No payload item named ") + name));
00320     }
00321     return;
00322 }
00323 
00337 void cMsgMessage::getBinaryArray(const string &name, const char ***vals,
00338                                  int **lens, int **endians, int &count)
00339         const throw(cMsgException) {
00340     int err = cMsgGetBinaryArray(myMsgPointer, name.c_str(), vals, lens, endians, &count);
00341     if (err != CMSG_OK) {
00342         if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type"));
00343         else throw(cMsgException(string("No payload item named ") + name));
00344     }
00345     return;
00346 }
00347 
00348 //-------------------------------------------------------------------
00349 // CMSG MESSAGES
00350 //-------------------------------------------------------------------
00351 
00361 cMsgMessage *cMsgMessage::getMessage(const string &name) const throw(cMsgException) {
00362   const void *val;
00363   int err = cMsgGetMessage(myMsgPointer, name.c_str(), &val);
00364   if (err != CMSG_OK) {
00365     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type"));
00366     else throw(cMsgException(string("No payload item named ") + name));
00367   }
00368 
00369   // copy message
00370   void *newMsgPointer=cMsgCopyMessage(val);
00371   if(newMsgPointer==NULL)
00372     throw(cMsgException("?cMsgMessage::getMessage...unable to create new message from message contents",CMSG_ERROR));
00373 
00374   return(new cMsgMessage(newMsgPointer));
00375 }
00376 
00377 
00378 //-------------------------------------------------------------------
00379 
00380 
00391 vector<cMsgMessage*> *cMsgMessage::getMessagePVector(const string &name) const throw(cMsgException) {
00392   int len;
00393   const void **vals;
00394   int err = cMsgGetMessageArray(myMsgPointer, name.c_str(), &vals, &len);
00395   if (err != CMSG_OK) {
00396     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00397     else throw(cMsgException(string("No payload item named ") + name));
00398   }
00399   
00400 
00401   // fill new vector with message copies
00402   vector<cMsgMessage*> *msgPVec = new vector<cMsgMessage*>;
00403   for (int i=0; i<len; i++) msgPVec->push_back(new cMsgMessage(cMsgCopyMessage(vals[i])));
00404 
00405   return(msgPVec);
00406 }
00407 
00408 
00409 //-------------------------------------------------------------------
00410 
00411 
00422 vector<cMsgMessage> *cMsgMessage::getMessageVector(const string &name) const throw(cMsgException) {
00423   int len;
00424   const void **vals;
00425   int err = cMsgGetMessageArray(myMsgPointer, name.c_str(), &vals, &len);
00426   if (err != CMSG_OK) {
00427     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00428     else throw(cMsgException(string("No payload item named ") + name));
00429   }
00430   
00431 
00432   // fill new vector with message copies
00433   vector<cMsgMessage> *msgVec = new vector<cMsgMessage>;
00434   for (int i=0; i<len; i++) msgVec->push_back(cMsgMessage(cMsgCopyMessage(vals[i])));
00435 
00436   return(msgVec);
00437 }
00438 
00439 
00440 //-------------------------------------------------------------------
00441 
00442 
00453 cMsgMessage* *cMsgMessage::getMessagePArray(const string &name) const throw(cMsgException) {
00454   int len;
00455   const void **vals;
00456   int err = cMsgGetMessageArray(myMsgPointer, name.c_str(), &vals, &len);
00457   if (err != CMSG_OK) {
00458     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00459     else throw(cMsgException(string("No payload item named ") + name));
00460   }
00461   
00462   // create and fill array with pointers to message copies
00463   cMsgMessage* *msgPArray = new cMsgMessage*[len];
00464   for (int i=0; i<len; i++) msgPArray[i]=(new cMsgMessage(cMsgCopyMessage(vals[i])));
00465 
00466   return(msgPArray);
00467 }
00468 
00469 
00470 //-------------------------------------------------------------------
00471 
00472 
00483 cMsgMessage *cMsgMessage::getMessageArray(const string &name) const throw(cMsgException) {
00484   int len;
00485   const void **vals;
00486   int err = cMsgGetMessageArray(myMsgPointer, name.c_str(), &vals, &len);
00487   if (err != CMSG_OK) {
00488     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00489     else throw(cMsgException(string("No payload item named ") + name));
00490   }
00491   
00492   // create and fill array with message copies
00493   cMsgMessage *msgArray = new cMsgMessage[len];
00494   for (int i=0; i<len; i++) msgArray[i]=(cMsgMessage(cMsgCopyMessage(vals[i])));
00495 
00496   return(msgArray);
00497 }
00498 
00499 
00500 //-------------------------------------------------------------------
00501 // STRINGS
00502 //-------------------------------------------------------------------
00503 
00511 string cMsgMessage::getString(const string &name) const throw(cMsgException) {
00512   const char *val;
00513   int err = cMsgGetString(myMsgPointer, name.c_str(), &val);
00514   if (err != CMSG_OK) {
00515     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00516     else throw(cMsgException(string("No payload item named ") + name));
00517   }
00518   string s(val);
00519   return s;
00520 }
00521 
00522 
00523 //-------------------------------------------------------------------
00524 
00525 
00535 vector<string> *cMsgMessage::getStringVector(const string &name) const throw(cMsgException) {
00536   int len;
00537   const char **vals;
00538   int err = cMsgGetStringArray(myMsgPointer, name.c_str(), &vals, &len);
00539   if (err != CMSG_OK) {
00540     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00541     else throw(cMsgException(string("No payload item named ") + name));
00542   }
00543   
00544   // copy array values and put into a vector
00545   vector<string> *strs = new vector<string>;
00546   for (int i=0; i<len; i++) strs->push_back(string(vals[i]));
00547   return strs;
00548 }
00549 
00550 
00551 //-------------------------------------------------------------------
00552 
00553 
00563 string *cMsgMessage::getStringArray(const string &name) const throw(cMsgException) {
00564   int len;
00565   const char **vals;
00566   int err = cMsgGetStringArray(myMsgPointer, name.c_str(), &vals, &len);
00567   if (err != CMSG_OK) {
00568     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00569     else throw(cMsgException(string("No payload item named ") + name));
00570   }
00571   
00572   // place strings into new array
00573   string *strs = new string[len];
00574   for (int i=0; i<len; i++) strs[i]=string(vals[i]);
00575   return strs;
00576 }
00577 
00578 
00579 //-------------------------------------------------------------------
00580 // REALS
00581 //-------------------------------------------------------------------
00582 
00590 float cMsgMessage::getFloat(const string &name) const throw(cMsgException) {
00591   float val;
00592   int err = cMsgGetFloat(myMsgPointer, name.c_str(), &val);
00593   if (err != CMSG_OK) {
00594     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00595     else throw(cMsgException(string("No payload item named ") + name));
00596   }
00597   return val;
00598 }
00599 
00600 //-------------------------------------------------------------------
00601 
00609 double cMsgMessage::getDouble(const string &name) const throw(cMsgException) {
00610   double val;
00611   int err = cMsgGetDouble(myMsgPointer, name.c_str(), &val);
00612   if (err != CMSG_OK) {
00613     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00614     else throw(cMsgException(string("No payload item named ") + name));
00615   }
00616   return val;
00617 }
00618 
00619 //-------------------------------------------------------------------
00620 // REAL ARRAYS
00621 //-------------------------------------------------------------------
00622 
00623 
00633 vector<float> *cMsgMessage::getFloatVector(const string &name) const throw(cMsgException) {
00634   int len;
00635   const float *vals;
00636   int err = cMsgGetFloatArray(myMsgPointer, name.c_str(), &vals, &len);
00637   if (err != CMSG_OK) {
00638     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00639     else throw(cMsgException(string("No payload item named ") + name));
00640   }
00641   // put array values into a vector
00642   vector<float> *flts = new vector<float>;
00643   for (int i=0; i<len; i++) flts->push_back(vals[i]);
00644   return flts;
00645 }
00646 
00647 
00648 //-------------------------------------------------------------------
00649 
00650 
00660 float *cMsgMessage::getFloatArray(const string &name) const throw(cMsgException) {
00661   int len;
00662   const float *vals;
00663   int err = cMsgGetFloatArray(myMsgPointer, name.c_str(), &vals, &len);
00664   if (err != CMSG_OK) {
00665     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00666     else throw(cMsgException(string("No payload item named ") + name));
00667   }
00668 
00669   // copy values into a new array
00670   float *flts = new float[len];
00671   for (int i=0; i<len; i++) flts[i]=vals[i];
00672   return flts;
00673 }
00674 
00675 
00676 //-------------------------------------------------------------------
00677 
00678 
00688 vector<double> *cMsgMessage::getDoubleVector(const string &name) const throw(cMsgException) {
00689   int len;
00690   const double *vals;
00691   int err = cMsgGetDoubleArray(myMsgPointer, name.c_str(), &vals, &len);
00692   if (err != CMSG_OK) {
00693     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type"));
00694     else throw(cMsgException(string("No payload item named ") + name));
00695   }
00696   // put array values into a vector
00697   vector<double> *dbls = new vector<double>;
00698   for (int i=0; i<len; i++) dbls->push_back(vals[i]);
00699   return dbls;
00700 }
00701 
00702 
00703 
00704 //-------------------------------------------------------------------
00705 
00706 
00716 double *cMsgMessage::getDoubleArray(const string &name) const throw(cMsgException) {
00717   int len;
00718   const double *vals;
00719   int err = cMsgGetDoubleArray(myMsgPointer, name.c_str(), &vals, &len);
00720   if (err != CMSG_OK) {
00721     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type"));
00722     else throw(cMsgException(string("No payload item named ") + name));
00723   }
00724 
00725   // put values into new array
00726   double *dbls = new double[len];
00727   for (int i=0; i<len; i++) dbls[i]=vals[i];
00728   return dbls;
00729 }
00730 
00731 
00732 //-------------------------------------------------------------------
00733 // INTS
00734 //-------------------------------------------------------------------
00735 
00743 int8_t cMsgMessage::getInt8(const string &name) const throw(cMsgException) {
00744   int8_t val;
00745   int err = cMsgGetInt8(myMsgPointer, name.c_str(), &val);
00746   if (err != CMSG_OK) {
00747     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00748     else throw(cMsgException(string("No payload item named ") + name));
00749   }
00750   return val;
00751 }
00752 
00753 //-------------------------------------------------------------------
00754 
00762 int16_t cMsgMessage::getInt16(const string &name) const throw(cMsgException) {
00763   int16_t val;
00764   int err = cMsgGetInt16(myMsgPointer, name.c_str(), &val);
00765   if (err != CMSG_OK) {
00766     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00767     else throw(cMsgException(string("No payload item named ") + name));
00768   }
00769   return val;
00770 }
00771 
00772 //-------------------------------------------------------------------
00773 
00781 int32_t cMsgMessage::getInt32(const string &name) const throw(cMsgException) {
00782   int32_t val;
00783   int err = cMsgGetInt32(myMsgPointer, name.c_str(), &val);
00784   if (err != CMSG_OK) {
00785     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00786     else throw(cMsgException(string("No payload item named ") + name));
00787   }
00788   return val;
00789 }
00790 
00791 //-------------------------------------------------------------------
00792 
00800 int64_t cMsgMessage::getInt64(const string &name) const throw(cMsgException) {
00801   int64_t val;
00802   int err = cMsgGetInt64(myMsgPointer, name.c_str(), &val);
00803   if (err != CMSG_OK) {
00804     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00805     else throw(cMsgException(string("No payload item named ") + name));
00806   }
00807   return val;
00808 }
00809 
00810 //-------------------------------------------------------------------
00811 
00819 uint8_t cMsgMessage::getUint8(const string &name) const throw(cMsgException) {
00820   uint8_t val;
00821   int err = cMsgGetUint8(myMsgPointer, name.c_str(), &val);
00822   if (err != CMSG_OK) {
00823     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00824     else throw(cMsgException(string("No payload item named ") + name));
00825   }
00826   return val;
00827 }
00828 
00829 //-------------------------------------------------------------------
00830 
00838 uint16_t cMsgMessage::getUint16(const string &name) const throw(cMsgException) {
00839   uint16_t val;
00840   int err = cMsgGetUint16(myMsgPointer, name.c_str(), &val);
00841   if (err != CMSG_OK) {
00842     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00843     else throw(cMsgException(string("No payload item named ") + name));
00844   }
00845   return val;
00846 }
00847 
00848 //-------------------------------------------------------------------
00849 
00857 uint32_t cMsgMessage::getUint32(const string &name) const throw(cMsgException) {
00858   uint32_t val;
00859   int err = cMsgGetUint32(myMsgPointer, name.c_str(), &val);
00860   if (err != CMSG_OK) {
00861     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00862     else throw(cMsgException(string("No payload item named ") + name));
00863   }
00864   return val;
00865 }
00866 
00867 //-------------------------------------------------------------------
00868 
00876 uint64_t cMsgMessage::getUint64(const string &name) const throw(cMsgException) {
00877   uint64_t val;
00878   int err = cMsgGetUint64(myMsgPointer, name.c_str(), &val);
00879   if (err != CMSG_OK) {
00880     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00881     else throw(cMsgException(string("No payload item named ") + name));
00882   }
00883   return val;
00884 }
00885 
00886 //-------------------------------------------------------------------
00887 // INT ARRAYS & VECTORS
00888 //-------------------------------------------------------------------
00889 
00899 vector<int8_t> *cMsgMessage::getInt8Vector(const string &name) const throw(cMsgException) {
00900   int len;
00901   const int8_t *vals;
00902   int err = cMsgGetInt8Array(myMsgPointer, name.c_str(), &vals, &len);
00903   if (err != CMSG_OK) {
00904     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00905     else throw(cMsgException(string("No payload item named ") + name));
00906   }
00907   // put array values into a vector
00908   vector<int8_t> *ints = new vector<int8_t>;
00909   for (int i=0; i<len; i++) ints->push_back(vals[i]);
00910   return ints;
00911 }
00912 
00913 
00914 //-------------------------------------------------------------------
00915 
00916 
00926 int8_t *cMsgMessage::getInt8Array(const string &name) const throw(cMsgException) {
00927   int len;
00928   const int8_t *vals;
00929   int err = cMsgGetInt8Array(myMsgPointer, name.c_str(), &vals, &len);
00930   if (err != CMSG_OK) {
00931     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00932     else throw(cMsgException(string("No payload item named ") + name));
00933   }
00934   // put values into new array
00935   int8_t *ints = new int8_t[len];
00936   for (int i=0; i<len; i++) ints[i]=vals[i];
00937   return ints;
00938 }
00939 
00940 
00941 //-------------------------------------------------------------------
00942 
00943 
00953 vector<int16_t> *cMsgMessage::getInt16Vector(const string &name) const throw(cMsgException) {
00954   int len;
00955   const int16_t *vals;
00956   int err = cMsgGetInt16Array(myMsgPointer, name.c_str(), &vals, &len);
00957   if (err != CMSG_OK) {
00958     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00959     else throw(cMsgException(string("No payload item named ") + name));
00960   }
00961   // put array values into a vector
00962   vector<int16_t> *ints = new vector<int16_t>;
00963   for (int i=0; i<len; i++) ints->push_back(vals[i]);
00964   return ints;
00965 }
00966 
00967 
00968 //-------------------------------------------------------------------
00969 
00970 
00980 int16_t *cMsgMessage::getInt16Array(const string &name) const throw(cMsgException) {
00981   int len;
00982   const int16_t *vals;
00983   int err = cMsgGetInt16Array(myMsgPointer, name.c_str(), &vals, &len);
00984   if (err != CMSG_OK) {
00985     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00986     else throw(cMsgException(string("No payload item named ") + name));
00987   }
00988   // put values into new array
00989   int16_t *ints = new int16_t[len];
00990   for (int i=0; i<len; i++) ints[i]=vals[i];
00991   return ints;
00992 }
00993 
00994 
00995 //-------------------------------------------------------------------
00996 
00997 
01007 vector<int32_t> *cMsgMessage::getInt32Vector(const string &name) const throw(cMsgException) {
01008   int len;
01009   const int32_t *vals;
01010   int err = cMsgGetInt32Array(myMsgPointer, name.c_str(), &vals, &len);
01011   if (err != CMSG_OK) {
01012     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01013     else throw(cMsgException(string("No payload item named ") + name));
01014   }
01015   // put array values into a vector
01016   vector<int32_t> *ints = new vector<int32_t>;
01017   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01018   return ints;
01019 }
01020 
01021 
01022 //-------------------------------------------------------------------
01023 
01024 
01034 int32_t *cMsgMessage::getInt32Array(const string &name) const throw(cMsgException) {
01035   int len;
01036   const int32_t *vals;
01037   int err = cMsgGetInt32Array(myMsgPointer, name.c_str(), &vals, &len);
01038   if (err != CMSG_OK) {
01039     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01040     else throw(cMsgException(string("No payload item named ") + name));
01041   }
01042   // put values into new array
01043   int32_t *ints = new int32_t[len];
01044   for (int i=0; i<len; i++) ints[i]=vals[i];
01045   return ints;
01046 }
01047 
01048 
01049 //-------------------------------------------------------------------
01050 
01051 
01061 vector<int64_t> *cMsgMessage::getInt64Vector(const string &name) const throw(cMsgException) {
01062   int len;
01063   const int64_t *vals;
01064   int err = cMsgGetInt64Array(myMsgPointer, name.c_str(), &vals, &len);
01065   if (err != CMSG_OK) {
01066     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01067     else throw(cMsgException(string("No payload item named ") + name));
01068   }
01069   // put array values into a vector
01070   vector<int64_t> *ints = new vector<int64_t>;
01071   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01072   return ints;
01073 }
01074 
01075 
01076 //-------------------------------------------------------------------
01077 
01078 
01088 int64_t *cMsgMessage::getInt64Array(const string &name) const throw(cMsgException) {
01089   int len;
01090   const int64_t *vals;
01091   int err = cMsgGetInt64Array(myMsgPointer, name.c_str(), &vals, &len);
01092   if (err != CMSG_OK) {
01093     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01094     else throw(cMsgException(string("No payload item named ") + name));
01095   }
01096   // put values into new array 
01097   int64_t *ints = new int64_t[len];
01098   for (int i=0; i<len; i++) ints[i]=vals[i];
01099   return ints;
01100 }
01101 
01102 
01103 //-------------------------------------------------------------------
01104 
01105 
01116 vector<uint8_t> *cMsgMessage::getUint8Vector(const string &name) const throw(cMsgException) {
01117   int len;
01118   const uint8_t *vals;
01119   int err = cMsgGetUint8Array(myMsgPointer, name.c_str(), &vals, &len);
01120   if (err != CMSG_OK) {
01121     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01122     else throw(cMsgException(string("No payload item named ") + name));
01123   }
01124   // put array values into a vector
01125   vector<uint8_t> *ints = new vector<uint8_t>;
01126   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01127   return ints;
01128 }
01129 
01130 
01131 //-------------------------------------------------------------------
01132 
01133 
01144 uint8_t *cMsgMessage::getUint8Array(const string &name) const throw(cMsgException) {
01145   int len;
01146   const uint8_t *vals;
01147   int err = cMsgGetUint8Array(myMsgPointer, name.c_str(), &vals, &len);
01148   if (err != CMSG_OK) {
01149     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01150     else throw(cMsgException(string("No payload item named ") + name));
01151   }
01152   // put values into new array
01153   uint8_t *ints = new uint8_t[len];
01154   for (int i=0; i<len; i++) ints[i]=vals[i];
01155   return ints;
01156 }
01157 
01158 
01159 //-------------------------------------------------------------------
01160 
01161 
01172 vector<uint16_t> *cMsgMessage::getUint16Vector(const string &name) const throw(cMsgException) {
01173   int len;
01174   const uint16_t *vals;
01175   int err = cMsgGetUint16Array(myMsgPointer, name.c_str(), &vals, &len);
01176   if (err != CMSG_OK) {
01177     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01178     else throw(cMsgException(string("No payload item named ") + name));
01179   }
01180   // put array values into a vector
01181   vector<uint16_t> *ints = new vector<uint16_t>;
01182   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01183   return ints;
01184 }
01185 
01186 
01187 //-------------------------------------------------------------------
01188 
01189 
01200 uint16_t *cMsgMessage::getUint16Array(const string &name) const throw(cMsgException) {
01201   int len;
01202   const uint16_t *vals;
01203   int err = cMsgGetUint16Array(myMsgPointer, name.c_str(), &vals, &len);
01204   if (err != CMSG_OK) {
01205     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01206     else throw(cMsgException(string("No payload item named ") + name));
01207   }
01208   // put values into new array
01209   uint16_t *ints = new uint16_t[len];
01210   for (int i=0; i<len; i++) ints[i]=vals[i];
01211   return ints;
01212 }
01213 
01214 
01215 //-------------------------------------------------------------------
01216 
01217 
01227 vector<uint32_t> *cMsgMessage::getUint32Vector(const string &name) const throw(cMsgException) {
01228   int len;
01229   const uint32_t *vals;
01230   int err = cMsgGetUint32Array(myMsgPointer, name.c_str(), &vals, &len);
01231   if (err != CMSG_OK) {
01232     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01233     else throw(cMsgException(string("No payload item named ") + name));
01234   }
01235   // put array values into a vector
01236   vector<uint32_t> *ints = new vector<uint32_t>;
01237   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01238   return ints;
01239 }
01240 
01241 
01242 //-------------------------------------------------------------------
01243 
01244 
01254 uint32_t *cMsgMessage::getUint32Array(const string &name) const throw(cMsgException) {
01255   int len;
01256   const uint32_t *vals;
01257   int err = cMsgGetUint32Array(myMsgPointer, name.c_str(), &vals, &len);
01258   if (err != CMSG_OK) {
01259     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01260     else throw(cMsgException(string("No payload item named ") + name));
01261   }
01262   // put values into new array
01263   uint32_t *ints = new uint32_t[len];
01264   for (int i=0; i<len; i++) ints[i]=vals[i];
01265   return ints;
01266 }
01267 
01268 
01269 //-------------------------------------------------------------------
01270 
01271 
01281 vector<uint64_t> *cMsgMessage::getUint64Vector(const string &name) const throw(cMsgException) {
01282   int len;
01283   const uint64_t *vals;
01284   int err = cMsgGetUint64Array(myMsgPointer, name.c_str(), &vals, &len);
01285   if (err != CMSG_OK) {
01286     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01287     else throw(cMsgException(string("No payload item named ") + name));
01288   }
01289   // put array values into a vector
01290   vector<uint64_t> *ints = new vector<uint64_t>;
01291   for (int i=0; i<len; i++) ints->push_back(vals[i]);
01292   return ints;
01293 }
01294 
01295 
01296 
01297 //-------------------------------------------------------------------
01298 
01299 
01309 uint64_t *cMsgMessage::getUint64Array(const string &name) const throw(cMsgException) {
01310   int len;
01311   const uint64_t *vals;
01312   int err = cMsgGetUint64Array(myMsgPointer, name.c_str(), &vals, &len);
01313   if (err != CMSG_OK) {
01314     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
01315     else throw(cMsgException(string("No payload item named ") + name));
01316   }
01317   // put values into new array 
01318   uint64_t *ints = new uint64_t[len];
01319   for (int i=0; i<len; i++) ints[i]=vals[i];
01320   return ints;
01321 }
01322 
01323 
01324 //-------------------------------------------------------------------
01325 // ADD METHODS
01326 //-------------------------------------------------------------------
01327 
01328 //-------------------------------------------------------------------
01329 // BINARY
01330 //-------------------------------------------------------------------
01331 
01347 void cMsgMessage::add(const string &name, const char *src, int size, int endian) {
01348   int err = cMsgAddBinary(myMsgPointer, name.c_str(), src, size, endian);
01349   if (err != CMSG_OK) {
01350          if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name or if error in binary-to-text conversion"));
01351     else if (err == CMSG_BAD_ARGUMENT)   throw(cMsgException("src or name null, size < 1, or endian improper value")); 
01352     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01353     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01354     else throw(cMsgException("Error")); 
01355   }
01356 }
01357 
01374 void cMsgMessage::add(const string &name, const char **srcs, int number,
01375                       const int sizes[], const int endians[]) {
01376     int err = cMsgAddBinaryArray(myMsgPointer, name.c_str(), srcs, number, sizes, endians);
01377     if (err != CMSG_OK) {
01378         if (err == CMSG_BAD_FORMAT) throw(cMsgException("Improper name or if error in binary-to-text conversion"));
01379         else if (err == CMSG_BAD_ARGUMENT)   throw(cMsgException("srcs or name null, sizes < 1, or endians improper value"));
01380         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01381         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01382         else throw(cMsgException("Error"));
01383     }
01384 }
01385 
01386 
01387 
01388 //-------------------------------------------------------------------
01389 // CMSG STRINGS
01390 //-------------------------------------------------------------------
01391 
01402 void cMsgMessage::add(const string &name, const string &s) {
01403     int err = cMsgAddString(myMsgPointer, name.c_str(), s.c_str());
01404     if (err != CMSG_OK) {
01405              if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
01406         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01407         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01408         else throw(cMsgException("Error"));
01409     }
01410 }
01411 
01412 //-------------------------------------------------------------------
01413 
01424 void cMsgMessage::add(const string &name, const string *s) {
01425   add(name,*s);
01426 }
01427 
01428 //-------------------------------------------------------------------
01429 
01441 void cMsgMessage::add(const string &name, const char **strs, int len) {
01442     if (strs == NULL) throw (cMsgException("strs arg is null"));
01443     if (len < 1) throw (cMsgException("string array len < 1"));
01444 
01445     int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strs, len);
01446     if (err != CMSG_OK) {
01447              if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
01448         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01449         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01450         else throw(cMsgException("Error"));
01451     }
01452 }
01453 
01454 //-------------------------------------------------------------------
01455 
01467 void cMsgMessage::add(const string &name, const string *strs, int len) {
01468   if (strs == NULL) throw (cMsgException("strs arg is null"));
01469   if (len < 1) throw (cMsgException("string array len < 1"));
01470 
01471 #ifdef linux
01472   const char *strings[len];
01473 #else
01474   const char **strings = (const char **)malloc(len*sizeof(char *));
01475   if (strings == NULL) throw(cMsgException("No memory available"));
01476 #endif
01477   
01478   for (int i=0; i<len; i++) {
01479     strings[i] = strs[i].c_str();
01480   }
01481 
01482   int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strings, len);
01483 #ifndef linux
01484   free(strings);
01485 #endif
01486   if (err != CMSG_OK) {
01487     if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
01488     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01489     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01490     else throw(cMsgException("Error"));
01491   }
01492  
01493 }
01494 
01495 //-------------------------------------------------------------------
01496 
01507 void cMsgMessage::add(const string &name, const vector<string> &strs) {
01508     if (strs.size() < 1) throw(cMsgException("Zero length vector"));
01509 #ifdef linux
01510     const char *strings[strs.size()];
01511 #else
01512     const char **strings = (const char **)malloc(strs.size()*sizeof(char *));
01513     if (strings == NULL) throw(cMsgException("No memory available"));
01514 #endif
01515 
01516   for (vector<string>::size_type i=0; i < strs.size(); i++) {
01517     strings[i] = strs[i].c_str();
01518   }
01519 
01520   int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strings, strs.size());
01521 #ifndef linux
01522   free(strings);
01523 #endif
01524   if (err != CMSG_OK) {
01525          if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
01526     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01527     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01528     else throw(cMsgException("Error"));
01529   }
01530 }
01531 
01542 void cMsgMessage::add(const string &name, const vector<string> *strs) {
01543   add(name,*strs);
01544 }
01545 
01546 //-------------------------------------------------------------------
01547 // CMSG MESSAGES
01548 //-------------------------------------------------------------------
01549 
01560 void cMsgMessage::add(const string &name, const cMsgMessage &msg) {
01561     int err = cMsgAddMessage(myMsgPointer, name.c_str(), msg.myMsgPointer);
01562     if (err != CMSG_OK) {
01563         if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01564         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01565         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01566         else throw(cMsgException("Error"));
01567     }
01568 }
01569 
01570 //-------------------------------------------------------------------
01571 
01582 void cMsgMessage::add(const string &name, const cMsgMessage *msg) {
01583   add(name,*msg);
01584 }
01585 
01586 //-------------------------------------------------------------------
01587 
01588 
01600 void cMsgMessage::add(const string &name, const cMsgMessage *msg, int len) {
01601   if (msg == NULL) throw (cMsgException("msg arg is null"));
01602   if (len < 1) throw (cMsgException("cmsg message array len < 1"));
01603   
01604 #ifdef linux
01605   const void *msgs[len];
01606 #else
01607   const void **msgs = (const void **)malloc(len*sizeof(void *));
01608   if (msgs == NULL) throw(cMsgException("No memory available"));
01609 #endif
01610 
01611   for (int i=0; i<len; i++) {
01612     msgs[i] = msg[i].myMsgPointer;
01613   }
01614 
01615   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, len);
01616 #ifndef linux
01617   free(msgs);
01618 #endif
01619   if (err != CMSG_OK) {
01620     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01621     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01622     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01623     else throw(cMsgException("Error")); 
01624   }
01625   
01626 }
01627 
01628 
01629 //-------------------------------------------------------------------
01630 
01631 
01643 void cMsgMessage::add(const string &name, const cMsgMessage* *msg, int len) {
01644   if (msg == NULL) throw (cMsgException("msg arg is null"));
01645   if (len < 1) throw (cMsgException("cmsg message array len < 1"));
01646   
01647 #ifdef linux
01648   const void *msgs[len];
01649 #else
01650   const void **msgs = (const void **)malloc(len*sizeof(void *));
01651   if (msgs == NULL) throw(cMsgException("No memory available"));
01652 #endif
01653 
01654   for (int i=0; i<len; i++) {
01655     msgs[i] = msg[i]->myMsgPointer;
01656   }
01657 
01658   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, len);
01659 #ifndef linux
01660   free(msgs);
01661 #endif
01662   if (err != CMSG_OK) {
01663     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01664     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01665     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01666     else throw(cMsgException("Error")); 
01667   }
01668   
01669 }
01670 
01671 
01672 //-------------------------------------------------------------------
01673 
01674 
01685 void cMsgMessage::add(const string &name, const vector<cMsgMessage*> &msgPVec) {
01686     if (msgPVec.size() < 1) throw(cMsgException("Zero length vector"));
01687 #ifdef linux
01688     const void *msgs[msgPVec.size()];
01689 #else
01690     const void **msgs = (const void **)malloc(msgPVec.size()*sizeof(void *));
01691     if (msgs == NULL) throw(cMsgException("No memory available"));
01692 #endif
01693   
01694   for (vector<cMsgMessage*>::size_type i=0; i < msgPVec.size(); i++) {
01695     msgs[i] = msgPVec[i]->myMsgPointer;
01696   }
01697   
01698   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, msgPVec.size());
01699 #ifndef linux
01700   free(msgs);
01701 #endif
01702   if (err != CMSG_OK) {
01703     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01704     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01705     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01706     else throw(cMsgException("Error")); 
01707   }
01708   
01709 }
01710 
01711 
01712 //-------------------------------------------------------------------
01713 
01714 
01725 void cMsgMessage::add(const string &name, const vector<cMsgMessage> &msgVec) {
01726     if (msgVec.size() < 1) throw(cMsgException("Zero length vector"));
01727 #ifdef linux
01728     const void *msgs[msgVec.size()];
01729 #else
01730     const void **msgs = (const void **)malloc(msgVec.size()*sizeof(void *));
01731     if (msgs == NULL) throw(cMsgException("No memory available"));
01732 #endif
01733   
01734   for (vector<cMsgMessage>::size_type i=0; i < msgVec.size(); i++) {
01735     msgs[i] = msgVec[i].myMsgPointer;
01736   }
01737   
01738   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, msgVec.size());
01739 #ifndef linux
01740   free(msgs);
01741 #endif
01742   if (err != CMSG_OK) {
01743     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01744     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01745     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01746     else throw(cMsgException("Error")); 
01747   }
01748   
01749 }
01750 
01751 
01752 //-------------------------------------------------------------------
01753 
01754 
01765 void cMsgMessage::add(const string &name, const vector<cMsgMessage*> *msgPVec) {
01766   add(name,*msgPVec);
01767 }
01768 
01769 
01770 //-------------------------------------------------------------------
01771 
01772 
01783 void cMsgMessage::add(const string &name, const vector<cMsgMessage> *msgVec) {
01784   add(name,*msgVec);
01785 }
01786 
01787 
01788 //-------------------------------------------------------------------
01789 // REALS
01790 //-------------------------------------------------------------------
01791 
01802 void cMsgMessage::add(const string &name, float val) {
01803   int err = cMsgAddFloat(myMsgPointer, name.c_str(), val);
01804   if (err != CMSG_OK) {
01805          if (err == CMSG_BAD_FORMAT ||
01806              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01807     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01808     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01809     else throw(cMsgException("Error")); 
01810   }
01811 }
01812 
01813 //-------------------------------------------------------------------
01814 
01825 void cMsgMessage::add(const string &name, double val) {
01826   int err = cMsgAddDouble(myMsgPointer, name.c_str(), val);
01827   if (err != CMSG_OK) {
01828          if (err == CMSG_BAD_FORMAT ||
01829              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01830     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01831     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01832     else throw(cMsgException("Error")); 
01833   }
01834 }
01835 
01836 //-------------------------------------------------------------------
01837 // REAL ARRAYS
01838 //-------------------------------------------------------------------
01839 
01851 void cMsgMessage::add(const string &name, const float *vals, int len) {
01852   int err = cMsgAddFloatArray(myMsgPointer, name.c_str(), vals, len);
01853   if (err != CMSG_OK) {
01854          if (err == CMSG_BAD_FORMAT ||
01855              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null"));
01856     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01857     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01858     else throw(cMsgException("Error")); 
01859   }
01860 }
01861 
01862 //-------------------------------------------------------------------
01863 
01874 void cMsgMessage::add(const string &name, const vector<float> &vals) {
01875   int err = cMsgAddFloatArray(myMsgPointer, name.c_str(), &vals[0], vals.size());
01876   if (err != CMSG_OK) {
01877          if (err == CMSG_BAD_FORMAT ||
01878              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01879     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01880     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01881     else throw(cMsgException("Error")); 
01882   }
01883 }
01884 
01885 //-------------------------------------------------------------------
01886 
01897 void cMsgMessage::add(const string &name, const vector<float> *vals) {
01898   add(name,*vals);
01899 }
01900 
01901 //-------------------------------------------------------------------
01902 
01914 void cMsgMessage::add(const string &name, const double *vals, int len) {
01915   int err = cMsgAddDoubleArray(myMsgPointer, name.c_str(), vals, len);
01916   if (err != CMSG_OK) {
01917          if (err == CMSG_BAD_FORMAT ||
01918              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01919     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01920     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01921     else throw(cMsgException("Error")); 
01922   }
01923 }
01924 
01925 //-------------------------------------------------------------------
01926 
01937 void cMsgMessage::add(const string &name, const vector<double> &vals) {
01938   int err = cMsgAddDoubleArray(myMsgPointer, name.c_str(), &vals[0], vals.size());
01939   if (err != CMSG_OK) {
01940          if (err == CMSG_BAD_FORMAT ||
01941              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01942     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01943     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01944     else throw(cMsgException("Error")); 
01945   }
01946 }
01947 
01948 //-------------------------------------------------------------------
01949 
01960 void cMsgMessage::add(const string &name, const vector<double> *vals) {
01961   add(name,*vals);
01962 }
01963 
01964 //-------------------------------------------------------------------
01965 // INTS
01966 //-------------------------------------------------------------------
01967 
01978 void cMsgMessage::add(const string &name, int8_t val) {
01979   int err = cMsgAddInt8(myMsgPointer, name.c_str(), val);
01980   if (err != CMSG_OK) {
01981          if (err == CMSG_BAD_FORMAT ||
01982              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01983     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01984     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01985     else throw(cMsgException("Error")); 
01986   }
01987 }
01988 
01989 //-------------------------------------------------------------------
01990 
02001 void cMsgMessage::add(const string &name, int16_t val) {
02002   int err = cMsgAddInt16(myMsgPointer, name.c_str(), val);
02003   if (err != CMSG_OK) {
02004          if (err == CMSG_BAD_FORMAT ||
02005              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02006     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02007     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02008     else throw(cMsgException("Error")); 
02009   }
02010 }
02011 
02012 //-------------------------------------------------------------------
02013 
02024 void cMsgMessage::add(const string &name, int32_t val) {
02025   int err = cMsgAddInt32(myMsgPointer, name.c_str(), val);
02026   if (err != CMSG_OK) {
02027          if (err == CMSG_BAD_FORMAT ||
02028              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02029     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02030     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02031     else throw(cMsgException("Error")); 
02032   }
02033 }
02034 
02035 //-------------------------------------------------------------------
02036 
02047 void cMsgMessage::add(const string &name, int64_t val) {
02048   int err = cMsgAddInt64(myMsgPointer, name.c_str(), val);
02049   if (err != CMSG_OK) {
02050          if (err == CMSG_BAD_FORMAT ||
02051              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02052     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02053     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02054     else throw(cMsgException("Error")); 
02055   }
02056 }
02057 
02058 //-------------------------------------------------------------------
02059 
02070 void cMsgMessage::add(const string &name, uint8_t val) {
02071   int err = cMsgAddUint8(myMsgPointer, name.c_str(), val);
02072   if (err != CMSG_OK) {
02073          if (err == CMSG_BAD_FORMAT ||
02074              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02075     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02076     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02077     else throw(cMsgException("Error")); 
02078   }
02079 }
02080 
02081 //-------------------------------------------------------------------
02082 
02093 void cMsgMessage::add(const string &name, uint16_t val) {
02094   int err = cMsgAddUint16(myMsgPointer, name.c_str(), val);
02095   if (err != CMSG_OK) {
02096          if (err == CMSG_BAD_FORMAT ||
02097              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02098     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02099     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02100     else throw(cMsgException("Error")); 
02101   }
02102 }
02103 
02104 //-------------------------------------------------------------------
02105 
02116 void cMsgMessage::add(const string &name, uint32_t val) {
02117   int err = cMsgAddUint32(myMsgPointer, name.c_str(), val);
02118   if (err != CMSG_OK) {
02119          if (err == CMSG_BAD_FORMAT ||
02120              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02121     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02122     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02123     else throw(cMsgException("Error")); 
02124   }
02125 }
02126 
02127 //-------------------------------------------------------------------
02128 
02139 void cMsgMessage::add(const string &name, uint64_t val) {
02140   int err = cMsgAddUint64(myMsgPointer, name.c_str(), val);
02141   if (err != CMSG_OK) {
02142          if (err == CMSG_BAD_FORMAT ||
02143              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02144     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02145     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02146     else throw(cMsgException("Error")); 
02147   }
02148 }
02149 
02150 //-------------------------------------------------------------------
02151 // INT ARRAYS
02152 //-------------------------------------------------------------------
02153 
02165 void cMsgMessage::add(const string &name, const int8_t *vals, int len) {
02166   int err = cMsgAddInt8Array(myMsgPointer, name.c_str(), vals, len);
02167   if (err != CMSG_OK) {
02168          if (err == CMSG_BAD_FORMAT ||
02169              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02170     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02171     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02172     else throw(cMsgException("Error")); 
02173   }
02174 }
02175 
02176 //-------------------------------------------------------------------
02177 
02189 void cMsgMessage::add(const string &name, const vector<int8_t> &vals) {
02190   
02191   // Can transform vector into array since STL standard mandates continguous
02192   // memory for storage of vector data (ie it's a standard C++ technique).
02193   int err = cMsgAddInt8Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02194   if (err != CMSG_OK) {
02195          if (err == CMSG_BAD_FORMAT ||
02196              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02197     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02198     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02199     else throw(cMsgException("Error")); 
02200   }
02201 }
02202 
02203 //-------------------------------------------------------------------
02204 
02216 void cMsgMessage::add(const string &name, const vector<int8_t> *vals) {
02217   add(name,*vals);
02218 }
02219 
02220 //-------------------------------------------------------------------
02221 
02233 void cMsgMessage::add(const string &name, const int16_t *vals, int len) {
02234   int err = cMsgAddInt16Array(myMsgPointer, name.c_str(), vals, len);
02235   if (err != CMSG_OK) {
02236          if (err == CMSG_BAD_FORMAT ||
02237              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02238     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02239     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02240     else throw(cMsgException("Error")); 
02241   }
02242 }
02243 
02244 //-------------------------------------------------------------------
02245 
02257 void cMsgMessage::add(const string &name, const vector<int16_t> &vals) {
02258   // Can transform vector into array since STL standard mandates continguous
02259   // memory for storage of vector data (ie it's a standard C++ technique).
02260   int err = cMsgAddInt16Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02261   if (err != CMSG_OK) {
02262          if (err == CMSG_BAD_FORMAT ||
02263              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02264     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02265     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02266     else throw(cMsgException("Error")); 
02267   }
02268 }
02269 
02270 //-------------------------------------------------------------------
02271 
02283 void cMsgMessage::add(const string &name, const vector<int16_t> *vals) {
02284   add(name,*vals);
02285 }
02286 
02287 //-------------------------------------------------------------------
02288 
02300 void cMsgMessage::add(const string &name, const int32_t *vals, int len) {
02301   int err = cMsgAddInt32Array(myMsgPointer, name.c_str(), vals, len);
02302   if (err != CMSG_OK) {
02303          if (err == CMSG_BAD_FORMAT ||
02304              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02305     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02306     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02307     else throw(cMsgException("Error")); 
02308   }
02309 }
02310 
02311 //-------------------------------------------------------------------
02312 
02324 void cMsgMessage::add(const string &name, const vector<int32_t> &vals) {
02325   
02326   // Can transform vector into array since STL standard mandates continguous
02327   // memory for storage of vector data (ie it's a standard C++ technique).
02328   int err = cMsgAddInt32Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02329   if (err != CMSG_OK) {
02330          if (err == CMSG_BAD_FORMAT ||
02331              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02332     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02333     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02334     else throw(cMsgException("Error")); 
02335   }
02336 }
02337 
02338 //-------------------------------------------------------------------
02339 
02351 void cMsgMessage::add(const string &name, const vector<int32_t> *vals) {
02352   add(name,*vals);
02353 }
02354 
02355 //-------------------------------------------------------------------
02356 
02368 void cMsgMessage::add(const string &name, const int64_t *vals, int len) {
02369   int err = cMsgAddInt64Array(myMsgPointer, name.c_str(), vals, len);
02370   if (err != CMSG_OK) {
02371          if (err == CMSG_BAD_FORMAT ||
02372              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02373     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02374     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02375     else throw(cMsgException("Error")); 
02376   }
02377 }
02378 
02379 //-------------------------------------------------------------------
02380 
02392 void cMsgMessage::add(const string &name, const vector<int64_t> &vals) {
02393   
02394   // Can transform vector into array since STL standard mandates continguous
02395   // memory for storage of vector data (ie it's a standard C++ technique).
02396   int err = cMsgAddInt64Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02397   if (err != CMSG_OK) {
02398          if (err == CMSG_BAD_FORMAT ||
02399              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02400     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02401     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02402     else throw(cMsgException("Error")); 
02403   }
02404 }
02405 
02406 //-------------------------------------------------------------------
02407 
02419 void cMsgMessage::add(const string &name, const vector<int64_t> *vals) {
02420   add(name,*vals);
02421 }
02422 
02423 //-------------------------------------------------------------------
02424 //-------------------------------------------------------------------
02425 
02437 void cMsgMessage::add(const string &name, const uint8_t *vals, int len) {
02438   int err = cMsgAddUint8Array(myMsgPointer, name.c_str(), vals, len);
02439   if (err != CMSG_OK) {
02440          if (err == CMSG_BAD_FORMAT ||
02441              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02442     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02443     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02444     else throw(cMsgException("Error")); 
02445   }
02446 }
02447 
02448 //-------------------------------------------------------------------
02449 
02461 void cMsgMessage::add(const string &name, const vector<uint8_t> &vals) {
02462   
02463   // Can transform vector into array since STL standard mandates continguous
02464   // memory for storage of vector data (ie it's a standard C++ technique).
02465   int err = cMsgAddUint8Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02466   if (err != CMSG_OK) {
02467          if (err == CMSG_BAD_FORMAT ||
02468              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02469     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02470     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02471     else throw(cMsgException("Error")); 
02472   }
02473 }
02474 
02475 //-------------------------------------------------------------------
02476 
02488 void cMsgMessage::add(const string &name, const vector<uint8_t> *vals) {
02489   add(name,*vals);
02490 }
02491 
02492 //-------------------------------------------------------------------
02493 
02505 void cMsgMessage::add(const string &name, const uint16_t *vals, int len) {
02506   int err = cMsgAddUint16Array(myMsgPointer, name.c_str(), vals, len);
02507   if (err != CMSG_OK) {
02508          if (err == CMSG_BAD_FORMAT ||
02509              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02510     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02511     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02512     else throw(cMsgException("Error")); 
02513   }
02514 }
02515 
02516 //-------------------------------------------------------------------
02517 
02529 void cMsgMessage::add(const string &name, const vector<uint16_t> &vals) {
02530   
02531   // Can transform vector into array since STL standard mandates continguous
02532   // memory for storage of vector data (ie it's a standard C++ technique).
02533   int err = cMsgAddUint16Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02534   if (err != CMSG_OK) {
02535          if (err == CMSG_BAD_FORMAT ||
02536              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02537     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02538     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02539     else throw(cMsgException("Error")); 
02540   }
02541 }
02542 
02543 //-------------------------------------------------------------------
02544 
02556 void cMsgMessage::add(const string &name, const vector<uint16_t> *vals) {
02557   add(name,*vals);
02558 }
02559 
02560 //-------------------------------------------------------------------
02561 
02573 void cMsgMessage::add(const string &name, const uint32_t *vals, int len) {
02574   int err = cMsgAddUint32Array(myMsgPointer, name.c_str(), vals, len);
02575   if (err != CMSG_OK) {
02576          if (err == CMSG_BAD_FORMAT ||
02577              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02578     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02579     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02580     else throw(cMsgException("Error")); 
02581   }
02582 }
02583 
02584 //-------------------------------------------------------------------
02585 
02597 void cMsgMessage::add(const string &name, const vector<uint32_t> &vals) {
02598   
02599   // Can transform vector into array since STL standard mandates continguous
02600   // memory for storage of vector data (ie it's a standard C++ technique).
02601   int err = cMsgAddUint32Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02602   if (err != CMSG_OK) {
02603          if (err == CMSG_BAD_FORMAT ||
02604              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02605     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02606     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02607     else throw(cMsgException("Error")); 
02608   }
02609 }
02610 
02611 //-------------------------------------------------------------------
02612 
02624 void cMsgMessage::add(const string &name, const vector<uint32_t> *vals) {
02625   add(name,*vals);
02626 }
02627 
02628 //-------------------------------------------------------------------
02629 
02641 void cMsgMessage::add(const string &name, const uint64_t *vals, int len) {
02642   int err = cMsgAddUint64Array(myMsgPointer, name.c_str(), vals, len);
02643   if (err != CMSG_OK) {
02644          if (err == CMSG_BAD_FORMAT ||
02645              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
02646     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02647     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02648     else throw(cMsgException("Error")); 
02649   }
02650 }
02651 
02652 //-------------------------------------------------------------------
02653 
02665 void cMsgMessage::add(const string &name, const vector<uint64_t> &vals) {
02666   
02667   // Can transform vector into array since STL standard mandates continguous
02668   // memory for storage of vector data (ie it's a standard C++ technique).
02669   int err = cMsgAddUint64Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
02670   if (err != CMSG_OK) {
02671          if (err == CMSG_BAD_FORMAT ||
02672              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
02673     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
02674     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
02675     else throw(cMsgException("Error")); 
02676   }
02677 }
02678 
02679 //-------------------------------------------------------------------
02680 
02692 void cMsgMessage::add(const string &name, const vector<uint64_t> *vals) {
02693   add(name,*vals);
02694 }
02695 
02696 //-------------------------------------------------------------------
02697 
02698 
02699 } // namespace cmsg

Generated on Fri Oct 21 09:54:18 2011 for cMsg Messaging System by  doxygen 1.3.9.1