1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "wgt/rds_parser.h"
10 const char kAdd[] = "#add";
11 const char kModify[] = "#modify";
12 const char kDelete[] = "#delete";
16 namespace rds_parser {
18 RDSParser::RDSParser(const std::string& path_to_delta)
19 : path_to_delta_(path_to_delta) {}
21 bool RDSParser::Parse() {
22 std::vector<std::string>* current_container = nullptr;
25 std::ifstream file_to_parse(path_to_delta_);
26 if (!file_to_parse.is_open())
28 while (getline(file_to_parse, line)) {
29 if (line.compare(kDelete) == 0) {
30 current_container = &files_to_delete_;
33 if (line.compare(kAdd) == 0) {
34 current_container = &files_to_add_;
37 if (line.compare(kModify) == 0) {
38 current_container = &files_to_modify_;
41 if (current_container)
42 current_container->push_back(line);
44 file_to_parse.close();
48 const std::vector<std::string>& RDSParser::files_to_modify() const {
49 return files_to_modify_;
52 const std::vector<std::string>& RDSParser::files_to_add() const {
56 const std::vector<std::string>& RDSParser::files_to_delete() const {
57 return files_to_delete_;
60 } // namespace rds_parser