Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mstringbufferbase.h Source File

m2mstringbufferbase.h

Go to the documentation of this file.
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 /*! \file m2mstringbufferbase.h
00023  *  \brief StringBufferBase.
00024  *  This class is the base class for fixed-sized string buffers.
00025  */
00026 class StringBufferBase
00027 {
00028 protected:
00029 
00030     // inline version of this produces smaller code
00031     inline StringBufferBase();
00032 
00033     // all the docs are at template level, as it is the only public API
00034 
00035     bool ensure_space(size_t max_size, size_t required_size) const;
00036 
00037     bool append(char *buff, size_t max_size, char data);
00038 
00039     bool append(char *buff, size_t max_size, const char *data);
00040 
00041     bool append(char *buff, size_t max_size, const char *data, size_t data_len);
00042 
00043     bool append_int(char *buff, size_t max_size, uint16_t data);
00044 
00045     int find_last_of(const char *buff, char search_char) const;
00046 
00047 protected:
00048     //const size_t _max_size;
00049     size_t _curr_size;
00050 };
00051 
00052 inline StringBufferBase::StringBufferBase() : _curr_size(0)
00053 {
00054 }
00055 
00056 #endif // !__STRING_BUFFER_BASE_H__