Example

Dependencies:   FXAS21002 FXOS8700Q

Committer:
maygup01
Date:
Tue Nov 19 09:49:38 2019 +0000
Revision:
0:11cc2b7889af
Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maygup01 0:11cc2b7889af 1 /*
maygup01 0:11cc2b7889af 2 * Copyright (c) 2016 ARM Limited. All rights reserved.
maygup01 0:11cc2b7889af 3 * SPDX-License-Identifier: Apache-2.0
maygup01 0:11cc2b7889af 4 * Licensed under the Apache License, Version 2.0 (the License); you may
maygup01 0:11cc2b7889af 5 * not use this file except in compliance with the License.
maygup01 0:11cc2b7889af 6 * You may obtain a copy of the License at
maygup01 0:11cc2b7889af 7 *
maygup01 0:11cc2b7889af 8 * http://www.apache.org/licenses/LICENSE-2.0
maygup01 0:11cc2b7889af 9 *
maygup01 0:11cc2b7889af 10 * Unless required by applicable law or agreed to in writing, software
maygup01 0:11cc2b7889af 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
maygup01 0:11cc2b7889af 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
maygup01 0:11cc2b7889af 13 * See the License for the specific language governing permissions and
maygup01 0:11cc2b7889af 14 * limitations under the License.
maygup01 0:11cc2b7889af 15 */
maygup01 0:11cc2b7889af 16 #ifndef __STRING_BUFFER_BASE_H__
maygup01 0:11cc2b7889af 17 #define __STRING_BUFFER_BASE_H__
maygup01 0:11cc2b7889af 18
maygup01 0:11cc2b7889af 19 #include <stdint.h>
maygup01 0:11cc2b7889af 20 #include <stddef.h>
maygup01 0:11cc2b7889af 21
maygup01 0:11cc2b7889af 22 /*! \file m2mstringbufferbase.h
maygup01 0:11cc2b7889af 23 * \brief StringBufferBase.
maygup01 0:11cc2b7889af 24 * This class is the base class for fixed-sized string buffers.
maygup01 0:11cc2b7889af 25 */
maygup01 0:11cc2b7889af 26 class StringBufferBase
maygup01 0:11cc2b7889af 27 {
maygup01 0:11cc2b7889af 28 protected:
maygup01 0:11cc2b7889af 29
maygup01 0:11cc2b7889af 30 // inline version of this produces smaller code
maygup01 0:11cc2b7889af 31 inline StringBufferBase();
maygup01 0:11cc2b7889af 32
maygup01 0:11cc2b7889af 33 // all the docs are at template level, as it is the only public API
maygup01 0:11cc2b7889af 34
maygup01 0:11cc2b7889af 35 bool ensure_space(size_t max_size, size_t required_size) const;
maygup01 0:11cc2b7889af 36
maygup01 0:11cc2b7889af 37 bool append(char *buff, size_t max_size, char data);
maygup01 0:11cc2b7889af 38
maygup01 0:11cc2b7889af 39 bool append(char *buff, size_t max_size, const char *data);
maygup01 0:11cc2b7889af 40
maygup01 0:11cc2b7889af 41 bool append(char *buff, size_t max_size, const char *data, size_t data_len);
maygup01 0:11cc2b7889af 42
maygup01 0:11cc2b7889af 43 bool append_int(char *buff, size_t max_size, uint16_t data);
maygup01 0:11cc2b7889af 44
maygup01 0:11cc2b7889af 45 int find_last_of(const char *buff, char search_char) const;
maygup01 0:11cc2b7889af 46
maygup01 0:11cc2b7889af 47 protected:
maygup01 0:11cc2b7889af 48 //const size_t _max_size;
maygup01 0:11cc2b7889af 49 size_t _curr_size;
maygup01 0:11cc2b7889af 50 };
maygup01 0:11cc2b7889af 51
maygup01 0:11cc2b7889af 52 inline StringBufferBase::StringBufferBase() : _curr_size(0)
maygup01 0:11cc2b7889af 53 {
maygup01 0:11cc2b7889af 54 }
maygup01 0:11cc2b7889af 55
maygup01 0:11cc2b7889af 56 #endif // !__STRING_BUFFER_BASE_H__