00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_ 00019 #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_ 00020 00021 #include <string> 00022 #include <string.h> 00023 #include <map> 00024 #include <decaf/util/Properties.h> 00025 #include <decaf/io/DataOutputStream.h> 00026 #include <decaf/io/DataInputStream.h> 00027 #include <activemq/util/Config.h> 00028 00029 namespace activemq { 00030 namespace wireformat { 00031 namespace stomp { 00032 00036 class AMQCPP_API StompFrame { 00037 private: 00038 00039 // String Name of this command. 00040 std::string command; 00041 00042 // Properties of the Stomp Message 00043 decaf::util::Properties properties; 00044 00045 // Byte data of Body. 00046 std::vector<unsigned char> body; 00047 00048 public: 00049 00053 StompFrame(); 00054 00058 virtual ~StompFrame(); 00059 00065 StompFrame* clone() const; 00066 00071 void copy(const StompFrame* src); 00072 00077 void setCommand(const std::string& cmd) { 00078 this->command = cmd; 00079 } 00080 00084 const std::string& getCommand() const { 00085 return command; 00086 } 00087 00093 bool hasProperty(const std::string& name) const { 00094 return this->properties.hasProperty(name); 00095 } 00096 00106 std::string getProperty(const std::string& name, const std::string& fallback = "") const { 00107 return this->properties.getProperty(name, fallback); 00108 } 00109 00116 std::string removeProperty(const std::string& name) { 00117 return this->properties.getProperty(name, ""); 00118 } 00119 00126 void setProperty(const std::string& name, const std::string& value) { 00127 this->properties.setProperty(name, value); 00128 } 00129 00134 decaf::util::Properties& getProperties() { 00135 return properties; 00136 } 00137 const decaf::util::Properties& getProperties() const { 00138 return properties; 00139 } 00140 00145 const std::vector<unsigned char>& getBody() const { 00146 return body; 00147 } 00148 00152 std::vector<unsigned char>& getBody() { 00153 return body; 00154 } 00155 00160 std::size_t getBodyLength() const { 00161 return body.size(); 00162 } 00163 00169 void setBody(const unsigned char* bytes, std::size_t numBytes); 00170 00178 void toStream(decaf::io::DataOutputStream* stream) const; 00179 00187 void fromStream(decaf::io::DataInputStream* stream); 00188 00189 private: 00190 00196 void readCommandHeader(decaf::io::DataInputStream* in); 00197 00203 void readHeaders(decaf::io::DataInputStream* in); 00204 00212 std::size_t readHeaderLine(std::vector<unsigned char>& buffer, decaf::io::DataInputStream* in); 00213 00219 void readBody(decaf::io::DataInputStream* in); 00220 00221 }; 00222 00223 }}} 00224 00225 #endif /*_ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_*/
1.6.1