action_parser.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2018 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. #ifndef _INIT_ACTION_PARSER_H
  17. #define _INIT_ACTION_PARSER_H
  18. #include <string>
  19. #include <vector>
  20. #include "action.h"
  21. #include "action_manager.h"
  22. #include "parser.h"
  23. #include "subcontext.h"
  24. namespace android {
  25. namespace init {
  26. class ActionParser : public SectionParser {
  27. public:
  28. ActionParser(ActionManager* action_manager, std::vector<Subcontext>* subcontexts)
  29. : action_manager_(action_manager), subcontexts_(subcontexts), action_(nullptr) {}
  30. Result<Success> ParseSection(std::vector<std::string>&& args, const std::string& filename,
  31. int line) override;
  32. Result<Success> ParseLineSection(std::vector<std::string>&& args, int line) override;
  33. Result<Success> EndSection() override;
  34. private:
  35. ActionManager* action_manager_;
  36. std::vector<Subcontext>* subcontexts_;
  37. std::unique_ptr<Action> action_;
  38. };
  39. } // namespace init
  40. } // namespace android
  41. #endif