Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/grpc/src/core/json/json.h

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 #ifndef GRPC_INTERNAL_CORE_JSON_JSON_H
35 #define GRPC_INTERNAL_CORE_JSON_JSON_H
36
37 #include <stdlib.h>
38
39 #include "src/core/json/json_common.h"
40
41 /* A tree-like structure to hold json values. The key and value pointers
42 * are not owned by it.
43 */
44 typedef struct grpc_json {
45 struct grpc_json *next;
46 struct grpc_json *prev;
47 struct grpc_json *child;
48 struct grpc_json *parent;
49
50 grpc_json_type type;
51 const char *key;
52 const char *value;
53 } grpc_json;
54
55 /* The next two functions are going to parse the input string, and
56 * modify it in the process, in order to use its space to store
57 * all of the keys and values for the returned object tree.
58 *
59 * They assume UTF-8 input stream, and will output UTF-8 encoded
60 * strings in the tree. The input stream's UTF-8 isn't validated,
61 * as in, what you input is what you get as an output.
62 *
63 * All the keys and values in the grpc_json objects will be strings
64 * pointing at your input buffer.
65 *
66 * Delete the allocated tree afterward using grpc_json_destroy().
67 */
68 grpc_json *grpc_json_parse_string_with_len(char *input, size_t size);
69 grpc_json *grpc_json_parse_string(char *input);
70
71 /* This function will create a new string using gpr_realloc, and will
72 * deserialize the grpc_json tree into it. It'll be zero-terminated,
73 * but will be allocated in chunks of 256 bytes.
74 *
75 * The indent parameter controls the way the output is formatted.
76 * If indent is 0, then newlines will be suppressed as well, and the
77 * output will be condensed at its maximum.
78 */
79 char *grpc_json_dump_to_string(grpc_json *json, int indent);
80
81 /* Use these to create or delete a grpc_json object.
82 * Deletion is recursive. We will not attempt to free any of the strings
83 * in any of the objects of that tree.
84 */
85 grpc_json *grpc_json_create(grpc_json_type type);
86 void grpc_json_destroy(grpc_json *json);
87
88 #endif /* GRPC_INTERNAL_CORE_JSON_JSON_H */
OLDNEW
« no previous file with comments | « third_party/grpc/src/core/iomgr/workqueue_windows.c ('k') | third_party/grpc/src/core/json/json.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698