libprom  1.2.0
C based libraries to expose metrics in Promtheus exposition format
prom_string_builder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2020 DigitalOcean Inc.
3  * Copyright 2021 Jens Elkner <jel+libprom@cs.uni-magdeburg.de>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
28 #ifndef PROM_STRING_BUILDER_I_H
29 #define PROM_STRING_BUILDER_I_H
30 
31 #include <stddef.h>
32 
34 struct psb;
35 typedef struct psb psb_t;
36 
41 psb_t *psb_new(void);
42 
48 int psb_destroy(psb_t *self);
49 
57 int psb_add_str(psb_t *self, const char *str);
58 
66 int psb_add_char(psb_t *self, char c);
67 
74 int psb_clear(psb_t *self);
75 
84 int psb_truncate(psb_t *self, size_t len);
85 
91 size_t psb_len(psb_t *self);
92 
99 char *psb_dump(psb_t *self);
100 
108 char *psb_str(psb_t *self);
109 
110 #endif // PROM_STRING_BUILDER_I_H
psb_truncate
int psb_truncate(psb_t *self, size_t len)
Set the length of the buffered string of the given string builder to the given length and append '\0'...
psb_add_str
int psb_add_str(psb_t *self, const char *str)
Append the given string to the buffered string of the given string builder.
psb_len
size_t psb_len(psb_t *self)
Get the length of the buffered string of the given string builder.
psb_dump
char * psb_dump(psb_t *self)
Get a copy of the buffered string of the given string builder.
psb_new
psb_t * psb_new(void)
Setup a new string builder.
psb_add_char
int psb_add_char(psb_t *self, char c)
Append the given character to the buffered string of the given string builder.
psb_clear
int psb_clear(psb_t *self)
Free the allocated string buffer area of the given string builder, allocate a new one with a default ...
psb_str
char * psb_str(psb_t *self)
Get a reference to the buffered string.
psb_destroy
int psb_destroy(psb_t *self)
Destroys the given string builder.