用boost::any存储各种类型。 class Amf0 { public: enum Type { kNumber = 0x00, kBoolean = 0x01, kString = 0x02, kObject = 0x03, kMovieClip = 0x04, kNull = 0x05, kUndefined = 0x06, kReference = 0x07, kEcmaArray = 0x08, kEndOfObject = 0x09, kArray = 0x0A, kDate = 0x0B, kLongString = 0x0C, kUnsupported = 0x0D, kRecordset = 0x0E, kXml = 0x0F, kClassObject = 0x10, kInvalid = 0xFF, kNone = 0x100, }; Amf0(Type type = kNone); Amf0(bool value); Amf0(const char * value); Amf0(const std::string & value); Amf0(double value); Amf0(const Amf0Object & value); Amf0(const Amf0EcmaArray & value); ~Amf0(); Amf0 & operator[](const std::string & name); Type GetType(); double GetNumber(); bool GetBool(); Amf0Object & GetObj(); Amf0EcmaArray & GetEcmaArray(); std::string GetString(); int GetDataSize(); boost::tribool Decode(v::net::Buffer & buffer); void Encode(v::net::Buffer & buffer); private: Type type_; boost::any value_; };