portable version of the cumulocity demo

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

utils/SmartRestTemplate.cpp

Committer:
ublox
Date:
2014-10-03
Revision:
56:2da813cc2f47
Parent:
41:804f6a0bda26

File content as of revision 56:2da813cc2f47:

#include "SmartRestTemplate.h"
#include <string.h>

SmartRestTemplate::SmartRestTemplate()
{
    _len = NULL;
}

bool SmartRestTemplate::add(const char *line)
{
    if (_len == SMARTREST_TEMPLATE_FIXED_SIZE)
        return false;
    _buffer[_len++] = line;
}

size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const
{
    size_t len = 0;
    
    for (size_t n = 0; n < _len; n++)
        len += sink.write((char*)_buffer[n], strlen(_buffer[n]));
    
    return len;
}

size_t SmartRestTemplate::writtenLength() const
{
    size_t len = 0;
    
    for (size_t n = 0; n < _len; n++)
        len += strlen(_buffer[n]);
    
    return len;
}

DataGenerator * SmartRestTemplate::copy() const
{
    return NULL;
}