blob: 3a5631342ece96fa164958a458f937c44d05a242 [file] [log] [blame]
Yuchen He1c9032d2021-08-12 21:40:26 +00001/*
2 * Copyright (C) 2021 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 android_hardware_gnss_common_default_ParseUtils_H_
18#define android_hardware_gnss_common_default_ParseUtils_H_
19
20#include <log/log.h>
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25namespace android {
26namespace hardware {
27namespace gnss {
28namespace common {
29
30struct ParseUtils {
31 static int tryParseInt(const std::string& s, int defaultVal = 0);
32 static float tryParsefloat(const std::string& s, float defaultVal = 0.0);
33 static double tryParseDouble(const std::string& s, double defaultVal = 0.0);
34 static long tryParseLong(const std::string& s, long defaultVal = 0);
35 static long long tryParseLongLong(const std::string& s, long long defaultVal = 0);
36 static void splitStr(const std::string& line, const char& delimiter,
37 std::vector<std::string>& out);
38 static bool isValidHeader(const std::unordered_map<std::string, int>& columnNameIdMapping);
39};
40
41} // namespace common
42} // namespace gnss
43} // namespace hardware
44} // namespace android
45
46#endif // android_hardware_gnss_common_default_ParseUtils_H_