libprom 1.2.1
C based libraries to expose metrics in Promtheus exposition format
Loading...
Searching...
No Matches
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
34struct psb;
35typedef struct psb psb_t;
36
41psb_t *psb_new(void);
42
48int psb_destroy(psb_t *self);
49
57int psb_add_str(psb_t *self, const char *str);
58
66int psb_add_char(psb_t *self, char c);
67
74int psb_clear(psb_t *self);
75
84int psb_truncate(psb_t *self, size_t len);
85
91size_t psb_len(psb_t *self);
92
99char *psb_dump(psb_t *self);
100
108char *psb_str(psb_t *self);
109
110#endif // PROM_STRING_BUILDER_I_H
size_t psb_len(psb_t *self)
Get the length of the buffered string of the given string builder.
int psb_add_str(psb_t *self, const char *str)
Append the given string to the buffered string of the given string builder.
psb_t * psb_new(void)
Setup a new string builder.
char * psb_str(psb_t *self)
Get a reference to the buffered string.
int psb_add_char(psb_t *self, char c)
Append the given character to the buffered string of the given string builder.
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'...
int psb_destroy(psb_t *self)
Destroys the given string builder.
int psb_clear(psb_t *self)
Free the allocated string buffer area of the given string builder, allocate a new one with a default ...
char * psb_dump(psb_t *self)
Get a copy of the buffered string of the given string builder.