Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
yaml.h
1#ifndef SOURCEMETA_CORE_YAML_H_
2#define SOURCEMETA_CORE_YAML_H_
3
4#ifndef SOURCEMETA_CORE_YAML_EXPORT
5#include <sourcemeta/core/yaml_export.h>
6#endif
7
8#include <sourcemeta/core/json.h>
9
10// NOLINTBEGIN(misc-include-cleaner)
11#include <sourcemeta/core/yaml_error.h>
12#include <sourcemeta/core/yaml_roundtrip.h>
13// NOLINTEND(misc-include-cleaner)
14
15#include <cstddef> // std::size_t
16#include <filesystem> // std::filesystem
17#include <istream> // std::basic_istream
18#include <optional> // std::optional, std::nullopt
19#include <ostream> // std::basic_ostream
20
29
30namespace sourcemeta::core {
31
48SOURCEMETA_CORE_YAML_EXPORT
49auto parse_yaml(std::basic_istream<JSON::Char, JSON::CharTraits> &stream)
50 -> JSON;
51
70SOURCEMETA_CORE_YAML_EXPORT
71auto parse_yaml(const JSON::String &input) -> JSON;
72
92SOURCEMETA_CORE_YAML_EXPORT
93auto read_yaml(const std::filesystem::path &path) -> JSON;
94
102SOURCEMETA_CORE_YAML_EXPORT
103auto parse_yaml(std::basic_istream<JSON::Char, JSON::CharTraits> &stream,
104 JSON &output, const JSON::ParseCallback &callback) -> void;
105
112SOURCEMETA_CORE_YAML_EXPORT
113auto parse_yaml(const JSON::String &input, JSON &output,
114 const JSON::ParseCallback &callback) -> void;
115
122SOURCEMETA_CORE_YAML_EXPORT
123auto read_yaml(const std::filesystem::path &path, JSON &output,
124 const JSON::ParseCallback &callback) -> void;
125
144SOURCEMETA_CORE_YAML_EXPORT
145auto read_yaml_or_json(const std::filesystem::path &path) -> JSON;
146
154SOURCEMETA_CORE_YAML_EXPORT
155auto read_yaml_or_json(const std::filesystem::path &path, JSON &output,
156 const JSON::ParseCallback &callback) -> void;
157
172SOURCEMETA_CORE_YAML_EXPORT
173auto parse_yaml(const JSON::String &input, YAMLRoundTrip &roundtrip) -> JSON;
174
196SOURCEMETA_CORE_YAML_EXPORT
197auto parse_yaml(std::basic_istream<JSON::Char, JSON::CharTraits> &stream,
198 YAMLRoundTrip &roundtrip) -> JSON;
199
207SOURCEMETA_CORE_YAML_EXPORT
208auto parse_yaml(const JSON::String &input, YAMLRoundTrip &roundtrip,
209 JSON &output, const JSON::ParseCallback &callback) -> void;
210
220SOURCEMETA_CORE_YAML_EXPORT
221auto parse_yaml(std::basic_istream<JSON::Char, JSON::CharTraits> &stream,
222 YAMLRoundTrip &roundtrip, JSON &output,
223 const JSON::ParseCallback &callback) -> void;
224
245SOURCEMETA_CORE_YAML_EXPORT
246auto read_yaml(const std::filesystem::path &path, YAMLRoundTrip &roundtrip)
247 -> JSON;
248
258SOURCEMETA_CORE_YAML_EXPORT
259auto read_yaml(const std::filesystem::path &path, YAMLRoundTrip &roundtrip,
260 JSON &output, const JSON::ParseCallback &callback) -> void;
261
287SOURCEMETA_CORE_YAML_EXPORT
288auto stringify_yaml(const JSON &document,
289 std::basic_ostream<JSON::Char, JSON::CharTraits> &stream,
290 const YAMLRoundTrip &roundtrip,
291 const std::optional<std::size_t> indentation = std::nullopt)
292 -> void;
293
310SOURCEMETA_CORE_YAML_EXPORT
311auto stringify_yaml(const JSON &document,
312 std::basic_ostream<JSON::Char, JSON::CharTraits> &stream,
313 const std::size_t indentation = 2) -> void;
314
315} // namespace sourcemeta::core
316
317#endif
std::function< void( const ParsePhase phase, const Type type, const std::uint64_t line, const std::uint64_t column, const ParseContext context, const std::size_t index, const String &property)> ParseCallback
Definition json_value.h:103
std::basic_string< Char, CharTraits, Allocator< Char > > String
The string type used by the JSON document.
Definition json_value.h:52
Definition json_value.h:39
Definition yaml_roundtrip.h:30
SOURCEMETA_CORE_YAML_EXPORT auto parse_yaml(std::basic_istream< JSON::Char, JSON::CharTraits > &stream) -> JSON
SOURCEMETA_CORE_YAML_EXPORT auto stringify_yaml(const JSON &document, std::basic_ostream< JSON::Char, JSON::CharTraits > &stream, const YAMLRoundTrip &roundtrip, const std::optional< std::size_t > indentation=std::nullopt) -> void
SOURCEMETA_CORE_YAML_EXPORT auto read_yaml(const std::filesystem::path &path) -> JSON
SOURCEMETA_CORE_YAML_EXPORT auto read_yaml_or_json(const std::filesystem::path &path) -> JSON