]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - benchtests/json-lib.c
po: Incorporate translations (sr)
[thirdparty/glibc.git] / benchtests / json-lib.c
index 61573c579a41400147dc0031c52c14346a966c82..a3db9213bbcd72cdd12e7ea479436ede624e0eb5 100644 (file)
@@ -1,5 +1,5 @@
 /* Simple library for printing JSON data.
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2024 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
 
@@ -100,6 +100,32 @@ json_attr_string (json_ctx_t *ctx, const char *name, const char *s)
   fprintf (ctx->fp, "\"%s\": \"%s\"", name, s);
 }
 
+void
+json_attr_uint (json_ctx_t *ctx, const char *name, uint64_t d)
+{
+  if (!ctx->first_element)
+    fprintf (ctx->fp, ",\n");
+  else
+    ctx->first_element = false;
+
+  do_indent (ctx);
+
+  fprintf (ctx->fp, "\"%s\": %" PRIu64 , name, d);
+}
+
+void
+json_attr_int (json_ctx_t *ctx, const char *name, int64_t d)
+{
+  if (!ctx->first_element)
+    fprintf (ctx->fp, ",\n");
+  else
+    ctx->first_element = false;
+
+  do_indent (ctx);
+
+  fprintf (ctx->fp, "\"%s\": %" PRId64 , name, d);
+}
+
 void
 json_attr_double (json_ctx_t *ctx, const char *name, double d)
 {
@@ -136,6 +162,42 @@ json_array_end (json_ctx_t *ctx)
   fputs ("]", ctx->fp);
 }
 
+void
+json_element_string (json_ctx_t *ctx, const char *s)
+{
+  if (!ctx->first_element)
+    fprintf (ctx->fp, ", \"%s\"", s);
+  else
+    {
+      fprintf (ctx->fp, "\"%s\"", s);
+      ctx->first_element = false;
+    }
+}
+
+void
+json_element_uint (json_ctx_t *ctx, uint64_t d)
+{
+  if (!ctx->first_element)
+    fprintf (ctx->fp, ", %" PRIu64, d);
+  else
+    {
+      fprintf (ctx->fp, "%" PRIu64, d);
+      ctx->first_element = false;
+    }
+}
+
+void
+json_element_int (json_ctx_t *ctx, int64_t d)
+{
+  if (!ctx->first_element)
+    fprintf (ctx->fp, ", %" PRId64, d);
+  else
+    {
+      fprintf (ctx->fp, "%" PRId64, d);
+      ctx->first_element = false;
+    }
+}
+
 void
 json_element_double (json_ctx_t *ctx, double d)
 {