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::payloadWipeout(void) {
00059         cMsgPayloadWipeout(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("No payload item of that name"));
00159         }
00160         return type;
00161     }
00162 
00163     //-------------------------------------------------------------------
00164 
00172     void cMsgMessage::payloadCopy(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 
00186     string cMsgMessage::payloadGetFieldDescription(const string &name) const
00187             throw(cMsgException) {
00188         const char *field = cMsgPayloadFieldDescription(myMsgPointer,
00189                 name.c_str());
00190         if (field == NULL) {
00191             string err("No such field as ");
00192             err += field;
00193             throw(cMsgException(err));
00194         }
00195         string s(field);
00196         return s;
00197     }
00198 
00199     //-------------------------------------------------------------------
00200 
00209     map<string,int> *cMsgMessage::payloadGet() const throw(cMsgException) {
00210         char **names;
00211         int *types, len;
00212 
00213         int err = cMsgPayloadGetInfo(myMsgPointer, &names, &types, &len);
00214         if (err != CMSG_OK) {
00215             if (err == CMSG_BAD_ARGUMENT)
00216                 throw(cMsgException("Name is null"));
00217             else if (err == CMSG_ERROR)
00218                 throw(cMsgException("No payload exists"));
00219             else
00220                 throw(cMsgException("Out of memory"));
00221         }
00222 
00223         map<string,int> *mp = new map<string,int>;
00224         for (int i=0; i<len; i++) {
00225             (*mp)[names[i]] = types[i];
00226         }
00227         return mp;
00228     }
00229 
00230     //-------------------------------------------------------------------
00231 
00240     bool cMsgMessage::payloadRemoveField(const string &name) {
00241         return cMsgPayloadRemove(myMsgPointer, name.c_str()) == 0 ? false : true;
00242     }
00243 
00244 
00245 //-------------------------------------------------------------------
00246 // GET VALUE METHODS
00247 //-------------------------------------------------------------------
00248 
00249 //-------------------------------------------------------------------
00250 // BINARY
00251 //-------------------------------------------------------------------
00252 
00264 void cMsgMessage::getBinary(string name, const char **val, int &len, int &endian) const throw(cMsgException) {
00265   int err = cMsgGetBinary(myMsgPointer, name.c_str(), val, &len, &endian);
00266   if (err != CMSG_OK) {
00267     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00268     else throw(cMsgException("No payload item of that name")); 
00269   }
00270   return;
00271 }
00272 
00273 //-------------------------------------------------------------------
00274 // CMSG MESSAGES
00275 //-------------------------------------------------------------------
00276 
00286 const cMsgMessage *cMsgMessage::getMessage(string name) const throw(cMsgException) {
00287   const void *val;
00288   int err = cMsgGetMessage(myMsgPointer, name.c_str(), &val);
00289   if (err != CMSG_OK) {
00290     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00291     else throw(cMsgException("No payload item of that name")); 
00292   }
00293   return new cMsgMessage(const_cast<void *>(val));
00294 }
00295 
00296 //-------------------------------------------------------------------
00297 
00307 vector<cMsgMessage> *cMsgMessage::getMessageVector(string name) const throw(cMsgException) {
00308   int len;
00309   const void **vals;
00310   int err = cMsgGetMessageArray(myMsgPointer, name.c_str(), &vals, &len);
00311   if (err != CMSG_OK) {
00312     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00313     else throw(cMsgException("No payload item of that name")); 
00314   }
00315   
00316   // put array values into a vector
00317   vector<cMsgMessage> *msgs = new vector<cMsgMessage>(len);
00318   for (int i=0; i<len; i++) {
00319     //msgs->push_back(new cMsgMessage(cMsgCopyMessage(vals[i])));
00320     // theoretically, 1st creation of message only copies pointer,
00321     // when added to vector, copy constructor gets called so we should be OK
00322     msgs->push_back(cMsgMessage(const_cast<void *>(vals[i])));
00323   }
00324   return msgs;
00325 }
00326 
00327 //-------------------------------------------------------------------
00328 // STRINGS
00329 //-------------------------------------------------------------------
00330 
00338 string cMsgMessage::getString(string name) const throw(cMsgException) {
00339   const char *val;
00340   int err = cMsgGetString(myMsgPointer, name.c_str(), &val);
00341   if (err != CMSG_OK) {
00342     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00343     else throw(cMsgException("No payload item of that name")); 
00344   }
00345   string s(val);
00346   return s;
00347 }
00348 
00349 //-------------------------------------------------------------------
00350 
00360 vector<string> *cMsgMessage::getStringVector(string name) const throw(cMsgException) {
00361   int len;
00362   const char **vals;
00363   int err = cMsgGetStringArray(myMsgPointer, name.c_str(), &vals, &len);
00364   if (err != CMSG_OK) {
00365     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00366     else throw(cMsgException("No payload item of that name")); 
00367   }
00368   
00369   // copy array values and put into a vector
00370   vector<string> *strs = new vector<string>(len);
00371   for (int i=0; i<len; i++) {
00372     strs->push_back(string(vals[i]));
00373   }
00374   return strs;
00375 }
00376 
00377 //-------------------------------------------------------------------
00378 // REALS
00379 //-------------------------------------------------------------------
00380 
00388 float cMsgMessage::getFloat(string name) const throw(cMsgException) {
00389   float val;
00390   int err = cMsgGetFloat(myMsgPointer, name.c_str(), &val);
00391   if (err != CMSG_OK) {
00392     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00393     else throw(cMsgException("No payload item of that name")); 
00394   }
00395   return val;
00396 }
00397 
00398 //-------------------------------------------------------------------
00399 
00407 double cMsgMessage::getDouble(string name) const throw(cMsgException) {
00408   double val;
00409   int err = cMsgGetDouble(myMsgPointer, name.c_str(), &val);
00410   if (err != CMSG_OK) {
00411     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00412     else throw(cMsgException("No payload item of that name")); 
00413   }
00414   return val;
00415 }
00416 
00417 //-------------------------------------------------------------------
00418 // REAL ARRAYS
00419 //-------------------------------------------------------------------
00420 
00421 
00431 vector<float> *cMsgMessage::getFloatVector(string name) const throw(cMsgException) {
00432   int len;
00433   const float *vals;
00434   int err = cMsgGetFloatArray(myMsgPointer, name.c_str(), &vals, &len);
00435   if (err != CMSG_OK) {
00436     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00437     else throw(cMsgException("No payload item of that name")); 
00438   }
00439   // put array values into a vector
00440   vector<float> *flts = new vector<float>(len);
00441   for (int i=0; i<len; i++) {
00442     flts->push_back(vals[i]);
00443   }
00444   return flts;
00445 }
00446 
00447 //-------------------------------------------------------------------
00448 
00458 vector<double> *cMsgMessage::getDoubleVector(string name) const throw(cMsgException) {
00459   int len;
00460   const double *vals;
00461   int err = cMsgGetDoubleArray(myMsgPointer, name.c_str(), &vals, &len);
00462   if (err != CMSG_OK) {
00463     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00464     else throw(cMsgException("No payload item of that name")); 
00465   }
00466   // put array values into a vector
00467   vector<double> *dbls = new vector<double>(len);
00468   for (int i=0; i<len; i++) {
00469     dbls->push_back(vals[i]);
00470   }
00471   return dbls;
00472 }
00473 
00474 //-------------------------------------------------------------------
00475 // INTS
00476 //-------------------------------------------------------------------
00477 
00485 int8_t cMsgMessage::getInt8(string name) const throw(cMsgException) {
00486   int8_t val;
00487   int err = cMsgGetInt8(myMsgPointer, name.c_str(), &val);
00488   if (err != CMSG_OK) {
00489     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00490     else throw(cMsgException("No payload item of that name")); 
00491   }
00492   return val;
00493 }
00494 
00495 //-------------------------------------------------------------------
00496 
00504 int16_t cMsgMessage::getInt16(string name) const throw(cMsgException) {
00505   int16_t val;
00506   int err = cMsgGetInt16(myMsgPointer, name.c_str(), &val);
00507   if (err != CMSG_OK) {
00508     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00509     else throw(cMsgException("No payload item of that name")); 
00510   }
00511   return val;
00512 }
00513 
00514 //-------------------------------------------------------------------
00515 
00523 int32_t cMsgMessage::getInt32(string name) const throw(cMsgException) {
00524   int32_t val;
00525   int err = cMsgGetInt32(myMsgPointer, name.c_str(), &val);
00526   if (err != CMSG_OK) {
00527     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00528     else throw(cMsgException("No payload item of that name")); 
00529   }
00530   return val;
00531 }
00532 
00533 //-------------------------------------------------------------------
00534 
00542 int64_t cMsgMessage::getInt64(string name) const throw(cMsgException) {
00543   int64_t val;
00544   int err = cMsgGetInt64(myMsgPointer, name.c_str(), &val);
00545   if (err != CMSG_OK) {
00546     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00547     else throw(cMsgException("No payload item of that name")); 
00548   }
00549   return val;
00550 }
00551 
00552 //-------------------------------------------------------------------
00553 
00561 uint8_t cMsgMessage::getUint8(string name) const throw(cMsgException) {
00562   uint8_t val;
00563   int err = cMsgGetUint8(myMsgPointer, name.c_str(), &val);
00564   if (err != CMSG_OK) {
00565     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00566     else throw(cMsgException("No payload item of that name")); 
00567   }
00568   return val;
00569 }
00570 
00571 //-------------------------------------------------------------------
00572 
00580 uint16_t cMsgMessage::getUint16(string name) const throw(cMsgException) {
00581   uint16_t val;
00582   int err = cMsgGetUint16(myMsgPointer, name.c_str(), &val);
00583   if (err != CMSG_OK) {
00584     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00585     else throw(cMsgException("No payload item of that name")); 
00586   }
00587   return val;
00588 }
00589 
00590 //-------------------------------------------------------------------
00591 
00599 uint32_t cMsgMessage::getUint32(string name) const throw(cMsgException) {
00600   uint32_t val;
00601   int err = cMsgGetUint32(myMsgPointer, name.c_str(), &val);
00602   if (err != CMSG_OK) {
00603     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00604     else throw(cMsgException("No payload item of that name")); 
00605   }
00606   return val;
00607 }
00608 
00609 //-------------------------------------------------------------------
00610 
00618 uint64_t cMsgMessage::getUint64(string name) const throw(cMsgException) {
00619   uint64_t val;
00620   int err = cMsgGetUint64(myMsgPointer, name.c_str(), &val);
00621   if (err != CMSG_OK) {
00622     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00623     else throw(cMsgException("No payload item of that name")); 
00624   }
00625   return val;
00626 }
00627 
00628 //-------------------------------------------------------------------
00629 // INT ARRAYS & VECTORS
00630 //-------------------------------------------------------------------
00631 
00641 vector<int8_t> *cMsgMessage::getInt8Vector(string name) const throw(cMsgException) {
00642   int len;
00643   const int8_t *vals;
00644   int err = cMsgGetInt8Array(myMsgPointer, name.c_str(), &vals, &len);
00645   if (err != CMSG_OK) {
00646     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00647     else throw(cMsgException("No payload item of that name")); 
00648   }
00649   // put array values into a vector
00650   vector<int8_t> *ints = new vector<int8_t>(len);
00651   for (int i=0; i<len; i++) {
00652     ints->push_back(vals[i]);
00653   }
00654   return ints;
00655 }
00656 
00657 //-------------------------------------------------------------------
00658 
00668 vector<int16_t> *cMsgMessage::getInt16Vector(string name) const throw(cMsgException) {
00669   int len;
00670   const int16_t *vals;
00671   int err = cMsgGetInt16Array(myMsgPointer, name.c_str(), &vals, &len);
00672   if (err != CMSG_OK) {
00673     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00674     else throw(cMsgException("No payload item of that name")); 
00675   }
00676   // put array values into a vector
00677   vector<int16_t> *ints = new vector<int16_t>(len);
00678   for (int i=0; i<len; i++) {
00679     ints->push_back(vals[i]);
00680   }
00681   return ints;
00682 }
00683 
00684 //-------------------------------------------------------------------
00685 
00695 vector<int32_t> *cMsgMessage::getInt32Vector(string name) const throw(cMsgException) {
00696   int len;
00697   const int32_t *vals;
00698   int err = cMsgGetInt32Array(myMsgPointer, name.c_str(), &vals, &len);
00699   if (err != CMSG_OK) {
00700     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00701     else throw(cMsgException("No payload item of that name")); 
00702   }
00703   // put array values into a vector
00704   vector<int32_t> *ints = new vector<int32_t>(len);
00705   for (int i=0; i<len; i++) {
00706     ints->push_back(vals[i]);
00707   }
00708   return ints;
00709 }
00710 
00711 //-------------------------------------------------------------------
00712 
00722 vector<int64_t> *cMsgMessage::getInt64Vector(string name) const throw(cMsgException) {
00723   int len;
00724   const int64_t *vals;
00725   int err = cMsgGetInt64Array(myMsgPointer, name.c_str(), &vals, &len);
00726   if (err != CMSG_OK) {
00727     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00728     else throw(cMsgException("No payload item of that name")); 
00729   }
00730   // put array values into a vector
00731   vector<int64_t> *ints = new vector<int64_t>(len);
00732   for (int i=0; i<len; i++) {
00733     ints->push_back(vals[i]);
00734   }
00735   return ints;
00736 }
00737 
00738 //-------------------------------------------------------------------
00739 
00750 vector<uint8_t> *cMsgMessage::getUint8Vector(string name) const throw(cMsgException) {
00751   int len;
00752   const uint8_t *vals;
00753   int err = cMsgGetUint8Array(myMsgPointer, name.c_str(), &vals, &len);
00754   if (err != CMSG_OK) {
00755     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00756     else throw(cMsgException("No payload item of that name")); 
00757   }
00758   // put array values into a vector
00759   vector<uint8_t> *ints = new vector<uint8_t>(len);
00760   for (int i=0; i<len; i++) {
00761     ints->push_back(vals[i]);
00762   }
00763   return ints;
00764 }
00765 
00766 //-------------------------------------------------------------------
00767 
00778 vector<uint16_t> *cMsgMessage::getUint16Vector(string name) const throw(cMsgException) {
00779   int len;
00780   const uint16_t *vals;
00781   int err = cMsgGetUint16Array(myMsgPointer, name.c_str(), &vals, &len);
00782   if (err != CMSG_OK) {
00783     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00784     else throw(cMsgException("No payload item of that name")); 
00785   }
00786   // put array values into a vector
00787   vector<uint16_t> *ints = new vector<uint16_t>(len);
00788   for (int i=0; i<len; i++) {
00789     ints->push_back(vals[i]);
00790   }
00791   return ints;
00792 }
00793 
00794 //-------------------------------------------------------------------
00795 
00805 vector<uint32_t> *cMsgMessage::getUint32Vector(string name) const throw(cMsgException) {
00806   int len;
00807   const uint32_t *vals;
00808   int err = cMsgGetUint32Array(myMsgPointer, name.c_str(), &vals, &len);
00809   if (err != CMSG_OK) {
00810     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00811     else throw(cMsgException("No payload item of that name")); 
00812   }
00813   // put array values into a vector
00814   vector<uint32_t> *ints = new vector<uint32_t>(len);
00815   for (int i=0; i<len; i++) {
00816     ints->push_back(vals[i]);
00817   }
00818   return ints;
00819 }
00820 
00821 //-------------------------------------------------------------------
00822 
00832 vector<uint64_t> *cMsgMessage::getUint64Vector(string name) const throw(cMsgException) {
00833   int len;
00834   const uint64_t *vals;
00835   int err = cMsgGetUint64Array(myMsgPointer, name.c_str(), &vals, &len);
00836   if (err != CMSG_OK) {
00837     if (err == CMSG_BAD_FORMAT) throw(cMsgException("Wrong field type")); 
00838     else throw(cMsgException("No payload item of that name")); 
00839   }
00840   // put array values into a vector
00841   vector<uint64_t> *ints = new vector<uint64_t>(len);
00842   for (int i=0; i<len; i++) {
00843     ints->push_back(vals[i]);
00844   }
00845   return ints;
00846 }
00847 
00848 //-------------------------------------------------------------------
00849 // ADD METHODS
00850 //-------------------------------------------------------------------
00851 
00852 //-------------------------------------------------------------------
00853 // BINARY
00854 //-------------------------------------------------------------------
00855 
00871 void cMsgMessage::addBinary(string name, const char *src, int size, int endian) {
00872   int err = cMsgAddBinary(myMsgPointer, name.c_str(), src, size, endian);
00873   if (err != CMSG_OK) {
00874          if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name or if error in binary-to-text conversion"));
00875     else if (err == CMSG_BAD_ARGUMENT)   throw(cMsgException("src or name null, size < 1, or endian improper value")); 
00876     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
00877     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
00878     else throw(cMsgException("Error")); 
00879   }
00880 }
00881 
00882 //-------------------------------------------------------------------
00883 // CMSG STRINGS
00884 //-------------------------------------------------------------------
00885 
00896 void cMsgMessage::addString(string name, string s) {
00897     int err = cMsgAddString(myMsgPointer, name.c_str(), s.c_str());
00898     if (err != CMSG_OK) {
00899              if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
00900         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
00901         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
00902         else throw(cMsgException("Error"));
00903     }
00904 }
00905 
00906 //-------------------------------------------------------------------
00907 
00919 void cMsgMessage::addStringArray(string name, const char **strs, int len) {
00920     if (strs == NULL) throw (cMsgException("strs arg is null"));
00921     if (len < 1) throw (cMsgException("len < 1"));
00922 
00923     int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strs, len);
00924     if (err != CMSG_OK) {
00925              if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
00926         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
00927         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
00928         else throw(cMsgException("Error"));
00929     }
00930 }
00931 
00932 //-------------------------------------------------------------------
00933 
00945 void cMsgMessage::addStringArray(string name, string *strs, int len) {
00946   if (strs == NULL) throw (cMsgException("strs arg is null"));
00947   if (len < 1) throw (cMsgException("len < 1"));
00948 
00949 #ifdef linux
00950   const char *strings[len];
00951 #else
00952   const char **strings = (const char **)malloc(len*sizeof(char *));
00953   if (strings == NULL) throw(cMsgException("No memory available"));
00954 #endif
00955   
00956   for (int i=0; i<len; i++) {
00957     strings[i] = strs[i].c_str();
00958   }
00959 
00960   int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strings, len);
00961   if (err != CMSG_OK) {
00962          if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
00963     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
00964     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
00965     else throw(cMsgException("Error"));
00966   }
00967  
00968 #ifndef linux
00969   free(strings);
00970 #endif
00971 }
00972 
00973 //-------------------------------------------------------------------
00974 
00985 void cMsgMessage::addStringVector(string name, vector<string> &strs) {
00986 #ifdef linux
00987     const char *strings[strs.size()];
00988 #else
00989     const char **strings = (const char **)malloc(strs.size()*sizeof(char *));
00990     if (strings == NULL) throw(cMsgException("No memory available"));
00991 #endif
00992 
00993   for (vector<string>::size_type i=0; i < strs.size(); i++) {
00994     strings[i] = strs[i].c_str();
00995   }
00996 
00997   int err = cMsgAddStringArray(myMsgPointer, name.c_str(), strings, strs.size());
00998   if (err != CMSG_OK) {
00999          if (err == CMSG_BAD_FORMAT)     throw(cMsgException("Improper name"));
01000     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01001     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01002     else throw(cMsgException("Error"));
01003   }
01004   
01005 #ifndef linux
01006   free(strings);
01007 #endif
01008 }
01009 
01010 //-------------------------------------------------------------------
01011 // CMSG MESSAGES
01012 //-------------------------------------------------------------------
01013 
01024 void cMsgMessage::addMessage(string name, cMsgMessage &msg) {
01025     int err = cMsgAddMessage(myMsgPointer, name.c_str(), msg.myMsgPointer);
01026     if (err != CMSG_OK) {
01027         if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01028         else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01029         else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available"));
01030         else throw(cMsgException("Error"));
01031     }
01032 }
01033 
01034 //-------------------------------------------------------------------
01035 
01047 void cMsgMessage::addMessageArray(string name, cMsgMessage *msg, int len) {
01048   if (msg == NULL) throw (cMsgException("msg arg is null"));
01049   if (len < 1) throw (cMsgException("len < 1"));
01050   
01051 #ifdef linux
01052   const void *msgs[len];
01053 #else
01054   const void **msgs = (const void **)malloc(len*sizeof(void *));
01055   if (msgs == NULL) throw(cMsgException("No memory available"));
01056 #endif
01057 
01058   for (int i=0; i<len; i++) {
01059     msgs[i] = msg[i].myMsgPointer;
01060   }
01061 
01062   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, len);
01063   if (err != CMSG_OK) {
01064     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01065     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01066     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01067     else throw(cMsgException("Error")); 
01068   }
01069   
01070 #ifndef linux
01071   free(msgs);
01072 #endif
01073 }
01074 
01075 //-------------------------------------------------------------------
01076 
01087 void cMsgMessage::addMessageVector(string name, vector<cMsgMessage> &msg) {
01088 #ifdef linux
01089     const void *msgs[msg.size()];
01090 #else
01091     const void **msgs = (const void **)malloc(msg.size()*sizeof(void *));
01092     if (msgs == NULL) throw(cMsgException("No memory available"));
01093 #endif
01094   
01095   for (vector<cMsgMessage>::size_type i=0; i < msg.size(); i++) {
01096     msgs[i] = msg[i].myMsgPointer;
01097   }
01098   
01099   int err = cMsgAddMessageArray(myMsgPointer, name.c_str(), msgs, msg.size());
01100   if (err != CMSG_OK) {
01101     if (err == CMSG_BAD_FORMAT)          throw(cMsgException("Improper name"));
01102     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used"));
01103     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01104     else throw(cMsgException("Error")); 
01105   }
01106   
01107 #ifndef linux
01108   free(msgs);
01109 #endif
01110 }
01111 
01112 //-------------------------------------------------------------------
01113 // REALS
01114 //-------------------------------------------------------------------
01115 
01126 void cMsgMessage::addFloat(string name, float val) {
01127   int err = cMsgAddFloat(myMsgPointer, name.c_str(), val);
01128   if (err != CMSG_OK) {
01129          if (err == CMSG_BAD_FORMAT ||
01130              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01131     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01132     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01133     else throw(cMsgException("Error")); 
01134   }
01135 }
01136 
01137 //-------------------------------------------------------------------
01138 
01149 void cMsgMessage::addDouble(string name, double val) {
01150   int err = cMsgAddDouble(myMsgPointer, name.c_str(), val);
01151   if (err != CMSG_OK) {
01152          if (err == CMSG_BAD_FORMAT ||
01153              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01154     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01155     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01156     else throw(cMsgException("Error")); 
01157   }
01158 }
01159 
01160 //-------------------------------------------------------------------
01161 // REAL ARRAYS
01162 //-------------------------------------------------------------------
01163 
01175 void cMsgMessage::addFloatArray(string name, float *vals, int len) {
01176   int err = cMsgAddFloatArray(myMsgPointer, name.c_str(), vals, len);
01177   if (err != CMSG_OK) {
01178          if (err == CMSG_BAD_FORMAT ||
01179              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null"));
01180     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01181     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01182     else throw(cMsgException("Error")); 
01183   }
01184 }
01185 
01186 //-------------------------------------------------------------------
01187 
01198 void cMsgMessage::addFloatVector(string name, vector<float> &vals) {
01199   int err = cMsgAddFloatArray(myMsgPointer, name.c_str(), &vals[0], vals.size());
01200   if (err != CMSG_OK) {
01201          if (err == CMSG_BAD_FORMAT ||
01202              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01203     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01204     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01205     else throw(cMsgException("Error")); 
01206   }
01207 }
01208 
01209 //-------------------------------------------------------------------
01210 
01222 void cMsgMessage::addDoubleArray(string name, double *vals, int len) {
01223   int err = cMsgAddDoubleArray(myMsgPointer, name.c_str(), vals, len);
01224   if (err != CMSG_OK) {
01225          if (err == CMSG_BAD_FORMAT ||
01226              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01227     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01228     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01229     else throw(cMsgException("Error")); 
01230   }
01231 }
01232 
01233 //-------------------------------------------------------------------
01234 
01245 void cMsgMessage::addDoubleVector(string name, vector<double> &vals) {
01246   int err = cMsgAddDoubleArray(myMsgPointer, name.c_str(), &vals[0], vals.size());
01247   if (err != CMSG_OK) {
01248          if (err == CMSG_BAD_FORMAT ||
01249              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01250     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01251     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01252     else throw(cMsgException("Error")); 
01253   }
01254 }
01255 
01256 //-------------------------------------------------------------------
01257 // INTS
01258 //-------------------------------------------------------------------
01259 
01270 void cMsgMessage::addInt8(string name, int8_t val) {
01271   int err = cMsgAddInt8(myMsgPointer, name.c_str(), val);
01272   if (err != CMSG_OK) {
01273          if (err == CMSG_BAD_FORMAT ||
01274              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01275     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01276     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01277     else throw(cMsgException("Error")); 
01278   }
01279 }
01280 
01281 //-------------------------------------------------------------------
01282 
01293 void cMsgMessage::addInt16(string name, int16_t val) {
01294   int err = cMsgAddInt16(myMsgPointer, name.c_str(), val);
01295   if (err != CMSG_OK) {
01296          if (err == CMSG_BAD_FORMAT ||
01297              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01298     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01299     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01300     else throw(cMsgException("Error")); 
01301   }
01302 }
01303 
01304 //-------------------------------------------------------------------
01305 
01316 void cMsgMessage::addInt32(string name, int32_t val) {
01317   int err = cMsgAddInt32(myMsgPointer, name.c_str(), val);
01318   if (err != CMSG_OK) {
01319          if (err == CMSG_BAD_FORMAT ||
01320              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01321     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01322     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01323     else throw(cMsgException("Error")); 
01324   }
01325 }
01326 
01327 //-------------------------------------------------------------------
01328 
01339 void cMsgMessage::addInt64(string name, int64_t val) {
01340   int err = cMsgAddInt64(myMsgPointer, name.c_str(), val);
01341   if (err != CMSG_OK) {
01342          if (err == CMSG_BAD_FORMAT ||
01343              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01344     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01345     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01346     else throw(cMsgException("Error")); 
01347   }
01348 }
01349 
01350 //-------------------------------------------------------------------
01351 
01362 void cMsgMessage::addUint8(string name, uint8_t val) {
01363   int err = cMsgAddUint8(myMsgPointer, name.c_str(), val);
01364   if (err != CMSG_OK) {
01365          if (err == CMSG_BAD_FORMAT ||
01366              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01367     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01368     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01369     else throw(cMsgException("Error")); 
01370   }
01371 }
01372 
01373 //-------------------------------------------------------------------
01374 
01385 void cMsgMessage::addUint16(string name, uint16_t val) {
01386   int err = cMsgAddUint16(myMsgPointer, name.c_str(), val);
01387   if (err != CMSG_OK) {
01388          if (err == CMSG_BAD_FORMAT ||
01389              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01390     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01391     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01392     else throw(cMsgException("Error")); 
01393   }
01394 }
01395 
01396 //-------------------------------------------------------------------
01397 
01408 void cMsgMessage::addUint32(string name, uint32_t val) {
01409   int err = cMsgAddUint32(myMsgPointer, name.c_str(), val);
01410   if (err != CMSG_OK) {
01411          if (err == CMSG_BAD_FORMAT ||
01412              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01413     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01414     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01415     else throw(cMsgException("Error")); 
01416   }
01417 }
01418 
01419 //-------------------------------------------------------------------
01420 
01431 void cMsgMessage::addUint64(string name, uint64_t val) {
01432   int err = cMsgAddUint64(myMsgPointer, name.c_str(), val);
01433   if (err != CMSG_OK) {
01434          if (err == CMSG_BAD_FORMAT ||
01435              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01436     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01437     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01438     else throw(cMsgException("Error")); 
01439   }
01440 }
01441 
01442 //-------------------------------------------------------------------
01443 // INT ARRAYS
01444 //-------------------------------------------------------------------
01445 
01457 void cMsgMessage::addInt8Array(string name, int8_t *vals, int len) {
01458   int err = cMsgAddInt8Array(myMsgPointer, name.c_str(), vals, len);
01459   if (err != CMSG_OK) {
01460          if (err == CMSG_BAD_FORMAT ||
01461              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01462     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01463     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01464     else throw(cMsgException("Error")); 
01465   }
01466 }
01467 
01468 //-------------------------------------------------------------------
01480 void cMsgMessage::addInt8Vector(string name, vector<int8_t> &vals) {
01481   
01482   // Can transform vector into array since STL standard mandates continguous
01483   // memory for storage of vector data (ie it's a standard C++ technique).
01484   int err = cMsgAddInt8Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01485   if (err != CMSG_OK) {
01486          if (err == CMSG_BAD_FORMAT ||
01487              err == CMSG_BAD_ARGUMENT)   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 
01507 void cMsgMessage::addInt16Array(string name, int16_t *vals, int len) {
01508   int err = cMsgAddInt16Array(myMsgPointer, name.c_str(), vals, len);
01509   if (err != CMSG_OK) {
01510          if (err == CMSG_BAD_FORMAT ||
01511              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01512     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01513     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01514     else throw(cMsgException("Error")); 
01515   }
01516 }
01517 
01518 //-------------------------------------------------------------------
01530 void cMsgMessage::addInt16Vector(string name, vector<int16_t> &vals) {
01531   
01532   // Can transform vector into array since STL standard mandates continguous
01533   // memory for storage of vector data (ie it's a standard C++ technique).
01534   int err = cMsgAddInt16Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01535   if (err != CMSG_OK) {
01536          if (err == CMSG_BAD_FORMAT ||
01537              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01538     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01539     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01540     else throw(cMsgException("Error")); 
01541   }
01542 }
01543 
01544 //-------------------------------------------------------------------
01545 
01557 void cMsgMessage::addInt32Array(string name, int32_t *vals, int len) {
01558   int err = cMsgAddInt32Array(myMsgPointer, name.c_str(), vals, len);
01559   if (err != CMSG_OK) {
01560          if (err == CMSG_BAD_FORMAT ||
01561              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01562     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01563     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01564     else throw(cMsgException("Error")); 
01565   }
01566 }
01567 
01568 //-------------------------------------------------------------------
01580 void cMsgMessage::addInt32Vector(string name, vector<int32_t> &vals) {
01581   
01582   // Can transform vector into array since STL standard mandates continguous
01583   // memory for storage of vector data (ie it's a standard C++ technique).
01584   int err = cMsgAddInt32Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01585   if (err != CMSG_OK) {
01586          if (err == CMSG_BAD_FORMAT ||
01587              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01588     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01589     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01590     else throw(cMsgException("Error")); 
01591   }
01592 }
01593 
01594 //-------------------------------------------------------------------
01595 
01607 void cMsgMessage::addInt64Array(string name, int64_t *vals, int len) {
01608   int err = cMsgAddInt64Array(myMsgPointer, name.c_str(), vals, len);
01609   if (err != CMSG_OK) {
01610          if (err == CMSG_BAD_FORMAT ||
01611              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01612     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01613     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01614     else throw(cMsgException("Error")); 
01615   }
01616 }
01617 
01618 //-------------------------------------------------------------------
01630 void cMsgMessage::addInt64Vector(string name, vector<int64_t> &vals) {
01631   
01632   // Can transform vector into array since STL standard mandates continguous
01633   // memory for storage of vector data (ie it's a standard C++ technique).
01634   int err = cMsgAddInt64Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01635   if (err != CMSG_OK) {
01636          if (err == CMSG_BAD_FORMAT ||
01637              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01638     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01639     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01640     else throw(cMsgException("Error")); 
01641   }
01642 }
01643 
01644 //-------------------------------------------------------------------
01645 //-------------------------------------------------------------------
01646 
01658 void cMsgMessage::addUint8Array(string name, uint8_t *vals, int len) {
01659   int err = cMsgAddUint8Array(myMsgPointer, name.c_str(), vals, len);
01660   if (err != CMSG_OK) {
01661          if (err == CMSG_BAD_FORMAT ||
01662              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01663     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01664     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01665     else throw(cMsgException("Error")); 
01666   }
01667 }
01668 
01669 //-------------------------------------------------------------------
01681 void cMsgMessage::addUint8Vector(string name, vector<uint8_t> &vals) {
01682   
01683   // Can transform vector into array since STL standard mandates continguous
01684   // memory for storage of vector data (ie it's a standard C++ technique).
01685   int err = cMsgAddUint8Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01686   if (err != CMSG_OK) {
01687          if (err == CMSG_BAD_FORMAT ||
01688              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01689     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01690     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01691     else throw(cMsgException("Error")); 
01692   }
01693 }
01694 
01695 //-------------------------------------------------------------------
01696 
01708 void cMsgMessage::addUint16Array(string name, uint16_t *vals, int len) {
01709   int err = cMsgAddUint16Array(myMsgPointer, name.c_str(), vals, len);
01710   if (err != CMSG_OK) {
01711          if (err == CMSG_BAD_FORMAT ||
01712              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01713     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01714     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01715     else throw(cMsgException("Error")); 
01716   }
01717 }
01718 
01719 //-------------------------------------------------------------------
01731 void cMsgMessage::addUint16Vector(string name, vector<uint16_t> &vals) {
01732   
01733   // Can transform vector into array since STL standard mandates continguous
01734   // memory for storage of vector data (ie it's a standard C++ technique).
01735   int err = cMsgAddUint16Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01736   if (err != CMSG_OK) {
01737          if (err == CMSG_BAD_FORMAT ||
01738              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01739     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01740     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01741     else throw(cMsgException("Error")); 
01742   }
01743 }
01744 
01745 //-------------------------------------------------------------------
01746 
01758 void cMsgMessage::addUint32Array(string name, uint32_t *vals, int len) {
01759   int err = cMsgAddUint32Array(myMsgPointer, name.c_str(), vals, len);
01760   if (err != CMSG_OK) {
01761          if (err == CMSG_BAD_FORMAT ||
01762              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01763     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01764     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01765     else throw(cMsgException("Error")); 
01766   }
01767 }
01768 
01769 //-------------------------------------------------------------------
01781 void cMsgMessage::addUint32Vector(string name, vector<uint32_t> &vals) {
01782   
01783   // Can transform vector into array since STL standard mandates continguous
01784   // memory for storage of vector data (ie it's a standard C++ technique).
01785   int err = cMsgAddUint32Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01786   if (err != CMSG_OK) {
01787          if (err == CMSG_BAD_FORMAT ||
01788              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01789     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01790     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01791     else throw(cMsgException("Error")); 
01792   }
01793 }
01794 
01795 //-------------------------------------------------------------------
01796 
01808 void cMsgMessage::addUint64Array(string name, uint64_t *vals, int len) {
01809   int err = cMsgAddUint64Array(myMsgPointer, name.c_str(), vals, len);
01810   if (err != CMSG_OK) {
01811          if (err == CMSG_BAD_FORMAT ||
01812              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name or vals is null")); 
01813     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01814     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01815     else throw(cMsgException("Error")); 
01816   }
01817 }
01818 
01819 //-------------------------------------------------------------------
01831 void cMsgMessage::addUint64Vector(string name, vector<uint64_t> &vals) {
01832   
01833   // Can transform vector into array since STL standard mandates continguous
01834   // memory for storage of vector data (ie it's a standard C++ technique).
01835   int err = cMsgAddUint64Array(myMsgPointer, name.c_str(), &vals[0], vals.size());
01836   if (err != CMSG_OK) {
01837          if (err == CMSG_BAD_FORMAT ||
01838              err == CMSG_BAD_ARGUMENT)   throw(cMsgException("Improper name")); 
01839     else if (err == CMSG_ALREADY_EXISTS) throw(cMsgException("Name being used")); 
01840     else if (err == CMSG_OUT_OF_MEMORY)  throw(cMsgException("No memory available")); 
01841     else throw(cMsgException("Error")); 
01842   }
01843 }
01844 
01845 //-------------------------------------------------------------------
01846 
01847 
01848 } // namespace cmsg

Generated on Wed Feb 6 13:37:50 2008 for cMsg Messaging System by  doxygen 1.3.9.1