123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #pragma once
- //#include "BSTTree.hpp"
- namespace ECOM
- {
- namespace Utility
- {
- class BSTTree;
- }
- }
- #ifndef _ServiceBus_DLL
- #define _ServiceBus_API _declspec(dllimport)
- #else
- #define _ServiceBus_API _declspec(dllexport)
- #endif
- namespace ECOM
- {
- namespace ServiceBus
- {
- class _ServiceBus_API MessageEncoder
- {
- public:
- MessageEncoder ();
- virtual ~MessageEncoder ();
- void Set (LPCSTR Key, const DString & Value);
- void Set (LPCSTR Key, LPCSTR Value);
- void Set (LPCSTR Key, __int64 Value);
- void Set (LPCSTR Key, unsigned __int64 Value);
- void Set (LPCSTR Key, int Value);
- void Set (LPCSTR Key, unsigned int Value);
- void Set (LPCSTR Key, bool Value);
- void Set (LPCSTR Key, float Value);
- void Set (LPCSTR Key, double Value);
- // void Set (LPCSTR Key, MessageEncoder & Element); // 作为嵌入对象
- #if 0
- void Add (const DString & Value);
- void Add (LPCSTR Value);
- void Add (__int64 Value);
- void Add (unsigned __int64 Value);
- void Add (int Value);
- void Add (unsigned int Value);
- void Add (bool Value);
- void Add (float Value);
- void Add (double Value);
- void Add (MessageEncoder & Element); // 作为嵌入对象
- #endif
- bool Recode (LPCSTR String);
- DString ToString () const;
- operator DString () const { return ToString (); }
- // 我没有拷贝构造函数
- private:
- MessageEncoder (const MessageEncoder &);
- MessageEncoder & operator = (MessageEncoder & Value);
- protected:
- // Json::Value * m_JsonRoot;
- ECOM::Utility::BSTTree * m_JsonRoot;
- protected:
- class Proxy
- {
- public:
- inline Proxy (MessageEncoder & Encoder, LPCSTR Key) :
- m_Encoder (Encoder),
- m_Key (Key)
- {
- }
- inline Proxy & operator = (const DString & Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (LPCSTR Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (__int64 Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (unsigned __int64 Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (int Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (unsigned int Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (bool Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (float Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (double Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- inline Proxy & operator = (MessageEncoder & Value)
- {
- m_Encoder.Set (m_Key, Value);
- return (*this);
- }
- protected:
- LPCSTR m_Key;
- MessageEncoder & m_Encoder;
- };
- public:
- Proxy operator [] (LPCSTR Key)
- {
- return Proxy (*this, Key);
- }
- Proxy operator () (LPCSTR Key)
- {
- return Proxy (*this, Key);
- }
- };
- };
- };
|