![](/media/cache/group/u-blox_logo_trans.png.50x50_q85.png)
portable version of the cumulocity demo
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
utils/SmartRestTemplate.cpp@56:2da813cc2f47, 2014-10-03 (annotated)
- Committer:
- ublox
- Date:
- Fri Oct 03 07:54:13 2014 +0000
- Revision:
- 56:2da813cc2f47
- Parent:
- 41:804f6a0bda26
update dependency
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Cumulocity | 41:804f6a0bda26 | 1 | #include "SmartRestTemplate.h" |
Cumulocity | 41:804f6a0bda26 | 2 | #include <string.h> |
Cumulocity | 41:804f6a0bda26 | 3 | |
Cumulocity | 41:804f6a0bda26 | 4 | SmartRestTemplate::SmartRestTemplate() |
Cumulocity | 41:804f6a0bda26 | 5 | { |
Cumulocity | 41:804f6a0bda26 | 6 | _len = NULL; |
Cumulocity | 41:804f6a0bda26 | 7 | } |
Cumulocity | 41:804f6a0bda26 | 8 | |
Cumulocity | 41:804f6a0bda26 | 9 | bool SmartRestTemplate::add(const char *line) |
Cumulocity | 41:804f6a0bda26 | 10 | { |
Cumulocity | 41:804f6a0bda26 | 11 | if (_len == SMARTREST_TEMPLATE_FIXED_SIZE) |
Cumulocity | 41:804f6a0bda26 | 12 | return false; |
Cumulocity | 41:804f6a0bda26 | 13 | _buffer[_len++] = line; |
Cumulocity | 41:804f6a0bda26 | 14 | } |
Cumulocity | 41:804f6a0bda26 | 15 | |
Cumulocity | 41:804f6a0bda26 | 16 | size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const |
Cumulocity | 41:804f6a0bda26 | 17 | { |
Cumulocity | 41:804f6a0bda26 | 18 | size_t len = 0; |
Cumulocity | 41:804f6a0bda26 | 19 | |
Cumulocity | 41:804f6a0bda26 | 20 | for (size_t n = 0; n < _len; n++) |
Cumulocity | 41:804f6a0bda26 | 21 | len += sink.write((char*)_buffer[n], strlen(_buffer[n])); |
Cumulocity | 41:804f6a0bda26 | 22 | |
Cumulocity | 41:804f6a0bda26 | 23 | return len; |
Cumulocity | 41:804f6a0bda26 | 24 | } |
Cumulocity | 41:804f6a0bda26 | 25 | |
Cumulocity | 41:804f6a0bda26 | 26 | size_t SmartRestTemplate::writtenLength() const |
Cumulocity | 41:804f6a0bda26 | 27 | { |
Cumulocity | 41:804f6a0bda26 | 28 | size_t len = 0; |
Cumulocity | 41:804f6a0bda26 | 29 | |
Cumulocity | 41:804f6a0bda26 | 30 | for (size_t n = 0; n < _len; n++) |
Cumulocity | 41:804f6a0bda26 | 31 | len += strlen(_buffer[n]); |
Cumulocity | 41:804f6a0bda26 | 32 | |
Cumulocity | 41:804f6a0bda26 | 33 | return len; |
Cumulocity | 41:804f6a0bda26 | 34 | } |
Cumulocity | 41:804f6a0bda26 | 35 | |
Cumulocity | 41:804f6a0bda26 | 36 | DataGenerator * SmartRestTemplate::copy() const |
Cumulocity | 41:804f6a0bda26 | 37 | { |
Cumulocity | 41:804f6a0bda26 | 38 | return NULL; |
Cumulocity | 41:804f6a0bda26 | 39 | } |