added max-age and content-format

Fork of mbedConnectorInterface by Doug Anson

api/DataWrapper.cpp

Committer:
ansond
Date:
2015-03-20
Revision:
24:a6915e19814e
Child:
25:1fc958ac14d1

File content as of revision 24:a6915e19814e:

/**
 * @file    DynamicResource.h
 * @brief   mbed CoAP Endpoint Dynamic Resource class (header)
 * @author  Doug Anson/Chris Paola
 * @version 1.0
 * @see
 *
 * Copyright (c) 2014
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
 #include "DataWrapper.h"
 
 // constructor
 DataWrapper::DataWrapper(uint8_t *data,int data_length) {
     this->m_data = data;
     this->m_data_length = data_length;
 }
 
 // copy constructor
 DataWrapper::DataWrapper(const DataWrapper &data) {
     this->m_data = data.m_data;
     this->m_data_length = data.m_data_length;
 }
 
 // destructor
 DataWrapper::~DataWrapper() {
 }
 
 // wrap
 void DataWrapper::wrap(uint8_t *data,int data_length) {
     this->reset();
     if (data != NULL && data_length > 0) {
        int length = data_length;
        if (length > this->m_data_length) length = this->m_data_length;
        memcpy(this->m_data,data,length);
        this->m_data_length = length;
     }
 }
 
 // unwrap       
 void DataWrapper::unwrap(uint8_t *data,int data_length) {
     this->reset();
     if (data != NULL && data_length > 0) {
        int length = data_length;
        if (length > this->m_data_length) length = this->m_data_length;
        memcpy(this->m_data,data,length);
        this->m_data_length = length;
     }
 }
 
 void DataWrapper::reset() {
     if (this->m_data != NULL && this->m_data_length > 0)
        memset(this->m_data,0,this->m_data_length);
     this->m_data_length = 0;
}