|
72 | 72 | parse_options const& opt = {}); |
73 | 73 | /** @} */ |
74 | 74 |
|
75 | | -/** Parse a string of JSON into a @ref value. |
| 75 | +/** Return parsed JSON as a @ref value. |
76 | 76 |
|
77 | 77 | This function parses an entire string in one |
78 | 78 | step to produce a complete JSON object, returned |
@@ -111,6 +111,94 @@ parse( |
111 | 111 | storage_ptr sp = {}, |
112 | 112 | parse_options const& opt = {}); |
113 | 113 |
|
| 114 | +/** Return parsed JSON as a @ref value. |
| 115 | +
|
| 116 | + This function reads data from an input stream and parses it to produce a |
| 117 | + complete JSON entity, returned as a @ref value. If the stream does not |
| 118 | + contain a complete serialized JSON, or contains extra non-whitespace data, |
| 119 | + an error occurs. In this case the returned value will be `null`, using the |
| 120 | + default memory resource. |
| 121 | +
|
| 122 | + @par Complexity |
| 123 | + Linear in the size of consumed input. |
| 124 | +
|
| 125 | + @par Exception Safety |
| 126 | + Basic guarantee. |
| 127 | + Calls to `memory_resource::allocate` may throw. |
| 128 | + The stream may throw as described by |
| 129 | + [`std::ios::exceptions`](https://en.cppreference.com/w/cpp/io/basic_ios/exceptions). |
| 130 | +
|
| 131 | + @return A value representing the parsed JSON, |
| 132 | + or a `null` if any error occurred. |
| 133 | +
|
| 134 | + @param is The stream to read from. |
| 135 | +
|
| 136 | + @param ec Set to the error, if any occurred. |
| 137 | +
|
| 138 | + @param sp The memory resource that the new value and all of its elements |
| 139 | + will use. If this parameter is omitted, the default memory resource |
| 140 | + is used. |
| 141 | +
|
| 142 | + @param opt The options for the parser. If this parameter is omitted, the |
| 143 | + parser will accept only standard JSON. |
| 144 | +
|
| 145 | + @see @ref parse_options, @ref stream_parser, @ref value::operator>>. |
| 146 | +*/ |
| 147 | +/** @{ */ |
| 148 | +BOOST_JSON_DECL |
| 149 | +value |
| 150 | +parse( |
| 151 | + std::istream& is, |
| 152 | + error_code& ec, |
| 153 | + storage_ptr sp = {}, |
| 154 | + parse_options const& opt = {}); |
| 155 | + |
| 156 | +BOOST_JSON_DECL |
| 157 | +value |
| 158 | +parse( |
| 159 | + std::istream& is, |
| 160 | + std::error_code& ec, |
| 161 | + storage_ptr sp = {}, |
| 162 | + parse_options const& opt = {}); |
| 163 | +/** @} */ |
| 164 | + |
| 165 | +/** Return parsed JSON as a @ref value. |
| 166 | +
|
| 167 | + This function reads data from an input stream and parses it to produce a |
| 168 | + complete JSON entity, returned as a @ref value. If the stream does not |
| 169 | + contain a complete serialized JSON, or contains extra non-whitespace data, |
| 170 | + an exception is thrown. |
| 171 | +
|
| 172 | + @par Complexity |
| 173 | + Linear in the size of consumed input. |
| 174 | +
|
| 175 | + @par Exception Safety |
| 176 | + Basic guarantee. |
| 177 | + Throws @ref system_error on failed parse. |
| 178 | + Calls to `memory_resource::allocate` may throw. |
| 179 | + The stream may throw as described by |
| 180 | + [`std::ios::exceptions`](https://en.cppreference.com/w/cpp/io/basic_ios/exceptions). |
| 181 | +
|
| 182 | + @return A value representing the parsed JSON upon success. |
| 183 | +
|
| 184 | + @param is The stream to read from. |
| 185 | +
|
| 186 | + @param sp The memory resource that the new value and all of its elements |
| 187 | + will use. If this parameter is omitted, the default memory resource |
| 188 | + is used. |
| 189 | +
|
| 190 | + @param opt The options for the parser. If this parameter is omitted, the |
| 191 | + parser will accept only standard JSON. |
| 192 | +
|
| 193 | + @see @ref parse_options, @ref stream_parser, @ref value::operator>>. |
| 194 | +*/ |
| 195 | +BOOST_JSON_DECL |
| 196 | +value |
| 197 | +parse( |
| 198 | + std::istream& is, |
| 199 | + storage_ptr sp = {}, |
| 200 | + parse_options const& opt = {}); |
| 201 | + |
114 | 202 | BOOST_JSON_NS_END |
115 | 203 |
|
116 | 204 | #endif |
0 commit comments