PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llsdmessagebuilder.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 126 lines | 60 code | 20 blank | 46 comment | 0 complexity | d4cbe5e10dc25b00c1a5e8ea3a3c5620 MD5 | raw file
  1/** 
  2 * @file llsdmessagebuilder.h
  3 * @brief Declaration of LLSDMessageBuilder class.
  4 *
  5 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLSDMESSAGEBUILDER_H
 28#define LL_LLSDMESSAGEBUILDER_H
 29
 30#include <map>
 31
 32#include "llmessagebuilder.h"
 33#include "llmsgvariabletype.h"
 34#include "llsd.h"
 35
 36class LLMessageTemplate;
 37class LLMsgData;
 38
 39class LLSDMessageBuilder : public LLMessageBuilder
 40{
 41public:
 42
 43	//CLASS_LOG_TYPE(LLSDMessageBuilder);
 44	
 45	LLSDMessageBuilder();
 46	virtual ~LLSDMessageBuilder();
 47
 48	virtual void newMessage(const char* name);
 49
 50	virtual void nextBlock(const char* blockname);
 51	virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
 52
 53	/** All add* methods expect pointers to canonical varname strings. */
 54	virtual void addBinaryData(
 55		const char* varname,
 56		const void* data, 
 57		S32 size);
 58	virtual void addBOOL(const char* varname, BOOL b);
 59	virtual void addS8(const char* varname, S8 s);
 60	virtual void addU8(const char* varname, U8 u);
 61	virtual void addS16(const char* varname, S16 i);
 62	virtual void addU16(const char* varname, U16 i);
 63	virtual void addF32(const char* varname, F32 f);
 64	virtual void addS32(const char* varname, S32 s);
 65	virtual void addU32(const char* varname, U32 u);
 66	virtual void addU64(const char* varname, U64 lu);
 67	virtual void addF64(const char* varname, F64 d);
 68	virtual void addVector3(const char* varname, const LLVector3& vec);
 69	virtual void addVector4(const char* varname, const LLVector4& vec);
 70	virtual void addVector3d(const char* varname, const LLVector3d& vec);
 71	virtual void addQuat(const char* varname, const LLQuaternion& quat);
 72	virtual void addUUID(const char* varname, const LLUUID& uuid);
 73	virtual void addIPAddr(const char* varname, const U32 ip);
 74	virtual void addIPPort(const char* varname, const U16 port);
 75	virtual void addString(const char* varname, const char* s);
 76	virtual void addString(const char* varname, const std::string& s);
 77
 78	virtual BOOL isMessageFull(const char* blockname) const;
 79	virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
 80
 81	virtual BOOL isBuilt() const;
 82	virtual BOOL isClear() const;
 83	virtual U32 buildMessage(U8* buffer, U32 buffer_size, U8 offset_to_data);
 84        /**< Null implementation which returns 0. */
 85	
 86	virtual void clearMessage();
 87
 88	// TODO: babbage: remove this horror.
 89	virtual void setBuilt(BOOL b);
 90
 91	virtual S32 getMessageSize();
 92	virtual const char* getMessageName() const;
 93
 94	virtual void copyFromMessageData(const LLMsgData& data);
 95
 96	virtual void copyFromLLSD(const LLSD& msg);
 97
 98	const LLSD& getMessage() const;
 99private:
100
101	/* mCurrentMessage is of the following format:
102		mCurrentMessage = { 'block_name1' : [ { 'block1_field1' : 'b1f1_data',
103												'block1_field2' : 'b1f2_data',
104												...
105												'block1_fieldn' : 'b1fn_data'},
106											{ 'block2_field1' : 'b2f1_data',
107												'block2_field2' : 'b2f2_data',
108												...
109												'block2_fieldn' : 'b2fn_data'},
110											...											
111											{ 'blockm_field1' : 'bmf1_data',
112												'blockm_field2' : 'bmf2_data',
113												...
114												'blockm_fieldn' : 'bmfn_data'} ],
115							'block_name2' : ...,
116							...
117							'block_namem' } */
118	LLSD mCurrentMessage;
119	LLSD* mCurrentBlock;
120	std::string mCurrentMessageName;
121	std::string mCurrentBlockName;
122	BOOL mbSBuilt;
123	BOOL mbSClear;
124};
125
126#endif // LL_LLSDMESSAGEBUILDER_H