activemq-cpp-3.4.0

src/main/activemq/wireformat/stomp/StompFrame.h

Go to the documentation of this file.
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 
00037     class AMQCPP_API StompFrame{
00038     private:
00039 
00040         // String Name of this command.
00041         std::string command;
00042 
00043         // Properties of the Stomp Message
00044         decaf::util::Properties properties;
00045 
00046         // Byte data of Body.
00047         std::vector<unsigned char> body;
00048 
00049     public:
00050 
00054         StompFrame();
00055 
00059         virtual ~StompFrame();
00060 
00066         StompFrame* clone() const;
00067 
00072         void copy( const StompFrame* src );
00073 
00078         void setCommand( const std::string& cmd ){
00079             this->command = cmd;
00080         }
00081 
00085         const std::string& getCommand() const{
00086             return command;
00087         }
00088 
00094         bool hasProperty( const std::string& name ) const {
00095             return this->properties.hasProperty( name );
00096         }
00097 
00107         std::string getProperty( const std::string& name, const std::string& fallback = "" ) const {
00108             return this->properties.getProperty( name, fallback );
00109         }
00110 
00117         std::string removeProperty( const std::string& name ) {
00118             return this->properties.getProperty( name, "" );
00119         }
00120 
00127         void setProperty( const std::string& name, const std::string& value ) {
00128             this->properties.setProperty( name, value );
00129         }
00130 
00135         decaf::util::Properties& getProperties(){ return properties; }
00136         const decaf::util::Properties& getProperties() const {
00137             return properties;
00138         }
00139 
00144         const std::vector<unsigned char>& getBody() const{
00145             return body;
00146         }
00147 
00151         std::vector<unsigned char>& getBody(){
00152             return body;
00153         }
00154 
00159         std::size_t getBodyLength() const{ return body.size(); }
00160 
00166         void setBody( const unsigned char* bytes, std::size_t numBytes );
00167 
00175         void toStream( decaf::io::DataOutputStream* stream ) const;
00176 
00184         void fromStream( decaf::io::DataInputStream* stream );
00185 
00186     private:
00187 
00193         void readCommandHeader( decaf::io::DataInputStream* in );
00194 
00200         void readHeaders( decaf::io::DataInputStream* in );
00201 
00209         std::size_t readHeaderLine( std::vector<unsigned char>& buffer,
00210                                     decaf::io::DataInputStream* in );
00211 
00217         void readBody( decaf::io::DataInputStream* in );
00218 
00219     };
00220 
00221 }}}
00222 
00223 #endif /*_ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_*/