added max-age and content-format

Fork of mbedConnectorInterface by Doug Anson

Committer:
ansond
Date:
Fri Mar 20 05:55:22 2015 +0000
Revision:
26:b06a19916f05
Parent:
25:1fc958ac14d1
Child:
27:eb6818ad257a
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 24:a6915e19814e 1 /**
ansond 24:a6915e19814e 2 * @file DataWrapper.h
ansond 26:b06a19916f05 3 * @brief mbed CoAP Endpoint Data Wrapper class (header)
ansond 24:a6915e19814e 4 * @author Doug Anson
ansond 24:a6915e19814e 5 * @version 1.0
ansond 24:a6915e19814e 6 * @see
ansond 24:a6915e19814e 7 *
ansond 24:a6915e19814e 8 * Copyright (c) 2014
ansond 24:a6915e19814e 9 *
ansond 24:a6915e19814e 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 24:a6915e19814e 11 * you may not use this file except in compliance with the License.
ansond 24:a6915e19814e 12 * You may obtain a copy of the License at
ansond 24:a6915e19814e 13 *
ansond 24:a6915e19814e 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 24:a6915e19814e 15 *
ansond 24:a6915e19814e 16 * Unless required by applicable law or agreed to in writing, software
ansond 24:a6915e19814e 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 24:a6915e19814e 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 24:a6915e19814e 19 * See the License for the specific language governing permissions and
ansond 24:a6915e19814e 20 * limitations under the License.
ansond 24:a6915e19814e 21 */
ansond 24:a6915e19814e 22
ansond 24:a6915e19814e 23 #ifndef __DATA_WRAPPER_H__
ansond 24:a6915e19814e 24 #define __DATA_WRAPPER_H__
ansond 24:a6915e19814e 25
ansond 24:a6915e19814e 26 // mbed support
ansond 24:a6915e19814e 27 #include "mbed.h"
ansond 24:a6915e19814e 28
ansond 24:a6915e19814e 29 class DataWrapper {
ansond 24:a6915e19814e 30 public:
ansond 24:a6915e19814e 31 /**
ansond 24:a6915e19814e 32 Default constructor
ansond 26:b06a19916f05 33 @param data input the buffer to use for operations
ansond 26:b06a19916f05 34 @param data_length input the data length
ansond 24:a6915e19814e 35 */
ansond 24:a6915e19814e 36 DataWrapper(uint8_t *data,int data_length);
ansond 24:a6915e19814e 37
ansond 24:a6915e19814e 38 /**
ansond 25:1fc958ac14d1 39 Default constructor (alloc)
ansond 26:b06a19916f05 40 @param data_length input the data length (alloc)
ansond 25:1fc958ac14d1 41 */
ansond 25:1fc958ac14d1 42 DataWrapper(int data_length);
ansond 25:1fc958ac14d1 43
ansond 25:1fc958ac14d1 44 /**
ansond 24:a6915e19814e 45 Default copy constructor
ansond 26:b06a19916f05 46 @param data input the DataWrapper to copy
ansond 24:a6915e19814e 47 */
ansond 24:a6915e19814e 48 DataWrapper(const DataWrapper &data);
ansond 24:a6915e19814e 49
ansond 24:a6915e19814e 50 /**
ansond 24:a6915e19814e 51 Destructor
ansond 24:a6915e19814e 52 */
ansond 24:a6915e19814e 53 virtual ~DataWrapper();
ansond 24:a6915e19814e 54
ansond 24:a6915e19814e 55 /**
ansond 26:b06a19916f05 56 Wrap the data (trivial in base class)
ansond 26:b06a19916f05 57 @param data input the data to wrap
ansond 26:b06a19916f05 58 @param data_length input the length of the data to wrap
ansond 24:a6915e19814e 59 */
ansond 24:a6915e19814e 60 virtual void wrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 61
ansond 24:a6915e19814e 62 /**
ansond 26:b06a19916f05 63 Unwrap the data (trivial in base class)
ansond 26:b06a19916f05 64 @param data input the data to unwrap
ansond 26:b06a19916f05 65 @param data_length input the length of the data to unwrap
ansond 24:a6915e19814e 66 */
ansond 24:a6915e19814e 67 virtual void unwrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 68
ansond 24:a6915e19814e 69 /**
ansond 24:a6915e19814e 70 Get the wrap/unwrap result
ansond 24:a6915e19814e 71 @return pointer to the data buffer of DataWrapper containing the wrap/unwrap result
ansond 24:a6915e19814e 72 */
ansond 24:a6915e19814e 73 uint8_t *get() { return this->m_data; }
ansond 24:a6915e19814e 74
ansond 24:a6915e19814e 75 /**
ansond 24:a6915e19814e 76 Get the wrap/unwrap result length
ansond 24:a6915e19814e 77 @return length of the wrap/unwrap data result
ansond 24:a6915e19814e 78 */
ansond 24:a6915e19814e 79 int length() { return this->m_data_length; }
ansond 24:a6915e19814e 80
ansond 24:a6915e19814e 81 /**
ansond 24:a6915e19814e 82 Reset the wrapper
ansond 24:a6915e19814e 83 */
ansond 24:a6915e19814e 84 void reset();
ansond 26:b06a19916f05 85
ansond 25:1fc958ac14d1 86 protected:
ansond 25:1fc958ac14d1 87 uint8_t *m_data;
ansond 25:1fc958ac14d1 88
ansond 24:a6915e19814e 89 private:
ansond 25:1fc958ac14d1 90 bool m_alloced;
ansond 24:a6915e19814e 91 int m_data_length;
ansond 25:1fc958ac14d1 92 int m_data_length_max;
ansond 24:a6915e19814e 93 };
ansond 24:a6915e19814e 94
ansond 24:a6915e19814e 95 #endif // __DATA_WRAPPER_H__