blob: 8efe2ef46c9d06058bd4a31a089b8c0775b8b011 [file] [log] [blame]
Tom Cherry2aeb1ad2019-06-26 10:46:20 -07001/*
2 * Copyright (C) 2019 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#pragma once
18
19#include <vector>
20
21#include "parser.h"
22#include "service.h"
23#include "service_list.h"
24#include "subcontext.h"
25
26namespace android {
27namespace init {
28
29class ServiceParser : public SectionParser {
30 public:
31 ServiceParser(ServiceList* service_list, std::vector<Subcontext>* subcontexts)
32 : service_list_(service_list), subcontexts_(subcontexts), service_(nullptr) {}
33 Result<void> ParseSection(std::vector<std::string>&& args, const std::string& filename,
34 int line) override;
35 Result<void> ParseLineSection(std::vector<std::string>&& args, int line) override;
36 Result<void> EndSection() override;
37 void EndFile() override { filename_ = ""; }
38
39 private:
40 bool IsValidName(const std::string& name) const;
41
42 ServiceList* service_list_;
43 std::vector<Subcontext>* subcontexts_;
44 std::unique_ptr<Service> service_;
45 std::string filename_;
46};
47
48} // namespace init
49} // namespace android