MIP_SDK  v4.0.0
MicroStrain Communications Library for embedded systems
strings.h
Go to the documentation of this file.
1 #pragma once
2 
3 // TODO: Find better way to check for this
4 // Used to check if IO operations are supported
5 #include "logging.h"
6 
7 #include <stdarg.h>
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 namespace microstrain {
14 namespace C {
15 extern "C" {
16 #endif
17 
40 
47 
48 bool microstrain_string_concat(char* buffer, size_t buffer_size, size_t* index, const char* str, size_t str_len);
49 bool microstrain_string_concat_z(char* buffer, size_t buffer_size, size_t* index, const char* str);
50 
51 #define microstrain_string_concat_l(buffer, buffer_size, index, str_lit) microstrain_string_concat(buffer, buffer_size, index, str_lit, sizeof(str_lit)-1)
52 
53 // TODO: Use better check for this or move to extras
54 #ifdef MICROSTRAIN_LOGGING_ENABLED
55 // sprintf is too big for some embedded systems.
56 // Disable it when logging is disabled.
57 bool microstrain_string_format_v(char* buffer, size_t buffer_size, size_t* index, const char* fmt, va_list args);
58 bool microstrain_string_format(char* buffer, size_t buffer_size, size_t* index, const char* fmt, ...);
59 #endif // MICROSTRAIN_LOGGING_ENABLED
60 
61 bool microstrain_string_bytes_to_hex_str(char* buffer, size_t buffer_size, size_t* index, const uint8_t* data, size_t data_size, unsigned int byte_grouping);
62 
66 
67 #ifdef __cplusplus
68 } // extern "C"
69 } // namespace C
70 } // namespace microstrain
71 #endif
microstrain::C::microstrain_string_format_v
bool microstrain_string_format_v(char *buffer, size_t buffer_size, size_t *index, const char *fmt, va_list args)
Wrapper for std::vsnprintf with a better interface.
Definition: strings.c:124
microstrain::C::microstrain_string_concat_z
bool microstrain_string_concat_z(char *buffer, size_t buffer_size, size_t *index, const char *str)
Concatenate a string into a buffer.
Definition: strings.c:92
microstrain::C::microstrain_string_bytes_to_hex_str
bool microstrain_string_bytes_to_hex_str(char *buffer, size_t buffer_size, size_t *index, const uint8_t *data, size_t data_size, unsigned int byte_grouping)
Formats a byte array to a text buffer in hexadecimal.
Definition: strings.c:239
microstrain::C::microstrain_string_concat
bool microstrain_string_concat(char *buffer, size_t buffer_size, size_t *index, const char *str, size_t str_len)
Concatenate a string into a buffer.
Definition: strings.c:33
logging.h
microstrain::C::microstrain_string_format
bool microstrain_string_format(char *buffer, size_t buffer_size, size_t *index, const char *fmt,...)
Wrapper for std::snprintf with a better interface.
Definition: strings.c:184
microstrain
Definition: embedded_time.h:8