activemq-cpp-3.8.2
StompFrame.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_
19 #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_
20 
21 #include <string>
22 #include <string.h>
23 #include <map>
24 #include <decaf/util/Properties.h>
27 #include <activemq/util/Config.h>
28 
29 namespace activemq {
30 namespace wireformat {
31 namespace stomp {
32 
37  private:
38 
39  // String Name of this command.
40  std::string command;
41 
42  // Properties of the Stomp Message
43  decaf::util::Properties properties;
44 
45  // Byte data of Body.
46  std::vector<unsigned char> body;
47 
48  public:
49 
53  StompFrame();
54 
58  virtual ~StompFrame();
59 
65  StompFrame* clone() const;
66 
71  void copy(const StompFrame* src);
72 
77  void setCommand(const std::string& cmd) {
78  this->command = cmd;
79  }
80 
84  const std::string& getCommand() const {
85  return command;
86  }
87 
93  bool hasProperty(const std::string& name) const {
94  return this->properties.hasProperty(name);
95  }
96 
106  std::string getProperty(const std::string& name, const std::string& fallback = "") const {
107  return this->properties.getProperty(name, fallback);
108  }
109 
116  std::string removeProperty(const std::string& name) {
117  return this->properties.getProperty(name, "");
118  }
119 
126  void setProperty(const std::string& name, const std::string& value) {
127  this->properties.setProperty(name, value);
128  }
129 
135  return properties;
136  }
138  return properties;
139  }
140 
145  const std::vector<unsigned char>& getBody() const {
146  return body;
147  }
148 
152  std::vector<unsigned char>& getBody() {
153  return body;
154  }
155 
160  std::size_t getBodyLength() const {
161  return body.size();
162  }
163 
169  void setBody(const unsigned char* bytes, std::size_t numBytes);
170 
178  void toStream(decaf::io::DataOutputStream* stream) const;
179 
187  void fromStream(decaf::io::DataInputStream* stream);
188 
189  private:
190 
196  void readCommandHeader(decaf::io::DataInputStream* in);
197 
203  void readHeaders(decaf::io::DataInputStream* in);
204 
212  std::size_t readHeaderLine(std::vector<unsigned char>& buffer, decaf::io::DataInputStream* in);
213 
219  void readBody(decaf::io::DataInputStream* in);
220 
221  };
222 
223 }}}
224 
225 #endif /*_ACTIVEMQ_WIREFORMAT_STOMP_STOMPFRAMEWRAPPER_H_*/
const char * getProperty(const std::string &name) const
Looks up the value for the given property.
A Stomp-level message frame that encloses all messages to and from the broker.
Definition: StompFrame.h:36
#define AMQCPP_API
Definition: Config.h:30
std::string getProperty(const std::string &name, const std::string &fallback="") const
Gets a property from this Frame&#39;s properties and returns it, or the default value given...
Definition: StompFrame.h:106
bool hasProperty(const std::string &name) const
Checks if the given property is present in the Frame.
Definition: StompFrame.h:93
void setProperty(const std::string &name, const std::string &value)
Sets the property given to the value specified in this Frame&#39;s Properties.
Definition: StompFrame.h:126
std::size_t getBodyLength() const
Return the number of bytes contained in this frames body.
Definition: StompFrame.h:160
A data output stream lets an application write primitive Java data types to an output stream in a por...
Definition: DataOutputStream.h:34
A data input stream lets an application read primitive Java data types from an underlying input strea...
Definition: DataInputStream.h:46
const decaf::util::Properties & getProperties() const
Definition: StompFrame.h:137
std::string removeProperty(const std::string &name)
Gets and remove the property specified, if the property is not set, this method returns the empty str...
Definition: StompFrame.h:116
std::string setProperty(const std::string &name, const std::string &value)
Sets the value for a given property.
std::vector< unsigned char > & getBody()
Non-const version of the body accessor.
Definition: StompFrame.h:152
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
const std::string & getCommand() const
Accessor for this frame&#39;s command field.
Definition: StompFrame.h:84
Java-like properties class for mapping string names to string values.
Definition: Properties.h:53
void setCommand(const std::string &cmd)
Sets the command for this stomp frame.
Definition: StompFrame.h:77
bool hasProperty(const std::string &name) const
Check to see if the Property exists in the set.
decaf::util::Properties & getProperties()
Gets access to the header properties for this frame.
Definition: StompFrame.h:134
const std::vector< unsigned char > & getBody() const
Accessor for the body data of this frame.
Definition: StompFrame.h:145