blob: 030cc0f0ff8b260b603f40da0b37dfd28d33ebaf [file] [log] [blame]
Tanmay Patilb2897b42020-06-08 17:55:02 -07001/*
2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SURROUND_VIEW_SERVICE_IMPL_CONFIGREADERUTIL_H_
18#define SURROUND_VIEW_SERVICE_IMPL_CONFIGREADERUTIL_H_
19
20#include <tinyxml2.h>
21#include <sstream>
22#include <string>
23
24namespace android {
25namespace hardware {
26namespace automotive {
27namespace sv {
28namespace V1_0 {
29namespace implementation {
30
31// Macro returning false if condition evaluates to false.
32#define RETURN_IF_FALSE(cond) \
33 do { \
34 if (!(cond)) { \
35 return false; \
36 } \
37 } while (0)
38
39// Returns true if element has text.
40bool ElementHasText(const tinyxml2::XMLElement* element);
41
42// Gets a xml element from the parent element, returns false if not found.
43bool GetElement(const tinyxml2::XMLElement* parent, const char* elementName,
44 tinyxml2::XMLElement const** element);
45
Tanmay Patilfcb633d2020-06-15 13:39:31 -070046// Reads a boolean value from a element, returns false if not found.
Tanmay Patilb2897b42020-06-08 17:55:02 -070047bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, bool* value);
48
Tanmay Patilfcb633d2020-06-15 13:39:31 -070049// Reads a string value from a element, returns false if not found.
Tanmay Patilb2897b42020-06-08 17:55:02 -070050bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, std::string* value);
51
Tanmay Patilfcb633d2020-06-15 13:39:31 -070052// Reads a float value from a element, returns false if not found.
Tanmay Patilb2897b42020-06-08 17:55:02 -070053bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, float* value);
54
Tanmay Patilfcb633d2020-06-15 13:39:31 -070055// Reads a int value from a element, returns false if not found.
Tanmay Patilb2897b42020-06-08 17:55:02 -070056bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, int* value);
57
58} // namespace implementation
59} // namespace V1_0
60} // namespace sv
61} // namespace automotive
62} // namespace hardware
63} // namespace android
64
65#endif // SURROUND_VIEW_SERVICE_IMPL_CONFIGREADERUTIL_H_