llmessagetemplate.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "llmessagetemplate.h"
00035 
00036 #include "message.h"
00037 
00038 void LLMsgVarData::addData(const void *data, S32 size, EMsgVariableType type, S32 data_size)
00039 {
00040         mSize = size;
00041         mDataSize = data_size;
00042         if ( (type != MVT_VARIABLE) && (type != MVT_FIXED) 
00043                  && (mType != MVT_VARIABLE) && (mType != MVT_FIXED))
00044         {
00045                 if (mType != type)
00046                 {
00047                         llwarns << "Type mismatch in LLMsgVarData::addData for " << mName
00048                                         << llendl;
00049                 }
00050         }
00051         if(size)
00052         {
00053                 delete mData; // Delete it if it already exists
00054                 mData = new U8[size];
00055                 htonmemcpy(mData, data, mType, size);
00056         }
00057 }
00058 
00059 void LLMsgData::addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size)
00060 {
00061         // remember that if the blocknumber is > 0 then the number is appended to the name
00062         char *namep = (char *)blockname;
00063         LLMsgBlkData* block_data = mMemberBlocks[namep];
00064         if (block_data->mBlockNumber)
00065         {
00066                 namep += block_data->mBlockNumber;
00067                 block_data->addData(varname, data, size, type, data_size);
00068         }
00069         else
00070         {
00071                 block_data->addData(varname, data, size, type, data_size);
00072         }
00073 }
00074 
00075 // LLMessageVariable functions and friends
00076 
00077 std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg)
00078 {
00079         s << "\t\t" << msg.mName << " (";
00080         switch (msg.mType)
00081         {
00082         case MVT_FIXED:
00083                 s << "Fixed, " << msg.mSize << " bytes total)\n";
00084                 break;
00085         case MVT_VARIABLE:
00086                 s << "Variable, " << msg.mSize << " bytes of size info)\n";
00087                 break;
00088         default:
00089                 s << "Unknown\n";
00090                 break;
00091         }
00092         return s;
00093 }
00094 
00095 // LLMessageBlock functions and friends
00096 
00097 std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg)
00098 {
00099         s << "\t" << msg.mName << " (";
00100         switch (msg.mType)
00101         {
00102         case MBT_SINGLE:
00103                 s << "Fixed";
00104                 break;
00105         case MBT_MULTIPLE:
00106                 s << "Multiple - " << msg.mNumber << " copies";
00107                 break;
00108         case MBT_VARIABLE:
00109                 s << "Variable";
00110                 break;
00111         default:
00112                 s << "Unknown";
00113                 break;
00114         }
00115         if (msg.mTotalSize != -1)
00116         {
00117                 s << ", " << msg.mTotalSize << " bytes each, " << msg.mNumber*msg.mTotalSize << " bytes total)\n";
00118         }
00119         else
00120         {
00121                 s << ")\n";
00122         }
00123 
00124 
00125         for (LLMessageBlock::message_variable_map_t::iterator iter = msg.mMemberVariables.begin();
00126                  iter != msg.mMemberVariables.end(); iter++)
00127         {
00128                 LLMessageVariable& ci = *(*iter);
00129                 s << ci;
00130         }
00131 
00132         return s;
00133 }
00134 
00135 // LLMessageTemplate functions and friends
00136 
00137 std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg)
00138 {
00139         switch (msg.mFrequency)
00140         {
00141         case MFT_HIGH:
00142                 s << "========================================\n" << "Message #" << msg.mMessageNumber << "\n" << msg.mName << " (";
00143                 s << "High";
00144                 break;
00145         case MFT_MEDIUM:
00146                 s << "========================================\n" << "Message #";
00147                 s << (msg.mMessageNumber & 0xFF) << "\n" << msg.mName << " (";
00148                 s << "Medium";
00149                 break;
00150         case MFT_LOW:
00151                 s << "========================================\n" << "Message #";
00152                 s << (msg.mMessageNumber & 0xFFFF) << "\n" << msg.mName << " (";
00153                 s << "Low";
00154                 break;
00155         default:
00156                 s << "Unknown";
00157                 break;
00158         }
00159 
00160         if (msg.mTotalSize != -1)
00161         {
00162                 s << ", " << msg.mTotalSize << " bytes total)\n";
00163         }
00164         else
00165         {
00166                 s << ")\n";
00167         }
00168         
00169         for (LLMessageTemplate::message_block_map_t::iterator iter = msg.mMemberBlocks.begin();
00170                  iter != msg.mMemberBlocks.end(); iter++)
00171         {
00172                 LLMessageBlock* ci = *iter;
00173                 s << *ci;
00174         }
00175 
00176         return s;
00177 }

Generated on Thu Jul 1 06:08:53 2010 for Second Life Viewer by  doxygen 1.4.7