Resource Tuner
Loading...
Searching...
No Matches
YamlParser.h
1// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2// SPDX-License-Identifier: BSD-3-Clause-Clear
3
4#ifndef YAML_PARSER_H
5#define YAML_PARSER_H
6
7#include <yaml.h>
8
9#include "ErrCodes.h"
10
11#define SETUP_LIBYAML_PARSING(filePath) \
12 FILE* configFile = fopen(filePath.c_str(), "r"); \
13 if(configFile == nullptr) { \
14 return RC_FILE_NOT_FOUND; \
15 } \
16 yaml_parser_t parser; \
17 yaml_event_t event; \
18 if(!yaml_parser_initialize(&parser)) { \
19 fclose(configFile); \
20 return RC_YAML_PARSING_ERROR; \
21 } \
22 yaml_parser_set_input_file(&parser, configFile); \
23
24#define TEARDOWN_LIBYAML_PARSING \
25 yaml_parser_delete(&parser); \
26 fclose(configFile); \
27
28#endif