Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mstringbufferbase.h Source File

m2mstringbufferbase.h

00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef __STRING_BUFFER_BASE_H__
00017 #define __STRING_BUFFER_BASE_H__
00018 
00019 #include <stdint.h>
00020 #include <stddef.h>
00021 
00022 class StringBufferBase
00023 {
00024 protected:
00025 
00026     // inline version of this produces smaller code
00027     inline StringBufferBase();
00028 
00029     // all the docs are at template level, as it is the only public API
00030 
00031     bool ensure_space(size_t max_size, size_t required_size) const;
00032 
00033     bool append(char *buff, size_t max_size, char data);
00034 
00035     bool append(char *buff, size_t max_size, const char *data);
00036 
00037     bool append(char *buff, size_t max_size, const char *data, size_t data_len);
00038 
00039     bool append_int(char *buff, size_t max_size, uint16_t data);
00040 
00041     int find_last_of(const char *buff, char search_char) const;
00042 
00043 protected:
00044     //const size_t _max_size;
00045     size_t _curr_size;
00046 };
00047 
00048 inline StringBufferBase::StringBufferBase() : _curr_size(0)
00049 {
00050 }
00051 
00052 #endif // !__STRING_BUFFER_BASE_H__